babylon.d.txt 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */ private _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Scalar computation library
  496. */
  497. export class Scalar {
  498. /**
  499. * Two pi constants convenient for computation.
  500. */
  501. static TwoPi: number;
  502. /**
  503. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  504. * @param a number
  505. * @param b number
  506. * @param epsilon (default = 1.401298E-45)
  507. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  508. */
  509. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  510. /**
  511. * Returns a string : the upper case translation of the number i to hexadecimal.
  512. * @param i number
  513. * @returns the upper case translation of the number i to hexadecimal.
  514. */
  515. static ToHex(i: number): string;
  516. /**
  517. * Returns -1 if value is negative and +1 is value is positive.
  518. * @param value the value
  519. * @returns the value itself if it's equal to zero.
  520. */
  521. static Sign(value: number): number;
  522. /**
  523. * Returns the value itself if it's between min and max.
  524. * Returns min if the value is lower than min.
  525. * Returns max if the value is greater than max.
  526. * @param value the value to clmap
  527. * @param min the min value to clamp to (default: 0)
  528. * @param max the max value to clamp to (default: 1)
  529. * @returns the clamped value
  530. */
  531. static Clamp(value: number, min?: number, max?: number): number;
  532. /**
  533. * the log2 of value.
  534. * @param value the value to compute log2 of
  535. * @returns the log2 of value.
  536. */
  537. static Log2(value: number): number;
  538. /**
  539. * Loops the value, so that it is never larger than length and never smaller than 0.
  540. *
  541. * This is similar to the modulo operator but it works with floating point numbers.
  542. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  543. * With t = 5 and length = 2.5, the result would be 0.0.
  544. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  545. * @param value the value
  546. * @param length the length
  547. * @returns the looped value
  548. */
  549. static Repeat(value: number, length: number): number;
  550. /**
  551. * Normalize the value between 0.0 and 1.0 using min and max values
  552. * @param value value to normalize
  553. * @param min max to normalize between
  554. * @param max min to normalize between
  555. * @returns the normalized value
  556. */
  557. static Normalize(value: number, min: number, max: number): number;
  558. /**
  559. * Denormalize the value from 0.0 and 1.0 using min and max values
  560. * @param normalized value to denormalize
  561. * @param min max to denormalize between
  562. * @param max min to denormalize between
  563. * @returns the denormalized value
  564. */
  565. static Denormalize(normalized: number, min: number, max: number): number;
  566. /**
  567. * Calculates the shortest difference between two given angles given in degrees.
  568. * @param current current angle in degrees
  569. * @param target target angle in degrees
  570. * @returns the delta
  571. */
  572. static DeltaAngle(current: number, target: number): number;
  573. /**
  574. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  575. * @param tx value
  576. * @param length length
  577. * @returns The returned value will move back and forth between 0 and length
  578. */
  579. static PingPong(tx: number, length: number): number;
  580. /**
  581. * Interpolates between min and max with smoothing at the limits.
  582. *
  583. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  584. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  585. * @param from from
  586. * @param to to
  587. * @param tx value
  588. * @returns the smooth stepped value
  589. */
  590. static SmoothStep(from: number, to: number, tx: number): number;
  591. /**
  592. * Moves a value current towards target.
  593. *
  594. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  595. * Negative values of maxDelta pushes the value away from target.
  596. * @param current current value
  597. * @param target target value
  598. * @param maxDelta max distance to move
  599. * @returns resulting value
  600. */
  601. static MoveTowards(current: number, target: number, maxDelta: number): number;
  602. /**
  603. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  604. *
  605. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  606. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  607. * @param current current value
  608. * @param target target value
  609. * @param maxDelta max distance to move
  610. * @returns resulting angle
  611. */
  612. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  613. /**
  614. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  615. * @param start start value
  616. * @param end target value
  617. * @param amount amount to lerp between
  618. * @returns the lerped value
  619. */
  620. static Lerp(start: number, end: number, amount: number): number;
  621. /**
  622. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  623. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  624. * @param start start value
  625. * @param end target value
  626. * @param amount amount to lerp between
  627. * @returns the lerped value
  628. */
  629. static LerpAngle(start: number, end: number, amount: number): number;
  630. /**
  631. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  632. * @param a start value
  633. * @param b target value
  634. * @param value value between a and b
  635. * @returns the inverseLerp value
  636. */
  637. static InverseLerp(a: number, b: number, value: number): number;
  638. /**
  639. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  640. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  641. * @param value1 spline value
  642. * @param tangent1 spline value
  643. * @param value2 spline value
  644. * @param tangent2 spline value
  645. * @param amount input value
  646. * @returns hermite result
  647. */
  648. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  649. /**
  650. * Returns a random float number between and min and max values
  651. * @param min min value of random
  652. * @param max max value of random
  653. * @returns random value
  654. */
  655. static RandomRange(min: number, max: number): number;
  656. /**
  657. * This function returns percentage of a number in a given range.
  658. *
  659. * RangeToPercent(40,20,60) will return 0.5 (50%)
  660. * RangeToPercent(34,0,100) will return 0.34 (34%)
  661. * @param number to convert to percentage
  662. * @param min min range
  663. * @param max max range
  664. * @returns the percentage
  665. */
  666. static RangeToPercent(number: number, min: number, max: number): number;
  667. /**
  668. * This function returns number that corresponds to the percentage in a given range.
  669. *
  670. * PercentToRange(0.34,0,100) will return 34.
  671. * @param percent to convert to number
  672. * @param min min range
  673. * @param max max range
  674. * @returns the number
  675. */
  676. static PercentToRange(percent: number, min: number, max: number): number;
  677. /**
  678. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  679. * @param angle The angle to normalize in radian.
  680. * @return The converted angle.
  681. */
  682. static NormalizeRadians(angle: number): number;
  683. }
  684. }
  685. declare module BABYLON {
  686. /**
  687. * Constant used to convert a value to gamma space
  688. * @ignorenaming
  689. */
  690. export const ToGammaSpace: number;
  691. /**
  692. * Constant used to convert a value to linear space
  693. * @ignorenaming
  694. */
  695. export const ToLinearSpace = 2.2;
  696. /**
  697. * Constant used to define the minimal number value in Babylon.js
  698. * @ignorenaming
  699. */
  700. let Epsilon: number;
  701. }
  702. declare module BABYLON {
  703. /**
  704. * Class used to represent a viewport on screen
  705. */
  706. export class Viewport {
  707. /** viewport left coordinate */
  708. x: number;
  709. /** viewport top coordinate */
  710. y: number;
  711. /**viewport width */
  712. width: number;
  713. /** viewport height */
  714. height: number;
  715. /**
  716. * Creates a Viewport object located at (x, y) and sized (width, height)
  717. * @param x defines viewport left coordinate
  718. * @param y defines viewport top coordinate
  719. * @param width defines the viewport width
  720. * @param height defines the viewport height
  721. */
  722. constructor(
  723. /** viewport left coordinate */
  724. x: number,
  725. /** viewport top coordinate */
  726. y: number,
  727. /**viewport width */
  728. width: number,
  729. /** viewport height */
  730. height: number);
  731. /**
  732. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  733. * @param renderWidth defines the rendering width
  734. * @param renderHeight defines the rendering height
  735. * @returns a new Viewport
  736. */
  737. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  738. /**
  739. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  740. * @param renderWidth defines the rendering width
  741. * @param renderHeight defines the rendering height
  742. * @param ref defines the target viewport
  743. * @returns the current viewport
  744. */
  745. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  746. /**
  747. * Returns a new Viewport copied from the current one
  748. * @returns a new Viewport
  749. */
  750. clone(): Viewport;
  751. }
  752. }
  753. declare module BABYLON {
  754. /**
  755. * Class containing a set of static utilities functions for arrays.
  756. */
  757. export class ArrayTools {
  758. /**
  759. * Returns an array of the given size filled with element built from the given constructor and the paramters
  760. * @param size the number of element to construct and put in the array
  761. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  762. * @returns a new array filled with new objects
  763. */
  764. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  765. }
  766. }
  767. declare module BABYLON {
  768. /**
  769. * @hidden
  770. */
  771. export interface IColor4Like {
  772. r: float;
  773. g: float;
  774. b: float;
  775. a: float;
  776. }
  777. /**
  778. * @hidden
  779. */
  780. export interface IColor3Like {
  781. r: float;
  782. g: float;
  783. b: float;
  784. }
  785. /**
  786. * @hidden
  787. */
  788. export interface IVector4Like {
  789. x: float;
  790. y: float;
  791. z: float;
  792. w: float;
  793. }
  794. /**
  795. * @hidden
  796. */
  797. export interface IVector3Like {
  798. x: float;
  799. y: float;
  800. z: float;
  801. }
  802. /**
  803. * @hidden
  804. */
  805. export interface IVector2Like {
  806. x: float;
  807. y: float;
  808. }
  809. /**
  810. * @hidden
  811. */
  812. export interface IMatrixLike {
  813. toArray(): DeepImmutable<Float32Array>;
  814. updateFlag: int;
  815. }
  816. /**
  817. * @hidden
  818. */
  819. export interface IViewportLike {
  820. x: float;
  821. y: float;
  822. width: float;
  823. height: float;
  824. }
  825. /**
  826. * @hidden
  827. */
  828. export interface IPlaneLike {
  829. normal: IVector3Like;
  830. d: float;
  831. normalize(): void;
  832. }
  833. }
  834. declare module BABYLON {
  835. /**
  836. * Class representing a vector containing 2 coordinates
  837. */
  838. export class Vector2 {
  839. /** defines the first coordinate */
  840. x: number;
  841. /** defines the second coordinate */
  842. y: number;
  843. /**
  844. * Creates a new Vector2 from the given x and y coordinates
  845. * @param x defines the first coordinate
  846. * @param y defines the second coordinate
  847. */
  848. constructor(
  849. /** defines the first coordinate */
  850. x?: number,
  851. /** defines the second coordinate */
  852. y?: number);
  853. /**
  854. * Gets a string with the Vector2 coordinates
  855. * @returns a string with the Vector2 coordinates
  856. */
  857. toString(): string;
  858. /**
  859. * Gets class name
  860. * @returns the string "Vector2"
  861. */
  862. getClassName(): string;
  863. /**
  864. * Gets current vector hash code
  865. * @returns the Vector2 hash code as a number
  866. */
  867. getHashCode(): number;
  868. /**
  869. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  870. * @param array defines the source array
  871. * @param index defines the offset in source array
  872. * @returns the current Vector2
  873. */
  874. toArray(array: FloatArray, index?: number): Vector2;
  875. /**
  876. * Copy the current vector to an array
  877. * @returns a new array with 2 elements: the Vector2 coordinates.
  878. */
  879. asArray(): number[];
  880. /**
  881. * Sets the Vector2 coordinates with the given Vector2 coordinates
  882. * @param source defines the source Vector2
  883. * @returns the current updated Vector2
  884. */
  885. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  886. /**
  887. * Sets the Vector2 coordinates with the given floats
  888. * @param x defines the first coordinate
  889. * @param y defines the second coordinate
  890. * @returns the current updated Vector2
  891. */
  892. copyFromFloats(x: number, y: number): Vector2;
  893. /**
  894. * Sets the Vector2 coordinates with the given floats
  895. * @param x defines the first coordinate
  896. * @param y defines the second coordinate
  897. * @returns the current updated Vector2
  898. */
  899. set(x: number, y: number): Vector2;
  900. /**
  901. * Add another vector with the current one
  902. * @param otherVector defines the other vector
  903. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  904. */
  905. add(otherVector: DeepImmutable<Vector2>): Vector2;
  906. /**
  907. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  908. * @param otherVector defines the other vector
  909. * @param result defines the target vector
  910. * @returns the unmodified current Vector2
  911. */
  912. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  913. /**
  914. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  915. * @param otherVector defines the other vector
  916. * @returns the current updated Vector2
  917. */
  918. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  921. * @param otherVector defines the other vector
  922. * @returns a new Vector2
  923. */
  924. addVector3(otherVector: Vector3): Vector2;
  925. /**
  926. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  927. * @param otherVector defines the other vector
  928. * @returns a new Vector2
  929. */
  930. subtract(otherVector: Vector2): Vector2;
  931. /**
  932. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  933. * @param otherVector defines the other vector
  934. * @param result defines the target vector
  935. * @returns the unmodified current Vector2
  936. */
  937. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  938. /**
  939. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  940. * @param otherVector defines the other vector
  941. * @returns the current updated Vector2
  942. */
  943. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  944. /**
  945. * Multiplies in place the current Vector2 coordinates by the given ones
  946. * @param otherVector defines the other vector
  947. * @returns the current updated Vector2
  948. */
  949. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  950. /**
  951. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  952. * @param otherVector defines the other vector
  953. * @returns a new Vector2
  954. */
  955. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  956. /**
  957. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  958. * @param otherVector defines the other vector
  959. * @param result defines the target vector
  960. * @returns the unmodified current Vector2
  961. */
  962. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  963. /**
  964. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  965. * @param x defines the first coordinate
  966. * @param y defines the second coordinate
  967. * @returns a new Vector2
  968. */
  969. multiplyByFloats(x: number, y: number): Vector2;
  970. /**
  971. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  972. * @param otherVector defines the other vector
  973. * @returns a new Vector2
  974. */
  975. divide(otherVector: Vector2): Vector2;
  976. /**
  977. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  978. * @param otherVector defines the other vector
  979. * @param result defines the target vector
  980. * @returns the unmodified current Vector2
  981. */
  982. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  983. /**
  984. * Divides the current Vector2 coordinates by the given ones
  985. * @param otherVector defines the other vector
  986. * @returns the current updated Vector2
  987. */
  988. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  989. /**
  990. * Gets a new Vector2 with current Vector2 negated coordinates
  991. * @returns a new Vector2
  992. */
  993. negate(): Vector2;
  994. /**
  995. * Multiply the Vector2 coordinates by scale
  996. * @param scale defines the scaling factor
  997. * @returns the current updated Vector2
  998. */
  999. scaleInPlace(scale: number): Vector2;
  1000. /**
  1001. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1002. * @param scale defines the scaling factor
  1003. * @returns a new Vector2
  1004. */
  1005. scale(scale: number): Vector2;
  1006. /**
  1007. * Scale the current Vector2 values by a factor to a given Vector2
  1008. * @param scale defines the scale factor
  1009. * @param result defines the Vector2 object where to store the result
  1010. * @returns the unmodified current Vector2
  1011. */
  1012. scaleToRef(scale: number, result: Vector2): Vector2;
  1013. /**
  1014. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1015. * @param scale defines the scale factor
  1016. * @param result defines the Vector2 object where to store the result
  1017. * @returns the unmodified current Vector2
  1018. */
  1019. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1020. /**
  1021. * Gets a boolean if two vectors are equals
  1022. * @param otherVector defines the other vector
  1023. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1024. */
  1025. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1026. /**
  1027. * Gets a boolean if two vectors are equals (using an epsilon value)
  1028. * @param otherVector defines the other vector
  1029. * @param epsilon defines the minimal distance to consider equality
  1030. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1031. */
  1032. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. floor(): Vector2;
  1038. /**
  1039. * Gets a new Vector2 from current Vector2 floored values
  1040. * @returns a new Vector2
  1041. */
  1042. fract(): Vector2;
  1043. /**
  1044. * Gets the length of the vector
  1045. * @returns the vector length (float)
  1046. */
  1047. length(): number;
  1048. /**
  1049. * Gets the vector squared length
  1050. * @returns the vector squared length (float)
  1051. */
  1052. lengthSquared(): number;
  1053. /**
  1054. * Normalize the vector
  1055. * @returns the current updated Vector2
  1056. */
  1057. normalize(): Vector2;
  1058. /**
  1059. * Gets a new Vector2 copied from the Vector2
  1060. * @returns a new Vector2
  1061. */
  1062. clone(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(0, 0)
  1065. * @returns a new Vector2
  1066. */
  1067. static Zero(): Vector2;
  1068. /**
  1069. * Gets a new Vector2(1, 1)
  1070. * @returns a new Vector2
  1071. */
  1072. static One(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 set from the given index element of the given array
  1075. * @param array defines the data source
  1076. * @param offset defines the offset in the data source
  1077. * @returns a new Vector2
  1078. */
  1079. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1080. /**
  1081. * Sets "result" from the given index element of the given array
  1082. * @param array defines the data source
  1083. * @param offset defines the offset in the data source
  1084. * @param result defines the target vector
  1085. */
  1086. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1087. /**
  1088. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1089. * @param value1 defines 1st point of control
  1090. * @param value2 defines 2nd point of control
  1091. * @param value3 defines 3rd point of control
  1092. * @param value4 defines 4th point of control
  1093. * @param amount defines the interpolation factor
  1094. * @returns a new Vector2
  1095. */
  1096. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1097. /**
  1098. * 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".
  1099. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1100. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1101. * @param value defines the value to clamp
  1102. * @param min defines the lower limit
  1103. * @param max defines the upper limit
  1104. * @returns a new Vector2
  1105. */
  1106. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1107. /**
  1108. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1109. * @param value1 defines the 1st control point
  1110. * @param tangent1 defines the outgoing tangent
  1111. * @param value2 defines the 2nd control point
  1112. * @param tangent2 defines the incoming tangent
  1113. * @param amount defines the interpolation factor
  1114. * @returns a new Vector2
  1115. */
  1116. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1117. /**
  1118. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1119. * @param start defines the start vector
  1120. * @param end defines the end vector
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Gets the dot product of the vector "left" and the vector "right"
  1127. * @param left defines first vector
  1128. * @param right defines second vector
  1129. * @returns the dot product (float)
  1130. */
  1131. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1132. /**
  1133. * Returns a new Vector2 equal to the normalized given vector
  1134. * @param vector defines the vector to normalize
  1135. * @returns a new Vector2
  1136. */
  1137. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1138. /**
  1139. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1140. * @param left defines 1st vector
  1141. * @param right defines 2nd vector
  1142. * @returns a new Vector2
  1143. */
  1144. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1145. /**
  1146. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1147. * @param left defines 1st vector
  1148. * @param right defines 2nd vector
  1149. * @returns a new Vector2
  1150. */
  1151. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1152. /**
  1153. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1154. * @param vector defines the vector to transform
  1155. * @param transformation defines the matrix to apply
  1156. * @returns a new Vector2
  1157. */
  1158. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1159. /**
  1160. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1161. * @param vector defines the vector to transform
  1162. * @param transformation defines the matrix to apply
  1163. * @param result defines the target vector
  1164. */
  1165. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1166. /**
  1167. * Determines if a given vector is included in a triangle
  1168. * @param p defines the vector to test
  1169. * @param p0 defines 1st triangle point
  1170. * @param p1 defines 2nd triangle point
  1171. * @param p2 defines 3rd triangle point
  1172. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1173. */
  1174. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1175. /**
  1176. * Gets the distance between the vectors "value1" and "value2"
  1177. * @param value1 defines first vector
  1178. * @param value2 defines second vector
  1179. * @returns the distance between vectors
  1180. */
  1181. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1182. /**
  1183. * Returns the squared distance between the vectors "value1" and "value2"
  1184. * @param value1 defines first vector
  1185. * @param value2 defines second vector
  1186. * @returns the squared distance between vectors
  1187. */
  1188. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1189. /**
  1190. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1191. * @param value1 defines first vector
  1192. * @param value2 defines second vector
  1193. * @returns a new Vector2
  1194. */
  1195. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1196. /**
  1197. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1198. * @param p defines the middle point
  1199. * @param segA defines one point of the segment
  1200. * @param segB defines the other point of the segment
  1201. * @returns the shortest distance
  1202. */
  1203. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1204. }
  1205. /**
  1206. * Classed used to store (x,y,z) vector representation
  1207. * A Vector3 is the main object used in 3D geometry
  1208. * It can represent etiher the coordinates of a point the space, either a direction
  1209. * Reminder: js uses a left handed forward facing system
  1210. */
  1211. export class Vector3 {
  1212. /**
  1213. * Defines the first coordinates (on X axis)
  1214. */
  1215. x: number;
  1216. /**
  1217. * Defines the second coordinates (on Y axis)
  1218. */
  1219. y: number;
  1220. /**
  1221. * Defines the third coordinates (on Z axis)
  1222. */
  1223. z: number;
  1224. private static _UpReadOnly;
  1225. private static _ZeroReadOnly;
  1226. /**
  1227. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1228. * @param x defines the first coordinates (on X axis)
  1229. * @param y defines the second coordinates (on Y axis)
  1230. * @param z defines the third coordinates (on Z axis)
  1231. */
  1232. constructor(
  1233. /**
  1234. * Defines the first coordinates (on X axis)
  1235. */
  1236. x?: number,
  1237. /**
  1238. * Defines the second coordinates (on Y axis)
  1239. */
  1240. y?: number,
  1241. /**
  1242. * Defines the third coordinates (on Z axis)
  1243. */
  1244. z?: number);
  1245. /**
  1246. * Creates a string representation of the Vector3
  1247. * @returns a string with the Vector3 coordinates.
  1248. */
  1249. toString(): string;
  1250. /**
  1251. * Gets the class name
  1252. * @returns the string "Vector3"
  1253. */
  1254. getClassName(): string;
  1255. /**
  1256. * Creates the Vector3 hash code
  1257. * @returns a number which tends to be unique between Vector3 instances
  1258. */
  1259. getHashCode(): number;
  1260. /**
  1261. * Creates an array containing three elements : the coordinates of the Vector3
  1262. * @returns a new array of numbers
  1263. */
  1264. asArray(): number[];
  1265. /**
  1266. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1267. * @param array defines the destination array
  1268. * @param index defines the offset in the destination array
  1269. * @returns the current Vector3
  1270. */
  1271. toArray(array: FloatArray, index?: number): Vector3;
  1272. /**
  1273. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1274. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1275. */
  1276. toQuaternion(): Quaternion;
  1277. /**
  1278. * Adds the given vector to the current Vector3
  1279. * @param otherVector defines the second operand
  1280. * @returns the current updated Vector3
  1281. */
  1282. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1283. /**
  1284. * Adds the given coordinates to the current Vector3
  1285. * @param x defines the x coordinate of the operand
  1286. * @param y defines the y coordinate of the operand
  1287. * @param z defines the z coordinate of the operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1291. /**
  1292. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1293. * @param otherVector defines the second operand
  1294. * @returns the resulting Vector3
  1295. */
  1296. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1297. /**
  1298. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1299. * @param otherVector defines the second operand
  1300. * @param result defines the Vector3 object where to store the result
  1301. * @returns the current Vector3
  1302. */
  1303. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1304. /**
  1305. * Subtract the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the current updated Vector3
  1308. */
  1309. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1312. * @param otherVector defines the second operand
  1313. * @returns the resulting Vector3
  1314. */
  1315. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1316. /**
  1317. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1318. * @param otherVector defines the second operand
  1319. * @param result defines the Vector3 object where to store the result
  1320. * @returns the current Vector3
  1321. */
  1322. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1323. /**
  1324. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1325. * @param x defines the x coordinate of the operand
  1326. * @param y defines the y coordinate of the operand
  1327. * @param z defines the z coordinate of the operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1331. /**
  1332. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @param result defines the Vector3 object where to store the result
  1337. * @returns the current Vector3
  1338. */
  1339. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1340. /**
  1341. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1342. * @returns a new Vector3
  1343. */
  1344. negate(): Vector3;
  1345. /**
  1346. * Multiplies the Vector3 coordinates by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns the current updated Vector3
  1349. */
  1350. scaleInPlace(scale: number): Vector3;
  1351. /**
  1352. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1353. * @param scale defines the multiplier factor
  1354. * @returns a new Vector3
  1355. */
  1356. scale(scale: number): Vector3;
  1357. /**
  1358. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1359. * @param scale defines the multiplier factor
  1360. * @param result defines the Vector3 object where to store the result
  1361. * @returns the current Vector3
  1362. */
  1363. scaleToRef(scale: number, result: Vector3): Vector3;
  1364. /**
  1365. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1366. * @param scale defines the scale factor
  1367. * @param result defines the Vector3 object where to store the result
  1368. * @returns the unmodified current Vector3
  1369. */
  1370. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1373. * @param otherVector defines the second operand
  1374. * @returns true if both vectors are equals
  1375. */
  1376. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1377. /**
  1378. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1379. * @param otherVector defines the second operand
  1380. * @param epsilon defines the minimal distance to define values as equals
  1381. * @returns true if both vectors are distant less than epsilon
  1382. */
  1383. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1384. /**
  1385. * Returns true if the current Vector3 coordinates equals the given floats
  1386. * @param x defines the x coordinate of the operand
  1387. * @param y defines the y coordinate of the operand
  1388. * @param z defines the z coordinate of the operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equalsToFloats(x: number, y: number, z: number): boolean;
  1392. /**
  1393. * Multiplies the current Vector3 coordinates by the given ones
  1394. * @param otherVector defines the second operand
  1395. * @returns the current updated Vector3
  1396. */
  1397. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1400. * @param otherVector defines the second operand
  1401. * @returns the new Vector3
  1402. */
  1403. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1404. /**
  1405. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1406. * @param otherVector defines the second operand
  1407. * @param result defines the Vector3 object where to store the result
  1408. * @returns the current Vector3
  1409. */
  1410. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1411. /**
  1412. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1413. * @param x defines the x coordinate of the operand
  1414. * @param y defines the y coordinate of the operand
  1415. * @param z defines the z coordinate of the operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1421. * @param otherVector defines the second operand
  1422. * @returns the new Vector3
  1423. */
  1424. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1425. /**
  1426. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1427. * @param otherVector defines the second operand
  1428. * @param result defines the Vector3 object where to store the result
  1429. * @returns the current Vector3
  1430. */
  1431. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1432. /**
  1433. * Divides the current Vector3 coordinates by the given ones.
  1434. * @param otherVector defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. divideInPlace(otherVector: Vector3): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1446. * @param other defines the second operand
  1447. * @returns the current updated Vector3
  1448. */
  1449. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1450. /**
  1451. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1452. * @param x defines the x coordinate of the operand
  1453. * @param y defines the y coordinate of the operand
  1454. * @param z defines the z coordinate of the operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1468. * Check if is non uniform within a certain amount of decimal places to account for this
  1469. * @param epsilon the amount the values can differ
  1470. * @returns if the the vector is non uniform to a certain number of decimal places
  1471. */
  1472. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1473. /**
  1474. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1475. */
  1476. readonly isNonUniform: boolean;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. floor(): Vector3;
  1482. /**
  1483. * Gets a new Vector3 from current Vector3 floored values
  1484. * @returns a new Vector3
  1485. */
  1486. fract(): Vector3;
  1487. /**
  1488. * Gets the length of the Vector3
  1489. * @returns the length of the Vector3
  1490. */
  1491. length(): number;
  1492. /**
  1493. * Gets the squared length of the Vector3
  1494. * @returns squared length of the Vector3
  1495. */
  1496. lengthSquared(): number;
  1497. /**
  1498. * Normalize the current Vector3.
  1499. * Please note that this is an in place operation.
  1500. * @returns the current updated Vector3
  1501. */
  1502. normalize(): Vector3;
  1503. /**
  1504. * Reorders the x y z properties of the vector in place
  1505. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1506. * @returns the current updated vector
  1507. */
  1508. reorderInPlace(order: string): this;
  1509. /**
  1510. * Rotates the vector around 0,0,0 by a quaternion
  1511. * @param quaternion the rotation quaternion
  1512. * @param result vector to store the result
  1513. * @returns the resulting vector
  1514. */
  1515. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1516. /**
  1517. * Rotates a vector around a given point
  1518. * @param quaternion the rotation quaternion
  1519. * @param point the point to rotate around
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1524. /**
  1525. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1526. * The cross product is then orthogonal to both current and "other"
  1527. * @param other defines the right operand
  1528. * @returns the cross product
  1529. */
  1530. cross(other: Vector3): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 with the given input length.
  1533. * Please note that this is an in place operation.
  1534. * @param len the length of the vector
  1535. * @returns the current updated Vector3
  1536. */
  1537. normalizeFromLength(len: number): Vector3;
  1538. /**
  1539. * Normalize the current Vector3 to a new vector
  1540. * @returns the new Vector3
  1541. */
  1542. normalizeToNew(): Vector3;
  1543. /**
  1544. * Normalize the current Vector3 to the reference
  1545. * @param reference define the Vector3 to update
  1546. * @returns the updated Vector3
  1547. */
  1548. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Creates a new Vector3 copied from the current Vector3
  1551. * @returns the new Vector3
  1552. */
  1553. clone(): Vector3;
  1554. /**
  1555. * Copies the given vector coordinates to the current Vector3 ones
  1556. * @param source defines the source Vector3
  1557. * @returns the current updated Vector3
  1558. */
  1559. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1560. /**
  1561. * Copies the given floats to the current Vector3 coordinates
  1562. * @param x defines the x coordinate of the operand
  1563. * @param y defines the y coordinate of the operand
  1564. * @param z defines the z coordinate of the operand
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFromFloats(x: number, y: number, z: number): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. set(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given float to the current Vector3 coordinates
  1578. * @param v defines the x, y and z coordinates of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. setAll(v: number): Vector3;
  1582. /**
  1583. * Get the clip factor between two vectors
  1584. * @param vector0 defines the first operand
  1585. * @param vector1 defines the second operand
  1586. * @param axis defines the axis to use
  1587. * @param size defines the size along the axis
  1588. * @returns the clip factor
  1589. */
  1590. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1591. /**
  1592. * Get angle between two vectors
  1593. * @param vector0 angle between vector0 and vector1
  1594. * @param vector1 angle between vector0 and vector1
  1595. * @param normal direction of the normal
  1596. * @return the angle between vector0 and vector1
  1597. */
  1598. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1599. /**
  1600. * Returns a new Vector3 set from the index "offset" of the given array
  1601. * @param array defines the source array
  1602. * @param offset defines the offset in the source array
  1603. * @returns the new Vector3
  1604. */
  1605. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1606. /**
  1607. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1608. * This function is deprecated. Use FromArray instead
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1614. /**
  1615. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1616. * @param array defines the source array
  1617. * @param offset defines the offset in the source array
  1618. * @param result defines the Vector3 where to store the result
  1619. */
  1620. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1621. /**
  1622. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1623. * This function is deprecated. Use FromArrayToRef instead.
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the given floats.
  1631. * @param x defines the x coordinate of the source
  1632. * @param y defines the y coordinate of the source
  1633. * @param z defines the z coordinate of the source
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1637. /**
  1638. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1639. * @returns a new empty Vector3
  1640. */
  1641. static Zero(): Vector3;
  1642. /**
  1643. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1644. * @returns a new unit Vector3
  1645. */
  1646. static One(): Vector3;
  1647. /**
  1648. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1649. * @returns a new up Vector3
  1650. */
  1651. static Up(): Vector3;
  1652. /**
  1653. * Gets a up Vector3 that must not be updated
  1654. */
  1655. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1656. /**
  1657. * Gets a zero Vector3 that must not be updated
  1658. */
  1659. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1660. /**
  1661. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1662. * @returns a new down Vector3
  1663. */
  1664. static Down(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1667. * @returns a new forward Vector3
  1668. */
  1669. static Forward(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1672. * @returns a new forward Vector3
  1673. */
  1674. static Backward(): Vector3;
  1675. /**
  1676. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1677. * @returns a new right Vector3
  1678. */
  1679. static Right(): Vector3;
  1680. /**
  1681. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1682. * @returns a new left Vector3
  1683. */
  1684. static Left(): Vector3;
  1685. /**
  1686. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1687. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1688. * @param vector defines the Vector3 to transform
  1689. * @param transformation defines the transformation matrix
  1690. * @returns the transformed Vector3
  1691. */
  1692. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1693. /**
  1694. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @param result defines the Vector3 where to store the result
  1699. */
  1700. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1703. * This method computes tranformed coordinates only, not transformed direction vectors
  1704. * @param x define the x coordinate of the source vector
  1705. * @param y define the y coordinate of the source vector
  1706. * @param z define the z coordinate of the source vector
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param vector defines the Vector3 to transform
  1715. * @param transformation defines the transformation matrix
  1716. * @returns the new Vector3
  1717. */
  1718. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1719. /**
  1720. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @param result defines the Vector3 where to store the result
  1725. */
  1726. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param x define the x coordinate of the source vector
  1731. * @param y define the y coordinate of the source vector
  1732. * @param z define the z coordinate of the source vector
  1733. * @param transformation defines the transformation matrix
  1734. * @param result defines the Vector3 where to store the result
  1735. */
  1736. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1737. /**
  1738. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1739. * @param value1 defines the first control point
  1740. * @param value2 defines the second control point
  1741. * @param value3 defines the third control point
  1742. * @param value4 defines the fourth control point
  1743. * @param amount defines the amount on the spline to use
  1744. * @returns the new Vector3
  1745. */
  1746. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1747. /**
  1748. * 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"
  1749. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1750. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1751. * @param value defines the current value
  1752. * @param min defines the lower range value
  1753. * @param max defines the upper range value
  1754. * @returns the new Vector3
  1755. */
  1756. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1757. /**
  1758. * 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"
  1759. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1760. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1761. * @param value defines the current value
  1762. * @param min defines the lower range value
  1763. * @param max defines the upper range value
  1764. * @param result defines the Vector3 where to store the result
  1765. */
  1766. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1767. /**
  1768. * Checks if a given vector is inside a specific range
  1769. * @param v defines the vector to test
  1770. * @param min defines the minimum range
  1771. * @param max defines the maximum range
  1772. */
  1773. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1774. /**
  1775. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1776. * @param value1 defines the first control point
  1777. * @param tangent1 defines the first tangent vector
  1778. * @param value2 defines the second control point
  1779. * @param tangent2 defines the second tangent vector
  1780. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1781. * @returns the new Vector3
  1782. */
  1783. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1784. /**
  1785. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1786. * @param start defines the start value
  1787. * @param end defines the end value
  1788. * @param amount max defines amount between both (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1800. /**
  1801. * Returns the dot product (float) between the vectors "left" and "right"
  1802. * @param left defines the left operand
  1803. * @param right defines the right operand
  1804. * @returns the dot product
  1805. */
  1806. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1807. /**
  1808. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1809. * The cross product is then orthogonal to both "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the cross product
  1813. */
  1814. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1815. /**
  1816. * Sets the given vector "result" with the cross product of "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @param result defines the Vector3 where to store the result
  1821. */
  1822. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1823. /**
  1824. * Returns a new Vector3 as the normalization of the given vector
  1825. * @param vector defines the Vector3 to normalize
  1826. * @returns the new Vector3
  1827. */
  1828. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Sets the given vector "result" with the normalization of the given first vector
  1831. * @param vector defines the Vector3 to normalize
  1832. * @param result defines the Vector3 where to store the result
  1833. */
  1834. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1835. /**
  1836. * Project a Vector3 onto screen space
  1837. * @param vector defines the Vector3 to project
  1838. * @param world defines the world matrix to use
  1839. * @param transform defines the transform (view x projection) matrix to use
  1840. * @param viewport defines the screen viewport to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1844. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Class used to store quaternion data
  2361. * @see https://en.wikipedia.org/wiki/Quaternion
  2362. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2363. */
  2364. export class Quaternion {
  2365. /** defines the first component (0 by default) */
  2366. x: number;
  2367. /** defines the second component (0 by default) */
  2368. y: number;
  2369. /** defines the third component (0 by default) */
  2370. z: number;
  2371. /** defines the fourth component (1.0 by default) */
  2372. w: number;
  2373. /**
  2374. * Creates a new Quaternion from the given floats
  2375. * @param x defines the first component (0 by default)
  2376. * @param y defines the second component (0 by default)
  2377. * @param z defines the third component (0 by default)
  2378. * @param w defines the fourth component (1.0 by default)
  2379. */
  2380. constructor(
  2381. /** defines the first component (0 by default) */
  2382. x?: number,
  2383. /** defines the second component (0 by default) */
  2384. y?: number,
  2385. /** defines the third component (0 by default) */
  2386. z?: number,
  2387. /** defines the fourth component (1.0 by default) */
  2388. w?: number);
  2389. /**
  2390. * Gets a string representation for the current quaternion
  2391. * @returns a string with the Quaternion coordinates
  2392. */
  2393. toString(): string;
  2394. /**
  2395. * Gets the class name of the quaternion
  2396. * @returns the string "Quaternion"
  2397. */
  2398. getClassName(): string;
  2399. /**
  2400. * Gets a hash code for this quaternion
  2401. * @returns the quaternion hash code
  2402. */
  2403. getHashCode(): number;
  2404. /**
  2405. * Copy the quaternion to an array
  2406. * @returns a new array populated with 4 elements from the quaternion coordinates
  2407. */
  2408. asArray(): number[];
  2409. /**
  2410. * Check if two quaternions are equals
  2411. * @param otherQuaternion defines the second operand
  2412. * @return true if the current quaternion and the given one coordinates are strictly equals
  2413. */
  2414. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2415. /**
  2416. * Clone the current quaternion
  2417. * @returns a new quaternion copied from the current one
  2418. */
  2419. clone(): Quaternion;
  2420. /**
  2421. * Copy a quaternion to the current one
  2422. * @param other defines the other quaternion
  2423. * @returns the updated current quaternion
  2424. */
  2425. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2426. /**
  2427. * Updates the current quaternion with the given float coordinates
  2428. * @param x defines the x coordinate
  2429. * @param y defines the y coordinate
  2430. * @param z defines the z coordinate
  2431. * @param w defines the w coordinate
  2432. * @returns the updated current quaternion
  2433. */
  2434. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2435. /**
  2436. * Updates the current quaternion from the given float coordinates
  2437. * @param x defines the x coordinate
  2438. * @param y defines the y coordinate
  2439. * @param z defines the z coordinate
  2440. * @param w defines the w coordinate
  2441. * @returns the updated current quaternion
  2442. */
  2443. set(x: number, y: number, z: number, w: number): Quaternion;
  2444. /**
  2445. * Adds two quaternions
  2446. * @param other defines the second operand
  2447. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2448. */
  2449. add(other: DeepImmutable<Quaternion>): Quaternion;
  2450. /**
  2451. * Add a quaternion to the current one
  2452. * @param other defines the quaternion to add
  2453. * @returns the current quaternion
  2454. */
  2455. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2456. /**
  2457. * Subtract two quaternions
  2458. * @param other defines the second operand
  2459. * @returns a new quaternion as the subtraction result of the given one from the current one
  2460. */
  2461. subtract(other: Quaternion): Quaternion;
  2462. /**
  2463. * Multiplies the current quaternion by a scale factor
  2464. * @param value defines the scale factor
  2465. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2466. */
  2467. scale(value: number): Quaternion;
  2468. /**
  2469. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2470. * @param scale defines the scale factor
  2471. * @param result defines the Quaternion object where to store the result
  2472. * @returns the unmodified current quaternion
  2473. */
  2474. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2475. /**
  2476. * Multiplies in place the current quaternion by a scale factor
  2477. * @param value defines the scale factor
  2478. * @returns the current modified quaternion
  2479. */
  2480. scaleInPlace(value: number): Quaternion;
  2481. /**
  2482. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2483. * @param scale defines the scale factor
  2484. * @param result defines the Quaternion object where to store the result
  2485. * @returns the unmodified current quaternion
  2486. */
  2487. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2488. /**
  2489. * Multiplies two quaternions
  2490. * @param q1 defines the second operand
  2491. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2492. */
  2493. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2494. /**
  2495. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2496. * @param q1 defines the second operand
  2497. * @param result defines the target quaternion
  2498. * @returns the current quaternion
  2499. */
  2500. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2501. /**
  2502. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2503. * @param q1 defines the second operand
  2504. * @returns the currentupdated quaternion
  2505. */
  2506. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2507. /**
  2508. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2509. * @param ref defines the target quaternion
  2510. * @returns the current quaternion
  2511. */
  2512. conjugateToRef(ref: Quaternion): Quaternion;
  2513. /**
  2514. * Conjugates in place (1-q) the current quaternion
  2515. * @returns the current updated quaternion
  2516. */
  2517. conjugateInPlace(): Quaternion;
  2518. /**
  2519. * Conjugates in place (1-q) the current quaternion
  2520. * @returns a new quaternion
  2521. */
  2522. conjugate(): Quaternion;
  2523. /**
  2524. * Gets length of current quaternion
  2525. * @returns the quaternion length (float)
  2526. */
  2527. length(): number;
  2528. /**
  2529. * Normalize in place the current quaternion
  2530. * @returns the current updated quaternion
  2531. */
  2532. normalize(): Quaternion;
  2533. /**
  2534. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2535. * @param order is a reserved parameter and is ignore for now
  2536. * @returns a new Vector3 containing the Euler angles
  2537. */
  2538. toEulerAngles(order?: string): Vector3;
  2539. /**
  2540. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2541. * @param result defines the vector which will be filled with the Euler angles
  2542. * @param order is a reserved parameter and is ignore for now
  2543. * @returns the current unchanged quaternion
  2544. */
  2545. toEulerAnglesToRef(result: Vector3): Quaternion;
  2546. /**
  2547. * Updates the given rotation matrix with the current quaternion values
  2548. * @param result defines the target matrix
  2549. * @returns the current unchanged quaternion
  2550. */
  2551. toRotationMatrix(result: Matrix): Quaternion;
  2552. /**
  2553. * Updates the current quaternion from the given rotation matrix values
  2554. * @param matrix defines the source matrix
  2555. * @returns the current updated quaternion
  2556. */
  2557. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2558. /**
  2559. * Creates a new quaternion from a rotation matrix
  2560. * @param matrix defines the source matrix
  2561. * @returns a new quaternion created from the given rotation matrix values
  2562. */
  2563. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2564. /**
  2565. * Updates the given quaternion with the given rotation matrix values
  2566. * @param matrix defines the source matrix
  2567. * @param result defines the target quaternion
  2568. */
  2569. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2570. /**
  2571. * Returns the dot product (float) between the quaternions "left" and "right"
  2572. * @param left defines the left operand
  2573. * @param right defines the right operand
  2574. * @returns the dot product
  2575. */
  2576. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2577. /**
  2578. * Checks if the two quaternions are close to each other
  2579. * @param quat0 defines the first quaternion to check
  2580. * @param quat1 defines the second quaternion to check
  2581. * @returns true if the two quaternions are close to each other
  2582. */
  2583. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2584. /**
  2585. * Creates an empty quaternion
  2586. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2587. */
  2588. static Zero(): Quaternion;
  2589. /**
  2590. * Inverse a given quaternion
  2591. * @param q defines the source quaternion
  2592. * @returns a new quaternion as the inverted current quaternion
  2593. */
  2594. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2595. /**
  2596. * Inverse a given quaternion
  2597. * @param q defines the source quaternion
  2598. * @param result the quaternion the result will be stored in
  2599. * @returns the result quaternion
  2600. */
  2601. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2602. /**
  2603. * Creates an identity quaternion
  2604. * @returns the identity quaternion
  2605. */
  2606. static Identity(): Quaternion;
  2607. /**
  2608. * Gets a boolean indicating if the given quaternion is identity
  2609. * @param quaternion defines the quaternion to check
  2610. * @returns true if the quaternion is identity
  2611. */
  2612. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2613. /**
  2614. * Creates a quaternion from a rotation around an axis
  2615. * @param axis defines the axis to use
  2616. * @param angle defines the angle to use
  2617. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2618. */
  2619. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2620. /**
  2621. * Creates a rotation around an axis and stores it into the given quaternion
  2622. * @param axis defines the axis to use
  2623. * @param angle defines the angle to use
  2624. * @param result defines the target quaternion
  2625. * @returns the target quaternion
  2626. */
  2627. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2628. /**
  2629. * Creates a new quaternion from data stored into an array
  2630. * @param array defines the data source
  2631. * @param offset defines the offset in the source array where the data starts
  2632. * @returns a new quaternion
  2633. */
  2634. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2635. /**
  2636. * Create a quaternion from Euler rotation angles
  2637. * @param x Pitch
  2638. * @param y Yaw
  2639. * @param z Roll
  2640. * @returns the new Quaternion
  2641. */
  2642. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2643. /**
  2644. * Updates a quaternion from Euler rotation angles
  2645. * @param x Pitch
  2646. * @param y Yaw
  2647. * @param z Roll
  2648. * @param result the quaternion to store the result
  2649. * @returns the updated quaternion
  2650. */
  2651. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2652. /**
  2653. * Create a quaternion from Euler rotation vector
  2654. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2655. * @returns the new Quaternion
  2656. */
  2657. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2658. /**
  2659. * Updates a quaternion from Euler rotation vector
  2660. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2661. * @param result the quaternion to store the result
  2662. * @returns the updated quaternion
  2663. */
  2664. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2665. /**
  2666. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2667. * @param yaw defines the rotation around Y axis
  2668. * @param pitch defines the rotation around X axis
  2669. * @param roll defines the rotation around Z axis
  2670. * @returns the new quaternion
  2671. */
  2672. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2673. /**
  2674. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2675. * @param yaw defines the rotation around Y axis
  2676. * @param pitch defines the rotation around X axis
  2677. * @param roll defines the rotation around Z axis
  2678. * @param result defines the target quaternion
  2679. */
  2680. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2681. /**
  2682. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2683. * @param alpha defines the rotation around first axis
  2684. * @param beta defines the rotation around second axis
  2685. * @param gamma defines the rotation around third axis
  2686. * @returns the new quaternion
  2687. */
  2688. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2689. /**
  2690. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2691. * @param alpha defines the rotation around first axis
  2692. * @param beta defines the rotation around second axis
  2693. * @param gamma defines the rotation around third axis
  2694. * @param result defines the target quaternion
  2695. */
  2696. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2697. /**
  2698. * 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)
  2699. * @param axis1 defines the first axis
  2700. * @param axis2 defines the second axis
  2701. * @param axis3 defines the third axis
  2702. * @returns the new quaternion
  2703. */
  2704. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2705. /**
  2706. * 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
  2707. * @param axis1 defines the first axis
  2708. * @param axis2 defines the second axis
  2709. * @param axis3 defines the third axis
  2710. * @param ref defines the target quaternion
  2711. */
  2712. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2713. /**
  2714. * Interpolates between two quaternions
  2715. * @param left defines first quaternion
  2716. * @param right defines second quaternion
  2717. * @param amount defines the gradient to use
  2718. * @returns the new interpolated quaternion
  2719. */
  2720. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2721. /**
  2722. * Interpolates between two quaternions and stores it into a target quaternion
  2723. * @param left defines first quaternion
  2724. * @param right defines second quaternion
  2725. * @param amount defines the gradient to use
  2726. * @param result defines the target quaternion
  2727. */
  2728. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2729. /**
  2730. * Interpolate between two quaternions using Hermite interpolation
  2731. * @param value1 defines first quaternion
  2732. * @param tangent1 defines the incoming tangent
  2733. * @param value2 defines second quaternion
  2734. * @param tangent2 defines the outgoing tangent
  2735. * @param amount defines the target quaternion
  2736. * @returns the new interpolated quaternion
  2737. */
  2738. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2739. }
  2740. /**
  2741. * Class used to store matrix data (4x4)
  2742. */
  2743. export class Matrix {
  2744. private static _updateFlagSeed;
  2745. private static _identityReadOnly;
  2746. private _isIdentity;
  2747. private _isIdentityDirty;
  2748. private _isIdentity3x2;
  2749. private _isIdentity3x2Dirty;
  2750. /**
  2751. * Gets the update flag of the matrix which is an unique number for the matrix.
  2752. * It will be incremented every time the matrix data change.
  2753. * You can use it to speed the comparison between two versions of the same matrix.
  2754. */
  2755. updateFlag: number;
  2756. private readonly _m;
  2757. /**
  2758. * Gets the internal data of the matrix
  2759. */
  2760. readonly m: DeepImmutable<Float32Array>;
  2761. /** @hidden */ private _markAsUpdated(): void;
  2762. /** @hidden */
  2763. private _updateIdentityStatus;
  2764. /**
  2765. * Creates an empty matrix (filled with zeros)
  2766. */
  2767. constructor();
  2768. /**
  2769. * Check if the current matrix is identity
  2770. * @returns true is the matrix is the identity matrix
  2771. */
  2772. isIdentity(): boolean;
  2773. /**
  2774. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2775. * @returns true is the matrix is the identity matrix
  2776. */
  2777. isIdentityAs3x2(): boolean;
  2778. /**
  2779. * Gets the determinant of the matrix
  2780. * @returns the matrix determinant
  2781. */
  2782. determinant(): number;
  2783. /**
  2784. * Returns the matrix as a Float32Array
  2785. * @returns the matrix underlying array
  2786. */
  2787. toArray(): DeepImmutable<Float32Array>;
  2788. /**
  2789. * Returns the matrix as a Float32Array
  2790. * @returns the matrix underlying array.
  2791. */
  2792. asArray(): DeepImmutable<Float32Array>;
  2793. /**
  2794. * Inverts the current matrix in place
  2795. * @returns the current inverted matrix
  2796. */
  2797. invert(): Matrix;
  2798. /**
  2799. * Sets all the matrix elements to zero
  2800. * @returns the current matrix
  2801. */
  2802. reset(): Matrix;
  2803. /**
  2804. * Adds the current matrix with a second one
  2805. * @param other defines the matrix to add
  2806. * @returns a new matrix as the addition of the current matrix and the given one
  2807. */
  2808. add(other: DeepImmutable<Matrix>): Matrix;
  2809. /**
  2810. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2811. * @param other defines the matrix to add
  2812. * @param result defines the target matrix
  2813. * @returns the current matrix
  2814. */
  2815. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2816. /**
  2817. * Adds in place the given matrix to the current matrix
  2818. * @param other defines the second operand
  2819. * @returns the current updated matrix
  2820. */
  2821. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2822. /**
  2823. * Sets the given matrix to the current inverted Matrix
  2824. * @param other defines the target matrix
  2825. * @returns the unmodified current matrix
  2826. */
  2827. invertToRef(other: Matrix): Matrix;
  2828. /**
  2829. * add a value at the specified position in the current Matrix
  2830. * @param index the index of the value within the matrix. between 0 and 15.
  2831. * @param value the value to be added
  2832. * @returns the current updated matrix
  2833. */
  2834. addAtIndex(index: number, value: number): Matrix;
  2835. /**
  2836. * mutiply the specified position in the current Matrix by a value
  2837. * @param index the index of the value within the matrix. between 0 and 15.
  2838. * @param value the value to be added
  2839. * @returns the current updated matrix
  2840. */
  2841. multiplyAtIndex(index: number, value: number): Matrix;
  2842. /**
  2843. * Inserts the translation vector (using 3 floats) in the current matrix
  2844. * @param x defines the 1st component of the translation
  2845. * @param y defines the 2nd component of the translation
  2846. * @param z defines the 3rd component of the translation
  2847. * @returns the current updated matrix
  2848. */
  2849. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2850. /**
  2851. * Adds the translation vector (using 3 floats) in the current matrix
  2852. * @param x defines the 1st component of the translation
  2853. * @param y defines the 2nd component of the translation
  2854. * @param z defines the 3rd component of the translation
  2855. * @returns the current updated matrix
  2856. */
  2857. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2858. /**
  2859. * Inserts the translation vector in the current matrix
  2860. * @param vector3 defines the translation to insert
  2861. * @returns the current updated matrix
  2862. */
  2863. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2864. /**
  2865. * Gets the translation value of the current matrix
  2866. * @returns a new Vector3 as the extracted translation from the matrix
  2867. */
  2868. getTranslation(): Vector3;
  2869. /**
  2870. * Fill a Vector3 with the extracted translation from the matrix
  2871. * @param result defines the Vector3 where to store the translation
  2872. * @returns the current matrix
  2873. */
  2874. getTranslationToRef(result: Vector3): Matrix;
  2875. /**
  2876. * Remove rotation and scaling part from the matrix
  2877. * @returns the updated matrix
  2878. */
  2879. removeRotationAndScaling(): Matrix;
  2880. /**
  2881. * Multiply two matrices
  2882. * @param other defines the second operand
  2883. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2884. */
  2885. multiply(other: DeepImmutable<Matrix>): Matrix;
  2886. /**
  2887. * Copy the current matrix from the given one
  2888. * @param other defines the source matrix
  2889. * @returns the current updated matrix
  2890. */
  2891. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2892. /**
  2893. * Populates the given array from the starting index with the current matrix values
  2894. * @param array defines the target array
  2895. * @param offset defines the offset in the target array where to start storing values
  2896. * @returns the current matrix
  2897. */
  2898. copyToArray(array: Float32Array, offset?: number): Matrix;
  2899. /**
  2900. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2901. * @param other defines the second operand
  2902. * @param result defines the matrix where to store the multiplication
  2903. * @returns the current matrix
  2904. */
  2905. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2906. /**
  2907. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2908. * @param other defines the second operand
  2909. * @param result defines the array where to store the multiplication
  2910. * @param offset defines the offset in the target array where to start storing values
  2911. * @returns the current matrix
  2912. */
  2913. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2914. /**
  2915. * Check equality between this matrix and a second one
  2916. * @param value defines the second matrix to compare
  2917. * @returns true is the current matrix and the given one values are strictly equal
  2918. */
  2919. equals(value: DeepImmutable<Matrix>): boolean;
  2920. /**
  2921. * Clone the current matrix
  2922. * @returns a new matrix from the current matrix
  2923. */
  2924. clone(): Matrix;
  2925. /**
  2926. * Returns the name of the current matrix class
  2927. * @returns the string "Matrix"
  2928. */
  2929. getClassName(): string;
  2930. /**
  2931. * Gets the hash code of the current matrix
  2932. * @returns the hash code
  2933. */
  2934. getHashCode(): number;
  2935. /**
  2936. * Decomposes the current Matrix into a translation, rotation and scaling components
  2937. * @param scale defines the scale vector3 given as a reference to update
  2938. * @param rotation defines the rotation quaternion given as a reference to update
  2939. * @param translation defines the translation vector3 given as a reference to update
  2940. * @returns true if operation was successful
  2941. */
  2942. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2943. /**
  2944. * Gets specific row of the matrix
  2945. * @param index defines the number of the row to get
  2946. * @returns the index-th row of the current matrix as a new Vector4
  2947. */
  2948. getRow(index: number): Nullable<Vector4>;
  2949. /**
  2950. * Sets the index-th row of the current matrix to the vector4 values
  2951. * @param index defines the number of the row to set
  2952. * @param row defines the target vector4
  2953. * @returns the updated current matrix
  2954. */
  2955. setRow(index: number, row: Vector4): Matrix;
  2956. /**
  2957. * Compute the transpose of the matrix
  2958. * @returns the new transposed matrix
  2959. */
  2960. transpose(): Matrix;
  2961. /**
  2962. * Compute the transpose of the matrix and store it in a given matrix
  2963. * @param result defines the target matrix
  2964. * @returns the current matrix
  2965. */
  2966. transposeToRef(result: Matrix): Matrix;
  2967. /**
  2968. * Sets the index-th row of the current matrix with the given 4 x float values
  2969. * @param index defines the row index
  2970. * @param x defines the x component to set
  2971. * @param y defines the y component to set
  2972. * @param z defines the z component to set
  2973. * @param w defines the w component to set
  2974. * @returns the updated current matrix
  2975. */
  2976. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2977. /**
  2978. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2979. * @param scale defines the scale factor
  2980. * @returns a new matrix
  2981. */
  2982. scale(scale: number): Matrix;
  2983. /**
  2984. * Scale the current matrix values by a factor to a given result matrix
  2985. * @param scale defines the scale factor
  2986. * @param result defines the matrix to store the result
  2987. * @returns the current matrix
  2988. */
  2989. scaleToRef(scale: number, result: Matrix): Matrix;
  2990. /**
  2991. * Scale the current matrix values by a factor and add the result to a given matrix
  2992. * @param scale defines the scale factor
  2993. * @param result defines the Matrix to store the result
  2994. * @returns the current matrix
  2995. */
  2996. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  2997. /**
  2998. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  2999. * @param ref matrix to store the result
  3000. */
  3001. toNormalMatrix(ref: Matrix): void;
  3002. /**
  3003. * Gets only rotation part of the current matrix
  3004. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3005. */
  3006. getRotationMatrix(): Matrix;
  3007. /**
  3008. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3009. * @param result defines the target matrix to store data to
  3010. * @returns the current matrix
  3011. */
  3012. getRotationMatrixToRef(result: Matrix): Matrix;
  3013. /**
  3014. * Toggles model matrix from being right handed to left handed in place and vice versa
  3015. */
  3016. toggleModelMatrixHandInPlace(): void;
  3017. /**
  3018. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3019. */
  3020. toggleProjectionMatrixHandInPlace(): void;
  3021. /**
  3022. * Creates a matrix from an array
  3023. * @param array defines the source array
  3024. * @param offset defines an offset in the source array
  3025. * @returns a new Matrix set from the starting index of the given array
  3026. */
  3027. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3028. /**
  3029. * Copy the content of an array into a given matrix
  3030. * @param array defines the source array
  3031. * @param offset defines an offset in the source array
  3032. * @param result defines the target matrix
  3033. */
  3034. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3035. /**
  3036. * Stores an array into a matrix after having multiplied each component by a given factor
  3037. * @param array defines the source array
  3038. * @param offset defines the offset in the source array
  3039. * @param scale defines the scaling factor
  3040. * @param result defines the target matrix
  3041. */
  3042. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3043. /**
  3044. * Gets an identity matrix that must not be updated
  3045. */
  3046. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3047. /**
  3048. * Stores a list of values (16) inside a given matrix
  3049. * @param initialM11 defines 1st value of 1st row
  3050. * @param initialM12 defines 2nd value of 1st row
  3051. * @param initialM13 defines 3rd value of 1st row
  3052. * @param initialM14 defines 4th value of 1st row
  3053. * @param initialM21 defines 1st value of 2nd row
  3054. * @param initialM22 defines 2nd value of 2nd row
  3055. * @param initialM23 defines 3rd value of 2nd row
  3056. * @param initialM24 defines 4th value of 2nd row
  3057. * @param initialM31 defines 1st value of 3rd row
  3058. * @param initialM32 defines 2nd value of 3rd row
  3059. * @param initialM33 defines 3rd value of 3rd row
  3060. * @param initialM34 defines 4th value of 3rd row
  3061. * @param initialM41 defines 1st value of 4th row
  3062. * @param initialM42 defines 2nd value of 4th row
  3063. * @param initialM43 defines 3rd value of 4th row
  3064. * @param initialM44 defines 4th value of 4th row
  3065. * @param result defines the target matrix
  3066. */
  3067. 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;
  3068. /**
  3069. * Creates new matrix from a list of values (16)
  3070. * @param initialM11 defines 1st value of 1st row
  3071. * @param initialM12 defines 2nd value of 1st row
  3072. * @param initialM13 defines 3rd value of 1st row
  3073. * @param initialM14 defines 4th value of 1st row
  3074. * @param initialM21 defines 1st value of 2nd row
  3075. * @param initialM22 defines 2nd value of 2nd row
  3076. * @param initialM23 defines 3rd value of 2nd row
  3077. * @param initialM24 defines 4th value of 2nd row
  3078. * @param initialM31 defines 1st value of 3rd row
  3079. * @param initialM32 defines 2nd value of 3rd row
  3080. * @param initialM33 defines 3rd value of 3rd row
  3081. * @param initialM34 defines 4th value of 3rd row
  3082. * @param initialM41 defines 1st value of 4th row
  3083. * @param initialM42 defines 2nd value of 4th row
  3084. * @param initialM43 defines 3rd value of 4th row
  3085. * @param initialM44 defines 4th value of 4th row
  3086. * @returns the new matrix
  3087. */
  3088. 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;
  3089. /**
  3090. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3091. * @param scale defines the scale vector3
  3092. * @param rotation defines the rotation quaternion
  3093. * @param translation defines the translation vector3
  3094. * @returns a new matrix
  3095. */
  3096. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3097. /**
  3098. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3099. * @param scale defines the scale vector3
  3100. * @param rotation defines the rotation quaternion
  3101. * @param translation defines the translation vector3
  3102. * @param result defines the target matrix
  3103. */
  3104. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3105. /**
  3106. * Creates a new identity matrix
  3107. * @returns a new identity matrix
  3108. */
  3109. static Identity(): Matrix;
  3110. /**
  3111. * Creates a new identity matrix and stores the result in a given matrix
  3112. * @param result defines the target matrix
  3113. */
  3114. static IdentityToRef(result: Matrix): void;
  3115. /**
  3116. * Creates a new zero matrix
  3117. * @returns a new zero matrix
  3118. */
  3119. static Zero(): Matrix;
  3120. /**
  3121. * Creates a new rotation matrix for "angle" radians around the X axis
  3122. * @param angle defines the angle (in radians) to use
  3123. * @return the new matrix
  3124. */
  3125. static RotationX(angle: number): Matrix;
  3126. /**
  3127. * Creates a new matrix as the invert of a given matrix
  3128. * @param source defines the source matrix
  3129. * @returns the new matrix
  3130. */
  3131. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3132. /**
  3133. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3134. * @param angle defines the angle (in radians) to use
  3135. * @param result defines the target matrix
  3136. */
  3137. static RotationXToRef(angle: number, result: Matrix): void;
  3138. /**
  3139. * Creates a new rotation matrix for "angle" radians around the Y axis
  3140. * @param angle defines the angle (in radians) to use
  3141. * @return the new matrix
  3142. */
  3143. static RotationY(angle: number): Matrix;
  3144. /**
  3145. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3146. * @param angle defines the angle (in radians) to use
  3147. * @param result defines the target matrix
  3148. */
  3149. static RotationYToRef(angle: number, result: Matrix): void;
  3150. /**
  3151. * Creates a new rotation matrix for "angle" radians around the Z axis
  3152. * @param angle defines the angle (in radians) to use
  3153. * @return the new matrix
  3154. */
  3155. static RotationZ(angle: number): Matrix;
  3156. /**
  3157. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3158. * @param angle defines the angle (in radians) to use
  3159. * @param result defines the target matrix
  3160. */
  3161. static RotationZToRef(angle: number, result: Matrix): void;
  3162. /**
  3163. * Creates a new rotation matrix for "angle" radians around the given axis
  3164. * @param axis defines the axis to use
  3165. * @param angle defines the angle (in radians) to use
  3166. * @return the new matrix
  3167. */
  3168. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3169. /**
  3170. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3171. * @param axis defines the axis to use
  3172. * @param angle defines the angle (in radians) to use
  3173. * @param result defines the target matrix
  3174. */
  3175. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3176. /**
  3177. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3178. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3179. * @param from defines the vector to align
  3180. * @param to defines the vector to align to
  3181. * @param result defines the target matrix
  3182. */
  3183. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3184. /**
  3185. * Creates a rotation matrix
  3186. * @param yaw defines the yaw angle in radians (Y axis)
  3187. * @param pitch defines the pitch angle in radians (X axis)
  3188. * @param roll defines the roll angle in radians (X axis)
  3189. * @returns the new rotation matrix
  3190. */
  3191. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3192. /**
  3193. * Creates a rotation matrix and stores it in a given matrix
  3194. * @param yaw defines the yaw angle in radians (Y axis)
  3195. * @param pitch defines the pitch angle in radians (X axis)
  3196. * @param roll defines the roll angle in radians (X axis)
  3197. * @param result defines the target matrix
  3198. */
  3199. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3200. /**
  3201. * Creates a scaling matrix
  3202. * @param x defines the scale factor on X axis
  3203. * @param y defines the scale factor on Y axis
  3204. * @param z defines the scale factor on Z axis
  3205. * @returns the new matrix
  3206. */
  3207. static Scaling(x: number, y: number, z: number): Matrix;
  3208. /**
  3209. * Creates a scaling matrix and stores it in a given matrix
  3210. * @param x defines the scale factor on X axis
  3211. * @param y defines the scale factor on Y axis
  3212. * @param z defines the scale factor on Z axis
  3213. * @param result defines the target matrix
  3214. */
  3215. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3216. /**
  3217. * Creates a translation matrix
  3218. * @param x defines the translation on X axis
  3219. * @param y defines the translation on Y axis
  3220. * @param z defines the translationon Z axis
  3221. * @returns the new matrix
  3222. */
  3223. static Translation(x: number, y: number, z: number): Matrix;
  3224. /**
  3225. * Creates a translation matrix and stores it in a given matrix
  3226. * @param x defines the translation on X axis
  3227. * @param y defines the translation on Y axis
  3228. * @param z defines the translationon Z axis
  3229. * @param result defines the target matrix
  3230. */
  3231. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3232. /**
  3233. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3234. * @param startValue defines the start value
  3235. * @param endValue defines the end value
  3236. * @param gradient defines the gradient factor
  3237. * @returns the new matrix
  3238. */
  3239. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3240. /**
  3241. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3242. * @param startValue defines the start value
  3243. * @param endValue defines the end value
  3244. * @param gradient defines the gradient factor
  3245. * @param result defines the Matrix object where to store data
  3246. */
  3247. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3248. /**
  3249. * Builds a new matrix whose values are computed by:
  3250. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3251. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3252. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3253. * @param startValue defines the first matrix
  3254. * @param endValue defines the second matrix
  3255. * @param gradient defines the gradient between the two matrices
  3256. * @returns the new matrix
  3257. */
  3258. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3259. /**
  3260. * Update a matrix to values which are computed by:
  3261. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3262. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3263. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3264. * @param startValue defines the first matrix
  3265. * @param endValue defines the second matrix
  3266. * @param gradient defines the gradient between the two matrices
  3267. * @param result defines the target matrix
  3268. */
  3269. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3270. /**
  3271. * 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"
  3272. * This function works in left handed mode
  3273. * @param eye defines the final position of the entity
  3274. * @param target defines where the entity should look at
  3275. * @param up defines the up vector for the entity
  3276. * @returns the new matrix
  3277. */
  3278. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3279. /**
  3280. * 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".
  3281. * This function works in left handed mode
  3282. * @param eye defines the final position of the entity
  3283. * @param target defines where the entity should look at
  3284. * @param up defines the up vector for the entity
  3285. * @param result defines the target matrix
  3286. */
  3287. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3288. /**
  3289. * 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"
  3290. * This function works in right handed mode
  3291. * @param eye defines the final position of the entity
  3292. * @param target defines where the entity should look at
  3293. * @param up defines the up vector for the entity
  3294. * @returns the new matrix
  3295. */
  3296. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3297. /**
  3298. * 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".
  3299. * This function works in right handed mode
  3300. * @param eye defines the final position of the entity
  3301. * @param target defines where the entity should look at
  3302. * @param up defines the up vector for the entity
  3303. * @param result defines the target matrix
  3304. */
  3305. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3306. /**
  3307. * Create a left-handed orthographic projection matrix
  3308. * @param width defines the viewport width
  3309. * @param height defines the viewport height
  3310. * @param znear defines the near clip plane
  3311. * @param zfar defines the far clip plane
  3312. * @returns a new matrix as a left-handed orthographic projection matrix
  3313. */
  3314. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3315. /**
  3316. * Store a left-handed orthographic projection to a given matrix
  3317. * @param width defines the viewport width
  3318. * @param height defines the viewport height
  3319. * @param znear defines the near clip plane
  3320. * @param zfar defines the far clip plane
  3321. * @param result defines the target matrix
  3322. */
  3323. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3324. /**
  3325. * Create a left-handed orthographic projection matrix
  3326. * @param left defines the viewport left coordinate
  3327. * @param right defines the viewport right coordinate
  3328. * @param bottom defines the viewport bottom coordinate
  3329. * @param top defines the viewport top coordinate
  3330. * @param znear defines the near clip plane
  3331. * @param zfar defines the far clip plane
  3332. * @returns a new matrix as a left-handed orthographic projection matrix
  3333. */
  3334. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3335. /**
  3336. * Stores a left-handed orthographic projection into a given matrix
  3337. * @param left defines the viewport left coordinate
  3338. * @param right defines the viewport right coordinate
  3339. * @param bottom defines the viewport bottom coordinate
  3340. * @param top defines the viewport top coordinate
  3341. * @param znear defines the near clip plane
  3342. * @param zfar defines the far clip plane
  3343. * @param result defines the target matrix
  3344. */
  3345. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3346. /**
  3347. * Creates a right-handed orthographic projection matrix
  3348. * @param left defines the viewport left coordinate
  3349. * @param right defines the viewport right coordinate
  3350. * @param bottom defines the viewport bottom coordinate
  3351. * @param top defines the viewport top coordinate
  3352. * @param znear defines the near clip plane
  3353. * @param zfar defines the far clip plane
  3354. * @returns a new matrix as a right-handed orthographic projection matrix
  3355. */
  3356. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3357. /**
  3358. * Stores a right-handed orthographic projection into a given matrix
  3359. * @param left defines the viewport left coordinate
  3360. * @param right defines the viewport right coordinate
  3361. * @param bottom defines the viewport bottom coordinate
  3362. * @param top defines the viewport top coordinate
  3363. * @param znear defines the near clip plane
  3364. * @param zfar defines the far clip plane
  3365. * @param result defines the target matrix
  3366. */
  3367. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3368. /**
  3369. * Creates a left-handed perspective projection matrix
  3370. * @param width defines the viewport width
  3371. * @param height defines the viewport height
  3372. * @param znear defines the near clip plane
  3373. * @param zfar defines the far clip plane
  3374. * @returns a new matrix as a left-handed perspective projection matrix
  3375. */
  3376. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3377. /**
  3378. * Creates a left-handed perspective projection matrix
  3379. * @param fov defines the horizontal field of view
  3380. * @param aspect defines the aspect ratio
  3381. * @param znear defines the near clip plane
  3382. * @param zfar defines the far clip plane
  3383. * @returns a new matrix as a left-handed perspective projection matrix
  3384. */
  3385. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3386. /**
  3387. * Stores a left-handed perspective projection into a given matrix
  3388. * @param fov defines the horizontal field of view
  3389. * @param aspect defines the aspect ratio
  3390. * @param znear defines the near clip plane
  3391. * @param zfar defines the far clip plane
  3392. * @param result defines the target matrix
  3393. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3394. */
  3395. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3396. /**
  3397. * Creates a right-handed perspective projection matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @returns a new matrix as a right-handed perspective projection matrix
  3403. */
  3404. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3405. /**
  3406. * Stores a right-handed perspective projection into a given matrix
  3407. * @param fov defines the horizontal field of view
  3408. * @param aspect defines the aspect ratio
  3409. * @param znear defines the near clip plane
  3410. * @param zfar defines the far clip plane
  3411. * @param result defines the target matrix
  3412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3413. */
  3414. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3415. /**
  3416. * Stores a perspective projection for WebVR info a given matrix
  3417. * @param fov defines the field of view
  3418. * @param znear defines the near clip plane
  3419. * @param zfar defines the far clip plane
  3420. * @param result defines the target matrix
  3421. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3422. */
  3423. static PerspectiveFovWebVRToRef(fov: {
  3424. upDegrees: number;
  3425. downDegrees: number;
  3426. leftDegrees: number;
  3427. rightDegrees: number;
  3428. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3429. /**
  3430. * Computes a complete transformation matrix
  3431. * @param viewport defines the viewport to use
  3432. * @param world defines the world matrix
  3433. * @param view defines the view matrix
  3434. * @param projection defines the projection matrix
  3435. * @param zmin defines the near clip plane
  3436. * @param zmax defines the far clip plane
  3437. * @returns the transformation matrix
  3438. */
  3439. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3440. /**
  3441. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3442. * @param matrix defines the matrix to use
  3443. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3444. */
  3445. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3446. /**
  3447. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3448. * @param matrix defines the matrix to use
  3449. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3450. */
  3451. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3452. /**
  3453. * Compute the transpose of a given matrix
  3454. * @param matrix defines the matrix to transpose
  3455. * @returns the new matrix
  3456. */
  3457. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3458. /**
  3459. * Compute the transpose of a matrix and store it in a target matrix
  3460. * @param matrix defines the matrix to transpose
  3461. * @param result defines the target matrix
  3462. */
  3463. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3464. /**
  3465. * Computes a reflection matrix from a plane
  3466. * @param plane defines the reflection plane
  3467. * @returns a new matrix
  3468. */
  3469. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3470. /**
  3471. * Computes a reflection matrix from a plane
  3472. * @param plane defines the reflection plane
  3473. * @param result defines the target matrix
  3474. */
  3475. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3476. /**
  3477. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3478. * @param xaxis defines the value of the 1st axis
  3479. * @param yaxis defines the value of the 2nd axis
  3480. * @param zaxis defines the value of the 3rd axis
  3481. * @param result defines the target matrix
  3482. */
  3483. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3484. /**
  3485. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3486. * @param quat defines the quaternion to use
  3487. * @param result defines the target matrix
  3488. */
  3489. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3490. }
  3491. /**
  3492. * @hidden
  3493. */
  3494. export class TmpVectors {
  3495. static Vector2: Vector2[];
  3496. static Vector3: Vector3[];
  3497. static Vector4: Vector4[];
  3498. static Quaternion: Quaternion[];
  3499. static Matrix: Matrix[];
  3500. }
  3501. }
  3502. declare module BABYLON {
  3503. /**
  3504. * Class used to hold a RBG color
  3505. */
  3506. export class Color3 {
  3507. /**
  3508. * Defines the red component (between 0 and 1, default is 0)
  3509. */
  3510. r: number;
  3511. /**
  3512. * Defines the green component (between 0 and 1, default is 0)
  3513. */
  3514. g: number;
  3515. /**
  3516. * Defines the blue component (between 0 and 1, default is 0)
  3517. */
  3518. b: number;
  3519. /**
  3520. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3521. * @param r defines the red component (between 0 and 1, default is 0)
  3522. * @param g defines the green component (between 0 and 1, default is 0)
  3523. * @param b defines the blue component (between 0 and 1, default is 0)
  3524. */
  3525. constructor(
  3526. /**
  3527. * Defines the red component (between 0 and 1, default is 0)
  3528. */
  3529. r?: number,
  3530. /**
  3531. * Defines the green component (between 0 and 1, default is 0)
  3532. */
  3533. g?: number,
  3534. /**
  3535. * Defines the blue component (between 0 and 1, default is 0)
  3536. */
  3537. b?: number);
  3538. /**
  3539. * Creates a string with the Color3 current values
  3540. * @returns the string representation of the Color3 object
  3541. */
  3542. toString(): string;
  3543. /**
  3544. * Returns the string "Color3"
  3545. * @returns "Color3"
  3546. */
  3547. getClassName(): string;
  3548. /**
  3549. * Compute the Color3 hash code
  3550. * @returns an unique number that can be used to hash Color3 objects
  3551. */
  3552. getHashCode(): number;
  3553. /**
  3554. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3555. * @param array defines the array where to store the r,g,b components
  3556. * @param index defines an optional index in the target array to define where to start storing values
  3557. * @returns the current Color3 object
  3558. */
  3559. toArray(array: FloatArray, index?: number): Color3;
  3560. /**
  3561. * Returns a new Color4 object from the current Color3 and the given alpha
  3562. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3563. * @returns a new Color4 object
  3564. */
  3565. toColor4(alpha?: number): Color4;
  3566. /**
  3567. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3568. * @returns the new array
  3569. */
  3570. asArray(): number[];
  3571. /**
  3572. * Returns the luminance value
  3573. * @returns a float value
  3574. */
  3575. toLuminance(): number;
  3576. /**
  3577. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3578. * @param otherColor defines the second operand
  3579. * @returns the new Color3 object
  3580. */
  3581. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3582. /**
  3583. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3584. * @param otherColor defines the second operand
  3585. * @param result defines the Color3 object where to store the result
  3586. * @returns the current Color3
  3587. */
  3588. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3589. /**
  3590. * Determines equality between Color3 objects
  3591. * @param otherColor defines the second operand
  3592. * @returns true if the rgb values are equal to the given ones
  3593. */
  3594. equals(otherColor: DeepImmutable<Color3>): boolean;
  3595. /**
  3596. * Determines equality between the current Color3 object and a set of r,b,g values
  3597. * @param r defines the red component to check
  3598. * @param g defines the green component to check
  3599. * @param b defines the blue component to check
  3600. * @returns true if the rgb values are equal to the given ones
  3601. */
  3602. equalsFloats(r: number, g: number, b: number): boolean;
  3603. /**
  3604. * Multiplies in place each rgb value by scale
  3605. * @param scale defines the scaling factor
  3606. * @returns the updated Color3
  3607. */
  3608. scale(scale: number): Color3;
  3609. /**
  3610. * Multiplies the rgb values by scale and stores the result into "result"
  3611. * @param scale defines the scaling factor
  3612. * @param result defines the Color3 object where to store the result
  3613. * @returns the unmodified current Color3
  3614. */
  3615. scaleToRef(scale: number, result: Color3): Color3;
  3616. /**
  3617. * Scale the current Color3 values by a factor and add the result to a given Color3
  3618. * @param scale defines the scale factor
  3619. * @param result defines color to store the result into
  3620. * @returns the unmodified current Color3
  3621. */
  3622. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3623. /**
  3624. * Clamps the rgb values by the min and max values and stores the result into "result"
  3625. * @param min defines minimum clamping value (default is 0)
  3626. * @param max defines maximum clamping value (default is 1)
  3627. * @param result defines color to store the result into
  3628. * @returns the original Color3
  3629. */
  3630. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3631. /**
  3632. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3633. * @param otherColor defines the second operand
  3634. * @returns the new Color3
  3635. */
  3636. add(otherColor: DeepImmutable<Color3>): Color3;
  3637. /**
  3638. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3639. * @param otherColor defines the second operand
  3640. * @param result defines Color3 object to store the result into
  3641. * @returns the unmodified current Color3
  3642. */
  3643. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3644. /**
  3645. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3646. * @param otherColor defines the second operand
  3647. * @returns the new Color3
  3648. */
  3649. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3650. /**
  3651. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3652. * @param otherColor defines the second operand
  3653. * @param result defines Color3 object to store the result into
  3654. * @returns the unmodified current Color3
  3655. */
  3656. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3657. /**
  3658. * Copy the current object
  3659. * @returns a new Color3 copied the current one
  3660. */
  3661. clone(): Color3;
  3662. /**
  3663. * Copies the rgb values from the source in the current Color3
  3664. * @param source defines the source Color3 object
  3665. * @returns the updated Color3 object
  3666. */
  3667. copyFrom(source: DeepImmutable<Color3>): Color3;
  3668. /**
  3669. * Updates the Color3 rgb values from the given floats
  3670. * @param r defines the red component to read from
  3671. * @param g defines the green component to read from
  3672. * @param b defines the blue component to read from
  3673. * @returns the current Color3 object
  3674. */
  3675. copyFromFloats(r: number, g: number, b: number): Color3;
  3676. /**
  3677. * Updates the Color3 rgb values from the given floats
  3678. * @param r defines the red component to read from
  3679. * @param g defines the green component to read from
  3680. * @param b defines the blue component to read from
  3681. * @returns the current Color3 object
  3682. */
  3683. set(r: number, g: number, b: number): Color3;
  3684. /**
  3685. * Compute the Color3 hexadecimal code as a string
  3686. * @returns a string containing the hexadecimal representation of the Color3 object
  3687. */
  3688. toHexString(): string;
  3689. /**
  3690. * Computes a new Color3 converted from the current one to linear space
  3691. * @returns a new Color3 object
  3692. */
  3693. toLinearSpace(): Color3;
  3694. /**
  3695. * Converts current color in rgb space to HSV values
  3696. * @returns a new color3 representing the HSV values
  3697. */
  3698. toHSV(): Color3;
  3699. /**
  3700. * Converts current color in rgb space to HSV values
  3701. * @param result defines the Color3 where to store the HSV values
  3702. */
  3703. toHSVToRef(result: Color3): void;
  3704. /**
  3705. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3706. * @param convertedColor defines the Color3 object where to store the linear space version
  3707. * @returns the unmodified Color3
  3708. */
  3709. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3710. /**
  3711. * Computes a new Color3 converted from the current one to gamma space
  3712. * @returns a new Color3 object
  3713. */
  3714. toGammaSpace(): Color3;
  3715. /**
  3716. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3717. * @param convertedColor defines the Color3 object where to store the gamma space version
  3718. * @returns the unmodified Color3
  3719. */
  3720. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3721. private static _BlackReadOnly;
  3722. /**
  3723. * Convert Hue, saturation and value to a Color3 (RGB)
  3724. * @param hue defines the hue
  3725. * @param saturation defines the saturation
  3726. * @param value defines the value
  3727. * @param result defines the Color3 where to store the RGB values
  3728. */
  3729. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3730. /**
  3731. * Creates a new Color3 from the string containing valid hexadecimal values
  3732. * @param hex defines a string containing valid hexadecimal values
  3733. * @returns a new Color3 object
  3734. */
  3735. static FromHexString(hex: string): Color3;
  3736. /**
  3737. * Creates a new Color3 from the starting index of the given array
  3738. * @param array defines the source array
  3739. * @param offset defines an offset in the source array
  3740. * @returns a new Color3 object
  3741. */
  3742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3743. /**
  3744. * Creates a new Color3 from integer values (< 256)
  3745. * @param r defines the red component to read from (value between 0 and 255)
  3746. * @param g defines the green component to read from (value between 0 and 255)
  3747. * @param b defines the blue component to read from (value between 0 and 255)
  3748. * @returns a new Color3 object
  3749. */
  3750. static FromInts(r: number, g: number, b: number): Color3;
  3751. /**
  3752. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3753. * @param start defines the start Color3 value
  3754. * @param end defines the end Color3 value
  3755. * @param amount defines the gradient value between start and end
  3756. * @returns a new Color3 object
  3757. */
  3758. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3759. /**
  3760. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3761. * @param left defines the start value
  3762. * @param right defines the end value
  3763. * @param amount defines the gradient factor
  3764. * @param result defines the Color3 object where to store the result
  3765. */
  3766. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3767. /**
  3768. * Returns a Color3 value containing a red color
  3769. * @returns a new Color3 object
  3770. */
  3771. static Red(): Color3;
  3772. /**
  3773. * Returns a Color3 value containing a green color
  3774. * @returns a new Color3 object
  3775. */
  3776. static Green(): Color3;
  3777. /**
  3778. * Returns a Color3 value containing a blue color
  3779. * @returns a new Color3 object
  3780. */
  3781. static Blue(): Color3;
  3782. /**
  3783. * Returns a Color3 value containing a black color
  3784. * @returns a new Color3 object
  3785. */
  3786. static Black(): Color3;
  3787. /**
  3788. * Gets a Color3 value containing a black color that must not be updated
  3789. */
  3790. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3791. /**
  3792. * Returns a Color3 value containing a white color
  3793. * @returns a new Color3 object
  3794. */
  3795. static White(): Color3;
  3796. /**
  3797. * Returns a Color3 value containing a purple color
  3798. * @returns a new Color3 object
  3799. */
  3800. static Purple(): Color3;
  3801. /**
  3802. * Returns a Color3 value containing a magenta color
  3803. * @returns a new Color3 object
  3804. */
  3805. static Magenta(): Color3;
  3806. /**
  3807. * Returns a Color3 value containing a yellow color
  3808. * @returns a new Color3 object
  3809. */
  3810. static Yellow(): Color3;
  3811. /**
  3812. * Returns a Color3 value containing a gray color
  3813. * @returns a new Color3 object
  3814. */
  3815. static Gray(): Color3;
  3816. /**
  3817. * Returns a Color3 value containing a teal color
  3818. * @returns a new Color3 object
  3819. */
  3820. static Teal(): Color3;
  3821. /**
  3822. * Returns a Color3 value containing a random color
  3823. * @returns a new Color3 object
  3824. */
  3825. static Random(): Color3;
  3826. }
  3827. /**
  3828. * Class used to hold a RBGA color
  3829. */
  3830. export class Color4 {
  3831. /**
  3832. * Defines the red component (between 0 and 1, default is 0)
  3833. */
  3834. r: number;
  3835. /**
  3836. * Defines the green component (between 0 and 1, default is 0)
  3837. */
  3838. g: number;
  3839. /**
  3840. * Defines the blue component (between 0 and 1, default is 0)
  3841. */
  3842. b: number;
  3843. /**
  3844. * Defines the alpha component (between 0 and 1, default is 1)
  3845. */
  3846. a: number;
  3847. /**
  3848. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3849. * @param r defines the red component (between 0 and 1, default is 0)
  3850. * @param g defines the green component (between 0 and 1, default is 0)
  3851. * @param b defines the blue component (between 0 and 1, default is 0)
  3852. * @param a defines the alpha component (between 0 and 1, default is 1)
  3853. */
  3854. constructor(
  3855. /**
  3856. * Defines the red component (between 0 and 1, default is 0)
  3857. */
  3858. r?: number,
  3859. /**
  3860. * Defines the green component (between 0 and 1, default is 0)
  3861. */
  3862. g?: number,
  3863. /**
  3864. * Defines the blue component (between 0 and 1, default is 0)
  3865. */
  3866. b?: number,
  3867. /**
  3868. * Defines the alpha component (between 0 and 1, default is 1)
  3869. */
  3870. a?: number);
  3871. /**
  3872. * Adds in place the given Color4 values to the current Color4 object
  3873. * @param right defines the second operand
  3874. * @returns the current updated Color4 object
  3875. */
  3876. addInPlace(right: DeepImmutable<Color4>): Color4;
  3877. /**
  3878. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3879. * @returns the new array
  3880. */
  3881. asArray(): number[];
  3882. /**
  3883. * Stores from the starting index in the given array the Color4 successive values
  3884. * @param array defines the array where to store the r,g,b components
  3885. * @param index defines an optional index in the target array to define where to start storing values
  3886. * @returns the current Color4 object
  3887. */
  3888. toArray(array: number[], index?: number): Color4;
  3889. /**
  3890. * Determines equality between Color4 objects
  3891. * @param otherColor defines the second operand
  3892. * @returns true if the rgba values are equal to the given ones
  3893. */
  3894. equals(otherColor: DeepImmutable<Color4>): boolean;
  3895. /**
  3896. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3897. * @param right defines the second operand
  3898. * @returns a new Color4 object
  3899. */
  3900. add(right: DeepImmutable<Color4>): Color4;
  3901. /**
  3902. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3903. * @param right defines the second operand
  3904. * @returns a new Color4 object
  3905. */
  3906. subtract(right: DeepImmutable<Color4>): Color4;
  3907. /**
  3908. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3909. * @param right defines the second operand
  3910. * @param result defines the Color4 object where to store the result
  3911. * @returns the current Color4 object
  3912. */
  3913. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3914. /**
  3915. * Creates a new Color4 with the current Color4 values multiplied by scale
  3916. * @param scale defines the scaling factor to apply
  3917. * @returns a new Color4 object
  3918. */
  3919. scale(scale: number): Color4;
  3920. /**
  3921. * Multiplies the current Color4 values by scale and stores the result in "result"
  3922. * @param scale defines the scaling factor to apply
  3923. * @param result defines the Color4 object where to store the result
  3924. * @returns the current unmodified Color4
  3925. */
  3926. scaleToRef(scale: number, result: Color4): Color4;
  3927. /**
  3928. * Scale the current Color4 values by a factor and add the result to a given Color4
  3929. * @param scale defines the scale factor
  3930. * @param result defines the Color4 object where to store the result
  3931. * @returns the unmodified current Color4
  3932. */
  3933. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3934. /**
  3935. * Clamps the rgb values by the min and max values and stores the result into "result"
  3936. * @param min defines minimum clamping value (default is 0)
  3937. * @param max defines maximum clamping value (default is 1)
  3938. * @param result defines color to store the result into.
  3939. * @returns the cuurent Color4
  3940. */
  3941. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3942. /**
  3943. * Multipy an Color4 value by another and return a new Color4 object
  3944. * @param color defines the Color4 value to multiply by
  3945. * @returns a new Color4 object
  3946. */
  3947. multiply(color: Color4): Color4;
  3948. /**
  3949. * Multipy a Color4 value by another and push the result in a reference value
  3950. * @param color defines the Color4 value to multiply by
  3951. * @param result defines the Color4 to fill the result in
  3952. * @returns the result Color4
  3953. */
  3954. multiplyToRef(color: Color4, result: Color4): Color4;
  3955. /**
  3956. * Creates a string with the Color4 current values
  3957. * @returns the string representation of the Color4 object
  3958. */
  3959. toString(): string;
  3960. /**
  3961. * Returns the string "Color4"
  3962. * @returns "Color4"
  3963. */
  3964. getClassName(): string;
  3965. /**
  3966. * Compute the Color4 hash code
  3967. * @returns an unique number that can be used to hash Color4 objects
  3968. */
  3969. getHashCode(): number;
  3970. /**
  3971. * Creates a new Color4 copied from the current one
  3972. * @returns a new Color4 object
  3973. */
  3974. clone(): Color4;
  3975. /**
  3976. * Copies the given Color4 values into the current one
  3977. * @param source defines the source Color4 object
  3978. * @returns the current updated Color4 object
  3979. */
  3980. copyFrom(source: Color4): Color4;
  3981. /**
  3982. * Copies the given float values into the current one
  3983. * @param r defines the red component to read from
  3984. * @param g defines the green component to read from
  3985. * @param b defines the blue component to read from
  3986. * @param a defines the alpha component to read from
  3987. * @returns the current updated Color4 object
  3988. */
  3989. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3990. /**
  3991. * Copies the given float values into the current one
  3992. * @param r defines the red component to read from
  3993. * @param g defines the green component to read from
  3994. * @param b defines the blue component to read from
  3995. * @param a defines the alpha component to read from
  3996. * @returns the current updated Color4 object
  3997. */
  3998. set(r: number, g: number, b: number, a: number): Color4;
  3999. /**
  4000. * Compute the Color4 hexadecimal code as a string
  4001. * @returns a string containing the hexadecimal representation of the Color4 object
  4002. */
  4003. toHexString(): string;
  4004. /**
  4005. * Computes a new Color4 converted from the current one to linear space
  4006. * @returns a new Color4 object
  4007. */
  4008. toLinearSpace(): Color4;
  4009. /**
  4010. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4011. * @param convertedColor defines the Color4 object where to store the linear space version
  4012. * @returns the unmodified Color4
  4013. */
  4014. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4015. /**
  4016. * Computes a new Color4 converted from the current one to gamma space
  4017. * @returns a new Color4 object
  4018. */
  4019. toGammaSpace(): Color4;
  4020. /**
  4021. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4022. * @param convertedColor defines the Color4 object where to store the gamma space version
  4023. * @returns the unmodified Color4
  4024. */
  4025. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4026. /**
  4027. * Creates a new Color4 from the string containing valid hexadecimal values
  4028. * @param hex defines a string containing valid hexadecimal values
  4029. * @returns a new Color4 object
  4030. */
  4031. static FromHexString(hex: string): Color4;
  4032. /**
  4033. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4034. * @param left defines the start value
  4035. * @param right defines the end value
  4036. * @param amount defines the gradient factor
  4037. * @returns a new Color4 object
  4038. */
  4039. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4040. /**
  4041. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4042. * @param left defines the start value
  4043. * @param right defines the end value
  4044. * @param amount defines the gradient factor
  4045. * @param result defines the Color4 object where to store data
  4046. */
  4047. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4048. /**
  4049. * Creates a new Color4 from a Color3 and an alpha value
  4050. * @param color3 defines the source Color3 to read from
  4051. * @param alpha defines the alpha component (1.0 by default)
  4052. * @returns a new Color4 object
  4053. */
  4054. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4055. /**
  4056. * Creates a new Color4 from the starting index element of the given array
  4057. * @param array defines the source array to read from
  4058. * @param offset defines the offset in the source array
  4059. * @returns a new Color4 object
  4060. */
  4061. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4062. /**
  4063. * Creates a new Color3 from integer values (< 256)
  4064. * @param r defines the red component to read from (value between 0 and 255)
  4065. * @param g defines the green component to read from (value between 0 and 255)
  4066. * @param b defines the blue component to read from (value between 0 and 255)
  4067. * @param a defines the alpha component to read from (value between 0 and 255)
  4068. * @returns a new Color3 object
  4069. */
  4070. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4071. /**
  4072. * Check the content of a given array and convert it to an array containing RGBA data
  4073. * If the original array was already containing count * 4 values then it is returned directly
  4074. * @param colors defines the array to check
  4075. * @param count defines the number of RGBA data to expect
  4076. * @returns an array containing count * 4 values (RGBA)
  4077. */
  4078. static CheckColors4(colors: number[], count: number): number[];
  4079. }
  4080. /**
  4081. * @hidden
  4082. */
  4083. export class TmpColors {
  4084. static Color3: Color3[];
  4085. static Color4: Color4[];
  4086. }
  4087. }
  4088. declare module BABYLON {
  4089. /**
  4090. * Class representing spherical harmonics coefficients to the 3rd degree
  4091. */
  4092. export class SphericalHarmonics {
  4093. /**
  4094. * Defines whether or not the harmonics have been prescaled for rendering.
  4095. */
  4096. preScaled: boolean;
  4097. /**
  4098. * The l0,0 coefficients of the spherical harmonics
  4099. */
  4100. l00: Vector3;
  4101. /**
  4102. * The l1,-1 coefficients of the spherical harmonics
  4103. */
  4104. l1_1: Vector3;
  4105. /**
  4106. * The l1,0 coefficients of the spherical harmonics
  4107. */
  4108. l10: Vector3;
  4109. /**
  4110. * The l1,1 coefficients of the spherical harmonics
  4111. */
  4112. l11: Vector3;
  4113. /**
  4114. * The l2,-2 coefficients of the spherical harmonics
  4115. */
  4116. l2_2: Vector3;
  4117. /**
  4118. * The l2,-1 coefficients of the spherical harmonics
  4119. */
  4120. l2_1: Vector3;
  4121. /**
  4122. * The l2,0 coefficients of the spherical harmonics
  4123. */
  4124. l20: Vector3;
  4125. /**
  4126. * The l2,1 coefficients of the spherical harmonics
  4127. */
  4128. l21: Vector3;
  4129. /**
  4130. * The l2,2 coefficients of the spherical harmonics
  4131. */
  4132. l22: Vector3;
  4133. /**
  4134. * Adds a light to the spherical harmonics
  4135. * @param direction the direction of the light
  4136. * @param color the color of the light
  4137. * @param deltaSolidAngle the delta solid angle of the light
  4138. */
  4139. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4140. /**
  4141. * Scales the spherical harmonics by the given amount
  4142. * @param scale the amount to scale
  4143. */
  4144. scaleInPlace(scale: number): void;
  4145. /**
  4146. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4147. *
  4148. * ```
  4149. * E_lm = A_l * L_lm
  4150. * ```
  4151. *
  4152. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4153. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4154. * the scaling factors are given in equation 9.
  4155. */
  4156. convertIncidentRadianceToIrradiance(): void;
  4157. /**
  4158. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4159. *
  4160. * ```
  4161. * L = (1/pi) * E * rho
  4162. * ```
  4163. *
  4164. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4165. */
  4166. convertIrradianceToLambertianRadiance(): void;
  4167. /**
  4168. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4169. * required operations at run time.
  4170. *
  4171. * This is simply done by scaling back the SH with Ylm constants parameter.
  4172. * The trigonometric part being applied by the shader at run time.
  4173. */
  4174. preScaleForRendering(): void;
  4175. /**
  4176. * Constructs a spherical harmonics from an array.
  4177. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4178. * @returns the spherical harmonics
  4179. */
  4180. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4181. /**
  4182. * Gets the spherical harmonics from polynomial
  4183. * @param polynomial the spherical polynomial
  4184. * @returns the spherical harmonics
  4185. */
  4186. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4187. }
  4188. /**
  4189. * Class representing spherical polynomial coefficients to the 3rd degree
  4190. */
  4191. export class SphericalPolynomial {
  4192. private _harmonics;
  4193. /**
  4194. * The spherical harmonics used to create the polynomials.
  4195. */
  4196. readonly preScaledHarmonics: SphericalHarmonics;
  4197. /**
  4198. * The x coefficients of the spherical polynomial
  4199. */
  4200. x: Vector3;
  4201. /**
  4202. * The y coefficients of the spherical polynomial
  4203. */
  4204. y: Vector3;
  4205. /**
  4206. * The z coefficients of the spherical polynomial
  4207. */
  4208. z: Vector3;
  4209. /**
  4210. * The xx coefficients of the spherical polynomial
  4211. */
  4212. xx: Vector3;
  4213. /**
  4214. * The yy coefficients of the spherical polynomial
  4215. */
  4216. yy: Vector3;
  4217. /**
  4218. * The zz coefficients of the spherical polynomial
  4219. */
  4220. zz: Vector3;
  4221. /**
  4222. * The xy coefficients of the spherical polynomial
  4223. */
  4224. xy: Vector3;
  4225. /**
  4226. * The yz coefficients of the spherical polynomial
  4227. */
  4228. yz: Vector3;
  4229. /**
  4230. * The zx coefficients of the spherical polynomial
  4231. */
  4232. zx: Vector3;
  4233. /**
  4234. * Adds an ambient color to the spherical polynomial
  4235. * @param color the color to add
  4236. */
  4237. addAmbient(color: Color3): void;
  4238. /**
  4239. * Scales the spherical polynomial by the given amount
  4240. * @param scale the amount to scale
  4241. */
  4242. scaleInPlace(scale: number): void;
  4243. /**
  4244. * Gets the spherical polynomial from harmonics
  4245. * @param harmonics the spherical harmonics
  4246. * @returns the spherical polynomial
  4247. */
  4248. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4249. /**
  4250. * Constructs a spherical polynomial from an array.
  4251. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4252. * @returns the spherical polynomial
  4253. */
  4254. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4255. }
  4256. }
  4257. declare module BABYLON {
  4258. /**
  4259. * Define options used to create a render target texture
  4260. */
  4261. export class RenderTargetCreationOptions {
  4262. /**
  4263. * Specifies is mipmaps must be generated
  4264. */
  4265. generateMipMaps?: boolean;
  4266. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4267. generateDepthBuffer?: boolean;
  4268. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4269. generateStencilBuffer?: boolean;
  4270. /** Defines texture type (int by default) */
  4271. type?: number;
  4272. /** Defines sampling mode (trilinear by default) */
  4273. samplingMode?: number;
  4274. /** Defines format (RGBA by default) */
  4275. format?: number;
  4276. }
  4277. }
  4278. declare module BABYLON {
  4279. /**
  4280. * @hidden
  4281. **/
  4282. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  4283. }
  4284. }
  4285. declare module BABYLON {
  4286. /** Defines the cross module used constants to avoid circular dependncies */
  4287. export class Constants {
  4288. /** Defines that alpha blending is disabled */
  4289. static readonly ALPHA_DISABLE: number;
  4290. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4291. static readonly ALPHA_ADD: number;
  4292. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4293. static readonly ALPHA_COMBINE: number;
  4294. /** Defines that alpha blending to DEST - SRC * DEST */
  4295. static readonly ALPHA_SUBTRACT: number;
  4296. /** Defines that alpha blending to SRC * DEST */
  4297. static readonly ALPHA_MULTIPLY: number;
  4298. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4299. static readonly ALPHA_MAXIMIZED: number;
  4300. /** Defines that alpha blending to SRC + DEST */
  4301. static readonly ALPHA_ONEONE: number;
  4302. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4303. static readonly ALPHA_PREMULTIPLIED: number;
  4304. /**
  4305. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4306. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4307. */
  4308. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4309. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4310. static readonly ALPHA_INTERPOLATE: number;
  4311. /**
  4312. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4313. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4314. */
  4315. static readonly ALPHA_SCREENMODE: number;
  4316. /**
  4317. * Defines that alpha blending to SRC + DST
  4318. * Alpha will be set to SRC ALPHA + DST ALPHA
  4319. */
  4320. static readonly ALPHA_ONEONE_ONEONE: number;
  4321. /**
  4322. * Defines that alpha blending to SRC * DST ALPHA + DST
  4323. * Alpha will be set to 0
  4324. */
  4325. static readonly ALPHA_ALPHATOCOLOR: number;
  4326. /**
  4327. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4328. */
  4329. static readonly ALPHA_REVERSEONEMINUS: number;
  4330. /**
  4331. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4332. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4333. */
  4334. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4335. /**
  4336. * Defines that alpha blending to SRC + DST
  4337. * Alpha will be set to SRC ALPHA
  4338. */
  4339. static readonly ALPHA_ONEONE_ONEZERO: number;
  4340. /** Defines that alpha blending equation a SUM */
  4341. static readonly ALPHA_EQUATION_ADD: number;
  4342. /** Defines that alpha blending equation a SUBSTRACTION */
  4343. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4344. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4345. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4346. /** Defines that alpha blending equation a MAX operation */
  4347. static readonly ALPHA_EQUATION_MAX: number;
  4348. /** Defines that alpha blending equation a MIN operation */
  4349. static readonly ALPHA_EQUATION_MIN: number;
  4350. /**
  4351. * Defines that alpha blending equation a DARKEN operation:
  4352. * It takes the min of the src and sums the alpha channels.
  4353. */
  4354. static readonly ALPHA_EQUATION_DARKEN: number;
  4355. /** Defines that the ressource is not delayed*/
  4356. static readonly DELAYLOADSTATE_NONE: number;
  4357. /** Defines that the ressource was successfully delay loaded */
  4358. static readonly DELAYLOADSTATE_LOADED: number;
  4359. /** Defines that the ressource is currently delay loading */
  4360. static readonly DELAYLOADSTATE_LOADING: number;
  4361. /** Defines that the ressource is delayed and has not started loading */
  4362. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4364. static readonly NEVER: number;
  4365. /** 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 */
  4366. static readonly ALWAYS: number;
  4367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4368. static readonly LESS: number;
  4369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4370. static readonly EQUAL: number;
  4371. /** 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 */
  4372. static readonly LEQUAL: number;
  4373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4374. static readonly GREATER: number;
  4375. /** 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 */
  4376. static readonly GEQUAL: number;
  4377. /** 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 */
  4378. static readonly NOTEQUAL: number;
  4379. /** Passed to stencilOperation to specify that stencil value must be kept */
  4380. static readonly KEEP: number;
  4381. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4382. static readonly REPLACE: number;
  4383. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4384. static readonly INCR: number;
  4385. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4386. static readonly DECR: number;
  4387. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4388. static readonly INVERT: number;
  4389. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4390. static readonly INCR_WRAP: number;
  4391. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4392. static readonly DECR_WRAP: number;
  4393. /** Texture is not repeating outside of 0..1 UVs */
  4394. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4395. /** Texture is repeating outside of 0..1 UVs */
  4396. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4397. /** Texture is repeating and mirrored */
  4398. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4399. /** ALPHA */
  4400. static readonly TEXTUREFORMAT_ALPHA: number;
  4401. /** LUMINANCE */
  4402. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4403. /** LUMINANCE_ALPHA */
  4404. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4405. /** RGB */
  4406. static readonly TEXTUREFORMAT_RGB: number;
  4407. /** RGBA */
  4408. static readonly TEXTUREFORMAT_RGBA: number;
  4409. /** RED */
  4410. static readonly TEXTUREFORMAT_RED: number;
  4411. /** RED (2nd reference) */
  4412. static readonly TEXTUREFORMAT_R: number;
  4413. /** RG */
  4414. static readonly TEXTUREFORMAT_RG: number;
  4415. /** RED_INTEGER */
  4416. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4417. /** RED_INTEGER (2nd reference) */
  4418. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4419. /** RG_INTEGER */
  4420. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4421. /** RGB_INTEGER */
  4422. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4423. /** RGBA_INTEGER */
  4424. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4425. /** UNSIGNED_BYTE */
  4426. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4427. /** UNSIGNED_BYTE (2nd reference) */
  4428. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4429. /** FLOAT */
  4430. static readonly TEXTURETYPE_FLOAT: number;
  4431. /** HALF_FLOAT */
  4432. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4433. /** BYTE */
  4434. static readonly TEXTURETYPE_BYTE: number;
  4435. /** SHORT */
  4436. static readonly TEXTURETYPE_SHORT: number;
  4437. /** UNSIGNED_SHORT */
  4438. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4439. /** INT */
  4440. static readonly TEXTURETYPE_INT: number;
  4441. /** UNSIGNED_INT */
  4442. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4443. /** UNSIGNED_SHORT_4_4_4_4 */
  4444. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4445. /** UNSIGNED_SHORT_5_5_5_1 */
  4446. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4447. /** UNSIGNED_SHORT_5_6_5 */
  4448. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4449. /** UNSIGNED_INT_2_10_10_10_REV */
  4450. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4451. /** UNSIGNED_INT_24_8 */
  4452. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4453. /** UNSIGNED_INT_10F_11F_11F_REV */
  4454. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4455. /** UNSIGNED_INT_5_9_9_9_REV */
  4456. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4457. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4458. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4459. /** nearest is mag = nearest and min = nearest and mip = linear */
  4460. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4461. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4462. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4463. /** Trilinear is mag = linear and min = linear and mip = linear */
  4464. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4465. /** nearest is mag = nearest and min = nearest and mip = linear */
  4466. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4468. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4469. /** Trilinear is mag = linear and min = linear and mip = linear */
  4470. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4471. /** mag = nearest and min = nearest and mip = nearest */
  4472. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4473. /** mag = nearest and min = linear and mip = nearest */
  4474. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4475. /** mag = nearest and min = linear and mip = linear */
  4476. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4477. /** mag = nearest and min = linear and mip = none */
  4478. static readonly TEXTURE_NEAREST_LINEAR: number;
  4479. /** mag = nearest and min = nearest and mip = none */
  4480. static readonly TEXTURE_NEAREST_NEAREST: number;
  4481. /** mag = linear and min = nearest and mip = nearest */
  4482. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4483. /** mag = linear and min = nearest and mip = linear */
  4484. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4485. /** mag = linear and min = linear and mip = none */
  4486. static readonly TEXTURE_LINEAR_LINEAR: number;
  4487. /** mag = linear and min = nearest and mip = none */
  4488. static readonly TEXTURE_LINEAR_NEAREST: number;
  4489. /** Explicit coordinates mode */
  4490. static readonly TEXTURE_EXPLICIT_MODE: number;
  4491. /** Spherical coordinates mode */
  4492. static readonly TEXTURE_SPHERICAL_MODE: number;
  4493. /** Planar coordinates mode */
  4494. static readonly TEXTURE_PLANAR_MODE: number;
  4495. /** Cubic coordinates mode */
  4496. static readonly TEXTURE_CUBIC_MODE: number;
  4497. /** Projection coordinates mode */
  4498. static readonly TEXTURE_PROJECTION_MODE: number;
  4499. /** Skybox coordinates mode */
  4500. static readonly TEXTURE_SKYBOX_MODE: number;
  4501. /** Inverse Cubic coordinates mode */
  4502. static readonly TEXTURE_INVCUBIC_MODE: number;
  4503. /** Equirectangular coordinates mode */
  4504. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4505. /** Equirectangular Fixed coordinates mode */
  4506. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4507. /** Equirectangular Fixed Mirrored coordinates mode */
  4508. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4509. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4510. static readonly SCALEMODE_FLOOR: number;
  4511. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4512. static readonly SCALEMODE_NEAREST: number;
  4513. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4514. static readonly SCALEMODE_CEILING: number;
  4515. /**
  4516. * The dirty texture flag value
  4517. */
  4518. static readonly MATERIAL_TextureDirtyFlag: number;
  4519. /**
  4520. * The dirty light flag value
  4521. */
  4522. static readonly MATERIAL_LightDirtyFlag: number;
  4523. /**
  4524. * The dirty fresnel flag value
  4525. */
  4526. static readonly MATERIAL_FresnelDirtyFlag: number;
  4527. /**
  4528. * The dirty attribute flag value
  4529. */
  4530. static readonly MATERIAL_AttributesDirtyFlag: number;
  4531. /**
  4532. * The dirty misc flag value
  4533. */
  4534. static readonly MATERIAL_MiscDirtyFlag: number;
  4535. /**
  4536. * The all dirty flag value
  4537. */
  4538. static readonly MATERIAL_AllDirtyFlag: number;
  4539. /**
  4540. * Returns the triangle fill mode
  4541. */
  4542. static readonly MATERIAL_TriangleFillMode: number;
  4543. /**
  4544. * Returns the wireframe mode
  4545. */
  4546. static readonly MATERIAL_WireFrameFillMode: number;
  4547. /**
  4548. * Returns the point fill mode
  4549. */
  4550. static readonly MATERIAL_PointFillMode: number;
  4551. /**
  4552. * Returns the point list draw mode
  4553. */
  4554. static readonly MATERIAL_PointListDrawMode: number;
  4555. /**
  4556. * Returns the line list draw mode
  4557. */
  4558. static readonly MATERIAL_LineListDrawMode: number;
  4559. /**
  4560. * Returns the line loop draw mode
  4561. */
  4562. static readonly MATERIAL_LineLoopDrawMode: number;
  4563. /**
  4564. * Returns the line strip draw mode
  4565. */
  4566. static readonly MATERIAL_LineStripDrawMode: number;
  4567. /**
  4568. * Returns the triangle strip draw mode
  4569. */
  4570. static readonly MATERIAL_TriangleStripDrawMode: number;
  4571. /**
  4572. * Returns the triangle fan draw mode
  4573. */
  4574. static readonly MATERIAL_TriangleFanDrawMode: number;
  4575. /**
  4576. * Stores the clock-wise side orientation
  4577. */
  4578. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4579. /**
  4580. * Stores the counter clock-wise side orientation
  4581. */
  4582. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4583. /**
  4584. * Nothing
  4585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4586. */
  4587. static readonly ACTION_NothingTrigger: number;
  4588. /**
  4589. * On pick
  4590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4591. */
  4592. static readonly ACTION_OnPickTrigger: number;
  4593. /**
  4594. * On left pick
  4595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4596. */
  4597. static readonly ACTION_OnLeftPickTrigger: number;
  4598. /**
  4599. * On right pick
  4600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4601. */
  4602. static readonly ACTION_OnRightPickTrigger: number;
  4603. /**
  4604. * On center pick
  4605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4606. */
  4607. static readonly ACTION_OnCenterPickTrigger: number;
  4608. /**
  4609. * On pick down
  4610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4611. */
  4612. static readonly ACTION_OnPickDownTrigger: number;
  4613. /**
  4614. * On double pick
  4615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4616. */
  4617. static readonly ACTION_OnDoublePickTrigger: number;
  4618. /**
  4619. * On pick up
  4620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4621. */
  4622. static readonly ACTION_OnPickUpTrigger: number;
  4623. /**
  4624. * On pick out.
  4625. * This trigger will only be raised if you also declared a OnPickDown
  4626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4627. */
  4628. static readonly ACTION_OnPickOutTrigger: number;
  4629. /**
  4630. * On long press
  4631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4632. */
  4633. static readonly ACTION_OnLongPressTrigger: number;
  4634. /**
  4635. * On pointer over
  4636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4637. */
  4638. static readonly ACTION_OnPointerOverTrigger: number;
  4639. /**
  4640. * On pointer out
  4641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4642. */
  4643. static readonly ACTION_OnPointerOutTrigger: number;
  4644. /**
  4645. * On every frame
  4646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4647. */
  4648. static readonly ACTION_OnEveryFrameTrigger: number;
  4649. /**
  4650. * On intersection enter
  4651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4652. */
  4653. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4654. /**
  4655. * On intersection exit
  4656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4657. */
  4658. static readonly ACTION_OnIntersectionExitTrigger: number;
  4659. /**
  4660. * On key down
  4661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4662. */
  4663. static readonly ACTION_OnKeyDownTrigger: number;
  4664. /**
  4665. * On key up
  4666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4667. */
  4668. static readonly ACTION_OnKeyUpTrigger: number;
  4669. /**
  4670. * Billboard mode will only apply to Y axis
  4671. */
  4672. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4673. /**
  4674. * Billboard mode will apply to all axes
  4675. */
  4676. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4677. /**
  4678. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4679. */
  4680. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4681. /**
  4682. * Gets or sets base Assets URL
  4683. */
  4684. static PARTICLES_BaseAssetsUrl: string;
  4685. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4686. * Test order :
  4687. * Is the bounding sphere outside the frustum ?
  4688. * If not, are the bounding box vertices outside the frustum ?
  4689. * It not, then the cullable object is in the frustum.
  4690. */
  4691. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4692. /** Culling strategy : Bounding Sphere Only.
  4693. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4694. * It's also less accurate than the standard because some not visible objects can still be selected.
  4695. * Test : is the bounding sphere outside the frustum ?
  4696. * If not, then the cullable object is in the frustum.
  4697. */
  4698. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4699. /** Culling strategy : Optimistic Inclusion.
  4700. * This in an inclusion test first, then the standard exclusion test.
  4701. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4702. * 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.
  4703. * Anyway, it's as accurate as the standard strategy.
  4704. * Test :
  4705. * Is the cullable object bounding sphere center in the frustum ?
  4706. * If not, apply the default culling strategy.
  4707. */
  4708. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4709. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4710. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4711. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4712. * 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.
  4713. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4714. * Test :
  4715. * Is the cullable object bounding sphere center in the frustum ?
  4716. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4717. */
  4718. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4719. /**
  4720. * No logging while loading
  4721. */
  4722. static readonly SCENELOADER_NO_LOGGING: number;
  4723. /**
  4724. * Minimal logging while loading
  4725. */
  4726. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4727. /**
  4728. * Summary logging while loading
  4729. */
  4730. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4731. /**
  4732. * Detailled logging while loading
  4733. */
  4734. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4735. }
  4736. }
  4737. declare module BABYLON {
  4738. /**
  4739. * This represents the required contract to create a new type of texture loader.
  4740. */
  4741. export interface IInternalTextureLoader {
  4742. /**
  4743. * Defines wether the loader supports cascade loading the different faces.
  4744. */
  4745. supportCascades: boolean;
  4746. /**
  4747. * This returns if the loader support the current file information.
  4748. * @param extension defines the file extension of the file being loaded
  4749. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4750. * @param fallback defines the fallback internal texture if any
  4751. * @param isBase64 defines whether the texture is encoded as a base64
  4752. * @param isBuffer defines whether the texture data are stored as a buffer
  4753. * @returns true if the loader can load the specified file
  4754. */
  4755. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4756. /**
  4757. * Transform the url before loading if required.
  4758. * @param rootUrl the url of the texture
  4759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4760. * @returns the transformed texture
  4761. */
  4762. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4763. /**
  4764. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4765. * @param rootUrl the url of the texture
  4766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4767. * @returns the fallback texture
  4768. */
  4769. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4770. /**
  4771. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4772. * @param data contains the texture data
  4773. * @param texture defines the BabylonJS internal texture
  4774. * @param createPolynomials will be true if polynomials have been requested
  4775. * @param onLoad defines the callback to trigger once the texture is ready
  4776. * @param onError defines the callback to trigger in case of error
  4777. */
  4778. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4779. /**
  4780. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4781. * @param data contains the texture data
  4782. * @param texture defines the BabylonJS internal texture
  4783. * @param callback defines the method to call once ready to upload
  4784. */
  4785. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4786. }
  4787. }
  4788. declare module BABYLON {
  4789. /**
  4790. * Class used to store and describe the pipeline context associated with an effect
  4791. */
  4792. export interface IPipelineContext {
  4793. /**
  4794. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4795. */
  4796. isAsync: boolean;
  4797. /**
  4798. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4799. */
  4800. isReady: boolean;
  4801. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4802. }
  4803. }
  4804. declare module BABYLON {
  4805. /**
  4806. * Class used to store gfx data (like WebGLBuffer)
  4807. */
  4808. export class DataBuffer {
  4809. /**
  4810. * Gets or sets the number of objects referencing this buffer
  4811. */
  4812. references: number;
  4813. /** Gets or sets the size of the underlying buffer */
  4814. capacity: number;
  4815. /**
  4816. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4817. */
  4818. is32Bits: boolean;
  4819. /**
  4820. * Gets the underlying buffer
  4821. */
  4822. readonly underlyingResource: any;
  4823. }
  4824. }
  4825. declare module BABYLON {
  4826. /** @hidden */
  4827. export interface IShaderProcessor {
  4828. attributeProcessor?: (attribute: string) => string;
  4829. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4830. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4831. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4832. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4833. lineProcessor?: (line: string, isFragment: boolean) => string;
  4834. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4835. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4836. }
  4837. }
  4838. declare module BABYLON {
  4839. /** @hidden */
  4840. export interface ProcessingOptions {
  4841. defines: string[];
  4842. indexParameters: any;
  4843. isFragment: boolean;
  4844. shouldUseHighPrecisionShader: boolean;
  4845. supportsUniformBuffers: boolean;
  4846. shadersRepository: string;
  4847. includesShadersStore: {
  4848. [key: string]: string;
  4849. };
  4850. processor?: IShaderProcessor;
  4851. version: string;
  4852. platformName: string;
  4853. lookForClosingBracketForUniformBuffer?: boolean;
  4854. }
  4855. }
  4856. declare module BABYLON {
  4857. /**
  4858. * Helper to manipulate strings
  4859. */
  4860. export class StringTools {
  4861. /**
  4862. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4863. * @param str Source string
  4864. * @param suffix Suffix to search for in the source string
  4865. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4866. */
  4867. static EndsWith(str: string, suffix: string): boolean;
  4868. /**
  4869. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4870. * @param str Source string
  4871. * @param suffix Suffix to search for in the source string
  4872. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4873. */
  4874. static StartsWith(str: string, suffix: string): boolean;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /** @hidden */
  4879. export class ShaderCodeNode {
  4880. line: string;
  4881. children: ShaderCodeNode[];
  4882. additionalDefineKey?: string;
  4883. additionalDefineValue?: string;
  4884. isValid(preprocessors: {
  4885. [key: string]: string;
  4886. }): boolean;
  4887. process(preprocessors: {
  4888. [key: string]: string;
  4889. }, options: ProcessingOptions): string;
  4890. }
  4891. }
  4892. declare module BABYLON {
  4893. /** @hidden */
  4894. export class ShaderCodeCursor {
  4895. private _lines;
  4896. lineIndex: number;
  4897. readonly currentLine: string;
  4898. readonly canRead: boolean;
  4899. lines: string[];
  4900. }
  4901. }
  4902. declare module BABYLON {
  4903. /** @hidden */
  4904. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4905. process(preprocessors: {
  4906. [key: string]: string;
  4907. }, options: ProcessingOptions): string;
  4908. }
  4909. }
  4910. declare module BABYLON {
  4911. /** @hidden */
  4912. export class ShaderDefineExpression {
  4913. isTrue(preprocessors: {
  4914. [key: string]: string;
  4915. }): boolean;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class ShaderCodeTestNode extends ShaderCodeNode {
  4921. testExpression: ShaderDefineExpression;
  4922. isValid(preprocessors: {
  4923. [key: string]: string;
  4924. }): boolean;
  4925. }
  4926. }
  4927. declare module BABYLON {
  4928. /** @hidden */
  4929. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4930. define: string;
  4931. not: boolean;
  4932. constructor(define: string, not?: boolean);
  4933. isTrue(preprocessors: {
  4934. [key: string]: string;
  4935. }): boolean;
  4936. }
  4937. }
  4938. declare module BABYLON {
  4939. /** @hidden */
  4940. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4941. leftOperand: ShaderDefineExpression;
  4942. rightOperand: ShaderDefineExpression;
  4943. isTrue(preprocessors: {
  4944. [key: string]: string;
  4945. }): boolean;
  4946. }
  4947. }
  4948. declare module BABYLON {
  4949. /** @hidden */
  4950. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4951. leftOperand: ShaderDefineExpression;
  4952. rightOperand: ShaderDefineExpression;
  4953. isTrue(preprocessors: {
  4954. [key: string]: string;
  4955. }): boolean;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /** @hidden */
  4960. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4961. define: string;
  4962. operand: string;
  4963. testValue: string;
  4964. constructor(define: string, operand: string, testValue: string);
  4965. isTrue(preprocessors: {
  4966. [key: string]: string;
  4967. }): boolean;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * @ignore
  4973. * Application error to support additional information when loading a file
  4974. */
  4975. export class LoadFileError extends Error {
  4976. /** defines the optional web request */
  4977. request?: WebRequest | undefined;
  4978. private static _setPrototypeOf;
  4979. /**
  4980. * Creates a new LoadFileError
  4981. * @param message defines the message of the error
  4982. * @param request defines the optional web request
  4983. */
  4984. constructor(message: string,
  4985. /** defines the optional web request */
  4986. request?: WebRequest | undefined);
  4987. }
  4988. }
  4989. declare module BABYLON {
  4990. /**
  4991. * Class used to enable access to offline support
  4992. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4993. */
  4994. export interface IOfflineProvider {
  4995. /**
  4996. * Gets a boolean indicating if scene must be saved in the database
  4997. */
  4998. enableSceneOffline: boolean;
  4999. /**
  5000. * Gets a boolean indicating if textures must be saved in the database
  5001. */
  5002. enableTexturesOffline: boolean;
  5003. /**
  5004. * Open the offline support and make it available
  5005. * @param successCallback defines the callback to call on success
  5006. * @param errorCallback defines the callback to call on error
  5007. */
  5008. open(successCallback: () => void, errorCallback: () => void): void;
  5009. /**
  5010. * Loads an image from the offline support
  5011. * @param url defines the url to load from
  5012. * @param image defines the target DOM image
  5013. */
  5014. loadImage(url: string, image: HTMLImageElement): void;
  5015. /**
  5016. * Loads a file from offline support
  5017. * @param url defines the URL to load from
  5018. * @param sceneLoaded defines a callback to call on success
  5019. * @param progressCallBack defines a callback to call when progress changed
  5020. * @param errorCallback defines a callback to call on error
  5021. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5022. */
  5023. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5024. }
  5025. }
  5026. declare module BABYLON {
  5027. /**
  5028. * Class used to help managing file picking and drag'n'drop
  5029. * File Storage
  5030. */
  5031. export class FilesInputStore {
  5032. /**
  5033. * List of files ready to be loaded
  5034. */
  5035. static FilesToLoad: {
  5036. [key: string]: File;
  5037. };
  5038. }
  5039. }
  5040. declare module BABYLON {
  5041. /**
  5042. * Class used to define a retry strategy when error happens while loading assets
  5043. */
  5044. export class RetryStrategy {
  5045. /**
  5046. * Function used to defines an exponential back off strategy
  5047. * @param maxRetries defines the maximum number of retries (3 by default)
  5048. * @param baseInterval defines the interval between retries
  5049. * @returns the strategy function to use
  5050. */
  5051. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5052. }
  5053. }
  5054. declare module BABYLON {
  5055. /**
  5056. * @hidden
  5057. */
  5058. export class FileTools {
  5059. /**
  5060. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5061. */
  5062. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5063. /**
  5064. * Gets or sets the base URL to use to load assets
  5065. */
  5066. static BaseUrl: string;
  5067. /**
  5068. * Default behaviour for cors in the application.
  5069. * It can be a string if the expected behavior is identical in the entire app.
  5070. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5071. */
  5072. static CorsBehavior: string | ((url: string | string[]) => string);
  5073. /**
  5074. * Gets or sets a function used to pre-process url before using them to load assets
  5075. */
  5076. static PreprocessUrl: (url: string) => string;
  5077. /**
  5078. * Removes unwanted characters from an url
  5079. * @param url defines the url to clean
  5080. * @returns the cleaned url
  5081. */
  5082. private static _CleanUrl;
  5083. /**
  5084. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5085. * @param url define the url we are trying
  5086. * @param element define the dom element where to configure the cors policy
  5087. */
  5088. static SetCorsBehavior(url: string | string[], element: {
  5089. crossOrigin: string | null;
  5090. }): void;
  5091. /**
  5092. * Loads an image as an HTMLImageElement.
  5093. * @param input url string, ArrayBuffer, or Blob to load
  5094. * @param onLoad callback called when the image successfully loads
  5095. * @param onError callback called when the image fails to load
  5096. * @param offlineProvider offline provider for caching
  5097. * @returns the HTMLImageElement of the loaded image
  5098. */
  5099. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5100. /**
  5101. * Loads a file
  5102. * @param fileToLoad defines the file to load
  5103. * @param callback defines the callback to call when data is loaded
  5104. * @param progressCallBack defines the callback to call during loading process
  5105. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5106. * @returns a file request object
  5107. */
  5108. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5109. /**
  5110. * Loads a file
  5111. * @param url url string, ArrayBuffer, or Blob to load
  5112. * @param onSuccess callback called when the file successfully loads
  5113. * @param onProgress callback called while file is loading (if the server supports this mode)
  5114. * @param offlineProvider defines the offline provider for caching
  5115. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5116. * @param onError callback called when the file fails to load
  5117. * @returns a file request object
  5118. */
  5119. 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;
  5120. /**
  5121. * Checks if the loaded document was accessed via `file:`-Protocol.
  5122. * @returns boolean
  5123. */
  5124. static IsFileURL(): boolean;
  5125. }
  5126. }
  5127. declare module BABYLON {
  5128. /** @hidden */
  5129. export class ShaderProcessor {
  5130. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5131. private static _ProcessPrecision;
  5132. private static _ExtractOperation;
  5133. private static _BuildSubExpression;
  5134. private static _BuildExpression;
  5135. private static _MoveCursorWithinIf;
  5136. private static _MoveCursor;
  5137. private static _EvaluatePreProcessors;
  5138. private static _PreparePreProcessors;
  5139. private static _ProcessShaderConversion;
  5140. private static _ProcessIncludes;
  5141. }
  5142. }
  5143. declare module BABYLON {
  5144. /**
  5145. * Interface used to define common properties for effect fallbacks
  5146. */
  5147. export interface IEffectFallbacks {
  5148. /**
  5149. * Removes the defines that should be removed when falling back.
  5150. * @param currentDefines defines the current define statements for the shader.
  5151. * @param effect defines the current effect we try to compile
  5152. * @returns The resulting defines with defines of the current rank removed.
  5153. */
  5154. reduce(currentDefines: string, effect: Effect): string;
  5155. /**
  5156. * Removes the fallback from the bound mesh.
  5157. */
  5158. unBindMesh(): void;
  5159. /**
  5160. * Checks to see if more fallbacks are still availible.
  5161. */
  5162. hasMoreFallbacks: boolean;
  5163. }
  5164. }
  5165. declare module BABYLON {
  5166. /**
  5167. * Class used to evalaute queries containing `and` and `or` operators
  5168. */
  5169. export class AndOrNotEvaluator {
  5170. /**
  5171. * Evaluate a query
  5172. * @param query defines the query to evaluate
  5173. * @param evaluateCallback defines the callback used to filter result
  5174. * @returns true if the query matches
  5175. */
  5176. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5177. private static _HandleParenthesisContent;
  5178. private static _SimplifyNegation;
  5179. }
  5180. }
  5181. declare module BABYLON {
  5182. /**
  5183. * Class used to store custom tags
  5184. */
  5185. export class Tags {
  5186. /**
  5187. * Adds support for tags on the given object
  5188. * @param obj defines the object to use
  5189. */
  5190. static EnableFor(obj: any): void;
  5191. /**
  5192. * Removes tags support
  5193. * @param obj defines the object to use
  5194. */
  5195. static DisableFor(obj: any): void;
  5196. /**
  5197. * Gets a boolean indicating if the given object has tags
  5198. * @param obj defines the object to use
  5199. * @returns a boolean
  5200. */
  5201. static HasTags(obj: any): boolean;
  5202. /**
  5203. * Gets the tags available on a given object
  5204. * @param obj defines the object to use
  5205. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5206. * @returns the tags
  5207. */
  5208. static GetTags(obj: any, asString?: boolean): any;
  5209. /**
  5210. * Adds tags to an object
  5211. * @param obj defines the object to use
  5212. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5213. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5214. */
  5215. static AddTagsTo(obj: any, tagsString: string): void;
  5216. /**
  5217. * @hidden
  5218. */ private static _AddTagTo(obj: any, tag: string): void;
  5219. /**
  5220. * Removes specific tags from a specific object
  5221. * @param obj defines the object to use
  5222. * @param tagsString defines the tags to remove
  5223. */
  5224. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5225. /**
  5226. * @hidden
  5227. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5228. /**
  5229. * Defines if tags hosted on an object match a given query
  5230. * @param obj defines the object to use
  5231. * @param tagsQuery defines the tag query
  5232. * @returns a boolean
  5233. */
  5234. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5235. }
  5236. }
  5237. declare module BABYLON {
  5238. /**
  5239. * Defines potential orientation for back face culling
  5240. */
  5241. export enum Orientation {
  5242. /**
  5243. * Clockwise
  5244. */
  5245. CW = 0,
  5246. /** Counter clockwise */
  5247. CCW = 1
  5248. }
  5249. /** Class used to represent a Bezier curve */
  5250. export class BezierCurve {
  5251. /**
  5252. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5253. * @param t defines the time
  5254. * @param x1 defines the left coordinate on X axis
  5255. * @param y1 defines the left coordinate on Y axis
  5256. * @param x2 defines the right coordinate on X axis
  5257. * @param y2 defines the right coordinate on Y axis
  5258. * @returns the interpolated value
  5259. */
  5260. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5261. }
  5262. /**
  5263. * Defines angle representation
  5264. */
  5265. export class Angle {
  5266. private _radians;
  5267. /**
  5268. * Creates an Angle object of "radians" radians (float).
  5269. * @param radians the angle in radians
  5270. */
  5271. constructor(radians: number);
  5272. /**
  5273. * Get value in degrees
  5274. * @returns the Angle value in degrees (float)
  5275. */
  5276. degrees(): number;
  5277. /**
  5278. * Get value in radians
  5279. * @returns the Angle value in radians (float)
  5280. */
  5281. radians(): number;
  5282. /**
  5283. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5284. * @param a defines first vector
  5285. * @param b defines second vector
  5286. * @returns a new Angle
  5287. */
  5288. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5289. /**
  5290. * Gets a new Angle object from the given float in radians
  5291. * @param radians defines the angle value in radians
  5292. * @returns a new Angle
  5293. */
  5294. static FromRadians(radians: number): Angle;
  5295. /**
  5296. * Gets a new Angle object from the given float in degrees
  5297. * @param degrees defines the angle value in degrees
  5298. * @returns a new Angle
  5299. */
  5300. static FromDegrees(degrees: number): Angle;
  5301. }
  5302. /**
  5303. * This represents an arc in a 2d space.
  5304. */
  5305. export class Arc2 {
  5306. /** Defines the start point of the arc */
  5307. startPoint: Vector2;
  5308. /** Defines the mid point of the arc */
  5309. midPoint: Vector2;
  5310. /** Defines the end point of the arc */
  5311. endPoint: Vector2;
  5312. /**
  5313. * Defines the center point of the arc.
  5314. */
  5315. centerPoint: Vector2;
  5316. /**
  5317. * Defines the radius of the arc.
  5318. */
  5319. radius: number;
  5320. /**
  5321. * Defines the angle of the arc (from mid point to end point).
  5322. */
  5323. angle: Angle;
  5324. /**
  5325. * Defines the start angle of the arc (from start point to middle point).
  5326. */
  5327. startAngle: Angle;
  5328. /**
  5329. * Defines the orientation of the arc (clock wise/counter clock wise).
  5330. */
  5331. orientation: Orientation;
  5332. /**
  5333. * Creates an Arc object from the three given points : start, middle and end.
  5334. * @param startPoint Defines the start point of the arc
  5335. * @param midPoint Defines the midlle point of the arc
  5336. * @param endPoint Defines the end point of the arc
  5337. */
  5338. constructor(
  5339. /** Defines the start point of the arc */
  5340. startPoint: Vector2,
  5341. /** Defines the mid point of the arc */
  5342. midPoint: Vector2,
  5343. /** Defines the end point of the arc */
  5344. endPoint: Vector2);
  5345. }
  5346. /**
  5347. * Represents a 2D path made up of multiple 2D points
  5348. */
  5349. export class Path2 {
  5350. private _points;
  5351. private _length;
  5352. /**
  5353. * If the path start and end point are the same
  5354. */
  5355. closed: boolean;
  5356. /**
  5357. * Creates a Path2 object from the starting 2D coordinates x and y.
  5358. * @param x the starting points x value
  5359. * @param y the starting points y value
  5360. */
  5361. constructor(x: number, y: number);
  5362. /**
  5363. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5364. * @param x the added points x value
  5365. * @param y the added points y value
  5366. * @returns the updated Path2.
  5367. */
  5368. addLineTo(x: number, y: number): Path2;
  5369. /**
  5370. * 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.
  5371. * @param midX middle point x value
  5372. * @param midY middle point y value
  5373. * @param endX end point x value
  5374. * @param endY end point y value
  5375. * @param numberOfSegments (default: 36)
  5376. * @returns the updated Path2.
  5377. */
  5378. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5379. /**
  5380. * Closes the Path2.
  5381. * @returns the Path2.
  5382. */
  5383. close(): Path2;
  5384. /**
  5385. * Gets the sum of the distance between each sequential point in the path
  5386. * @returns the Path2 total length (float).
  5387. */
  5388. length(): number;
  5389. /**
  5390. * Gets the points which construct the path
  5391. * @returns the Path2 internal array of points.
  5392. */
  5393. getPoints(): Vector2[];
  5394. /**
  5395. * Retreives the point at the distance aways from the starting point
  5396. * @param normalizedLengthPosition the length along the path to retreive the point from
  5397. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5398. */
  5399. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5400. /**
  5401. * Creates a new path starting from an x and y position
  5402. * @param x starting x value
  5403. * @param y starting y value
  5404. * @returns a new Path2 starting at the coordinates (x, y).
  5405. */
  5406. static StartingAt(x: number, y: number): Path2;
  5407. }
  5408. /**
  5409. * Represents a 3D path made up of multiple 3D points
  5410. */
  5411. export class Path3D {
  5412. /**
  5413. * an array of Vector3, the curve axis of the Path3D
  5414. */
  5415. path: Vector3[];
  5416. private _curve;
  5417. private _distances;
  5418. private _tangents;
  5419. private _normals;
  5420. private _binormals;
  5421. private _raw;
  5422. /**
  5423. * new Path3D(path, normal, raw)
  5424. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5425. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5426. * @param path an array of Vector3, the curve axis of the Path3D
  5427. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5428. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5429. */
  5430. constructor(
  5431. /**
  5432. * an array of Vector3, the curve axis of the Path3D
  5433. */
  5434. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5435. /**
  5436. * Returns the Path3D array of successive Vector3 designing its curve.
  5437. * @returns the Path3D array of successive Vector3 designing its curve.
  5438. */
  5439. getCurve(): Vector3[];
  5440. /**
  5441. * Returns an array populated with tangent vectors on each Path3D curve point.
  5442. * @returns an array populated with tangent vectors on each Path3D curve point.
  5443. */
  5444. getTangents(): Vector3[];
  5445. /**
  5446. * Returns an array populated with normal vectors on each Path3D curve point.
  5447. * @returns an array populated with normal vectors on each Path3D curve point.
  5448. */
  5449. getNormals(): Vector3[];
  5450. /**
  5451. * Returns an array populated with binormal vectors on each Path3D curve point.
  5452. * @returns an array populated with binormal vectors on each Path3D curve point.
  5453. */
  5454. getBinormals(): Vector3[];
  5455. /**
  5456. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5457. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5458. */
  5459. getDistances(): number[];
  5460. /**
  5461. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5462. * @param path path which all values are copied into the curves points
  5463. * @param firstNormal which should be projected onto the curve
  5464. * @returns the same object updated.
  5465. */
  5466. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5467. private _compute;
  5468. private _getFirstNonNullVector;
  5469. private _getLastNonNullVector;
  5470. private _normalVector;
  5471. }
  5472. /**
  5473. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5474. * A Curve3 is designed from a series of successive Vector3.
  5475. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5476. */
  5477. export class Curve3 {
  5478. private _points;
  5479. private _length;
  5480. /**
  5481. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5482. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5483. * @param v1 (Vector3) the control point
  5484. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5485. * @param nbPoints (integer) the wanted number of points in the curve
  5486. * @returns the created Curve3
  5487. */
  5488. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5489. /**
  5490. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5491. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5492. * @param v1 (Vector3) the first control point
  5493. * @param v2 (Vector3) the second control point
  5494. * @param v3 (Vector3) the end point of the Cubic Bezier
  5495. * @param nbPoints (integer) the wanted number of points in the curve
  5496. * @returns the created Curve3
  5497. */
  5498. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5499. /**
  5500. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5501. * @param p1 (Vector3) the origin point of the Hermite Spline
  5502. * @param t1 (Vector3) the tangent vector at the origin point
  5503. * @param p2 (Vector3) the end point of the Hermite Spline
  5504. * @param t2 (Vector3) the tangent vector at the end point
  5505. * @param nbPoints (integer) the wanted number of points in the curve
  5506. * @returns the created Curve3
  5507. */
  5508. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5509. /**
  5510. * Returns a Curve3 object along a CatmullRom Spline curve :
  5511. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5512. * @param nbPoints (integer) the wanted number of points between each curve control points
  5513. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5514. * @returns the created Curve3
  5515. */
  5516. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5517. /**
  5518. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5519. * A Curve3 is designed from a series of successive Vector3.
  5520. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5521. * @param points points which make up the curve
  5522. */
  5523. constructor(points: Vector3[]);
  5524. /**
  5525. * @returns the Curve3 stored array of successive Vector3
  5526. */
  5527. getPoints(): Vector3[];
  5528. /**
  5529. * @returns the computed length (float) of the curve.
  5530. */
  5531. length(): number;
  5532. /**
  5533. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5534. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5535. * curveA and curveB keep unchanged.
  5536. * @param curve the curve to continue from this curve
  5537. * @returns the newly constructed curve
  5538. */
  5539. continue(curve: DeepImmutable<Curve3>): Curve3;
  5540. private _computeLength;
  5541. }
  5542. }
  5543. declare module BABYLON {
  5544. /**
  5545. * This represents the main contract an easing function should follow.
  5546. * Easing functions are used throughout the animation system.
  5547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5548. */
  5549. export interface IEasingFunction {
  5550. /**
  5551. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5552. * of the easing function.
  5553. * The link below provides some of the most common examples of easing functions.
  5554. * @see https://easings.net/
  5555. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5556. * @returns the corresponding value on the curve defined by the easing function
  5557. */
  5558. ease(gradient: number): number;
  5559. }
  5560. /**
  5561. * Base class used for every default easing function.
  5562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5563. */
  5564. export class EasingFunction implements IEasingFunction {
  5565. /**
  5566. * Interpolation follows the mathematical formula associated with the easing function.
  5567. */
  5568. static readonly EASINGMODE_EASEIN: number;
  5569. /**
  5570. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5571. */
  5572. static readonly EASINGMODE_EASEOUT: number;
  5573. /**
  5574. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5575. */
  5576. static readonly EASINGMODE_EASEINOUT: number;
  5577. private _easingMode;
  5578. /**
  5579. * Sets the easing mode of the current function.
  5580. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5581. */
  5582. setEasingMode(easingMode: number): void;
  5583. /**
  5584. * Gets the current easing mode.
  5585. * @returns the easing mode
  5586. */
  5587. getEasingMode(): number;
  5588. /**
  5589. * @hidden
  5590. */
  5591. easeInCore(gradient: number): number;
  5592. /**
  5593. * Given an input gradient between 0 and 1, this returns the corresponding value
  5594. * of the easing function.
  5595. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5596. * @returns the corresponding value on the curve defined by the easing function
  5597. */
  5598. ease(gradient: number): number;
  5599. }
  5600. /**
  5601. * Easing function with a circle shape (see link below).
  5602. * @see https://easings.net/#easeInCirc
  5603. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5604. */
  5605. export class CircleEase extends EasingFunction implements IEasingFunction {
  5606. /** @hidden */
  5607. easeInCore(gradient: number): number;
  5608. }
  5609. /**
  5610. * Easing function with a ease back shape (see link below).
  5611. * @see https://easings.net/#easeInBack
  5612. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5613. */
  5614. export class BackEase extends EasingFunction implements IEasingFunction {
  5615. /** Defines the amplitude of the function */
  5616. amplitude: number;
  5617. /**
  5618. * Instantiates a back ease easing
  5619. * @see https://easings.net/#easeInBack
  5620. * @param amplitude Defines the amplitude of the function
  5621. */
  5622. constructor(
  5623. /** Defines the amplitude of the function */
  5624. amplitude?: number);
  5625. /** @hidden */
  5626. easeInCore(gradient: number): number;
  5627. }
  5628. /**
  5629. * Easing function with a bouncing shape (see link below).
  5630. * @see https://easings.net/#easeInBounce
  5631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5632. */
  5633. export class BounceEase extends EasingFunction implements IEasingFunction {
  5634. /** Defines the number of bounces */
  5635. bounces: number;
  5636. /** Defines the amplitude of the bounce */
  5637. bounciness: number;
  5638. /**
  5639. * Instantiates a bounce easing
  5640. * @see https://easings.net/#easeInBounce
  5641. * @param bounces Defines the number of bounces
  5642. * @param bounciness Defines the amplitude of the bounce
  5643. */
  5644. constructor(
  5645. /** Defines the number of bounces */
  5646. bounces?: number,
  5647. /** Defines the amplitude of the bounce */
  5648. bounciness?: number);
  5649. /** @hidden */
  5650. easeInCore(gradient: number): number;
  5651. }
  5652. /**
  5653. * Easing function with a power of 3 shape (see link below).
  5654. * @see https://easings.net/#easeInCubic
  5655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5656. */
  5657. export class CubicEase extends EasingFunction implements IEasingFunction {
  5658. /** @hidden */
  5659. easeInCore(gradient: number): number;
  5660. }
  5661. /**
  5662. * Easing function with an elastic shape (see link below).
  5663. * @see https://easings.net/#easeInElastic
  5664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5665. */
  5666. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5667. /** Defines the number of oscillations*/
  5668. oscillations: number;
  5669. /** Defines the amplitude of the oscillations*/
  5670. springiness: number;
  5671. /**
  5672. * Instantiates an elastic easing function
  5673. * @see https://easings.net/#easeInElastic
  5674. * @param oscillations Defines the number of oscillations
  5675. * @param springiness Defines the amplitude of the oscillations
  5676. */
  5677. constructor(
  5678. /** Defines the number of oscillations*/
  5679. oscillations?: number,
  5680. /** Defines the amplitude of the oscillations*/
  5681. springiness?: number);
  5682. /** @hidden */
  5683. easeInCore(gradient: number): number;
  5684. }
  5685. /**
  5686. * Easing function with an exponential shape (see link below).
  5687. * @see https://easings.net/#easeInExpo
  5688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5689. */
  5690. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5691. /** Defines the exponent of the function */
  5692. exponent: number;
  5693. /**
  5694. * Instantiates an exponential easing function
  5695. * @see https://easings.net/#easeInExpo
  5696. * @param exponent Defines the exponent of the function
  5697. */
  5698. constructor(
  5699. /** Defines the exponent of the function */
  5700. exponent?: number);
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with a power shape (see link below).
  5706. * @see https://easings.net/#easeInQuad
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class PowerEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the power of the function */
  5711. power: number;
  5712. /**
  5713. * Instantiates an power base easing function
  5714. * @see https://easings.net/#easeInQuad
  5715. * @param power Defines the power of the function
  5716. */
  5717. constructor(
  5718. /** Defines the power of the function */
  5719. power?: number);
  5720. /** @hidden */
  5721. easeInCore(gradient: number): number;
  5722. }
  5723. /**
  5724. * Easing function with a power of 2 shape (see link below).
  5725. * @see https://easings.net/#easeInQuad
  5726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5727. */
  5728. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5729. /** @hidden */
  5730. easeInCore(gradient: number): number;
  5731. }
  5732. /**
  5733. * Easing function with a power of 4 shape (see link below).
  5734. * @see https://easings.net/#easeInQuart
  5735. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5736. */
  5737. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5738. /** @hidden */
  5739. easeInCore(gradient: number): number;
  5740. }
  5741. /**
  5742. * Easing function with a power of 5 shape (see link below).
  5743. * @see https://easings.net/#easeInQuint
  5744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5745. */
  5746. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5747. /** @hidden */
  5748. easeInCore(gradient: number): number;
  5749. }
  5750. /**
  5751. * Easing function with a sin shape (see link below).
  5752. * @see https://easings.net/#easeInSine
  5753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5754. */
  5755. export class SineEase extends EasingFunction implements IEasingFunction {
  5756. /** @hidden */
  5757. easeInCore(gradient: number): number;
  5758. }
  5759. /**
  5760. * Easing function with a bezier shape (see link below).
  5761. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5762. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5763. */
  5764. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5765. /** Defines the x component of the start tangent in the bezier curve */
  5766. x1: number;
  5767. /** Defines the y component of the start tangent in the bezier curve */
  5768. y1: number;
  5769. /** Defines the x component of the end tangent in the bezier curve */
  5770. x2: number;
  5771. /** Defines the y component of the end tangent in the bezier curve */
  5772. y2: number;
  5773. /**
  5774. * Instantiates a bezier function
  5775. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5776. * @param x1 Defines the x component of the start tangent in the bezier curve
  5777. * @param y1 Defines the y component of the start tangent in the bezier curve
  5778. * @param x2 Defines the x component of the end tangent in the bezier curve
  5779. * @param y2 Defines the y component of the end tangent in the bezier curve
  5780. */
  5781. constructor(
  5782. /** Defines the x component of the start tangent in the bezier curve */
  5783. x1?: number,
  5784. /** Defines the y component of the start tangent in the bezier curve */
  5785. y1?: number,
  5786. /** Defines the x component of the end tangent in the bezier curve */
  5787. x2?: number,
  5788. /** Defines the y component of the end tangent in the bezier curve */
  5789. y2?: number);
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. }
  5794. declare module BABYLON {
  5795. /**
  5796. * Defines an interface which represents an animation key frame
  5797. */
  5798. export interface IAnimationKey {
  5799. /**
  5800. * Frame of the key frame
  5801. */
  5802. frame: number;
  5803. /**
  5804. * Value at the specifies key frame
  5805. */
  5806. value: any;
  5807. /**
  5808. * The input tangent for the cubic hermite spline
  5809. */
  5810. inTangent?: any;
  5811. /**
  5812. * The output tangent for the cubic hermite spline
  5813. */
  5814. outTangent?: any;
  5815. /**
  5816. * The animation interpolation type
  5817. */
  5818. interpolation?: AnimationKeyInterpolation;
  5819. }
  5820. /**
  5821. * Enum for the animation key frame interpolation type
  5822. */
  5823. export enum AnimationKeyInterpolation {
  5824. /**
  5825. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5826. */
  5827. STEP = 1
  5828. }
  5829. }
  5830. declare module BABYLON {
  5831. /**
  5832. * Represents the range of an animation
  5833. */
  5834. export class AnimationRange {
  5835. /**The name of the animation range**/
  5836. name: string;
  5837. /**The starting frame of the animation */
  5838. from: number;
  5839. /**The ending frame of the animation*/
  5840. to: number;
  5841. /**
  5842. * Initializes the range of an animation
  5843. * @param name The name of the animation range
  5844. * @param from The starting frame of the animation
  5845. * @param to The ending frame of the animation
  5846. */
  5847. constructor(
  5848. /**The name of the animation range**/
  5849. name: string,
  5850. /**The starting frame of the animation */
  5851. from: number,
  5852. /**The ending frame of the animation*/
  5853. to: number);
  5854. /**
  5855. * Makes a copy of the animation range
  5856. * @returns A copy of the animation range
  5857. */
  5858. clone(): AnimationRange;
  5859. }
  5860. }
  5861. declare module BABYLON {
  5862. /**
  5863. * Composed of a frame, and an action function
  5864. */
  5865. export class AnimationEvent {
  5866. /** The frame for which the event is triggered **/
  5867. frame: number;
  5868. /** The event to perform when triggered **/
  5869. action: (currentFrame: number) => void;
  5870. /** Specifies if the event should be triggered only once**/
  5871. onlyOnce?: boolean | undefined;
  5872. /**
  5873. * Specifies if the animation event is done
  5874. */
  5875. isDone: boolean;
  5876. /**
  5877. * Initializes the animation event
  5878. * @param frame The frame for which the event is triggered
  5879. * @param action The event to perform when triggered
  5880. * @param onlyOnce Specifies if the event should be triggered only once
  5881. */
  5882. constructor(
  5883. /** The frame for which the event is triggered **/
  5884. frame: number,
  5885. /** The event to perform when triggered **/
  5886. action: (currentFrame: number) => void,
  5887. /** Specifies if the event should be triggered only once**/
  5888. onlyOnce?: boolean | undefined);
  5889. /** @hidden */ private _clone(): AnimationEvent;
  5890. }
  5891. }
  5892. declare module BABYLON {
  5893. /**
  5894. * Interface used to define a behavior
  5895. */
  5896. export interface Behavior<T> {
  5897. /** gets or sets behavior's name */
  5898. name: string;
  5899. /**
  5900. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5901. */
  5902. init(): void;
  5903. /**
  5904. * Called when the behavior is attached to a target
  5905. * @param target defines the target where the behavior is attached to
  5906. */
  5907. attach(target: T): void;
  5908. /**
  5909. * Called when the behavior is detached from its target
  5910. */
  5911. detach(): void;
  5912. }
  5913. /**
  5914. * Interface implemented by classes supporting behaviors
  5915. */
  5916. export interface IBehaviorAware<T> {
  5917. /**
  5918. * Attach a behavior
  5919. * @param behavior defines the behavior to attach
  5920. * @returns the current host
  5921. */
  5922. addBehavior(behavior: Behavior<T>): T;
  5923. /**
  5924. * Remove a behavior from the current object
  5925. * @param behavior defines the behavior to detach
  5926. * @returns the current host
  5927. */
  5928. removeBehavior(behavior: Behavior<T>): T;
  5929. /**
  5930. * Gets a behavior using its name to search
  5931. * @param name defines the name to search
  5932. * @returns the behavior or null if not found
  5933. */
  5934. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5935. }
  5936. }
  5937. declare module BABYLON {
  5938. /**
  5939. * Defines an array and its length.
  5940. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5941. */
  5942. export interface ISmartArrayLike<T> {
  5943. /**
  5944. * The data of the array.
  5945. */
  5946. data: Array<T>;
  5947. /**
  5948. * The active length of the array.
  5949. */
  5950. length: number;
  5951. }
  5952. /**
  5953. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5954. */
  5955. export class SmartArray<T> implements ISmartArrayLike<T> {
  5956. /**
  5957. * The full set of data from the array.
  5958. */
  5959. data: Array<T>;
  5960. /**
  5961. * The active length of the array.
  5962. */
  5963. length: number;
  5964. protected _id: number;
  5965. /**
  5966. * Instantiates a Smart Array.
  5967. * @param capacity defines the default capacity of the array.
  5968. */
  5969. constructor(capacity: number);
  5970. /**
  5971. * Pushes a value at the end of the active data.
  5972. * @param value defines the object to push in the array.
  5973. */
  5974. push(value: T): void;
  5975. /**
  5976. * Iterates over the active data and apply the lambda to them.
  5977. * @param func defines the action to apply on each value.
  5978. */
  5979. forEach(func: (content: T) => void): void;
  5980. /**
  5981. * Sorts the full sets of data.
  5982. * @param compareFn defines the comparison function to apply.
  5983. */
  5984. sort(compareFn: (a: T, b: T) => number): void;
  5985. /**
  5986. * Resets the active data to an empty array.
  5987. */
  5988. reset(): void;
  5989. /**
  5990. * Releases all the data from the array as well as the array.
  5991. */
  5992. dispose(): void;
  5993. /**
  5994. * Concats the active data with a given array.
  5995. * @param array defines the data to concatenate with.
  5996. */
  5997. concat(array: any): void;
  5998. /**
  5999. * Returns the position of a value in the active data.
  6000. * @param value defines the value to find the index for
  6001. * @returns the index if found in the active data otherwise -1
  6002. */
  6003. indexOf(value: T): number;
  6004. /**
  6005. * Returns whether an element is part of the active data.
  6006. * @param value defines the value to look for
  6007. * @returns true if found in the active data otherwise false
  6008. */
  6009. contains(value: T): boolean;
  6010. private static _GlobalId;
  6011. }
  6012. /**
  6013. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6014. * The data in this array can only be present once
  6015. */
  6016. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6017. private _duplicateId;
  6018. /**
  6019. * Pushes a value at the end of the active data.
  6020. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6021. * @param value defines the object to push in the array.
  6022. */
  6023. push(value: T): void;
  6024. /**
  6025. * Pushes a value at the end of the active data.
  6026. * If the data is already present, it won t be added again
  6027. * @param value defines the object to push in the array.
  6028. * @returns true if added false if it was already present
  6029. */
  6030. pushNoDuplicate(value: T): boolean;
  6031. /**
  6032. * Resets the active data to an empty array.
  6033. */
  6034. reset(): void;
  6035. /**
  6036. * Concats the active data with a given array.
  6037. * This ensures no dupplicate will be present in the result.
  6038. * @param array defines the data to concatenate with.
  6039. */
  6040. concatWithNoDuplicate(array: any): void;
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * @ignore
  6046. * This is a list of all the different input types that are available in the application.
  6047. * Fo instance: ArcRotateCameraGamepadInput...
  6048. */
  6049. export var CameraInputTypes: {};
  6050. /**
  6051. * This is the contract to implement in order to create a new input class.
  6052. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6053. */
  6054. export interface ICameraInput<TCamera extends Camera> {
  6055. /**
  6056. * Defines the camera the input is attached to.
  6057. */
  6058. camera: Nullable<TCamera>;
  6059. /**
  6060. * Gets the class name of the current intput.
  6061. * @returns the class name
  6062. */
  6063. getClassName(): string;
  6064. /**
  6065. * Get the friendly name associated with the input class.
  6066. * @returns the input friendly name
  6067. */
  6068. getSimpleName(): string;
  6069. /**
  6070. * Attach the input controls to a specific dom element to get the input from.
  6071. * @param element Defines the element the controls should be listened from
  6072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6073. */
  6074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6075. /**
  6076. * Detach the current controls from the specified dom element.
  6077. * @param element Defines the element to stop listening the inputs from
  6078. */
  6079. detachControl(element: Nullable<HTMLElement>): void;
  6080. /**
  6081. * Update the current camera state depending on the inputs that have been used this frame.
  6082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6083. */
  6084. checkInputs?: () => void;
  6085. }
  6086. /**
  6087. * Represents a map of input types to input instance or input index to input instance.
  6088. */
  6089. export interface CameraInputsMap<TCamera extends Camera> {
  6090. /**
  6091. * Accessor to the input by input type.
  6092. */
  6093. [name: string]: ICameraInput<TCamera>;
  6094. /**
  6095. * Accessor to the input by input index.
  6096. */
  6097. [idx: number]: ICameraInput<TCamera>;
  6098. }
  6099. /**
  6100. * This represents the input manager used within a camera.
  6101. * It helps dealing with all the different kind of input attached to a camera.
  6102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6103. */
  6104. export class CameraInputsManager<TCamera extends Camera> {
  6105. /**
  6106. * Defines the list of inputs attahed to the camera.
  6107. */
  6108. attached: CameraInputsMap<TCamera>;
  6109. /**
  6110. * Defines the dom element the camera is collecting inputs from.
  6111. * This is null if the controls have not been attached.
  6112. */
  6113. attachedElement: Nullable<HTMLElement>;
  6114. /**
  6115. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6116. */
  6117. noPreventDefault: boolean;
  6118. /**
  6119. * Defined the camera the input manager belongs to.
  6120. */
  6121. camera: TCamera;
  6122. /**
  6123. * Update the current camera state depending on the inputs that have been used this frame.
  6124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6125. */
  6126. checkInputs: () => void;
  6127. /**
  6128. * Instantiate a new Camera Input Manager.
  6129. * @param camera Defines the camera the input manager blongs to
  6130. */
  6131. constructor(camera: TCamera);
  6132. /**
  6133. * Add an input method to a camera
  6134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6135. * @param input camera input method
  6136. */
  6137. add(input: ICameraInput<TCamera>): void;
  6138. /**
  6139. * Remove a specific input method from a camera
  6140. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6141. * @param inputToRemove camera input method
  6142. */
  6143. remove(inputToRemove: ICameraInput<TCamera>): void;
  6144. /**
  6145. * Remove a specific input type from a camera
  6146. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6147. * @param inputType the type of the input to remove
  6148. */
  6149. removeByType(inputType: string): void;
  6150. private _addCheckInputs;
  6151. /**
  6152. * Attach the input controls to the currently attached dom element to listen the events from.
  6153. * @param input Defines the input to attach
  6154. */
  6155. attachInput(input: ICameraInput<TCamera>): void;
  6156. /**
  6157. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6158. * @param element Defines the dom element to collect the events from
  6159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6160. */
  6161. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6162. /**
  6163. * Detach the current manager inputs controls from a specific dom element.
  6164. * @param element Defines the dom element to collect the events from
  6165. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6166. */
  6167. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6168. /**
  6169. * Rebuild the dynamic inputCheck function from the current list of
  6170. * defined inputs in the manager.
  6171. */
  6172. rebuildInputCheck(): void;
  6173. /**
  6174. * Remove all attached input methods from a camera
  6175. */
  6176. clear(): void;
  6177. /**
  6178. * Serialize the current input manager attached to a camera.
  6179. * This ensures than once parsed,
  6180. * the input associated to the camera will be identical to the current ones
  6181. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6182. */
  6183. serialize(serializedCamera: any): void;
  6184. /**
  6185. * Parses an input manager serialized JSON to restore the previous list of inputs
  6186. * and states associated to a camera.
  6187. * @param parsedCamera Defines the JSON to parse
  6188. */
  6189. parse(parsedCamera: any): void;
  6190. }
  6191. }
  6192. declare module BABYLON {
  6193. /**
  6194. * Class used to store data that will be store in GPU memory
  6195. */
  6196. export class Buffer {
  6197. private _engine;
  6198. private _buffer;
  6199. /** @hidden */ private _data: Nullable<DataArray>;
  6200. private _updatable;
  6201. private _instanced;
  6202. /**
  6203. * Gets the byte stride.
  6204. */
  6205. readonly byteStride: number;
  6206. /**
  6207. * Constructor
  6208. * @param engine the engine
  6209. * @param data the data to use for this buffer
  6210. * @param updatable whether the data is updatable
  6211. * @param stride the stride (optional)
  6212. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6213. * @param instanced whether the buffer is instanced (optional)
  6214. * @param useBytes set to true if the stride in in bytes (optional)
  6215. */
  6216. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6217. /**
  6218. * Create a new VertexBuffer based on the current buffer
  6219. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6220. * @param offset defines offset in the buffer (0 by default)
  6221. * @param size defines the size in floats of attributes (position is 3 for instance)
  6222. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6223. * @param instanced defines if the vertex buffer contains indexed data
  6224. * @param useBytes defines if the offset and stride are in bytes
  6225. * @returns the new vertex buffer
  6226. */
  6227. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6228. /**
  6229. * Gets a boolean indicating if the Buffer is updatable?
  6230. * @returns true if the buffer is updatable
  6231. */
  6232. isUpdatable(): boolean;
  6233. /**
  6234. * Gets current buffer's data
  6235. * @returns a DataArray or null
  6236. */
  6237. getData(): Nullable<DataArray>;
  6238. /**
  6239. * Gets underlying native buffer
  6240. * @returns underlying native buffer
  6241. */
  6242. getBuffer(): Nullable<DataBuffer>;
  6243. /**
  6244. * Gets the stride in float32 units (i.e. byte stride / 4).
  6245. * May not be an integer if the byte stride is not divisible by 4.
  6246. * DEPRECATED. Use byteStride instead.
  6247. * @returns the stride in float32 units
  6248. */
  6249. getStrideSize(): number;
  6250. /**
  6251. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6252. * @param data defines the data to store
  6253. */
  6254. create(data?: Nullable<DataArray>): void;
  6255. /** @hidden */ private _rebuild(): void;
  6256. /**
  6257. * Update current buffer data
  6258. * @param data defines the data to store
  6259. */
  6260. update(data: DataArray): void;
  6261. /**
  6262. * Updates the data directly.
  6263. * @param data the new data
  6264. * @param offset the new offset
  6265. * @param vertexCount the vertex count (optional)
  6266. * @param useBytes set to true if the offset is in bytes
  6267. */
  6268. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6269. /**
  6270. * Release all resources
  6271. */
  6272. dispose(): void;
  6273. }
  6274. /**
  6275. * Specialized buffer used to store vertex data
  6276. */
  6277. export class VertexBuffer {
  6278. /** @hidden */ private _buffer: Buffer;
  6279. private _kind;
  6280. private _size;
  6281. private _ownsBuffer;
  6282. private _instanced;
  6283. private _instanceDivisor;
  6284. /**
  6285. * The byte type.
  6286. */
  6287. static readonly BYTE: number;
  6288. /**
  6289. * The unsigned byte type.
  6290. */
  6291. static readonly UNSIGNED_BYTE: number;
  6292. /**
  6293. * The short type.
  6294. */
  6295. static readonly SHORT: number;
  6296. /**
  6297. * The unsigned short type.
  6298. */
  6299. static readonly UNSIGNED_SHORT: number;
  6300. /**
  6301. * The integer type.
  6302. */
  6303. static readonly INT: number;
  6304. /**
  6305. * The unsigned integer type.
  6306. */
  6307. static readonly UNSIGNED_INT: number;
  6308. /**
  6309. * The float type.
  6310. */
  6311. static readonly FLOAT: number;
  6312. /**
  6313. * Gets or sets the instance divisor when in instanced mode
  6314. */
  6315. instanceDivisor: number;
  6316. /**
  6317. * Gets the byte stride.
  6318. */
  6319. readonly byteStride: number;
  6320. /**
  6321. * Gets the byte offset.
  6322. */
  6323. readonly byteOffset: number;
  6324. /**
  6325. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6326. */
  6327. readonly normalized: boolean;
  6328. /**
  6329. * Gets the data type of each component in the array.
  6330. */
  6331. readonly type: number;
  6332. /**
  6333. * Constructor
  6334. * @param engine the engine
  6335. * @param data the data to use for this vertex buffer
  6336. * @param kind the vertex buffer kind
  6337. * @param updatable whether the data is updatable
  6338. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6339. * @param stride the stride (optional)
  6340. * @param instanced whether the buffer is instanced (optional)
  6341. * @param offset the offset of the data (optional)
  6342. * @param size the number of components (optional)
  6343. * @param type the type of the component (optional)
  6344. * @param normalized whether the data contains normalized data (optional)
  6345. * @param useBytes set to true if stride and offset are in bytes (optional)
  6346. */
  6347. 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);
  6348. /** @hidden */ private _rebuild(): void;
  6349. /**
  6350. * Returns the kind of the VertexBuffer (string)
  6351. * @returns a string
  6352. */
  6353. getKind(): string;
  6354. /**
  6355. * Gets a boolean indicating if the VertexBuffer is updatable?
  6356. * @returns true if the buffer is updatable
  6357. */
  6358. isUpdatable(): boolean;
  6359. /**
  6360. * Gets current buffer's data
  6361. * @returns a DataArray or null
  6362. */
  6363. getData(): Nullable<DataArray>;
  6364. /**
  6365. * Gets underlying native buffer
  6366. * @returns underlying native buffer
  6367. */
  6368. getBuffer(): Nullable<DataBuffer>;
  6369. /**
  6370. * Gets the stride in float32 units (i.e. byte stride / 4).
  6371. * May not be an integer if the byte stride is not divisible by 4.
  6372. * DEPRECATED. Use byteStride instead.
  6373. * @returns the stride in float32 units
  6374. */
  6375. getStrideSize(): number;
  6376. /**
  6377. * Returns the offset as a multiple of the type byte length.
  6378. * DEPRECATED. Use byteOffset instead.
  6379. * @returns the offset in bytes
  6380. */
  6381. getOffset(): number;
  6382. /**
  6383. * Returns the number of components per vertex attribute (integer)
  6384. * @returns the size in float
  6385. */
  6386. getSize(): number;
  6387. /**
  6388. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6389. * @returns true if this buffer is instanced
  6390. */
  6391. getIsInstanced(): boolean;
  6392. /**
  6393. * Returns the instancing divisor, zero for non-instanced (integer).
  6394. * @returns a number
  6395. */
  6396. getInstanceDivisor(): number;
  6397. /**
  6398. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6399. * @param data defines the data to store
  6400. */
  6401. create(data?: DataArray): void;
  6402. /**
  6403. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6404. * This function will create a new buffer if the current one is not updatable
  6405. * @param data defines the data to store
  6406. */
  6407. update(data: DataArray): void;
  6408. /**
  6409. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6410. * Returns the directly updated WebGLBuffer.
  6411. * @param data the new data
  6412. * @param offset the new offset
  6413. * @param useBytes set to true if the offset is in bytes
  6414. */
  6415. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6416. /**
  6417. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6418. */
  6419. dispose(): void;
  6420. /**
  6421. * Enumerates each value of this vertex buffer as numbers.
  6422. * @param count the number of values to enumerate
  6423. * @param callback the callback function called for each value
  6424. */
  6425. forEach(count: number, callback: (value: number, index: number) => void): void;
  6426. /**
  6427. * Positions
  6428. */
  6429. static readonly PositionKind: string;
  6430. /**
  6431. * Normals
  6432. */
  6433. static readonly NormalKind: string;
  6434. /**
  6435. * Tangents
  6436. */
  6437. static readonly TangentKind: string;
  6438. /**
  6439. * Texture coordinates
  6440. */
  6441. static readonly UVKind: string;
  6442. /**
  6443. * Texture coordinates 2
  6444. */
  6445. static readonly UV2Kind: string;
  6446. /**
  6447. * Texture coordinates 3
  6448. */
  6449. static readonly UV3Kind: string;
  6450. /**
  6451. * Texture coordinates 4
  6452. */
  6453. static readonly UV4Kind: string;
  6454. /**
  6455. * Texture coordinates 5
  6456. */
  6457. static readonly UV5Kind: string;
  6458. /**
  6459. * Texture coordinates 6
  6460. */
  6461. static readonly UV6Kind: string;
  6462. /**
  6463. * Colors
  6464. */
  6465. static readonly ColorKind: string;
  6466. /**
  6467. * Matrix indices (for bones)
  6468. */
  6469. static readonly MatricesIndicesKind: string;
  6470. /**
  6471. * Matrix weights (for bones)
  6472. */
  6473. static readonly MatricesWeightsKind: string;
  6474. /**
  6475. * Additional matrix indices (for bones)
  6476. */
  6477. static readonly MatricesIndicesExtraKind: string;
  6478. /**
  6479. * Additional matrix weights (for bones)
  6480. */
  6481. static readonly MatricesWeightsExtraKind: string;
  6482. /**
  6483. * Deduces the stride given a kind.
  6484. * @param kind The kind string to deduce
  6485. * @returns The deduced stride
  6486. */
  6487. static DeduceStride(kind: string): number;
  6488. /**
  6489. * Gets the byte length of the given type.
  6490. * @param type the type
  6491. * @returns the number of bytes
  6492. */
  6493. static GetTypeByteLength(type: number): number;
  6494. /**
  6495. * Enumerates each value of the given parameters as numbers.
  6496. * @param data the data to enumerate
  6497. * @param byteOffset the byte offset of the data
  6498. * @param byteStride the byte stride of the data
  6499. * @param componentCount the number of components per element
  6500. * @param componentType the type of the component
  6501. * @param count the number of values to enumerate
  6502. * @param normalized whether the data is normalized
  6503. * @param callback the callback function called for each value
  6504. */
  6505. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6506. private static _GetFloatValue;
  6507. }
  6508. }
  6509. declare module BABYLON {
  6510. /**
  6511. * @hidden
  6512. */
  6513. export class IntersectionInfo {
  6514. bu: Nullable<number>;
  6515. bv: Nullable<number>;
  6516. distance: number;
  6517. faceId: number;
  6518. subMeshId: number;
  6519. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6520. }
  6521. }
  6522. declare module BABYLON {
  6523. /**
  6524. * Represens a plane by the equation ax + by + cz + d = 0
  6525. */
  6526. export class Plane {
  6527. private static _TmpMatrix;
  6528. /**
  6529. * Normal of the plane (a,b,c)
  6530. */
  6531. normal: Vector3;
  6532. /**
  6533. * d component of the plane
  6534. */
  6535. d: number;
  6536. /**
  6537. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6538. * @param a a component of the plane
  6539. * @param b b component of the plane
  6540. * @param c c component of the plane
  6541. * @param d d component of the plane
  6542. */
  6543. constructor(a: number, b: number, c: number, d: number);
  6544. /**
  6545. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6546. */
  6547. asArray(): number[];
  6548. /**
  6549. * @returns a new plane copied from the current Plane.
  6550. */
  6551. clone(): Plane;
  6552. /**
  6553. * @returns the string "Plane".
  6554. */
  6555. getClassName(): string;
  6556. /**
  6557. * @returns the Plane hash code.
  6558. */
  6559. getHashCode(): number;
  6560. /**
  6561. * Normalize the current Plane in place.
  6562. * @returns the updated Plane.
  6563. */
  6564. normalize(): Plane;
  6565. /**
  6566. * Applies a transformation the plane and returns the result
  6567. * @param transformation the transformation matrix to be applied to the plane
  6568. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6569. */
  6570. transform(transformation: DeepImmutable<Matrix>): Plane;
  6571. /**
  6572. * Calcualtte the dot product between the point and the plane normal
  6573. * @param point point to calculate the dot product with
  6574. * @returns the dot product (float) of the point coordinates and the plane normal.
  6575. */
  6576. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6577. /**
  6578. * Updates the current Plane from the plane defined by the three given points.
  6579. * @param point1 one of the points used to contruct the plane
  6580. * @param point2 one of the points used to contruct the plane
  6581. * @param point3 one of the points used to contruct the plane
  6582. * @returns the updated Plane.
  6583. */
  6584. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Checks if the plane is facing a given direction
  6587. * @param direction the direction to check if the plane is facing
  6588. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6589. * @returns True is the vector "direction" is the same side than the plane normal.
  6590. */
  6591. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6592. /**
  6593. * Calculates the distance to a point
  6594. * @param point point to calculate distance to
  6595. * @returns the signed distance (float) from the given point to the Plane.
  6596. */
  6597. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6598. /**
  6599. * Creates a plane from an array
  6600. * @param array the array to create a plane from
  6601. * @returns a new Plane from the given array.
  6602. */
  6603. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6604. /**
  6605. * Creates a plane from three points
  6606. * @param point1 point used to create the plane
  6607. * @param point2 point used to create the plane
  6608. * @param point3 point used to create the plane
  6609. * @returns a new Plane defined by the three given points.
  6610. */
  6611. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6612. /**
  6613. * Creates a plane from an origin point and a normal
  6614. * @param origin origin of the plane to be constructed
  6615. * @param normal normal of the plane to be constructed
  6616. * @returns a new Plane the normal vector to this plane at the given origin point.
  6617. * Note : the vector "normal" is updated because normalized.
  6618. */
  6619. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6620. /**
  6621. * Calculates the distance from a plane and a point
  6622. * @param origin origin of the plane to be constructed
  6623. * @param normal normal of the plane to be constructed
  6624. * @param point point to calculate distance to
  6625. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6626. */
  6627. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6628. }
  6629. }
  6630. declare module BABYLON {
  6631. /**
  6632. * Class used to store bounding sphere information
  6633. */
  6634. export class BoundingSphere {
  6635. /**
  6636. * Gets the center of the bounding sphere in local space
  6637. */
  6638. readonly center: Vector3;
  6639. /**
  6640. * Radius of the bounding sphere in local space
  6641. */
  6642. radius: number;
  6643. /**
  6644. * Gets the center of the bounding sphere in world space
  6645. */
  6646. readonly centerWorld: Vector3;
  6647. /**
  6648. * Radius of the bounding sphere in world space
  6649. */
  6650. radiusWorld: number;
  6651. /**
  6652. * Gets the minimum vector in local space
  6653. */
  6654. readonly minimum: Vector3;
  6655. /**
  6656. * Gets the maximum vector in local space
  6657. */
  6658. readonly maximum: Vector3;
  6659. private _worldMatrix;
  6660. private static readonly TmpVector3;
  6661. /**
  6662. * Creates a new bounding sphere
  6663. * @param min defines the minimum vector (in local space)
  6664. * @param max defines the maximum vector (in local space)
  6665. * @param worldMatrix defines the new world matrix
  6666. */
  6667. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6668. /**
  6669. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6670. * @param min defines the new minimum vector (in local space)
  6671. * @param max defines the new maximum vector (in local space)
  6672. * @param worldMatrix defines the new world matrix
  6673. */
  6674. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6675. /**
  6676. * Scale the current bounding sphere by applying a scale factor
  6677. * @param factor defines the scale factor to apply
  6678. * @returns the current bounding box
  6679. */
  6680. scale(factor: number): BoundingSphere;
  6681. /**
  6682. * Gets the world matrix of the bounding box
  6683. * @returns a matrix
  6684. */
  6685. getWorldMatrix(): DeepImmutable<Matrix>;
  6686. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6687. /**
  6688. * Tests if the bounding sphere is intersecting the frustum planes
  6689. * @param frustumPlanes defines the frustum planes to test
  6690. * @returns true if there is an intersection
  6691. */
  6692. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6693. /**
  6694. * Tests if the bounding sphere center is in between the frustum planes.
  6695. * Used for optimistic fast inclusion.
  6696. * @param frustumPlanes defines the frustum planes to test
  6697. * @returns true if the sphere center is in between the frustum planes
  6698. */
  6699. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6700. /**
  6701. * Tests if a point is inside the bounding sphere
  6702. * @param point defines the point to test
  6703. * @returns true if the point is inside the bounding sphere
  6704. */
  6705. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6706. /**
  6707. * Checks if two sphere intersct
  6708. * @param sphere0 sphere 0
  6709. * @param sphere1 sphere 1
  6710. * @returns true if the speres intersect
  6711. */
  6712. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6713. }
  6714. }
  6715. declare module BABYLON {
  6716. /**
  6717. * Class used to store bounding box information
  6718. */
  6719. export class BoundingBox implements ICullable {
  6720. /**
  6721. * Gets the 8 vectors representing the bounding box in local space
  6722. */
  6723. readonly vectors: Vector3[];
  6724. /**
  6725. * Gets the center of the bounding box in local space
  6726. */
  6727. readonly center: Vector3;
  6728. /**
  6729. * Gets the center of the bounding box in world space
  6730. */
  6731. readonly centerWorld: Vector3;
  6732. /**
  6733. * Gets the extend size in local space
  6734. */
  6735. readonly extendSize: Vector3;
  6736. /**
  6737. * Gets the extend size in world space
  6738. */
  6739. readonly extendSizeWorld: Vector3;
  6740. /**
  6741. * Gets the OBB (object bounding box) directions
  6742. */
  6743. readonly directions: Vector3[];
  6744. /**
  6745. * Gets the 8 vectors representing the bounding box in world space
  6746. */
  6747. readonly vectorsWorld: Vector3[];
  6748. /**
  6749. * Gets the minimum vector in world space
  6750. */
  6751. readonly minimumWorld: Vector3;
  6752. /**
  6753. * Gets the maximum vector in world space
  6754. */
  6755. readonly maximumWorld: Vector3;
  6756. /**
  6757. * Gets the minimum vector in local space
  6758. */
  6759. readonly minimum: Vector3;
  6760. /**
  6761. * Gets the maximum vector in local space
  6762. */
  6763. readonly maximum: Vector3;
  6764. private _worldMatrix;
  6765. private static readonly TmpVector3;
  6766. /**
  6767. * @hidden
  6768. */ private _tag: number;
  6769. /**
  6770. * Creates a new bounding box
  6771. * @param min defines the minimum vector (in local space)
  6772. * @param max defines the maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6776. /**
  6777. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6778. * @param min defines the new minimum vector (in local space)
  6779. * @param max defines the new maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6783. /**
  6784. * Scale the current bounding box by applying a scale factor
  6785. * @param factor defines the scale factor to apply
  6786. * @returns the current bounding box
  6787. */
  6788. scale(factor: number): BoundingBox;
  6789. /**
  6790. * Gets the world matrix of the bounding box
  6791. * @returns a matrix
  6792. */
  6793. getWorldMatrix(): DeepImmutable<Matrix>;
  6794. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6795. /**
  6796. * Tests if the bounding box is intersecting the frustum planes
  6797. * @param frustumPlanes defines the frustum planes to test
  6798. * @returns true if there is an intersection
  6799. */
  6800. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6801. /**
  6802. * Tests if the bounding box is entirely inside the frustum planes
  6803. * @param frustumPlanes defines the frustum planes to test
  6804. * @returns true if there is an inclusion
  6805. */
  6806. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6807. /**
  6808. * Tests if a point is inside the bounding box
  6809. * @param point defines the point to test
  6810. * @returns true if the point is inside the bounding box
  6811. */
  6812. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6813. /**
  6814. * Tests if the bounding box intersects with a bounding sphere
  6815. * @param sphere defines the sphere to test
  6816. * @returns true if there is an intersection
  6817. */
  6818. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6819. /**
  6820. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6821. * @param min defines the min vector to use
  6822. * @param max defines the max vector to use
  6823. * @returns true if there is an intersection
  6824. */
  6825. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6826. /**
  6827. * Tests if two bounding boxes are intersections
  6828. * @param box0 defines the first box to test
  6829. * @param box1 defines the second box to test
  6830. * @returns true if there is an intersection
  6831. */
  6832. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6833. /**
  6834. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6835. * @param minPoint defines the minimum vector of the bounding box
  6836. * @param maxPoint defines the maximum vector of the bounding box
  6837. * @param sphereCenter defines the sphere center
  6838. * @param sphereRadius defines the sphere radius
  6839. * @returns true if there is an intersection
  6840. */
  6841. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6842. /**
  6843. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6844. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6845. * @param frustumPlanes defines the frustum planes to test
  6846. * @return true if there is an inclusion
  6847. */
  6848. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6849. /**
  6850. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6851. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @return true if there is an intersection
  6854. */
  6855. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. }
  6857. }
  6858. declare module BABYLON {
  6859. /** @hidden */
  6860. export class Collider {
  6861. /** Define if a collision was found */
  6862. collisionFound: boolean;
  6863. /**
  6864. * Define last intersection point in local space
  6865. */
  6866. intersectionPoint: Vector3;
  6867. /**
  6868. * Define last collided mesh
  6869. */
  6870. collidedMesh: Nullable<AbstractMesh>;
  6871. private _collisionPoint;
  6872. private _planeIntersectionPoint;
  6873. private _tempVector;
  6874. private _tempVector2;
  6875. private _tempVector3;
  6876. private _tempVector4;
  6877. private _edge;
  6878. private _baseToVertex;
  6879. private _destinationPoint;
  6880. private _slidePlaneNormal;
  6881. private _displacementVector;
  6882. /** @hidden */ private _radius: Vector3;
  6883. /** @hidden */ private _retry: number;
  6884. private _velocity;
  6885. private _basePoint;
  6886. private _epsilon;
  6887. /** @hidden */ private _velocityWorldLength: number;
  6888. /** @hidden */ private _basePointWorld: Vector3;
  6889. private _velocityWorld;
  6890. private _normalizedVelocity;
  6891. /** @hidden */ private _initialVelocity: Vector3;
  6892. /** @hidden */ private _initialPosition: Vector3;
  6893. private _nearestDistance;
  6894. private _collisionMask;
  6895. collisionMask: number;
  6896. /**
  6897. * Gets the plane normal used to compute the sliding response (in local space)
  6898. */
  6899. readonly slidePlaneNormal: Vector3;
  6900. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6901. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6902. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6903. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6904. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6905. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Interface for cullable objects
  6911. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6912. */
  6913. export interface ICullable {
  6914. /**
  6915. * Checks if the object or part of the object is in the frustum
  6916. * @param frustumPlanes Camera near/planes
  6917. * @returns true if the object is in frustum otherwise false
  6918. */
  6919. isInFrustum(frustumPlanes: Plane[]): boolean;
  6920. /**
  6921. * Checks if a cullable object (mesh...) is in the camera frustum
  6922. * Unlike isInFrustum this cheks the full bounding box
  6923. * @param frustumPlanes Camera near/planes
  6924. * @returns true if the object is in frustum otherwise false
  6925. */
  6926. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6927. }
  6928. /**
  6929. * Info for a bounding data of a mesh
  6930. */
  6931. export class BoundingInfo implements ICullable {
  6932. /**
  6933. * Bounding box for the mesh
  6934. */
  6935. readonly boundingBox: BoundingBox;
  6936. /**
  6937. * Bounding sphere for the mesh
  6938. */
  6939. readonly boundingSphere: BoundingSphere;
  6940. private _isLocked;
  6941. private static readonly TmpVector3;
  6942. /**
  6943. * Constructs bounding info
  6944. * @param minimum min vector of the bounding box/sphere
  6945. * @param maximum max vector of the bounding box/sphere
  6946. * @param worldMatrix defines the new world matrix
  6947. */
  6948. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6949. /**
  6950. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6951. * @param min defines the new minimum vector (in local space)
  6952. * @param max defines the new maximum vector (in local space)
  6953. * @param worldMatrix defines the new world matrix
  6954. */
  6955. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6956. /**
  6957. * min vector of the bounding box/sphere
  6958. */
  6959. readonly minimum: Vector3;
  6960. /**
  6961. * max vector of the bounding box/sphere
  6962. */
  6963. readonly maximum: Vector3;
  6964. /**
  6965. * If the info is locked and won't be updated to avoid perf overhead
  6966. */
  6967. isLocked: boolean;
  6968. /**
  6969. * Updates the bounding sphere and box
  6970. * @param world world matrix to be used to update
  6971. */
  6972. update(world: DeepImmutable<Matrix>): void;
  6973. /**
  6974. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6975. * @param center New center of the bounding info
  6976. * @param extend New extend of the bounding info
  6977. * @returns the current bounding info
  6978. */
  6979. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6980. /**
  6981. * Scale the current bounding info by applying a scale factor
  6982. * @param factor defines the scale factor to apply
  6983. * @returns the current bounding info
  6984. */
  6985. scale(factor: number): BoundingInfo;
  6986. /**
  6987. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6988. * @param frustumPlanes defines the frustum to test
  6989. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6990. * @returns true if the bounding info is in the frustum planes
  6991. */
  6992. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6993. /**
  6994. * Gets the world distance between the min and max points of the bounding box
  6995. */
  6996. readonly diagonalLength: number;
  6997. /**
  6998. * Checks if a cullable object (mesh...) is in the camera frustum
  6999. * Unlike isInFrustum this cheks the full bounding box
  7000. * @param frustumPlanes Camera near/planes
  7001. * @returns true if the object is in frustum otherwise false
  7002. */
  7003. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7005. /**
  7006. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7007. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7008. * @param point the point to check intersection with
  7009. * @returns if the point intersects
  7010. */
  7011. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7012. /**
  7013. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7014. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7015. * @param boundingInfo the bounding info to check intersection with
  7016. * @param precise if the intersection should be done using OBB
  7017. * @returns if the bounding info intersects
  7018. */
  7019. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7020. }
  7021. }
  7022. declare module BABYLON {
  7023. /**
  7024. * Extracts minimum and maximum values from a list of indexed positions
  7025. * @param positions defines the positions to use
  7026. * @param indices defines the indices to the positions
  7027. * @param indexStart defines the start index
  7028. * @param indexCount defines the end index
  7029. * @param bias defines bias value to add to the result
  7030. * @return minimum and maximum values
  7031. */
  7032. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7033. minimum: Vector3;
  7034. maximum: Vector3;
  7035. };
  7036. /**
  7037. * Extracts minimum and maximum values from a list of positions
  7038. * @param positions defines the positions to use
  7039. * @param start defines the start index in the positions array
  7040. * @param count defines the number of positions to handle
  7041. * @param bias defines bias value to add to the result
  7042. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7043. * @return minimum and maximum values
  7044. */
  7045. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7046. minimum: Vector3;
  7047. maximum: Vector3;
  7048. };
  7049. }
  7050. declare module BABYLON {
  7051. /** @hidden */
  7052. export class WebGLDataBuffer extends DataBuffer {
  7053. private _buffer;
  7054. constructor(resource: WebGLBuffer);
  7055. readonly underlyingResource: any;
  7056. }
  7057. }
  7058. declare module BABYLON {
  7059. /** @hidden */
  7060. export class WebGLPipelineContext implements IPipelineContext {
  7061. engine: ThinEngine;
  7062. program: Nullable<WebGLProgram>;
  7063. context?: WebGLRenderingContext;
  7064. vertexShader?: WebGLShader;
  7065. fragmentShader?: WebGLShader;
  7066. isParallelCompiled: boolean;
  7067. onCompiled?: () => void;
  7068. transformFeedback?: WebGLTransformFeedback | null;
  7069. readonly isAsync: boolean;
  7070. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7071. }
  7072. }
  7073. declare module BABYLON {
  7074. interface ThinEngine {
  7075. /**
  7076. * Create an uniform buffer
  7077. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7078. * @param elements defines the content of the uniform buffer
  7079. * @returns the webGL uniform buffer
  7080. */
  7081. createUniformBuffer(elements: FloatArray): DataBuffer;
  7082. /**
  7083. * Create a dynamic uniform buffer
  7084. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7085. * @param elements defines the content of the uniform buffer
  7086. * @returns the webGL uniform buffer
  7087. */
  7088. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7089. /**
  7090. * Update an existing uniform buffer
  7091. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7092. * @param uniformBuffer defines the target uniform buffer
  7093. * @param elements defines the content to update
  7094. * @param offset defines the offset in the uniform buffer where update should start
  7095. * @param count defines the size of the data to update
  7096. */
  7097. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7098. /**
  7099. * Bind an uniform buffer to the current webGL context
  7100. * @param buffer defines the buffer to bind
  7101. */
  7102. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7103. /**
  7104. * Bind a buffer to the current webGL context at a given location
  7105. * @param buffer defines the buffer to bind
  7106. * @param location defines the index where to bind the buffer
  7107. */
  7108. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7109. /**
  7110. * Bind a specific block at a given index in a specific shader program
  7111. * @param pipelineContext defines the pipeline context to use
  7112. * @param blockName defines the block name
  7113. * @param index defines the index where to bind the block
  7114. */
  7115. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7116. }
  7117. }
  7118. declare module BABYLON {
  7119. /**
  7120. * Uniform buffer objects.
  7121. *
  7122. * Handles blocks of uniform on the GPU.
  7123. *
  7124. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7125. *
  7126. * For more information, please refer to :
  7127. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7128. */
  7129. export class UniformBuffer {
  7130. private _engine;
  7131. private _buffer;
  7132. private _data;
  7133. private _bufferData;
  7134. private _dynamic?;
  7135. private _uniformLocations;
  7136. private _uniformSizes;
  7137. private _uniformLocationPointer;
  7138. private _needSync;
  7139. private _noUBO;
  7140. private _currentEffect;
  7141. private static _MAX_UNIFORM_SIZE;
  7142. private static _tempBuffer;
  7143. /**
  7144. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7145. * This is dynamic to allow compat with webgl 1 and 2.
  7146. * You will need to pass the name of the uniform as well as the value.
  7147. */
  7148. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7149. /**
  7150. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7151. * This is dynamic to allow compat with webgl 1 and 2.
  7152. * You will need to pass the name of the uniform as well as the value.
  7153. */
  7154. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7155. /**
  7156. * Lambda to Update a single float in a uniform buffer.
  7157. * This is dynamic to allow compat with webgl 1 and 2.
  7158. * You will need to pass the name of the uniform as well as the value.
  7159. */
  7160. updateFloat: (name: string, x: number) => void;
  7161. /**
  7162. * Lambda to Update a vec2 of float in a uniform buffer.
  7163. * This is dynamic to allow compat with webgl 1 and 2.
  7164. * You will need to pass the name of the uniform as well as the value.
  7165. */
  7166. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7167. /**
  7168. * Lambda to Update a vec3 of float in a uniform buffer.
  7169. * This is dynamic to allow compat with webgl 1 and 2.
  7170. * You will need to pass the name of the uniform as well as the value.
  7171. */
  7172. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7173. /**
  7174. * Lambda to Update a vec4 of float in a uniform buffer.
  7175. * This is dynamic to allow compat with webgl 1 and 2.
  7176. * You will need to pass the name of the uniform as well as the value.
  7177. */
  7178. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7179. /**
  7180. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7181. * This is dynamic to allow compat with webgl 1 and 2.
  7182. * You will need to pass the name of the uniform as well as the value.
  7183. */
  7184. updateMatrix: (name: string, mat: Matrix) => void;
  7185. /**
  7186. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7187. * This is dynamic to allow compat with webgl 1 and 2.
  7188. * You will need to pass the name of the uniform as well as the value.
  7189. */
  7190. updateVector3: (name: string, vector: Vector3) => void;
  7191. /**
  7192. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7193. * This is dynamic to allow compat with webgl 1 and 2.
  7194. * You will need to pass the name of the uniform as well as the value.
  7195. */
  7196. updateVector4: (name: string, vector: Vector4) => void;
  7197. /**
  7198. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7199. * This is dynamic to allow compat with webgl 1 and 2.
  7200. * You will need to pass the name of the uniform as well as the value.
  7201. */
  7202. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7203. /**
  7204. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7205. * This is dynamic to allow compat with webgl 1 and 2.
  7206. * You will need to pass the name of the uniform as well as the value.
  7207. */
  7208. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7209. /**
  7210. * Instantiates a new Uniform buffer objects.
  7211. *
  7212. * Handles blocks of uniform on the GPU.
  7213. *
  7214. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7215. *
  7216. * For more information, please refer to :
  7217. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7218. * @param engine Define the engine the buffer is associated with
  7219. * @param data Define the data contained in the buffer
  7220. * @param dynamic Define if the buffer is updatable
  7221. */
  7222. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7223. /**
  7224. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7225. * or just falling back on setUniformXXX calls.
  7226. */
  7227. readonly useUbo: boolean;
  7228. /**
  7229. * Indicates if the WebGL underlying uniform buffer is in sync
  7230. * with the javascript cache data.
  7231. */
  7232. readonly isSync: boolean;
  7233. /**
  7234. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7235. * Also, a dynamic UniformBuffer will disable cache verification and always
  7236. * update the underlying WebGL uniform buffer to the GPU.
  7237. * @returns if Dynamic, otherwise false
  7238. */
  7239. isDynamic(): boolean;
  7240. /**
  7241. * The data cache on JS side.
  7242. * @returns the underlying data as a float array
  7243. */
  7244. getData(): Float32Array;
  7245. /**
  7246. * The underlying WebGL Uniform buffer.
  7247. * @returns the webgl buffer
  7248. */
  7249. getBuffer(): Nullable<DataBuffer>;
  7250. /**
  7251. * std140 layout specifies how to align data within an UBO structure.
  7252. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7253. * for specs.
  7254. */
  7255. private _fillAlignment;
  7256. /**
  7257. * Adds an uniform in the buffer.
  7258. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7259. * for the layout to be correct !
  7260. * @param name Name of the uniform, as used in the uniform block in the shader.
  7261. * @param size Data size, or data directly.
  7262. */
  7263. addUniform(name: string, size: number | number[]): void;
  7264. /**
  7265. * Adds a Matrix 4x4 to the uniform buffer.
  7266. * @param name Name of the uniform, as used in the uniform block in the shader.
  7267. * @param mat A 4x4 matrix.
  7268. */
  7269. addMatrix(name: string, mat: Matrix): void;
  7270. /**
  7271. * Adds a vec2 to the uniform buffer.
  7272. * @param name Name of the uniform, as used in the uniform block in the shader.
  7273. * @param x Define the x component value of the vec2
  7274. * @param y Define the y component value of the vec2
  7275. */
  7276. addFloat2(name: string, x: number, y: number): void;
  7277. /**
  7278. * Adds a vec3 to the uniform buffer.
  7279. * @param name Name of the uniform, as used in the uniform block in the shader.
  7280. * @param x Define the x component value of the vec3
  7281. * @param y Define the y component value of the vec3
  7282. * @param z Define the z component value of the vec3
  7283. */
  7284. addFloat3(name: string, x: number, y: number, z: number): void;
  7285. /**
  7286. * Adds a vec3 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param color Define the vec3 from a Color
  7289. */
  7290. addColor3(name: string, color: Color3): void;
  7291. /**
  7292. * Adds a vec4 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param color Define the rgb components from a Color
  7295. * @param alpha Define the a component of the vec4
  7296. */
  7297. addColor4(name: string, color: Color3, alpha: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param vector Define the vec3 components from a Vector
  7302. */
  7303. addVector3(name: string, vector: Vector3): void;
  7304. /**
  7305. * Adds a Matrix 3x3 to the uniform buffer.
  7306. * @param name Name of the uniform, as used in the uniform block in the shader.
  7307. */
  7308. addMatrix3x3(name: string): void;
  7309. /**
  7310. * Adds a Matrix 2x2 to the uniform buffer.
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. */
  7313. addMatrix2x2(name: string): void;
  7314. /**
  7315. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7316. */
  7317. create(): void;
  7318. /** @hidden */ private _rebuild(): void;
  7319. /**
  7320. * Updates the WebGL Uniform Buffer on the GPU.
  7321. * If the `dynamic` flag is set to true, no cache comparison is done.
  7322. * Otherwise, the buffer will be updated only if the cache differs.
  7323. */
  7324. update(): void;
  7325. /**
  7326. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7327. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7328. * @param data Define the flattened data
  7329. * @param size Define the size of the data.
  7330. */
  7331. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7332. private _valueCache;
  7333. private _cacheMatrix;
  7334. private _updateMatrix3x3ForUniform;
  7335. private _updateMatrix3x3ForEffect;
  7336. private _updateMatrix2x2ForEffect;
  7337. private _updateMatrix2x2ForUniform;
  7338. private _updateFloatForEffect;
  7339. private _updateFloatForUniform;
  7340. private _updateFloat2ForEffect;
  7341. private _updateFloat2ForUniform;
  7342. private _updateFloat3ForEffect;
  7343. private _updateFloat3ForUniform;
  7344. private _updateFloat4ForEffect;
  7345. private _updateFloat4ForUniform;
  7346. private _updateMatrixForEffect;
  7347. private _updateMatrixForUniform;
  7348. private _updateVector3ForEffect;
  7349. private _updateVector3ForUniform;
  7350. private _updateVector4ForEffect;
  7351. private _updateVector4ForUniform;
  7352. private _updateColor3ForEffect;
  7353. private _updateColor3ForUniform;
  7354. private _updateColor4ForEffect;
  7355. private _updateColor4ForUniform;
  7356. /**
  7357. * Sets a sampler uniform on the effect.
  7358. * @param name Define the name of the sampler.
  7359. * @param texture Define the texture to set in the sampler
  7360. */
  7361. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7362. /**
  7363. * Directly updates the value of the uniform in the cache AND on the GPU.
  7364. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7365. * @param data Define the flattened data
  7366. */
  7367. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7368. /**
  7369. * Binds this uniform buffer to an effect.
  7370. * @param effect Define the effect to bind the buffer to
  7371. * @param name Name of the uniform block in the shader.
  7372. */
  7373. bindToEffect(effect: Effect, name: string): void;
  7374. /**
  7375. * Disposes the uniform buffer.
  7376. */
  7377. dispose(): void;
  7378. }
  7379. }
  7380. declare module BABYLON {
  7381. /**
  7382. * Enum that determines the text-wrapping mode to use.
  7383. */
  7384. export enum InspectableType {
  7385. /**
  7386. * Checkbox for booleans
  7387. */
  7388. Checkbox = 0,
  7389. /**
  7390. * Sliders for numbers
  7391. */
  7392. Slider = 1,
  7393. /**
  7394. * Vector3
  7395. */
  7396. Vector3 = 2,
  7397. /**
  7398. * Quaternions
  7399. */
  7400. Quaternion = 3,
  7401. /**
  7402. * Color3
  7403. */
  7404. Color3 = 4,
  7405. /**
  7406. * String
  7407. */
  7408. String = 5
  7409. }
  7410. /**
  7411. * Interface used to define custom inspectable properties.
  7412. * This interface is used by the inspector to display custom property grids
  7413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7414. */
  7415. export interface IInspectable {
  7416. /**
  7417. * Gets the label to display
  7418. */
  7419. label: string;
  7420. /**
  7421. * Gets the name of the property to edit
  7422. */
  7423. propertyName: string;
  7424. /**
  7425. * Gets the type of the editor to use
  7426. */
  7427. type: InspectableType;
  7428. /**
  7429. * Gets the minimum value of the property when using in "slider" mode
  7430. */
  7431. min?: number;
  7432. /**
  7433. * Gets the maximum value of the property when using in "slider" mode
  7434. */
  7435. max?: number;
  7436. /**
  7437. * Gets the setp to use when using in "slider" mode
  7438. */
  7439. step?: number;
  7440. }
  7441. }
  7442. declare module BABYLON {
  7443. /**
  7444. * Class used to provide helper for timing
  7445. */
  7446. export class TimingTools {
  7447. /**
  7448. * Polyfill for setImmediate
  7449. * @param action defines the action to execute after the current execution block
  7450. */
  7451. static SetImmediate(action: () => void): void;
  7452. }
  7453. }
  7454. declare module BABYLON {
  7455. /**
  7456. * Class used to enable instatition of objects by class name
  7457. */
  7458. export class InstantiationTools {
  7459. /**
  7460. * Use this object to register external classes like custom textures or material
  7461. * to allow the laoders to instantiate them
  7462. */
  7463. static RegisteredExternalClasses: {
  7464. [key: string]: Object;
  7465. };
  7466. /**
  7467. * Tries to instantiate a new object from a given class name
  7468. * @param className defines the class name to instantiate
  7469. * @returns the new object or null if the system was not able to do the instantiation
  7470. */
  7471. static Instantiate(className: string): any;
  7472. }
  7473. }
  7474. declare module BABYLON {
  7475. /**
  7476. * Define options used to create a depth texture
  7477. */
  7478. export class DepthTextureCreationOptions {
  7479. /** Specifies whether or not a stencil should be allocated in the texture */
  7480. generateStencil?: boolean;
  7481. /** Specifies whether or not bilinear filtering is enable on the texture */
  7482. bilinearFiltering?: boolean;
  7483. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7484. comparisonFunction?: number;
  7485. /** Specifies if the created texture is a cube texture */
  7486. isCube?: boolean;
  7487. }
  7488. }
  7489. declare module BABYLON {
  7490. interface ThinEngine {
  7491. /**
  7492. * Creates a depth stencil cube texture.
  7493. * This is only available in WebGL 2.
  7494. * @param size The size of face edge in the cube texture.
  7495. * @param options The options defining the cube texture.
  7496. * @returns The cube texture
  7497. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7498. /**
  7499. * Creates a cube texture
  7500. * @param rootUrl defines the url where the files to load is located
  7501. * @param scene defines the current scene
  7502. * @param files defines the list of files to load (1 per face)
  7503. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7504. * @param onLoad defines an optional callback raised when the texture is loaded
  7505. * @param onError defines an optional callback raised if there is an issue to load the texture
  7506. * @param format defines the format of the data
  7507. * @param forcedExtension defines the extension to use to pick the right loader
  7508. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7509. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7510. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7511. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7512. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @returns the cube texture as an InternalTexture
  7527. */
  7528. 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;
  7529. /**
  7530. * Creates a cube texture
  7531. * @param rootUrl defines the url where the files to load is located
  7532. * @param scene defines the current scene
  7533. * @param files defines the list of files to load (1 per face)
  7534. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7535. * @param onLoad defines an optional callback raised when the texture is loaded
  7536. * @param onError defines an optional callback raised if there is an issue to load the texture
  7537. * @param format defines the format of the data
  7538. * @param forcedExtension defines the extension to use to pick the right loader
  7539. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7540. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7541. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7546. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7547. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7548. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7549. }
  7550. }
  7551. declare module BABYLON {
  7552. /**
  7553. * Class for creating a cube texture
  7554. */
  7555. export class CubeTexture extends BaseTexture {
  7556. private _delayedOnLoad;
  7557. /**
  7558. * The url of the texture
  7559. */
  7560. url: string;
  7561. /**
  7562. * Gets or sets the center of the bounding box associated with the cube texture.
  7563. * It must define where the camera used to render the texture was set
  7564. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7565. */
  7566. boundingBoxPosition: Vector3;
  7567. private _boundingBoxSize;
  7568. /**
  7569. * Gets or sets the size of the bounding box associated with the cube texture
  7570. * When defined, the cubemap will switch to local mode
  7571. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7572. * @example https://www.babylonjs-playground.com/#RNASML
  7573. */
  7574. /**
  7575. * Returns the bounding box size
  7576. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7577. */
  7578. boundingBoxSize: Vector3;
  7579. protected _rotationY: number;
  7580. /**
  7581. * Sets texture matrix rotation angle around Y axis in radians.
  7582. */
  7583. /**
  7584. * Gets texture matrix rotation angle around Y axis radians.
  7585. */
  7586. rotationY: number;
  7587. /**
  7588. * Are mip maps generated for this texture or not.
  7589. */
  7590. readonly noMipmap: boolean;
  7591. private _noMipmap;
  7592. private _files;
  7593. private _extensions;
  7594. private _textureMatrix;
  7595. private _format;
  7596. private _createPolynomials;
  7597. /** @hidden */ private _prefiltered: boolean;
  7598. /**
  7599. * Creates a cube texture from an array of image urls
  7600. * @param files defines an array of image urls
  7601. * @param scene defines the hosting scene
  7602. * @param noMipmap specifies if mip maps are not used
  7603. * @returns a cube texture
  7604. */
  7605. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7606. /**
  7607. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7608. * @param url defines the url of the prefiltered texture
  7609. * @param scene defines the scene the texture is attached to
  7610. * @param forcedExtension defines the extension of the file if different from the url
  7611. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7612. * @return the prefiltered texture
  7613. */
  7614. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7615. /**
  7616. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7617. * as prefiltered data.
  7618. * @param rootUrl defines the url of the texture or the root name of the six images
  7619. * @param scene defines the scene the texture is attached to
  7620. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7621. * @param noMipmap defines if mipmaps should be created or not
  7622. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7623. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7624. * @param onError defines a callback triggered in case of error during load
  7625. * @param format defines the internal format to use for the texture once loaded
  7626. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7627. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7628. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7629. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7630. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7631. * @return the cube texture
  7632. */
  7633. 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);
  7634. /**
  7635. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7636. */
  7637. readonly isPrefiltered: boolean;
  7638. /**
  7639. * Get the current class name of the texture useful for serialization or dynamic coding.
  7640. * @returns "CubeTexture"
  7641. */
  7642. getClassName(): string;
  7643. /**
  7644. * Update the url (and optional buffer) of this texture if url was null during construction.
  7645. * @param url the url of the texture
  7646. * @param forcedExtension defines the extension to use
  7647. * @param onLoad callback called when the texture is loaded (defaults to null)
  7648. */
  7649. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7650. /**
  7651. * Delays loading of the cube texture
  7652. * @param forcedExtension defines the extension to use
  7653. */
  7654. delayLoad(forcedExtension?: string): void;
  7655. /**
  7656. * Returns the reflection texture matrix
  7657. * @returns the reflection texture matrix
  7658. */
  7659. getReflectionTextureMatrix(): Matrix;
  7660. /**
  7661. * Sets the reflection texture matrix
  7662. * @param value Reflection texture matrix
  7663. */
  7664. setReflectionTextureMatrix(value: Matrix): void;
  7665. /**
  7666. * Parses text to create a cube texture
  7667. * @param parsedTexture define the serialized text to read from
  7668. * @param scene defines the hosting scene
  7669. * @param rootUrl defines the root url of the cube texture
  7670. * @returns a cube texture
  7671. */
  7672. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7673. /**
  7674. * Makes a clone, or deep copy, of the cube texture
  7675. * @returns a new cube texture
  7676. */
  7677. clone(): CubeTexture;
  7678. }
  7679. }
  7680. declare module BABYLON {
  7681. /**
  7682. * Manages the defines for the Material
  7683. */
  7684. export class MaterialDefines {
  7685. /** @hidden */
  7686. protected _keys: string[];
  7687. private _isDirty;
  7688. /** @hidden */ private _renderId: number;
  7689. /** @hidden */ private _areLightsDirty: boolean;
  7690. /** @hidden */ private _areLightsDisposed: boolean;
  7691. /** @hidden */ private _areAttributesDirty: boolean;
  7692. /** @hidden */ private _areTexturesDirty: boolean;
  7693. /** @hidden */ private _areFresnelDirty: boolean;
  7694. /** @hidden */ private _areMiscDirty: boolean;
  7695. /** @hidden */ private _areImageProcessingDirty: boolean;
  7696. /** @hidden */ private _normals: boolean;
  7697. /** @hidden */ private _uvs: boolean;
  7698. /** @hidden */ private _needNormals: boolean;
  7699. /** @hidden */ private _needUVs: boolean;
  7700. [id: string]: any;
  7701. /**
  7702. * Specifies if the material needs to be re-calculated
  7703. */
  7704. readonly isDirty: boolean;
  7705. /**
  7706. * Marks the material to indicate that it has been re-calculated
  7707. */
  7708. markAsProcessed(): void;
  7709. /**
  7710. * Marks the material to indicate that it needs to be re-calculated
  7711. */
  7712. markAsUnprocessed(): void;
  7713. /**
  7714. * Marks the material to indicate all of its defines need to be re-calculated
  7715. */
  7716. markAllAsDirty(): void;
  7717. /**
  7718. * Marks the material to indicate that image processing needs to be re-calculated
  7719. */
  7720. markAsImageProcessingDirty(): void;
  7721. /**
  7722. * Marks the material to indicate the lights need to be re-calculated
  7723. * @param disposed Defines whether the light is dirty due to dispose or not
  7724. */
  7725. markAsLightDirty(disposed?: boolean): void;
  7726. /**
  7727. * Marks the attribute state as changed
  7728. */
  7729. markAsAttributesDirty(): void;
  7730. /**
  7731. * Marks the texture state as changed
  7732. */
  7733. markAsTexturesDirty(): void;
  7734. /**
  7735. * Marks the fresnel state as changed
  7736. */
  7737. markAsFresnelDirty(): void;
  7738. /**
  7739. * Marks the misc state as changed
  7740. */
  7741. markAsMiscDirty(): void;
  7742. /**
  7743. * Rebuilds the material defines
  7744. */
  7745. rebuild(): void;
  7746. /**
  7747. * Specifies if two material defines are equal
  7748. * @param other - A material define instance to compare to
  7749. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7750. */
  7751. isEqual(other: MaterialDefines): boolean;
  7752. /**
  7753. * Clones this instance's defines to another instance
  7754. * @param other - material defines to clone values to
  7755. */
  7756. cloneTo(other: MaterialDefines): void;
  7757. /**
  7758. * Resets the material define values
  7759. */
  7760. reset(): void;
  7761. /**
  7762. * Converts the material define values to a string
  7763. * @returns - String of material define information
  7764. */
  7765. toString(): string;
  7766. }
  7767. }
  7768. declare module BABYLON {
  7769. /**
  7770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7772. * 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;
  7773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7774. */
  7775. export class ColorCurves {
  7776. private _dirty;
  7777. private _tempColor;
  7778. private _globalCurve;
  7779. private _highlightsCurve;
  7780. private _midtonesCurve;
  7781. private _shadowsCurve;
  7782. private _positiveCurve;
  7783. private _negativeCurve;
  7784. private _globalHue;
  7785. private _globalDensity;
  7786. private _globalSaturation;
  7787. private _globalExposure;
  7788. /**
  7789. * Gets the global Hue value.
  7790. * 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).
  7791. */
  7792. /**
  7793. * Sets the global Hue value.
  7794. * 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).
  7795. */
  7796. globalHue: number;
  7797. /**
  7798. * Gets the global Density value.
  7799. * 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.
  7800. * Values less than zero provide a filter of opposite hue.
  7801. */
  7802. /**
  7803. * Sets the global Density value.
  7804. * 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.
  7805. * Values less than zero provide a filter of opposite hue.
  7806. */
  7807. globalDensity: number;
  7808. /**
  7809. * Gets the global Saturation value.
  7810. * 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.
  7811. */
  7812. /**
  7813. * Sets the global Saturation value.
  7814. * 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.
  7815. */
  7816. globalSaturation: number;
  7817. /**
  7818. * Gets the global Exposure value.
  7819. * 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.
  7820. */
  7821. /**
  7822. * Sets the global Exposure value.
  7823. * 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.
  7824. */
  7825. globalExposure: number;
  7826. private _highlightsHue;
  7827. private _highlightsDensity;
  7828. private _highlightsSaturation;
  7829. private _highlightsExposure;
  7830. /**
  7831. * Gets the highlights Hue value.
  7832. * 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).
  7833. */
  7834. /**
  7835. * Sets the highlights Hue value.
  7836. * 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).
  7837. */
  7838. highlightsHue: number;
  7839. /**
  7840. * Gets the highlights Density value.
  7841. * 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.
  7842. * Values less than zero provide a filter of opposite hue.
  7843. */
  7844. /**
  7845. * Sets the highlights Density value.
  7846. * 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.
  7847. * Values less than zero provide a filter of opposite hue.
  7848. */
  7849. highlightsDensity: number;
  7850. /**
  7851. * Gets the highlights Saturation value.
  7852. * 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.
  7853. */
  7854. /**
  7855. * Sets the highlights Saturation value.
  7856. * 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.
  7857. */
  7858. highlightsSaturation: number;
  7859. /**
  7860. * Gets the highlights Exposure value.
  7861. * 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.
  7862. */
  7863. /**
  7864. * Sets the highlights Exposure value.
  7865. * 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.
  7866. */
  7867. highlightsExposure: number;
  7868. private _midtonesHue;
  7869. private _midtonesDensity;
  7870. private _midtonesSaturation;
  7871. private _midtonesExposure;
  7872. /**
  7873. * Gets the midtones Hue value.
  7874. * 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).
  7875. */
  7876. /**
  7877. * Sets the midtones Hue value.
  7878. * 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).
  7879. */
  7880. midtonesHue: number;
  7881. /**
  7882. * Gets the midtones Density value.
  7883. * 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.
  7884. * Values less than zero provide a filter of opposite hue.
  7885. */
  7886. /**
  7887. * Sets the midtones Density value.
  7888. * 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.
  7889. * Values less than zero provide a filter of opposite hue.
  7890. */
  7891. midtonesDensity: number;
  7892. /**
  7893. * Gets the midtones Saturation value.
  7894. * 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.
  7895. */
  7896. /**
  7897. * Sets the midtones Saturation value.
  7898. * 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.
  7899. */
  7900. midtonesSaturation: number;
  7901. /**
  7902. * Gets the midtones Exposure value.
  7903. * 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.
  7904. */
  7905. /**
  7906. * Sets the midtones Exposure value.
  7907. * 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.
  7908. */
  7909. midtonesExposure: number;
  7910. private _shadowsHue;
  7911. private _shadowsDensity;
  7912. private _shadowsSaturation;
  7913. private _shadowsExposure;
  7914. /**
  7915. * Gets the shadows Hue value.
  7916. * 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).
  7917. */
  7918. /**
  7919. * Sets the shadows Hue value.
  7920. * 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).
  7921. */
  7922. shadowsHue: number;
  7923. /**
  7924. * Gets the shadows Density value.
  7925. * 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.
  7926. * Values less than zero provide a filter of opposite hue.
  7927. */
  7928. /**
  7929. * Sets the shadows Density value.
  7930. * 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.
  7931. * Values less than zero provide a filter of opposite hue.
  7932. */
  7933. shadowsDensity: number;
  7934. /**
  7935. * Gets the shadows Saturation value.
  7936. * 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.
  7937. */
  7938. /**
  7939. * Sets the shadows Saturation value.
  7940. * 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.
  7941. */
  7942. shadowsSaturation: number;
  7943. /**
  7944. * Gets the shadows Exposure value.
  7945. * 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.
  7946. */
  7947. /**
  7948. * Sets the shadows Exposure value.
  7949. * 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.
  7950. */
  7951. shadowsExposure: number;
  7952. /**
  7953. * Returns the class name
  7954. * @returns The class name
  7955. */
  7956. getClassName(): string;
  7957. /**
  7958. * Binds the color curves to the shader.
  7959. * @param colorCurves The color curve to bind
  7960. * @param effect The effect to bind to
  7961. * @param positiveUniform The positive uniform shader parameter
  7962. * @param neutralUniform The neutral uniform shader parameter
  7963. * @param negativeUniform The negative uniform shader parameter
  7964. */
  7965. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7966. /**
  7967. * Prepare the list of uniforms associated with the ColorCurves effects.
  7968. * @param uniformsList The list of uniforms used in the effect
  7969. */
  7970. static PrepareUniforms(uniformsList: string[]): void;
  7971. /**
  7972. * Returns color grading data based on a hue, density, saturation and exposure value.
  7973. * @param filterHue The hue of the color filter.
  7974. * @param filterDensity The density of the color filter.
  7975. * @param saturation The saturation.
  7976. * @param exposure The exposure.
  7977. * @param result The result data container.
  7978. */
  7979. private getColorGradingDataToRef;
  7980. /**
  7981. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7982. * @param value The input slider value in range [-100,100].
  7983. * @returns Adjusted value.
  7984. */
  7985. private static applyColorGradingSliderNonlinear;
  7986. /**
  7987. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7988. * @param hue The hue (H) input.
  7989. * @param saturation The saturation (S) input.
  7990. * @param brightness The brightness (B) input.
  7991. * @result An RGBA color represented as Vector4.
  7992. */
  7993. private static fromHSBToRef;
  7994. /**
  7995. * Returns a value clamped between min and max
  7996. * @param value The value to clamp
  7997. * @param min The minimum of value
  7998. * @param max The maximum of value
  7999. * @returns The clamped value.
  8000. */
  8001. private static clamp;
  8002. /**
  8003. * Clones the current color curve instance.
  8004. * @return The cloned curves
  8005. */
  8006. clone(): ColorCurves;
  8007. /**
  8008. * Serializes the current color curve instance to a json representation.
  8009. * @return a JSON representation
  8010. */
  8011. serialize(): any;
  8012. /**
  8013. * Parses the color curve from a json representation.
  8014. * @param source the JSON source to parse
  8015. * @return The parsed curves
  8016. */
  8017. static Parse(source: any): ColorCurves;
  8018. }
  8019. }
  8020. declare module BABYLON {
  8021. /**
  8022. * Interface to follow in your material defines to integrate easily the
  8023. * Image proccessing functions.
  8024. * @hidden
  8025. */
  8026. export interface IImageProcessingConfigurationDefines {
  8027. IMAGEPROCESSING: boolean;
  8028. VIGNETTE: boolean;
  8029. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8030. VIGNETTEBLENDMODEOPAQUE: boolean;
  8031. TONEMAPPING: boolean;
  8032. TONEMAPPING_ACES: boolean;
  8033. CONTRAST: boolean;
  8034. EXPOSURE: boolean;
  8035. COLORCURVES: boolean;
  8036. COLORGRADING: boolean;
  8037. COLORGRADING3D: boolean;
  8038. SAMPLER3DGREENDEPTH: boolean;
  8039. SAMPLER3DBGRMAP: boolean;
  8040. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8041. }
  8042. /**
  8043. * @hidden
  8044. */
  8045. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8046. IMAGEPROCESSING: boolean;
  8047. VIGNETTE: boolean;
  8048. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8049. VIGNETTEBLENDMODEOPAQUE: boolean;
  8050. TONEMAPPING: boolean;
  8051. TONEMAPPING_ACES: boolean;
  8052. CONTRAST: boolean;
  8053. COLORCURVES: boolean;
  8054. COLORGRADING: boolean;
  8055. COLORGRADING3D: boolean;
  8056. SAMPLER3DGREENDEPTH: boolean;
  8057. SAMPLER3DBGRMAP: boolean;
  8058. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8059. EXPOSURE: boolean;
  8060. constructor();
  8061. }
  8062. /**
  8063. * This groups together the common properties used for image processing either in direct forward pass
  8064. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8065. * or not.
  8066. */
  8067. export class ImageProcessingConfiguration {
  8068. /**
  8069. * Default tone mapping applied in BabylonJS.
  8070. */
  8071. static readonly TONEMAPPING_STANDARD: number;
  8072. /**
  8073. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8074. * to other engines rendering to increase portability.
  8075. */
  8076. static readonly TONEMAPPING_ACES: number;
  8077. /**
  8078. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8079. */
  8080. colorCurves: Nullable<ColorCurves>;
  8081. private _colorCurvesEnabled;
  8082. /**
  8083. * Gets wether the color curves effect is enabled.
  8084. */
  8085. /**
  8086. * Sets wether the color curves effect is enabled.
  8087. */
  8088. colorCurvesEnabled: boolean;
  8089. private _colorGradingTexture;
  8090. /**
  8091. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8092. */
  8093. /**
  8094. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8095. */
  8096. colorGradingTexture: Nullable<BaseTexture>;
  8097. private _colorGradingEnabled;
  8098. /**
  8099. * Gets wether the color grading effect is enabled.
  8100. */
  8101. /**
  8102. * Sets wether the color grading effect is enabled.
  8103. */
  8104. colorGradingEnabled: boolean;
  8105. private _colorGradingWithGreenDepth;
  8106. /**
  8107. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8108. */
  8109. /**
  8110. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8111. */
  8112. colorGradingWithGreenDepth: boolean;
  8113. private _colorGradingBGR;
  8114. /**
  8115. * Gets wether the color grading texture contains BGR values.
  8116. */
  8117. /**
  8118. * Sets wether the color grading texture contains BGR values.
  8119. */
  8120. colorGradingBGR: boolean;
  8121. /** @hidden */ private _exposure: number;
  8122. /**
  8123. * Gets the Exposure used in the effect.
  8124. */
  8125. /**
  8126. * Sets the Exposure used in the effect.
  8127. */
  8128. exposure: number;
  8129. private _toneMappingEnabled;
  8130. /**
  8131. * Gets wether the tone mapping effect is enabled.
  8132. */
  8133. /**
  8134. * Sets wether the tone mapping effect is enabled.
  8135. */
  8136. toneMappingEnabled: boolean;
  8137. private _toneMappingType;
  8138. /**
  8139. * Gets the type of tone mapping effect.
  8140. */
  8141. /**
  8142. * Sets the type of tone mapping effect used in BabylonJS.
  8143. */
  8144. toneMappingType: number;
  8145. protected _contrast: number;
  8146. /**
  8147. * Gets the contrast used in the effect.
  8148. */
  8149. /**
  8150. * Sets the contrast used in the effect.
  8151. */
  8152. contrast: number;
  8153. /**
  8154. * Vignette stretch size.
  8155. */
  8156. vignetteStretch: number;
  8157. /**
  8158. * Vignette centre X Offset.
  8159. */
  8160. vignetteCentreX: number;
  8161. /**
  8162. * Vignette centre Y Offset.
  8163. */
  8164. vignetteCentreY: number;
  8165. /**
  8166. * Vignette weight or intensity of the vignette effect.
  8167. */
  8168. vignetteWeight: number;
  8169. /**
  8170. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8171. * if vignetteEnabled is set to true.
  8172. */
  8173. vignetteColor: Color4;
  8174. /**
  8175. * Camera field of view used by the Vignette effect.
  8176. */
  8177. vignetteCameraFov: number;
  8178. private _vignetteBlendMode;
  8179. /**
  8180. * Gets the vignette blend mode allowing different kind of effect.
  8181. */
  8182. /**
  8183. * Sets the vignette blend mode allowing different kind of effect.
  8184. */
  8185. vignetteBlendMode: number;
  8186. private _vignetteEnabled;
  8187. /**
  8188. * Gets wether the vignette effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the vignette effect is enabled.
  8192. */
  8193. vignetteEnabled: boolean;
  8194. private _applyByPostProcess;
  8195. /**
  8196. * Gets wether the image processing is applied through a post process or not.
  8197. */
  8198. /**
  8199. * Sets wether the image processing is applied through a post process or not.
  8200. */
  8201. applyByPostProcess: boolean;
  8202. private _isEnabled;
  8203. /**
  8204. * Gets wether the image processing is enabled or not.
  8205. */
  8206. /**
  8207. * Sets wether the image processing is enabled or not.
  8208. */
  8209. isEnabled: boolean;
  8210. /**
  8211. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8212. */
  8213. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8214. /**
  8215. * Method called each time the image processing information changes requires to recompile the effect.
  8216. */
  8217. protected _updateParameters(): void;
  8218. /**
  8219. * Gets the current class name.
  8220. * @return "ImageProcessingConfiguration"
  8221. */
  8222. getClassName(): string;
  8223. /**
  8224. * Prepare the list of uniforms associated with the Image Processing effects.
  8225. * @param uniforms The list of uniforms used in the effect
  8226. * @param defines the list of defines currently in use
  8227. */
  8228. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8229. /**
  8230. * Prepare the list of samplers associated with the Image Processing effects.
  8231. * @param samplersList The list of uniforms used in the effect
  8232. * @param defines the list of defines currently in use
  8233. */
  8234. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8235. /**
  8236. * Prepare the list of defines associated to the shader.
  8237. * @param defines the list of defines to complete
  8238. * @param forPostProcess Define if we are currently in post process mode or not
  8239. */
  8240. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8241. /**
  8242. * Returns true if all the image processing information are ready.
  8243. * @returns True if ready, otherwise, false
  8244. */
  8245. isReady(): boolean;
  8246. /**
  8247. * Binds the image processing to the shader.
  8248. * @param effect The effect to bind to
  8249. * @param aspectRatio Define the current aspect ratio of the effect
  8250. */
  8251. bind(effect: Effect, aspectRatio?: number): void;
  8252. /**
  8253. * Clones the current image processing instance.
  8254. * @return The cloned image processing
  8255. */
  8256. clone(): ImageProcessingConfiguration;
  8257. /**
  8258. * Serializes the current image processing instance to a json representation.
  8259. * @return a JSON representation
  8260. */
  8261. serialize(): any;
  8262. /**
  8263. * Parses the image processing from a json representation.
  8264. * @param source the JSON source to parse
  8265. * @return The parsed image processing
  8266. */
  8267. static Parse(source: any): ImageProcessingConfiguration;
  8268. private static _VIGNETTEMODE_MULTIPLY;
  8269. private static _VIGNETTEMODE_OPAQUE;
  8270. /**
  8271. * Used to apply the vignette as a mix with the pixel color.
  8272. */
  8273. static readonly VIGNETTEMODE_MULTIPLY: number;
  8274. /**
  8275. * Used to apply the vignette as a replacement of the pixel color.
  8276. */
  8277. static readonly VIGNETTEMODE_OPAQUE: number;
  8278. }
  8279. }
  8280. declare module BABYLON {
  8281. /** @hidden */
  8282. export var postprocessVertexShader: {
  8283. name: string;
  8284. shader: string;
  8285. };
  8286. }
  8287. declare module BABYLON {
  8288. /** Defines supported spaces */
  8289. export enum Space {
  8290. /** Local (object) space */
  8291. LOCAL = 0,
  8292. /** World space */
  8293. WORLD = 1,
  8294. /** Bone space */
  8295. BONE = 2
  8296. }
  8297. /** Defines the 3 main axes */
  8298. export class Axis {
  8299. /** X axis */
  8300. static X: Vector3;
  8301. /** Y axis */
  8302. static Y: Vector3;
  8303. /** Z axis */
  8304. static Z: Vector3;
  8305. }
  8306. }
  8307. declare module BABYLON {
  8308. /**
  8309. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8310. * This is the base of the follow, arc rotate cameras and Free camera
  8311. * @see http://doc.babylonjs.com/features/cameras
  8312. */
  8313. export class TargetCamera extends Camera {
  8314. private static _RigCamTransformMatrix;
  8315. private static _TargetTransformMatrix;
  8316. private static _TargetFocalPoint;
  8317. /**
  8318. * Define the current direction the camera is moving to
  8319. */
  8320. cameraDirection: Vector3;
  8321. /**
  8322. * Define the current rotation the camera is rotating to
  8323. */
  8324. cameraRotation: Vector2;
  8325. /**
  8326. * When set, the up vector of the camera will be updated by the rotation of the camera
  8327. */
  8328. updateUpVectorFromRotation: boolean;
  8329. private _tmpQuaternion;
  8330. /**
  8331. * Define the current rotation of the camera
  8332. */
  8333. rotation: Vector3;
  8334. /**
  8335. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8336. */
  8337. rotationQuaternion: Quaternion;
  8338. /**
  8339. * Define the current speed of the camera
  8340. */
  8341. speed: number;
  8342. /**
  8343. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8344. * around all axis.
  8345. */
  8346. noRotationConstraint: boolean;
  8347. /**
  8348. * Define the current target of the camera as an object or a position.
  8349. */
  8350. lockedTarget: any;
  8351. /** @hidden */ private _currentTarget: Vector3;
  8352. /** @hidden */ private _initialFocalDistance: number;
  8353. /** @hidden */ private _viewMatrix: Matrix;
  8354. /** @hidden */ private _camMatrix: Matrix;
  8355. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8356. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8357. /** @hidden */ private _referencePoint: Vector3;
  8358. /** @hidden */ private _transformedReferencePoint: Vector3;
  8359. protected _globalCurrentTarget: Vector3;
  8360. protected _globalCurrentUpVector: Vector3;
  8361. /** @hidden */ private _reset: () => void;
  8362. private _defaultUp;
  8363. /**
  8364. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8365. * This is the base of the follow, arc rotate cameras and Free camera
  8366. * @see http://doc.babylonjs.com/features/cameras
  8367. * @param name Defines the name of the camera in the scene
  8368. * @param position Defines the start position of the camera in the scene
  8369. * @param scene Defines the scene the camera belongs to
  8370. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8371. */
  8372. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8373. /**
  8374. * Gets the position in front of the camera at a given distance.
  8375. * @param distance The distance from the camera we want the position to be
  8376. * @returns the position
  8377. */
  8378. getFrontPosition(distance: number): Vector3;
  8379. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8380. private _storedPosition;
  8381. private _storedRotation;
  8382. private _storedRotationQuaternion;
  8383. /**
  8384. * Store current camera state of the camera (fov, position, rotation, etc..)
  8385. * @returns the camera
  8386. */
  8387. storeState(): Camera;
  8388. /**
  8389. * Restored camera state. You must call storeState() first
  8390. * @returns whether it was successful or not
  8391. * @hidden
  8392. */ private _restoreStateValues(): boolean;
  8393. /** @hidden */ private _initCache(): void;
  8394. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8395. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8396. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8397. /**
  8398. * Defines the target the camera should look at.
  8399. * @param target Defines the new target as a Vector or a mesh
  8400. */
  8401. setTarget(target: Vector3): void;
  8402. /**
  8403. * Return the current target position of the camera. This value is expressed in local space.
  8404. * @returns the target position
  8405. */
  8406. getTarget(): Vector3;
  8407. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8408. /** @hidden */ private _updatePosition(): void;
  8409. /** @hidden */ private _checkInputs(): void;
  8410. protected _updateCameraRotationMatrix(): void;
  8411. /**
  8412. * 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)
  8413. * @returns the current camera
  8414. */
  8415. private _rotateUpVectorWithCameraRotationMatrix;
  8416. private _cachedRotationZ;
  8417. private _cachedQuaternionRotationZ;
  8418. /** @hidden */ private _getViewMatrix(): Matrix;
  8419. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8420. /**
  8421. * @hidden
  8422. */
  8423. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8424. /**
  8425. * @hidden
  8426. */ private _updateRigCameras(): void;
  8427. private _getRigCamPositionAndTarget;
  8428. /**
  8429. * Gets the current object class name.
  8430. * @return the class name
  8431. */
  8432. getClassName(): string;
  8433. }
  8434. }
  8435. declare module BABYLON {
  8436. /**
  8437. * Gather the list of keyboard event types as constants.
  8438. */
  8439. export class KeyboardEventTypes {
  8440. /**
  8441. * The keydown event is fired when a key becomes active (pressed).
  8442. */
  8443. static readonly KEYDOWN: number;
  8444. /**
  8445. * The keyup event is fired when a key has been released.
  8446. */
  8447. static readonly KEYUP: number;
  8448. }
  8449. /**
  8450. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8451. */
  8452. export class KeyboardInfo {
  8453. /**
  8454. * Defines the type of event (KeyboardEventTypes)
  8455. */
  8456. type: number;
  8457. /**
  8458. * Defines the related dom event
  8459. */
  8460. event: KeyboardEvent;
  8461. /**
  8462. * Instantiates a new keyboard info.
  8463. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8464. * @param type Defines the type of event (KeyboardEventTypes)
  8465. * @param event Defines the related dom event
  8466. */
  8467. constructor(
  8468. /**
  8469. * Defines the type of event (KeyboardEventTypes)
  8470. */
  8471. type: number,
  8472. /**
  8473. * Defines the related dom event
  8474. */
  8475. event: KeyboardEvent);
  8476. }
  8477. /**
  8478. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8479. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8480. */
  8481. export class KeyboardInfoPre extends KeyboardInfo {
  8482. /**
  8483. * Defines the type of event (KeyboardEventTypes)
  8484. */
  8485. type: number;
  8486. /**
  8487. * Defines the related dom event
  8488. */
  8489. event: KeyboardEvent;
  8490. /**
  8491. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8492. */
  8493. skipOnPointerObservable: boolean;
  8494. /**
  8495. * Instantiates a new keyboard pre info.
  8496. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8497. * @param type Defines the type of event (KeyboardEventTypes)
  8498. * @param event Defines the related dom event
  8499. */
  8500. constructor(
  8501. /**
  8502. * Defines the type of event (KeyboardEventTypes)
  8503. */
  8504. type: number,
  8505. /**
  8506. * Defines the related dom event
  8507. */
  8508. event: KeyboardEvent);
  8509. }
  8510. }
  8511. declare module BABYLON {
  8512. /**
  8513. * Manage the keyboard inputs to control the movement of a free camera.
  8514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8515. */
  8516. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8517. /**
  8518. * Defines the camera the input is attached to.
  8519. */
  8520. camera: FreeCamera;
  8521. /**
  8522. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8523. */
  8524. keysUp: number[];
  8525. /**
  8526. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8527. */
  8528. keysDown: number[];
  8529. /**
  8530. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8531. */
  8532. keysLeft: number[];
  8533. /**
  8534. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8535. */
  8536. keysRight: number[];
  8537. private _keys;
  8538. private _onCanvasBlurObserver;
  8539. private _onKeyboardObserver;
  8540. private _engine;
  8541. private _scene;
  8542. /**
  8543. * Attach the input controls to a specific dom element to get the input from.
  8544. * @param element Defines the element the controls should be listened from
  8545. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8546. */
  8547. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8548. /**
  8549. * Detach the current controls from the specified dom element.
  8550. * @param element Defines the element to stop listening the inputs from
  8551. */
  8552. detachControl(element: Nullable<HTMLElement>): void;
  8553. /**
  8554. * Update the current camera state depending on the inputs that have been used this frame.
  8555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8556. */
  8557. checkInputs(): void;
  8558. /**
  8559. * Gets the class name of the current intput.
  8560. * @returns the class name
  8561. */
  8562. getClassName(): string;
  8563. /** @hidden */ private _onLostFocus(): void;
  8564. /**
  8565. * Get the friendly name associated with the input class.
  8566. * @returns the input friendly name
  8567. */
  8568. getSimpleName(): string;
  8569. }
  8570. }
  8571. declare module BABYLON {
  8572. /**
  8573. * Interface describing all the common properties and methods a shadow light needs to implement.
  8574. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8575. * as well as binding the different shadow properties to the effects.
  8576. */
  8577. export interface IShadowLight extends Light {
  8578. /**
  8579. * The light id in the scene (used in scene.findLighById for instance)
  8580. */
  8581. id: string;
  8582. /**
  8583. * The position the shdow will be casted from.
  8584. */
  8585. position: Vector3;
  8586. /**
  8587. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8588. */
  8589. direction: Vector3;
  8590. /**
  8591. * The transformed position. Position of the light in world space taking parenting in account.
  8592. */
  8593. transformedPosition: Vector3;
  8594. /**
  8595. * The transformed direction. Direction of the light in world space taking parenting in account.
  8596. */
  8597. transformedDirection: Vector3;
  8598. /**
  8599. * The friendly name of the light in the scene.
  8600. */
  8601. name: string;
  8602. /**
  8603. * Defines the shadow projection clipping minimum z value.
  8604. */
  8605. shadowMinZ: number;
  8606. /**
  8607. * Defines the shadow projection clipping maximum z value.
  8608. */
  8609. shadowMaxZ: number;
  8610. /**
  8611. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8612. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8613. */
  8614. computeTransformedInformation(): boolean;
  8615. /**
  8616. * Gets the scene the light belongs to.
  8617. * @returns The scene
  8618. */
  8619. getScene(): Scene;
  8620. /**
  8621. * Callback defining a custom Projection Matrix Builder.
  8622. * This can be used to override the default projection matrix computation.
  8623. */
  8624. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8625. /**
  8626. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8627. * @param matrix The materix to updated with the projection information
  8628. * @param viewMatrix The transform matrix of the light
  8629. * @param renderList The list of mesh to render in the map
  8630. * @returns The current light
  8631. */
  8632. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8633. /**
  8634. * Gets the current depth scale used in ESM.
  8635. * @returns The scale
  8636. */
  8637. getDepthScale(): number;
  8638. /**
  8639. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8640. * @returns true if a cube texture needs to be use
  8641. */
  8642. needCube(): boolean;
  8643. /**
  8644. * Detects if the projection matrix requires to be recomputed this frame.
  8645. * @returns true if it requires to be recomputed otherwise, false.
  8646. */
  8647. needProjectionMatrixCompute(): boolean;
  8648. /**
  8649. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8650. */
  8651. forceProjectionMatrixCompute(): void;
  8652. /**
  8653. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8654. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8655. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8656. */
  8657. getShadowDirection(faceIndex?: number): Vector3;
  8658. /**
  8659. * Gets the minZ used for shadow according to both the scene and the light.
  8660. * @param activeCamera The camera we are returning the min for
  8661. * @returns the depth min z
  8662. */
  8663. getDepthMinZ(activeCamera: Camera): number;
  8664. /**
  8665. * Gets the maxZ used for shadow according to both the scene and the light.
  8666. * @param activeCamera The camera we are returning the max for
  8667. * @returns the depth max z
  8668. */
  8669. getDepthMaxZ(activeCamera: Camera): number;
  8670. }
  8671. /**
  8672. * Base implementation IShadowLight
  8673. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8674. */
  8675. export abstract class ShadowLight extends Light implements IShadowLight {
  8676. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8677. protected _position: Vector3;
  8678. protected _setPosition(value: Vector3): void;
  8679. /**
  8680. * Sets the position the shadow will be casted from. Also use as the light position for both
  8681. * point and spot lights.
  8682. */
  8683. /**
  8684. * Sets the position the shadow will be casted from. Also use as the light position for both
  8685. * point and spot lights.
  8686. */
  8687. position: Vector3;
  8688. protected _direction: Vector3;
  8689. protected _setDirection(value: Vector3): void;
  8690. /**
  8691. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8692. * Also use as the light direction on spot and directional lights.
  8693. */
  8694. /**
  8695. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8696. * Also use as the light direction on spot and directional lights.
  8697. */
  8698. direction: Vector3;
  8699. private _shadowMinZ;
  8700. /**
  8701. * Gets the shadow projection clipping minimum z value.
  8702. */
  8703. /**
  8704. * Sets the shadow projection clipping minimum z value.
  8705. */
  8706. shadowMinZ: number;
  8707. private _shadowMaxZ;
  8708. /**
  8709. * Sets the shadow projection clipping maximum z value.
  8710. */
  8711. /**
  8712. * Gets the shadow projection clipping maximum z value.
  8713. */
  8714. shadowMaxZ: number;
  8715. /**
  8716. * Callback defining a custom Projection Matrix Builder.
  8717. * This can be used to override the default projection matrix computation.
  8718. */
  8719. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8720. /**
  8721. * The transformed position. Position of the light in world space taking parenting in account.
  8722. */
  8723. transformedPosition: Vector3;
  8724. /**
  8725. * The transformed direction. Direction of the light in world space taking parenting in account.
  8726. */
  8727. transformedDirection: Vector3;
  8728. private _needProjectionMatrixCompute;
  8729. /**
  8730. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8731. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8732. */
  8733. computeTransformedInformation(): boolean;
  8734. /**
  8735. * Return the depth scale used for the shadow map.
  8736. * @returns the depth scale.
  8737. */
  8738. getDepthScale(): number;
  8739. /**
  8740. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8741. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8742. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8743. */
  8744. getShadowDirection(faceIndex?: number): Vector3;
  8745. /**
  8746. * Returns the ShadowLight absolute position in the World.
  8747. * @returns the position vector in world space
  8748. */
  8749. getAbsolutePosition(): Vector3;
  8750. /**
  8751. * Sets the ShadowLight direction toward the passed target.
  8752. * @param target The point to target in local space
  8753. * @returns the updated ShadowLight direction
  8754. */
  8755. setDirectionToTarget(target: Vector3): Vector3;
  8756. /**
  8757. * Returns the light rotation in euler definition.
  8758. * @returns the x y z rotation in local space.
  8759. */
  8760. getRotation(): Vector3;
  8761. /**
  8762. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8763. * @returns true if a cube texture needs to be use
  8764. */
  8765. needCube(): boolean;
  8766. /**
  8767. * Detects if the projection matrix requires to be recomputed this frame.
  8768. * @returns true if it requires to be recomputed otherwise, false.
  8769. */
  8770. needProjectionMatrixCompute(): boolean;
  8771. /**
  8772. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8773. */
  8774. forceProjectionMatrixCompute(): void;
  8775. /** @hidden */ private _initCache(): void;
  8776. /** @hidden */ private _isSynchronized(): boolean;
  8777. /**
  8778. * Computes the world matrix of the node
  8779. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8780. * @returns the world matrix
  8781. */
  8782. computeWorldMatrix(force?: boolean): Matrix;
  8783. /**
  8784. * Gets the minZ used for shadow according to both the scene and the light.
  8785. * @param activeCamera The camera we are returning the min for
  8786. * @returns the depth min z
  8787. */
  8788. getDepthMinZ(activeCamera: Camera): number;
  8789. /**
  8790. * Gets the maxZ used for shadow according to both the scene and the light.
  8791. * @param activeCamera The camera we are returning the max for
  8792. * @returns the depth max z
  8793. */
  8794. getDepthMaxZ(activeCamera: Camera): number;
  8795. /**
  8796. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8797. * @param matrix The materix to updated with the projection information
  8798. * @param viewMatrix The transform matrix of the light
  8799. * @param renderList The list of mesh to render in the map
  8800. * @returns The current light
  8801. */
  8802. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8803. }
  8804. }
  8805. declare module BABYLON {
  8806. /**
  8807. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8808. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8809. */
  8810. export class EffectFallbacks implements IEffectFallbacks {
  8811. private _defines;
  8812. private _currentRank;
  8813. private _maxRank;
  8814. private _mesh;
  8815. /**
  8816. * Removes the fallback from the bound mesh.
  8817. */
  8818. unBindMesh(): void;
  8819. /**
  8820. * Adds a fallback on the specified property.
  8821. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8822. * @param define The name of the define in the shader
  8823. */
  8824. addFallback(rank: number, define: string): void;
  8825. /**
  8826. * Sets the mesh to use CPU skinning when needing to fallback.
  8827. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8828. * @param mesh The mesh to use the fallbacks.
  8829. */
  8830. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8831. /**
  8832. * Checks to see if more fallbacks are still availible.
  8833. */
  8834. readonly hasMoreFallbacks: boolean;
  8835. /**
  8836. * Removes the defines that should be removed when falling back.
  8837. * @param currentDefines defines the current define statements for the shader.
  8838. * @param effect defines the current effect we try to compile
  8839. * @returns The resulting defines with defines of the current rank removed.
  8840. */
  8841. reduce(currentDefines: string, effect: Effect): string;
  8842. }
  8843. }
  8844. declare module BABYLON {
  8845. /**
  8846. * "Static Class" containing the most commonly used helper while dealing with material for
  8847. * rendering purpose.
  8848. *
  8849. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8850. *
  8851. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8852. */
  8853. export class MaterialHelper {
  8854. /**
  8855. * Bind the current view position to an effect.
  8856. * @param effect The effect to be bound
  8857. * @param scene The scene the eyes position is used from
  8858. */
  8859. static BindEyePosition(effect: Effect, scene: Scene): void;
  8860. /**
  8861. * Helps preparing the defines values about the UVs in used in the effect.
  8862. * UVs are shared as much as we can accross channels in the shaders.
  8863. * @param texture The texture we are preparing the UVs for
  8864. * @param defines The defines to update
  8865. * @param key The channel key "diffuse", "specular"... used in the shader
  8866. */
  8867. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8868. /**
  8869. * Binds a texture matrix value to its corrsponding uniform
  8870. * @param texture The texture to bind the matrix for
  8871. * @param uniformBuffer The uniform buffer receivin the data
  8872. * @param key The channel key "diffuse", "specular"... used in the shader
  8873. */
  8874. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8875. /**
  8876. * Gets the current status of the fog (should it be enabled?)
  8877. * @param mesh defines the mesh to evaluate for fog support
  8878. * @param scene defines the hosting scene
  8879. * @returns true if fog must be enabled
  8880. */
  8881. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8882. /**
  8883. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8884. * @param mesh defines the current mesh
  8885. * @param scene defines the current scene
  8886. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8887. * @param pointsCloud defines if point cloud rendering has to be turned on
  8888. * @param fogEnabled defines if fog has to be turned on
  8889. * @param alphaTest defines if alpha testing has to be turned on
  8890. * @param defines defines the current list of defines
  8891. */
  8892. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8893. /**
  8894. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8895. * @param scene defines the current scene
  8896. * @param engine defines the current engine
  8897. * @param defines specifies the list of active defines
  8898. * @param useInstances defines if instances have to be turned on
  8899. * @param useClipPlane defines if clip plane have to be turned on
  8900. */
  8901. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8902. /**
  8903. * Prepares the defines for bones
  8904. * @param mesh The mesh containing the geometry data we will draw
  8905. * @param defines The defines to update
  8906. */
  8907. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8908. /**
  8909. * Prepares the defines for morph targets
  8910. * @param mesh The mesh containing the geometry data we will draw
  8911. * @param defines The defines to update
  8912. */
  8913. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8914. /**
  8915. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8916. * @param mesh The mesh containing the geometry data we will draw
  8917. * @param defines The defines to update
  8918. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8919. * @param useBones Precise whether bones should be used or not (override mesh info)
  8920. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8921. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8922. * @returns false if defines are considered not dirty and have not been checked
  8923. */
  8924. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8925. /**
  8926. * Prepares the defines related to multiview
  8927. * @param scene The scene we are intending to draw
  8928. * @param defines The defines to update
  8929. */
  8930. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8931. /**
  8932. * Prepares the defines related to the light information passed in parameter
  8933. * @param scene The scene we are intending to draw
  8934. * @param mesh The mesh the effect is compiling for
  8935. * @param light The light the effect is compiling for
  8936. * @param lightIndex The index of the light
  8937. * @param defines The defines to update
  8938. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8939. * @param state Defines the current state regarding what is needed (normals, etc...)
  8940. */
  8941. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8942. needNormals: boolean;
  8943. needRebuild: boolean;
  8944. shadowEnabled: boolean;
  8945. specularEnabled: boolean;
  8946. lightmapMode: boolean;
  8947. }): void;
  8948. /**
  8949. * Prepares the defines related to the light information passed in parameter
  8950. * @param scene The scene we are intending to draw
  8951. * @param mesh The mesh the effect is compiling for
  8952. * @param defines The defines to update
  8953. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8954. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8955. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8956. * @returns true if normals will be required for the rest of the effect
  8957. */
  8958. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8959. /**
  8960. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8961. * @param lightIndex defines the light index
  8962. * @param uniformsList The uniform list
  8963. * @param samplersList The sampler list
  8964. * @param projectedLightTexture defines if projected texture must be used
  8965. * @param uniformBuffersList defines an optional list of uniform buffers
  8966. */
  8967. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8968. /**
  8969. * Prepares the uniforms and samplers list to be used in the effect
  8970. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8971. * @param samplersList The sampler list
  8972. * @param defines The defines helping in the list generation
  8973. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8974. */
  8975. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8976. /**
  8977. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8978. * @param defines The defines to update while falling back
  8979. * @param fallbacks The authorized effect fallbacks
  8980. * @param maxSimultaneousLights The maximum number of lights allowed
  8981. * @param rank the current rank of the Effect
  8982. * @returns The newly affected rank
  8983. */
  8984. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8985. private static _TmpMorphInfluencers;
  8986. /**
  8987. * Prepares the list of attributes required for morph targets according to the effect defines.
  8988. * @param attribs The current list of supported attribs
  8989. * @param mesh The mesh to prepare the morph targets attributes for
  8990. * @param influencers The number of influencers
  8991. */
  8992. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8993. /**
  8994. * Prepares the list of attributes required for morph targets according to the effect defines.
  8995. * @param attribs The current list of supported attribs
  8996. * @param mesh The mesh to prepare the morph targets attributes for
  8997. * @param defines The current Defines of the effect
  8998. */
  8999. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9000. /**
  9001. * Prepares the list of attributes required for bones according to the effect defines.
  9002. * @param attribs The current list of supported attribs
  9003. * @param mesh The mesh to prepare the bones attributes for
  9004. * @param defines The current Defines of the effect
  9005. * @param fallbacks The current efffect fallback strategy
  9006. */
  9007. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9008. /**
  9009. * Check and prepare the list of attributes required for instances according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param defines The current MaterialDefines of the effect
  9012. */
  9013. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9014. /**
  9015. * Add the list of attributes required for instances to the attribs array.
  9016. * @param attribs The current list of supported attribs
  9017. */
  9018. static PushAttributesForInstances(attribs: string[]): void;
  9019. /**
  9020. * Binds the light shadow information to the effect for the given mesh.
  9021. * @param light The light containing the generator
  9022. * @param scene The scene the lights belongs to
  9023. * @param mesh The mesh we are binding the information to render
  9024. * @param lightIndex The light index in the effect used to render the mesh
  9025. * @param effect The effect we are binding the data to
  9026. */
  9027. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9028. /**
  9029. * Binds the light information to the effect.
  9030. * @param light The light containing the generator
  9031. * @param effect The effect we are binding the data to
  9032. * @param lightIndex The light index in the effect used to render
  9033. */
  9034. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9035. /**
  9036. * Binds the lights information from the scene to the effect for the given mesh.
  9037. * @param light Light to bind
  9038. * @param lightIndex Light index
  9039. * @param scene The scene where the light belongs to
  9040. * @param mesh The mesh we are binding the information to render
  9041. * @param effect The effect we are binding the data to
  9042. * @param useSpecular Defines if specular is supported
  9043. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9044. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9045. */
  9046. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9047. /**
  9048. * Binds the lights information from the scene to the effect for the given mesh.
  9049. * @param scene The scene the lights belongs to
  9050. * @param mesh The mesh we are binding the information to render
  9051. * @param effect The effect we are binding the data to
  9052. * @param defines The generated defines for the effect
  9053. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9054. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9055. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9056. */
  9057. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9058. private static _tempFogColor;
  9059. /**
  9060. * Binds the fog information from the scene to the effect for the given mesh.
  9061. * @param scene The scene the lights belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param linearSpace Defines if the fog effect is applied in linear space
  9065. */
  9066. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9067. /**
  9068. * Binds the bones information from the mesh to the effect.
  9069. * @param mesh The mesh we are binding the information to render
  9070. * @param effect The effect we are binding the data to
  9071. */
  9072. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9073. /**
  9074. * Binds the morph targets information from the mesh to the effect.
  9075. * @param abstractMesh The mesh we are binding the information to render
  9076. * @param effect The effect we are binding the data to
  9077. */
  9078. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9079. /**
  9080. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9081. * @param defines The generated defines used in the effect
  9082. * @param effect The effect we are binding the data to
  9083. * @param scene The scene we are willing to render with logarithmic scale for
  9084. */
  9085. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9086. /**
  9087. * Binds the clip plane information from the scene to the effect.
  9088. * @param scene The scene the clip plane information are extracted from
  9089. * @param effect The effect we are binding the data to
  9090. */
  9091. static BindClipPlane(effect: Effect, scene: Scene): void;
  9092. }
  9093. }
  9094. declare module BABYLON {
  9095. /** @hidden */
  9096. export var packingFunctions: {
  9097. name: string;
  9098. shader: string;
  9099. };
  9100. }
  9101. declare module BABYLON {
  9102. /** @hidden */
  9103. export var shadowMapPixelShader: {
  9104. name: string;
  9105. shader: string;
  9106. };
  9107. }
  9108. declare module BABYLON {
  9109. /** @hidden */
  9110. export var bonesDeclaration: {
  9111. name: string;
  9112. shader: string;
  9113. };
  9114. }
  9115. declare module BABYLON {
  9116. /** @hidden */
  9117. export var morphTargetsVertexGlobalDeclaration: {
  9118. name: string;
  9119. shader: string;
  9120. };
  9121. }
  9122. declare module BABYLON {
  9123. /** @hidden */
  9124. export var morphTargetsVertexDeclaration: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module BABYLON {
  9130. /** @hidden */
  9131. export var instancesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module BABYLON {
  9137. /** @hidden */
  9138. export var helperFunctions: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module BABYLON {
  9144. /** @hidden */
  9145. export var morphTargetsVertex: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module BABYLON {
  9151. /** @hidden */
  9152. export var instancesVertex: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module BABYLON {
  9158. /** @hidden */
  9159. export var bonesVertex: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module BABYLON {
  9165. /** @hidden */
  9166. export var shadowMapVertexShader: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module BABYLON {
  9172. /** @hidden */
  9173. export var depthBoxBlurPixelShader: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module BABYLON {
  9179. /**
  9180. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9181. */
  9182. export interface ICustomShaderOptions {
  9183. /**
  9184. * Gets or sets the custom shader name to use
  9185. */
  9186. shaderName: string;
  9187. /**
  9188. * The list of attribute names used in the shader
  9189. */
  9190. attributes?: string[];
  9191. /**
  9192. * The list of unifrom names used in the shader
  9193. */
  9194. uniforms?: string[];
  9195. /**
  9196. * The list of sampler names used in the shader
  9197. */
  9198. samplers?: string[];
  9199. /**
  9200. * The list of defines used in the shader
  9201. */
  9202. defines?: string[];
  9203. }
  9204. /**
  9205. * Interface to implement to create a shadow generator compatible with BJS.
  9206. */
  9207. export interface IShadowGenerator {
  9208. /**
  9209. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9210. * @returns The render target texture if present otherwise, null
  9211. */
  9212. getShadowMap(): Nullable<RenderTargetTexture>;
  9213. /**
  9214. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9215. * @returns The render target texture if the shadow map is present otherwise, null
  9216. */
  9217. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9218. /**
  9219. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9220. * @param subMesh The submesh we want to render in the shadow map
  9221. * @param useInstances Defines wether will draw in the map using instances
  9222. * @returns true if ready otherwise, false
  9223. */
  9224. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9225. /**
  9226. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9227. * @param defines Defines of the material we want to update
  9228. * @param lightIndex Index of the light in the enabled light list of the material
  9229. */
  9230. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9231. /**
  9232. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9233. * defined in the generator but impacting the effect).
  9234. * It implies the unifroms available on the materials are the standard BJS ones.
  9235. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9236. * @param effect The effect we are binfing the information for
  9237. */
  9238. bindShadowLight(lightIndex: string, effect: Effect): void;
  9239. /**
  9240. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9241. * (eq to shadow prjection matrix * light transform matrix)
  9242. * @returns The transform matrix used to create the shadow map
  9243. */
  9244. getTransformMatrix(): Matrix;
  9245. /**
  9246. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9247. * Cube and 2D textures for instance.
  9248. */
  9249. recreateShadowMap(): void;
  9250. /**
  9251. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9252. * @param onCompiled Callback triggered at the and of the effects compilation
  9253. * @param options Sets of optional options forcing the compilation with different modes
  9254. */
  9255. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9256. useInstances: boolean;
  9257. }>): void;
  9258. /**
  9259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9260. * @param options Sets of optional options forcing the compilation with different modes
  9261. * @returns A promise that resolves when the compilation completes
  9262. */
  9263. forceCompilationAsync(options?: Partial<{
  9264. useInstances: boolean;
  9265. }>): Promise<void>;
  9266. /**
  9267. * Serializes the shadow generator setup to a json object.
  9268. * @returns The serialized JSON object
  9269. */
  9270. serialize(): any;
  9271. /**
  9272. * Disposes the Shadow map and related Textures and effects.
  9273. */
  9274. dispose(): void;
  9275. }
  9276. /**
  9277. * Default implementation IShadowGenerator.
  9278. * This is the main object responsible of generating shadows in the framework.
  9279. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9280. */
  9281. export class ShadowGenerator implements IShadowGenerator {
  9282. /**
  9283. * Shadow generator mode None: no filtering applied.
  9284. */
  9285. static readonly FILTER_NONE: number;
  9286. /**
  9287. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9288. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9289. */
  9290. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9291. /**
  9292. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9293. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9294. */
  9295. static readonly FILTER_POISSONSAMPLING: number;
  9296. /**
  9297. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9298. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9299. */
  9300. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9301. /**
  9302. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9303. * edge artifacts on steep falloff.
  9304. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9305. */
  9306. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9307. /**
  9308. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9309. * edge artifacts on steep falloff.
  9310. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9311. */
  9312. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9313. /**
  9314. * Shadow generator mode PCF: Percentage Closer Filtering
  9315. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9316. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9317. */
  9318. static readonly FILTER_PCF: number;
  9319. /**
  9320. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9321. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9322. * Contact Hardening
  9323. */
  9324. static readonly FILTER_PCSS: number;
  9325. /**
  9326. * Reserved for PCF and PCSS
  9327. * Highest Quality.
  9328. *
  9329. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9330. *
  9331. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9332. */
  9333. static readonly QUALITY_HIGH: number;
  9334. /**
  9335. * Reserved for PCF and PCSS
  9336. * Good tradeoff for quality/perf cross devices
  9337. *
  9338. * Execute PCF on a 3*3 kernel.
  9339. *
  9340. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9341. */
  9342. static readonly QUALITY_MEDIUM: number;
  9343. /**
  9344. * Reserved for PCF and PCSS
  9345. * The lowest quality but the fastest.
  9346. *
  9347. * Execute PCF on a 1*1 kernel.
  9348. *
  9349. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9350. */
  9351. static readonly QUALITY_LOW: number;
  9352. /** Gets or sets the custom shader name to use */
  9353. customShaderOptions: ICustomShaderOptions;
  9354. /**
  9355. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9356. */
  9357. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9358. /**
  9359. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9360. */
  9361. onAfterShadowMapRenderObservable: Observable<Effect>;
  9362. /**
  9363. * Observable triggered before a mesh is rendered in the shadow map.
  9364. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9365. */
  9366. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9367. /**
  9368. * Observable triggered after a mesh is rendered in the shadow map.
  9369. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9370. */
  9371. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9372. private _bias;
  9373. /**
  9374. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9375. */
  9376. /**
  9377. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9378. */
  9379. bias: number;
  9380. private _normalBias;
  9381. /**
  9382. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9383. */
  9384. /**
  9385. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9386. */
  9387. normalBias: number;
  9388. private _blurBoxOffset;
  9389. /**
  9390. * Gets the blur box offset: offset applied during the blur pass.
  9391. * Only useful if useKernelBlur = false
  9392. */
  9393. /**
  9394. * Sets the blur box offset: offset applied during the blur pass.
  9395. * Only useful if useKernelBlur = false
  9396. */
  9397. blurBoxOffset: number;
  9398. private _blurScale;
  9399. /**
  9400. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9401. * 2 means half of the size.
  9402. */
  9403. /**
  9404. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9405. * 2 means half of the size.
  9406. */
  9407. blurScale: number;
  9408. private _blurKernel;
  9409. /**
  9410. * Gets the blur kernel: kernel size of the blur pass.
  9411. * Only useful if useKernelBlur = true
  9412. */
  9413. /**
  9414. * Sets the blur kernel: kernel size of the blur pass.
  9415. * Only useful if useKernelBlur = true
  9416. */
  9417. blurKernel: number;
  9418. private _useKernelBlur;
  9419. /**
  9420. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9421. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9422. */
  9423. /**
  9424. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9425. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9426. */
  9427. useKernelBlur: boolean;
  9428. private _depthScale;
  9429. /**
  9430. * Gets the depth scale used in ESM mode.
  9431. */
  9432. /**
  9433. * Sets the depth scale used in ESM mode.
  9434. * This can override the scale stored on the light.
  9435. */
  9436. depthScale: number;
  9437. private _filter;
  9438. /**
  9439. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9440. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9441. */
  9442. /**
  9443. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9444. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9445. */
  9446. filter: number;
  9447. /**
  9448. * Gets if the current filter is set to Poisson Sampling.
  9449. */
  9450. /**
  9451. * Sets the current filter to Poisson Sampling.
  9452. */
  9453. usePoissonSampling: boolean;
  9454. /**
  9455. * Gets if the current filter is set to ESM.
  9456. */
  9457. /**
  9458. * Sets the current filter is to ESM.
  9459. */
  9460. useExponentialShadowMap: boolean;
  9461. /**
  9462. * Gets if the current filter is set to filtered ESM.
  9463. */
  9464. /**
  9465. * Gets if the current filter is set to filtered ESM.
  9466. */
  9467. useBlurExponentialShadowMap: boolean;
  9468. /**
  9469. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9470. * exponential to prevent steep falloff artifacts).
  9471. */
  9472. /**
  9473. * Sets the current filter to "close ESM" (using the inverse of the
  9474. * exponential to prevent steep falloff artifacts).
  9475. */
  9476. useCloseExponentialShadowMap: boolean;
  9477. /**
  9478. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9479. * exponential to prevent steep falloff artifacts).
  9480. */
  9481. /**
  9482. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9483. * exponential to prevent steep falloff artifacts).
  9484. */
  9485. useBlurCloseExponentialShadowMap: boolean;
  9486. /**
  9487. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9488. */
  9489. /**
  9490. * Sets the current filter to "PCF" (percentage closer filtering).
  9491. */
  9492. usePercentageCloserFiltering: boolean;
  9493. private _filteringQuality;
  9494. /**
  9495. * Gets the PCF or PCSS Quality.
  9496. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9497. */
  9498. /**
  9499. * Sets the PCF or PCSS Quality.
  9500. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9501. */
  9502. filteringQuality: number;
  9503. /**
  9504. * Gets if the current filter is set to "PCSS" (contact hardening).
  9505. */
  9506. /**
  9507. * Sets the current filter to "PCSS" (contact hardening).
  9508. */
  9509. useContactHardeningShadow: boolean;
  9510. private _contactHardeningLightSizeUVRatio;
  9511. /**
  9512. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9513. * Using a ratio helps keeping shape stability independently of the map size.
  9514. *
  9515. * It does not account for the light projection as it was having too much
  9516. * instability during the light setup or during light position changes.
  9517. *
  9518. * Only valid if useContactHardeningShadow is true.
  9519. */
  9520. /**
  9521. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9522. * Using a ratio helps keeping shape stability independently of the map size.
  9523. *
  9524. * It does not account for the light projection as it was having too much
  9525. * instability during the light setup or during light position changes.
  9526. *
  9527. * Only valid if useContactHardeningShadow is true.
  9528. */
  9529. contactHardeningLightSizeUVRatio: number;
  9530. private _darkness;
  9531. /** Gets or sets the actual darkness of a shadow */
  9532. darkness: number;
  9533. /**
  9534. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9535. * 0 means strongest and 1 would means no shadow.
  9536. * @returns the darkness.
  9537. */
  9538. getDarkness(): number;
  9539. /**
  9540. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9541. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9542. * @returns the shadow generator allowing fluent coding.
  9543. */
  9544. setDarkness(darkness: number): ShadowGenerator;
  9545. private _transparencyShadow;
  9546. /** Gets or sets the ability to have transparent shadow */
  9547. transparencyShadow: boolean;
  9548. /**
  9549. * Sets the ability to have transparent shadow (boolean).
  9550. * @param transparent True if transparent else False
  9551. * @returns the shadow generator allowing fluent coding
  9552. */
  9553. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9554. private _shadowMap;
  9555. private _shadowMap2;
  9556. /**
  9557. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9558. * @returns The render target texture if present otherwise, null
  9559. */
  9560. getShadowMap(): Nullable<RenderTargetTexture>;
  9561. /**
  9562. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9563. * @returns The render target texture if the shadow map is present otherwise, null
  9564. */
  9565. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9566. /**
  9567. * Gets the class name of that object
  9568. * @returns "ShadowGenerator"
  9569. */
  9570. getClassName(): string;
  9571. /**
  9572. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9573. * @param mesh Mesh to add
  9574. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9575. * @returns the Shadow Generator itself
  9576. */
  9577. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9578. /**
  9579. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9580. * @param mesh Mesh to remove
  9581. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9582. * @returns the Shadow Generator itself
  9583. */
  9584. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9585. /**
  9586. * Controls the extent to which the shadows fade out at the edge of the frustum
  9587. * Used only by directionals and spots
  9588. */
  9589. frustumEdgeFalloff: number;
  9590. private _light;
  9591. /**
  9592. * Returns the associated light object.
  9593. * @returns the light generating the shadow
  9594. */
  9595. getLight(): IShadowLight;
  9596. /**
  9597. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9598. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9599. * It might on the other hand introduce peter panning.
  9600. */
  9601. forceBackFacesOnly: boolean;
  9602. private _scene;
  9603. private _lightDirection;
  9604. private _effect;
  9605. private _viewMatrix;
  9606. private _projectionMatrix;
  9607. private _transformMatrix;
  9608. private _cachedPosition;
  9609. private _cachedDirection;
  9610. private _cachedDefines;
  9611. private _currentRenderID;
  9612. private _boxBlurPostprocess;
  9613. private _kernelBlurXPostprocess;
  9614. private _kernelBlurYPostprocess;
  9615. private _blurPostProcesses;
  9616. private _mapSize;
  9617. private _currentFaceIndex;
  9618. private _currentFaceIndexCache;
  9619. private _textureType;
  9620. private _defaultTextureMatrix;
  9621. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9622. /**
  9623. * Creates a ShadowGenerator object.
  9624. * A ShadowGenerator is the required tool to use the shadows.
  9625. * Each light casting shadows needs to use its own ShadowGenerator.
  9626. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9627. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9628. * @param light The light object generating the shadows.
  9629. * @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.
  9630. */
  9631. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9632. private _initializeGenerator;
  9633. private _initializeShadowMap;
  9634. private _initializeBlurRTTAndPostProcesses;
  9635. private _renderForShadowMap;
  9636. private _renderSubMeshForShadowMap;
  9637. private _applyFilterValues;
  9638. /**
  9639. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9640. * @param onCompiled Callback triggered at the and of the effects compilation
  9641. * @param options Sets of optional options forcing the compilation with different modes
  9642. */
  9643. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9644. useInstances: boolean;
  9645. }>): void;
  9646. /**
  9647. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9648. * @param options Sets of optional options forcing the compilation with different modes
  9649. * @returns A promise that resolves when the compilation completes
  9650. */
  9651. forceCompilationAsync(options?: Partial<{
  9652. useInstances: boolean;
  9653. }>): Promise<void>;
  9654. /**
  9655. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9656. * @param subMesh The submesh we want to render in the shadow map
  9657. * @param useInstances Defines wether will draw in the map using instances
  9658. * @returns true if ready otherwise, false
  9659. */
  9660. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9661. /**
  9662. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9663. * @param defines Defines of the material we want to update
  9664. * @param lightIndex Index of the light in the enabled light list of the material
  9665. */
  9666. prepareDefines(defines: any, lightIndex: number): void;
  9667. /**
  9668. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9669. * defined in the generator but impacting the effect).
  9670. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9671. * @param effect The effect we are binfing the information for
  9672. */
  9673. bindShadowLight(lightIndex: string, effect: Effect): void;
  9674. /**
  9675. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9676. * (eq to shadow prjection matrix * light transform matrix)
  9677. * @returns The transform matrix used to create the shadow map
  9678. */
  9679. getTransformMatrix(): Matrix;
  9680. /**
  9681. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9682. * Cube and 2D textures for instance.
  9683. */
  9684. recreateShadowMap(): void;
  9685. private _disposeBlurPostProcesses;
  9686. private _disposeRTTandPostProcesses;
  9687. /**
  9688. * Disposes the ShadowGenerator.
  9689. * Returns nothing.
  9690. */
  9691. dispose(): void;
  9692. /**
  9693. * Serializes the shadow generator setup to a json object.
  9694. * @returns The serialized JSON object
  9695. */
  9696. serialize(): any;
  9697. /**
  9698. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9699. * @param parsedShadowGenerator The JSON object to parse
  9700. * @param scene The scene to create the shadow map for
  9701. * @returns The parsed shadow generator
  9702. */
  9703. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9704. }
  9705. }
  9706. declare module BABYLON {
  9707. /**
  9708. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9709. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9710. * 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.
  9711. */
  9712. export abstract class Light extends Node {
  9713. /**
  9714. * Falloff Default: light is falling off following the material specification:
  9715. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9716. */
  9717. static readonly FALLOFF_DEFAULT: number;
  9718. /**
  9719. * Falloff Physical: light is falling off following the inverse squared distance law.
  9720. */
  9721. static readonly FALLOFF_PHYSICAL: number;
  9722. /**
  9723. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9724. * to enhance interoperability with other engines.
  9725. */
  9726. static readonly FALLOFF_GLTF: number;
  9727. /**
  9728. * Falloff Standard: light is falling off like in the standard material
  9729. * to enhance interoperability with other materials.
  9730. */
  9731. static readonly FALLOFF_STANDARD: number;
  9732. /**
  9733. * If every light affecting the material is in this lightmapMode,
  9734. * material.lightmapTexture adds or multiplies
  9735. * (depends on material.useLightmapAsShadowmap)
  9736. * after every other light calculations.
  9737. */
  9738. static readonly LIGHTMAP_DEFAULT: number;
  9739. /**
  9740. * material.lightmapTexture as only diffuse lighting from this light
  9741. * adds only specular lighting from this light
  9742. * adds dynamic shadows
  9743. */
  9744. static readonly LIGHTMAP_SPECULAR: number;
  9745. /**
  9746. * material.lightmapTexture as only lighting
  9747. * no light calculation from this light
  9748. * only adds dynamic shadows from this light
  9749. */
  9750. static readonly LIGHTMAP_SHADOWSONLY: number;
  9751. /**
  9752. * Each light type uses the default quantity according to its type:
  9753. * point/spot lights use luminous intensity
  9754. * directional lights use illuminance
  9755. */
  9756. static readonly INTENSITYMODE_AUTOMATIC: number;
  9757. /**
  9758. * lumen (lm)
  9759. */
  9760. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9761. /**
  9762. * candela (lm/sr)
  9763. */
  9764. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9765. /**
  9766. * lux (lm/m^2)
  9767. */
  9768. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9769. /**
  9770. * nit (cd/m^2)
  9771. */
  9772. static readonly INTENSITYMODE_LUMINANCE: number;
  9773. /**
  9774. * Light type const id of the point light.
  9775. */
  9776. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9777. /**
  9778. * Light type const id of the directional light.
  9779. */
  9780. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9781. /**
  9782. * Light type const id of the spot light.
  9783. */
  9784. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9785. /**
  9786. * Light type const id of the hemispheric light.
  9787. */
  9788. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9789. /**
  9790. * Diffuse gives the basic color to an object.
  9791. */
  9792. diffuse: Color3;
  9793. /**
  9794. * Specular produces a highlight color on an object.
  9795. * Note: This is note affecting PBR materials.
  9796. */
  9797. specular: Color3;
  9798. /**
  9799. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9800. * falling off base on range or angle.
  9801. * This can be set to any values in Light.FALLOFF_x.
  9802. *
  9803. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9804. * other types of materials.
  9805. */
  9806. falloffType: number;
  9807. /**
  9808. * Strength of the light.
  9809. * Note: By default it is define in the framework own unit.
  9810. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9811. */
  9812. intensity: number;
  9813. private _range;
  9814. protected _inverseSquaredRange: number;
  9815. /**
  9816. * Defines how far from the source the light is impacting in scene units.
  9817. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9818. */
  9819. /**
  9820. * Defines how far from the source the light is impacting in scene units.
  9821. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9822. */
  9823. range: number;
  9824. /**
  9825. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9826. * of light.
  9827. */
  9828. private _photometricScale;
  9829. private _intensityMode;
  9830. /**
  9831. * Gets the photometric scale used to interpret the intensity.
  9832. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9833. */
  9834. /**
  9835. * Sets the photometric scale used to interpret the intensity.
  9836. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9837. */
  9838. intensityMode: number;
  9839. private _radius;
  9840. /**
  9841. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9842. */
  9843. /**
  9844. * sets the light radius used by PBR Materials to simulate soft area lights.
  9845. */
  9846. radius: number;
  9847. private _renderPriority;
  9848. /**
  9849. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9850. * exceeding the number allowed of the materials.
  9851. */
  9852. renderPriority: number;
  9853. private _shadowEnabled;
  9854. /**
  9855. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9856. * the current shadow generator.
  9857. */
  9858. /**
  9859. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9860. * the current shadow generator.
  9861. */
  9862. shadowEnabled: boolean;
  9863. private _includedOnlyMeshes;
  9864. /**
  9865. * Gets the only meshes impacted by this light.
  9866. */
  9867. /**
  9868. * Sets the only meshes impacted by this light.
  9869. */
  9870. includedOnlyMeshes: AbstractMesh[];
  9871. private _excludedMeshes;
  9872. /**
  9873. * Gets the meshes not impacted by this light.
  9874. */
  9875. /**
  9876. * Sets the meshes not impacted by this light.
  9877. */
  9878. excludedMeshes: AbstractMesh[];
  9879. private _excludeWithLayerMask;
  9880. /**
  9881. * Gets the layer id use to find what meshes are not impacted by the light.
  9882. * Inactive if 0
  9883. */
  9884. /**
  9885. * Sets the layer id use to find what meshes are not impacted by the light.
  9886. * Inactive if 0
  9887. */
  9888. excludeWithLayerMask: number;
  9889. private _includeOnlyWithLayerMask;
  9890. /**
  9891. * Gets the layer id use to find what meshes are impacted by the light.
  9892. * Inactive if 0
  9893. */
  9894. /**
  9895. * Sets the layer id use to find what meshes are impacted by the light.
  9896. * Inactive if 0
  9897. */
  9898. includeOnlyWithLayerMask: number;
  9899. private _lightmapMode;
  9900. /**
  9901. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9902. */
  9903. /**
  9904. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9905. */
  9906. lightmapMode: number;
  9907. /**
  9908. * Shadow generator associted to the light.
  9909. * @hidden Internal use only.
  9910. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9911. /**
  9912. * @hidden Internal use only.
  9913. */ private _excludedMeshesIds: string[];
  9914. /**
  9915. * @hidden Internal use only.
  9916. */ private _includedOnlyMeshesIds: string[];
  9917. /**
  9918. * The current light unifom buffer.
  9919. * @hidden Internal use only.
  9920. */ private _uniformBuffer: UniformBuffer;
  9921. /**
  9922. * Creates a Light object in the scene.
  9923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9924. * @param name The firendly name of the light
  9925. * @param scene The scene the light belongs too
  9926. */
  9927. constructor(name: string, scene: Scene);
  9928. protected abstract _buildUniformLayout(): void;
  9929. /**
  9930. * Sets the passed Effect "effect" with the Light information.
  9931. * @param effect The effect to update
  9932. * @param lightIndex The index of the light in the effect to update
  9933. * @returns The light
  9934. */
  9935. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9936. /**
  9937. * Sets the passed Effect "effect" with the Light information.
  9938. * @param effect The effect to update
  9939. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9940. * @returns The light
  9941. */
  9942. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9943. /**
  9944. * Returns the string "Light".
  9945. * @returns the class name
  9946. */
  9947. getClassName(): string;
  9948. /** @hidden */ protected readonly _isLight: boolean;
  9949. /**
  9950. * Converts the light information to a readable string for debug purpose.
  9951. * @param fullDetails Supports for multiple levels of logging within scene loading
  9952. * @returns the human readable light info
  9953. */
  9954. toString(fullDetails?: boolean): string;
  9955. /** @hidden */
  9956. protected _syncParentEnabledState(): void;
  9957. /**
  9958. * Set the enabled state of this node.
  9959. * @param value - the new enabled state
  9960. */
  9961. setEnabled(value: boolean): void;
  9962. /**
  9963. * Returns the Light associated shadow generator if any.
  9964. * @return the associated shadow generator.
  9965. */
  9966. getShadowGenerator(): Nullable<IShadowGenerator>;
  9967. /**
  9968. * Returns a Vector3, the absolute light position in the World.
  9969. * @returns the world space position of the light
  9970. */
  9971. getAbsolutePosition(): Vector3;
  9972. /**
  9973. * Specifies if the light will affect the passed mesh.
  9974. * @param mesh The mesh to test against the light
  9975. * @return true the mesh is affected otherwise, false.
  9976. */
  9977. canAffectMesh(mesh: AbstractMesh): boolean;
  9978. /**
  9979. * Sort function to order lights for rendering.
  9980. * @param a First Light object to compare to second.
  9981. * @param b Second Light object to compare first.
  9982. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9983. */
  9984. static CompareLightsPriority(a: Light, b: Light): number;
  9985. /**
  9986. * Releases resources associated with this node.
  9987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9989. */
  9990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9991. /**
  9992. * Returns the light type ID (integer).
  9993. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9994. */
  9995. getTypeID(): number;
  9996. /**
  9997. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9998. * @returns the scaled intensity in intensity mode unit
  9999. */
  10000. getScaledIntensity(): number;
  10001. /**
  10002. * Returns a new Light object, named "name", from the current one.
  10003. * @param name The name of the cloned light
  10004. * @returns the new created light
  10005. */
  10006. clone(name: string): Nullable<Light>;
  10007. /**
  10008. * Serializes the current light into a Serialization object.
  10009. * @returns the serialized object.
  10010. */
  10011. serialize(): any;
  10012. /**
  10013. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10014. * This new light is named "name" and added to the passed scene.
  10015. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10016. * @param name The friendly name of the light
  10017. * @param scene The scene the new light will belong to
  10018. * @returns the constructor function
  10019. */
  10020. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10021. /**
  10022. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10023. * @param parsedLight The JSON representation of the light
  10024. * @param scene The scene to create the parsed light in
  10025. * @returns the created light after parsing
  10026. */
  10027. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10028. private _hookArrayForExcluded;
  10029. private _hookArrayForIncludedOnly;
  10030. private _resyncMeshes;
  10031. /**
  10032. * Forces the meshes to update their light related information in their rendering used effects
  10033. * @hidden Internal Use Only
  10034. */ private _markMeshesAsLightDirty(): void;
  10035. /**
  10036. * Recomputes the cached photometric scale if needed.
  10037. */
  10038. private _computePhotometricScale;
  10039. /**
  10040. * Returns the Photometric Scale according to the light type and intensity mode.
  10041. */
  10042. private _getPhotometricScale;
  10043. /**
  10044. * Reorder the light in the scene according to their defined priority.
  10045. * @hidden Internal Use Only
  10046. */ private _reorderLightsInScene(): void;
  10047. /**
  10048. * Prepares the list of defines specific to the light type.
  10049. * @param defines the list of defines
  10050. * @param lightIndex defines the index of the light for the effect
  10051. */
  10052. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10053. }
  10054. }
  10055. declare module BABYLON {
  10056. /**
  10057. * Interface used to define Action
  10058. */
  10059. export interface IAction {
  10060. /**
  10061. * Trigger for the action
  10062. */
  10063. trigger: number;
  10064. /** Options of the trigger */
  10065. triggerOptions: any;
  10066. /**
  10067. * Gets the trigger parameters
  10068. * @returns the trigger parameters
  10069. */
  10070. getTriggerParameter(): any;
  10071. /**
  10072. * Internal only - executes current action event
  10073. * @hidden
  10074. */ private _executeCurrent(evt?: ActionEvent): void;
  10075. /**
  10076. * Serialize placeholder for child classes
  10077. * @param parent of child
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */ private _prepare(): void;
  10085. /**
  10086. * Internal only - manager for action
  10087. * @hidden
  10088. */ private _actionManager: AbstractActionManager;
  10089. /**
  10090. * Adds action to chain of actions, may be a DoNothingAction
  10091. * @param action defines the next action to execute
  10092. * @returns The action passed in
  10093. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10094. */
  10095. then(action: IAction): IAction;
  10096. }
  10097. /**
  10098. * The action to be carried out following a trigger
  10099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10100. */
  10101. export class Action implements IAction {
  10102. /** the trigger, with or without parameters, for the action */
  10103. triggerOptions: any;
  10104. /**
  10105. * Trigger for the action
  10106. */
  10107. trigger: number;
  10108. /**
  10109. * Internal only - manager for action
  10110. * @hidden
  10111. */ private _actionManager: ActionManager;
  10112. private _nextActiveAction;
  10113. private _child;
  10114. private _condition?;
  10115. private _triggerParameter;
  10116. /**
  10117. * An event triggered prior to action being executed.
  10118. */
  10119. onBeforeExecuteObservable: Observable<Action>;
  10120. /**
  10121. * Creates a new Action
  10122. * @param triggerOptions the trigger, with or without parameters, for the action
  10123. * @param condition an optional determinant of action
  10124. */
  10125. constructor(
  10126. /** the trigger, with or without parameters, for the action */
  10127. triggerOptions: any, condition?: Condition);
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */ private _prepare(): void;
  10132. /**
  10133. * Gets the trigger parameters
  10134. * @returns the trigger parameters
  10135. */
  10136. getTriggerParameter(): any;
  10137. /**
  10138. * Internal only - executes current action event
  10139. * @hidden
  10140. */ private _executeCurrent(evt?: ActionEvent): void;
  10141. /**
  10142. * Execute placeholder for child classes
  10143. * @param evt optional action event
  10144. */
  10145. execute(evt?: ActionEvent): void;
  10146. /**
  10147. * Skips to next active action
  10148. */
  10149. skipToNextActiveAction(): void;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: Action): Action;
  10157. /**
  10158. * Internal only
  10159. * @hidden
  10160. */ private _getProperty(propertyPath: string): string;
  10161. /**
  10162. * Internal only
  10163. * @hidden
  10164. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10165. /**
  10166. * Serialize placeholder for child classes
  10167. * @param parent of child
  10168. * @returns the serialized object
  10169. */
  10170. serialize(parent: any): any;
  10171. /**
  10172. * Internal only called by serialize
  10173. * @hidden
  10174. */
  10175. protected _serialize(serializedAction: any, parent?: any): any;
  10176. /**
  10177. * Internal only
  10178. * @hidden
  10179. */ private static _SerializeValueAsString: (value: any) => string;
  10180. /**
  10181. * Internal only
  10182. * @hidden
  10183. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10184. name: string;
  10185. targetType: string;
  10186. value: string;
  10187. };
  10188. }
  10189. }
  10190. declare module BABYLON {
  10191. /**
  10192. * A Condition applied to an Action
  10193. */
  10194. export class Condition {
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */ private _actionManager: ActionManager;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */ private _evaluationId: number;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */ private _currentResult: boolean;
  10207. /**
  10208. * Creates a new Condition
  10209. * @param actionManager the manager of the action the condition is applied to
  10210. */
  10211. constructor(actionManager: ActionManager);
  10212. /**
  10213. * Check if the current condition is valid
  10214. * @returns a boolean
  10215. */
  10216. isValid(): boolean;
  10217. /**
  10218. * Internal only
  10219. * @hidden
  10220. */ private _getProperty(propertyPath: string): string;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10225. /**
  10226. * Serialize placeholder for child classes
  10227. * @returns the serialized object
  10228. */
  10229. serialize(): any;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. protected _serialize(serializedCondition: any): any;
  10235. }
  10236. /**
  10237. * Defines specific conditional operators as extensions of Condition
  10238. */
  10239. export class ValueCondition extends Condition {
  10240. /** path to specify the property of the target the conditional operator uses */
  10241. propertyPath: string;
  10242. /** the value compared by the conditional operator against the current value of the property */
  10243. value: any;
  10244. /** the conditional operator, default ValueCondition.IsEqual */
  10245. operator: number;
  10246. /**
  10247. * Internal only
  10248. * @hidden
  10249. */
  10250. private static _IsEqual;
  10251. /**
  10252. * Internal only
  10253. * @hidden
  10254. */
  10255. private static _IsDifferent;
  10256. /**
  10257. * Internal only
  10258. * @hidden
  10259. */
  10260. private static _IsGreater;
  10261. /**
  10262. * Internal only
  10263. * @hidden
  10264. */
  10265. private static _IsLesser;
  10266. /**
  10267. * returns the number for IsEqual
  10268. */
  10269. static readonly IsEqual: number;
  10270. /**
  10271. * Returns the number for IsDifferent
  10272. */
  10273. static readonly IsDifferent: number;
  10274. /**
  10275. * Returns the number for IsGreater
  10276. */
  10277. static readonly IsGreater: number;
  10278. /**
  10279. * Returns the number for IsLesser
  10280. */
  10281. static readonly IsLesser: number;
  10282. /**
  10283. * Internal only The action manager for the condition
  10284. * @hidden
  10285. */ private _actionManager: ActionManager;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. private _target;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. private _effectiveTarget;
  10296. /**
  10297. * Internal only
  10298. * @hidden
  10299. */
  10300. private _property;
  10301. /**
  10302. * Creates a new ValueCondition
  10303. * @param actionManager manager for the action the condition applies to
  10304. * @param target for the action
  10305. * @param propertyPath path to specify the property of the target the conditional operator uses
  10306. * @param value the value compared by the conditional operator against the current value of the property
  10307. * @param operator the conditional operator, default ValueCondition.IsEqual
  10308. */
  10309. constructor(actionManager: ActionManager, target: any,
  10310. /** path to specify the property of the target the conditional operator uses */
  10311. propertyPath: string,
  10312. /** the value compared by the conditional operator against the current value of the property */
  10313. value: any,
  10314. /** the conditional operator, default ValueCondition.IsEqual */
  10315. operator?: number);
  10316. /**
  10317. * Compares the given value with the property value for the specified conditional operator
  10318. * @returns the result of the comparison
  10319. */
  10320. isValid(): boolean;
  10321. /**
  10322. * Serialize the ValueCondition into a JSON compatible object
  10323. * @returns serialization object
  10324. */
  10325. serialize(): any;
  10326. /**
  10327. * Gets the name of the conditional operator for the ValueCondition
  10328. * @param operator the conditional operator
  10329. * @returns the name
  10330. */
  10331. static GetOperatorName(operator: number): string;
  10332. }
  10333. /**
  10334. * Defines a predicate condition as an extension of Condition
  10335. */
  10336. export class PredicateCondition extends Condition {
  10337. /** defines the predicate function used to validate the condition */
  10338. predicate: () => boolean;
  10339. /**
  10340. * Internal only - manager for action
  10341. * @hidden
  10342. */ private _actionManager: ActionManager;
  10343. /**
  10344. * Creates a new PredicateCondition
  10345. * @param actionManager manager for the action the condition applies to
  10346. * @param predicate defines the predicate function used to validate the condition
  10347. */
  10348. constructor(actionManager: ActionManager,
  10349. /** defines the predicate function used to validate the condition */
  10350. predicate: () => boolean);
  10351. /**
  10352. * @returns the validity of the predicate condition
  10353. */
  10354. isValid(): boolean;
  10355. }
  10356. /**
  10357. * Defines a state condition as an extension of Condition
  10358. */
  10359. export class StateCondition extends Condition {
  10360. /** Value to compare with target state */
  10361. value: string;
  10362. /**
  10363. * Internal only - manager for action
  10364. * @hidden
  10365. */ private _actionManager: ActionManager;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _target;
  10371. /**
  10372. * Creates a new StateCondition
  10373. * @param actionManager manager for the action the condition applies to
  10374. * @param target of the condition
  10375. * @param value to compare with target state
  10376. */
  10377. constructor(actionManager: ActionManager, target: any,
  10378. /** Value to compare with target state */
  10379. value: string);
  10380. /**
  10381. * Gets a boolean indicating if the current condition is met
  10382. * @returns the validity of the state
  10383. */
  10384. isValid(): boolean;
  10385. /**
  10386. * Serialize the StateCondition into a JSON compatible object
  10387. * @returns serialization object
  10388. */
  10389. serialize(): any;
  10390. }
  10391. }
  10392. declare module BABYLON {
  10393. /**
  10394. * This defines an action responsible to toggle a boolean once triggered.
  10395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10396. */
  10397. export class SwitchBooleanAction extends Action {
  10398. /**
  10399. * The path to the boolean property in the target object
  10400. */
  10401. propertyPath: string;
  10402. private _target;
  10403. private _effectiveTarget;
  10404. private _property;
  10405. /**
  10406. * Instantiate the action
  10407. * @param triggerOptions defines the trigger options
  10408. * @param target defines the object containing the boolean
  10409. * @param propertyPath defines the path to the boolean property in the target object
  10410. * @param condition defines the trigger related conditions
  10411. */
  10412. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10413. /** @hidden */ private _prepare(): void;
  10414. /**
  10415. * Execute the action toggle the boolean value.
  10416. */
  10417. execute(): void;
  10418. /**
  10419. * Serializes the actions and its related information.
  10420. * @param parent defines the object to serialize in
  10421. * @returns the serialized object
  10422. */
  10423. serialize(parent: any): any;
  10424. }
  10425. /**
  10426. * This defines an action responsible to set a the state field of the target
  10427. * to a desired value once triggered.
  10428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10429. */
  10430. export class SetStateAction extends Action {
  10431. /**
  10432. * The value to store in the state field.
  10433. */
  10434. value: string;
  10435. private _target;
  10436. /**
  10437. * Instantiate the action
  10438. * @param triggerOptions defines the trigger options
  10439. * @param target defines the object containing the state property
  10440. * @param value defines the value to store in the state field
  10441. * @param condition defines the trigger related conditions
  10442. */
  10443. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10444. /**
  10445. * Execute the action and store the value on the target state property.
  10446. */
  10447. execute(): void;
  10448. /**
  10449. * Serializes the actions and its related information.
  10450. * @param parent defines the object to serialize in
  10451. * @returns the serialized object
  10452. */
  10453. serialize(parent: any): any;
  10454. }
  10455. /**
  10456. * This defines an action responsible to set a property of the target
  10457. * to a desired value once triggered.
  10458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10459. */
  10460. export class SetValueAction extends Action {
  10461. /**
  10462. * The path of the property to set in the target.
  10463. */
  10464. propertyPath: string;
  10465. /**
  10466. * The value to set in the property
  10467. */
  10468. value: any;
  10469. private _target;
  10470. private _effectiveTarget;
  10471. private _property;
  10472. /**
  10473. * Instantiate the action
  10474. * @param triggerOptions defines the trigger options
  10475. * @param target defines the object containing the property
  10476. * @param propertyPath defines the path of the property to set in the target
  10477. * @param value defines the value to set in the property
  10478. * @param condition defines the trigger related conditions
  10479. */
  10480. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10481. /** @hidden */ private _prepare(): void;
  10482. /**
  10483. * Execute the action and set the targetted property to the desired value.
  10484. */
  10485. execute(): void;
  10486. /**
  10487. * Serializes the actions and its related information.
  10488. * @param parent defines the object to serialize in
  10489. * @returns the serialized object
  10490. */
  10491. serialize(parent: any): any;
  10492. }
  10493. /**
  10494. * This defines an action responsible to increment the target value
  10495. * to a desired value once triggered.
  10496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10497. */
  10498. export class IncrementValueAction extends Action {
  10499. /**
  10500. * The path of the property to increment in the target.
  10501. */
  10502. propertyPath: string;
  10503. /**
  10504. * The value we should increment the property by.
  10505. */
  10506. value: any;
  10507. private _target;
  10508. private _effectiveTarget;
  10509. private _property;
  10510. /**
  10511. * Instantiate the action
  10512. * @param triggerOptions defines the trigger options
  10513. * @param target defines the object containing the property
  10514. * @param propertyPath defines the path of the property to increment in the target
  10515. * @param value defines the value value we should increment the property by
  10516. * @param condition defines the trigger related conditions
  10517. */
  10518. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10519. /** @hidden */ private _prepare(): void;
  10520. /**
  10521. * Execute the action and increment the target of the value amount.
  10522. */
  10523. execute(): void;
  10524. /**
  10525. * Serializes the actions and its related information.
  10526. * @param parent defines the object to serialize in
  10527. * @returns the serialized object
  10528. */
  10529. serialize(parent: any): any;
  10530. }
  10531. /**
  10532. * This defines an action responsible to start an animation once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class PlayAnimationAction extends Action {
  10536. /**
  10537. * Where the animation should start (animation frame)
  10538. */
  10539. from: number;
  10540. /**
  10541. * Where the animation should stop (animation frame)
  10542. */
  10543. to: number;
  10544. /**
  10545. * Define if the animation should loop or stop after the first play.
  10546. */
  10547. loop?: boolean;
  10548. private _target;
  10549. /**
  10550. * Instantiate the action
  10551. * @param triggerOptions defines the trigger options
  10552. * @param target defines the target animation or animation name
  10553. * @param from defines from where the animation should start (animation frame)
  10554. * @param end defines where the animation should stop (animation frame)
  10555. * @param loop defines if the animation should loop or stop after the first play
  10556. * @param condition defines the trigger related conditions
  10557. */
  10558. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10559. /** @hidden */ private _prepare(): void;
  10560. /**
  10561. * Execute the action and play the animation.
  10562. */
  10563. execute(): void;
  10564. /**
  10565. * Serializes the actions and its related information.
  10566. * @param parent defines the object to serialize in
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. }
  10571. /**
  10572. * This defines an action responsible to stop an animation once triggered.
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10574. */
  10575. export class StopAnimationAction extends Action {
  10576. private _target;
  10577. /**
  10578. * Instantiate the action
  10579. * @param triggerOptions defines the trigger options
  10580. * @param target defines the target animation or animation name
  10581. * @param condition defines the trigger related conditions
  10582. */
  10583. constructor(triggerOptions: any, target: any, condition?: Condition);
  10584. /** @hidden */ private _prepare(): void;
  10585. /**
  10586. * Execute the action and stop the animation.
  10587. */
  10588. execute(): void;
  10589. /**
  10590. * Serializes the actions and its related information.
  10591. * @param parent defines the object to serialize in
  10592. * @returns the serialized object
  10593. */
  10594. serialize(parent: any): any;
  10595. }
  10596. /**
  10597. * This defines an action responsible that does nothing once triggered.
  10598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10599. */
  10600. export class DoNothingAction extends Action {
  10601. /**
  10602. * Instantiate the action
  10603. * @param triggerOptions defines the trigger options
  10604. * @param condition defines the trigger related conditions
  10605. */
  10606. constructor(triggerOptions?: any, condition?: Condition);
  10607. /**
  10608. * Execute the action and do nothing.
  10609. */
  10610. execute(): void;
  10611. /**
  10612. * Serializes the actions and its related information.
  10613. * @param parent defines the object to serialize in
  10614. * @returns the serialized object
  10615. */
  10616. serialize(parent: any): any;
  10617. }
  10618. /**
  10619. * This defines an action responsible to trigger several actions once triggered.
  10620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10621. */
  10622. export class CombineAction extends Action {
  10623. /**
  10624. * The list of aggregated animations to run.
  10625. */
  10626. children: Action[];
  10627. /**
  10628. * Instantiate the action
  10629. * @param triggerOptions defines the trigger options
  10630. * @param children defines the list of aggregated animations to run
  10631. * @param condition defines the trigger related conditions
  10632. */
  10633. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10634. /** @hidden */ private _prepare(): void;
  10635. /**
  10636. * Execute the action and executes all the aggregated actions.
  10637. */
  10638. execute(evt: ActionEvent): void;
  10639. /**
  10640. * Serializes the actions and its related information.
  10641. * @param parent defines the object to serialize in
  10642. * @returns the serialized object
  10643. */
  10644. serialize(parent: any): any;
  10645. }
  10646. /**
  10647. * This defines an action responsible to run code (external event) once triggered.
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10649. */
  10650. export class ExecuteCodeAction extends Action {
  10651. /**
  10652. * The callback function to run.
  10653. */
  10654. func: (evt: ActionEvent) => void;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param func defines the callback function to run
  10659. * @param condition defines the trigger related conditions
  10660. */
  10661. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10662. /**
  10663. * Execute the action and run the attached code.
  10664. */
  10665. execute(evt: ActionEvent): void;
  10666. }
  10667. /**
  10668. * This defines an action responsible to set the parent property of the target once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetParentAction extends Action {
  10672. private _parent;
  10673. private _target;
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param target defines the target containing the parent property
  10678. * @param parent defines from where the animation should start (animation frame)
  10679. * @param condition defines the trigger related conditions
  10680. */
  10681. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10682. /** @hidden */ private _prepare(): void;
  10683. /**
  10684. * Execute the action and set the parent property.
  10685. */
  10686. execute(): void;
  10687. /**
  10688. * Serializes the actions and its related information.
  10689. * @param parent defines the object to serialize in
  10690. * @returns the serialized object
  10691. */
  10692. serialize(parent: any): any;
  10693. }
  10694. }
  10695. declare module BABYLON {
  10696. /**
  10697. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10698. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10700. */
  10701. export class ActionManager extends AbstractActionManager {
  10702. /**
  10703. * Nothing
  10704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10705. */
  10706. static readonly NothingTrigger: number;
  10707. /**
  10708. * On pick
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10710. */
  10711. static readonly OnPickTrigger: number;
  10712. /**
  10713. * On left pick
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10715. */
  10716. static readonly OnLeftPickTrigger: number;
  10717. /**
  10718. * On right pick
  10719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10720. */
  10721. static readonly OnRightPickTrigger: number;
  10722. /**
  10723. * On center pick
  10724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10725. */
  10726. static readonly OnCenterPickTrigger: number;
  10727. /**
  10728. * On pick down
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10730. */
  10731. static readonly OnPickDownTrigger: number;
  10732. /**
  10733. * On double pick
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10735. */
  10736. static readonly OnDoublePickTrigger: number;
  10737. /**
  10738. * On pick up
  10739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10740. */
  10741. static readonly OnPickUpTrigger: number;
  10742. /**
  10743. * On pick out.
  10744. * This trigger will only be raised if you also declared a OnPickDown
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnPickOutTrigger: number;
  10748. /**
  10749. * On long press
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnLongPressTrigger: number;
  10753. /**
  10754. * On pointer over
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnPointerOverTrigger: number;
  10758. /**
  10759. * On pointer out
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnPointerOutTrigger: number;
  10763. /**
  10764. * On every frame
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnEveryFrameTrigger: number;
  10768. /**
  10769. * On intersection enter
  10770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10771. */
  10772. static readonly OnIntersectionEnterTrigger: number;
  10773. /**
  10774. * On intersection exit
  10775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10776. */
  10777. static readonly OnIntersectionExitTrigger: number;
  10778. /**
  10779. * On key down
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10781. */
  10782. static readonly OnKeyDownTrigger: number;
  10783. /**
  10784. * On key up
  10785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10786. */
  10787. static readonly OnKeyUpTrigger: number;
  10788. private _scene;
  10789. /**
  10790. * Creates a new action manager
  10791. * @param scene defines the hosting scene
  10792. */
  10793. constructor(scene: Scene);
  10794. /**
  10795. * Releases all associated resources
  10796. */
  10797. dispose(): void;
  10798. /**
  10799. * Gets hosting scene
  10800. * @returns the hosting scene
  10801. */
  10802. getScene(): Scene;
  10803. /**
  10804. * Does this action manager handles actions of any of the given triggers
  10805. * @param triggers defines the triggers to be tested
  10806. * @return a boolean indicating whether one (or more) of the triggers is handled
  10807. */
  10808. hasSpecificTriggers(triggers: number[]): boolean;
  10809. /**
  10810. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10811. * speed.
  10812. * @param triggerA defines the trigger to be tested
  10813. * @param triggerB defines the trigger to be tested
  10814. * @return a boolean indicating whether one (or more) of the triggers is handled
  10815. */
  10816. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10817. /**
  10818. * Does this action manager handles actions of a given trigger
  10819. * @param trigger defines the trigger to be tested
  10820. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10821. * @return whether the trigger is handled
  10822. */
  10823. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10824. /**
  10825. * Does this action manager has pointer triggers
  10826. */
  10827. readonly hasPointerTriggers: boolean;
  10828. /**
  10829. * Does this action manager has pick triggers
  10830. */
  10831. readonly hasPickTriggers: boolean;
  10832. /**
  10833. * Registers an action to this action manager
  10834. * @param action defines the action to be registered
  10835. * @return the action amended (prepared) after registration
  10836. */
  10837. registerAction(action: IAction): Nullable<IAction>;
  10838. /**
  10839. * Unregisters an action to this action manager
  10840. * @param action defines the action to be unregistered
  10841. * @return a boolean indicating whether the action has been unregistered
  10842. */
  10843. unregisterAction(action: IAction): Boolean;
  10844. /**
  10845. * Process a specific trigger
  10846. * @param trigger defines the trigger to process
  10847. * @param evt defines the event details to be processed
  10848. */
  10849. processTrigger(trigger: number, evt?: IActionEvent): void;
  10850. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10851. /** @hidden */ private _getProperty(propertyPath: string): string;
  10852. /**
  10853. * Serialize this manager to a JSON object
  10854. * @param name defines the property name to store this manager
  10855. * @returns a JSON representation of this manager
  10856. */
  10857. serialize(name: string): any;
  10858. /**
  10859. * Creates a new ActionManager from a JSON data
  10860. * @param parsedActions defines the JSON data to read from
  10861. * @param object defines the hosting mesh
  10862. * @param scene defines the hosting scene
  10863. */
  10864. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10865. /**
  10866. * Get a trigger name by index
  10867. * @param trigger defines the trigger index
  10868. * @returns a trigger name
  10869. */
  10870. static GetTriggerName(trigger: number): string;
  10871. }
  10872. }
  10873. declare module BABYLON {
  10874. /**
  10875. * Class representing a ray with position and direction
  10876. */
  10877. export class Ray {
  10878. /** origin point */
  10879. origin: Vector3;
  10880. /** direction */
  10881. direction: Vector3;
  10882. /** length of the ray */
  10883. length: number;
  10884. private static readonly TmpVector3;
  10885. private _tmpRay;
  10886. /**
  10887. * Creates a new ray
  10888. * @param origin origin point
  10889. * @param direction direction
  10890. * @param length length of the ray
  10891. */
  10892. constructor(
  10893. /** origin point */
  10894. origin: Vector3,
  10895. /** direction */
  10896. direction: Vector3,
  10897. /** length of the ray */
  10898. length?: number);
  10899. /**
  10900. * Checks if the ray intersects a box
  10901. * @param minimum bound of the box
  10902. * @param maximum bound of the box
  10903. * @param intersectionTreshold extra extend to be added to the box in all direction
  10904. * @returns if the box was hit
  10905. */
  10906. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10907. /**
  10908. * Checks if the ray intersects a box
  10909. * @param box the bounding box to check
  10910. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10911. * @returns if the box was hit
  10912. */
  10913. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10914. /**
  10915. * If the ray hits a sphere
  10916. * @param sphere the bounding sphere to check
  10917. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10918. * @returns true if it hits the sphere
  10919. */
  10920. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10921. /**
  10922. * If the ray hits a triange
  10923. * @param vertex0 triangle vertex
  10924. * @param vertex1 triangle vertex
  10925. * @param vertex2 triangle vertex
  10926. * @returns intersection information if hit
  10927. */
  10928. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10929. /**
  10930. * Checks if ray intersects a plane
  10931. * @param plane the plane to check
  10932. * @returns the distance away it was hit
  10933. */
  10934. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10935. /**
  10936. * Calculate the intercept of a ray on a given axis
  10937. * @param axis to check 'x' | 'y' | 'z'
  10938. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10939. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10940. */
  10941. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10942. /**
  10943. * Checks if ray intersects a mesh
  10944. * @param mesh the mesh to check
  10945. * @param fastCheck if only the bounding box should checked
  10946. * @returns picking info of the intersecton
  10947. */
  10948. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10949. /**
  10950. * Checks if ray intersects a mesh
  10951. * @param meshes the meshes to check
  10952. * @param fastCheck if only the bounding box should checked
  10953. * @param results array to store result in
  10954. * @returns Array of picking infos
  10955. */
  10956. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10957. private _comparePickingInfo;
  10958. private static smallnum;
  10959. private static rayl;
  10960. /**
  10961. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10962. * @param sega the first point of the segment to test the intersection against
  10963. * @param segb the second point of the segment to test the intersection against
  10964. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10965. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10966. */
  10967. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10968. /**
  10969. * Update the ray from viewport position
  10970. * @param x position
  10971. * @param y y position
  10972. * @param viewportWidth viewport width
  10973. * @param viewportHeight viewport height
  10974. * @param world world matrix
  10975. * @param view view matrix
  10976. * @param projection projection matrix
  10977. * @returns this ray updated
  10978. */
  10979. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10980. /**
  10981. * Creates a ray with origin and direction of 0,0,0
  10982. * @returns the new ray
  10983. */
  10984. static Zero(): Ray;
  10985. /**
  10986. * Creates a new ray from screen space and viewport
  10987. * @param x position
  10988. * @param y y position
  10989. * @param viewportWidth viewport width
  10990. * @param viewportHeight viewport height
  10991. * @param world world matrix
  10992. * @param view view matrix
  10993. * @param projection projection matrix
  10994. * @returns new ray
  10995. */
  10996. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10997. /**
  10998. * 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
  10999. * transformed to the given world matrix.
  11000. * @param origin The origin point
  11001. * @param end The end point
  11002. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11003. * @returns the new ray
  11004. */
  11005. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11006. /**
  11007. * Transforms a ray by a matrix
  11008. * @param ray ray to transform
  11009. * @param matrix matrix to apply
  11010. * @returns the resulting new ray
  11011. */
  11012. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11013. /**
  11014. * Transforms a ray by a matrix
  11015. * @param ray ray to transform
  11016. * @param matrix matrix to apply
  11017. * @param result ray to store result in
  11018. */
  11019. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11020. /**
  11021. * Unproject a ray from screen space to object space
  11022. * @param sourceX defines the screen space x coordinate to use
  11023. * @param sourceY defines the screen space y coordinate to use
  11024. * @param viewportWidth defines the current width of the viewport
  11025. * @param viewportHeight defines the current height of the viewport
  11026. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11027. * @param view defines the view matrix to use
  11028. * @param projection defines the projection matrix to use
  11029. */
  11030. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11031. }
  11032. /**
  11033. * Type used to define predicate used to select faces when a mesh intersection is detected
  11034. */
  11035. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11036. interface Scene {
  11037. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  11038. /** @hidden */ private _cachedRayForTransform: Ray;
  11039. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  11040. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11041. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11042. }
  11043. }
  11044. declare module BABYLON {
  11045. /**
  11046. * Groups all the scene component constants in one place to ease maintenance.
  11047. * @hidden
  11048. */
  11049. export class SceneComponentConstants {
  11050. static readonly NAME_EFFECTLAYER: string;
  11051. static readonly NAME_LAYER: string;
  11052. static readonly NAME_LENSFLARESYSTEM: string;
  11053. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11054. static readonly NAME_PARTICLESYSTEM: string;
  11055. static readonly NAME_GAMEPAD: string;
  11056. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11057. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11058. static readonly NAME_DEPTHRENDERER: string;
  11059. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11060. static readonly NAME_SPRITE: string;
  11061. static readonly NAME_OUTLINERENDERER: string;
  11062. static readonly NAME_PROCEDURALTEXTURE: string;
  11063. static readonly NAME_SHADOWGENERATOR: string;
  11064. static readonly NAME_OCTREE: string;
  11065. static readonly NAME_PHYSICSENGINE: string;
  11066. static readonly NAME_AUDIO: string;
  11067. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11068. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11069. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11070. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11071. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11072. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11073. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11074. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11075. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11076. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11077. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11078. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11079. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11080. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11081. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11082. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11083. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11084. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11085. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11086. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11087. static readonly STEP_AFTERRENDER_AUDIO: number;
  11088. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11089. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11090. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11091. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11092. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11093. static readonly STEP_POINTERMOVE_SPRITE: number;
  11094. static readonly STEP_POINTERDOWN_SPRITE: number;
  11095. static readonly STEP_POINTERUP_SPRITE: number;
  11096. }
  11097. /**
  11098. * This represents a scene component.
  11099. *
  11100. * This is used to decouple the dependency the scene is having on the different workloads like
  11101. * layers, post processes...
  11102. */
  11103. export interface ISceneComponent {
  11104. /**
  11105. * The name of the component. Each component must have a unique name.
  11106. */
  11107. name: string;
  11108. /**
  11109. * The scene the component belongs to.
  11110. */
  11111. scene: Scene;
  11112. /**
  11113. * Register the component to one instance of a scene.
  11114. */
  11115. register(): void;
  11116. /**
  11117. * Rebuilds the elements related to this component in case of
  11118. * context lost for instance.
  11119. */
  11120. rebuild(): void;
  11121. /**
  11122. * Disposes the component and the associated ressources.
  11123. */
  11124. dispose(): void;
  11125. }
  11126. /**
  11127. * This represents a SERIALIZABLE scene component.
  11128. *
  11129. * This extends Scene Component to add Serialization methods on top.
  11130. */
  11131. export interface ISceneSerializableComponent extends ISceneComponent {
  11132. /**
  11133. * Adds all the elements from the container to the scene
  11134. * @param container the container holding the elements
  11135. */
  11136. addFromContainer(container: AbstractScene): void;
  11137. /**
  11138. * Removes all the elements in the container from the scene
  11139. * @param container contains the elements to remove
  11140. * @param dispose if the removed element should be disposed (default: false)
  11141. */
  11142. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11143. /**
  11144. * Serializes the component data to the specified json object
  11145. * @param serializationObject The object to serialize to
  11146. */
  11147. serialize(serializationObject: any): void;
  11148. }
  11149. /**
  11150. * Strong typing of a Mesh related stage step action
  11151. */
  11152. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11153. /**
  11154. * Strong typing of a Evaluate Sub Mesh related stage step action
  11155. */
  11156. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11157. /**
  11158. * Strong typing of a Active Mesh related stage step action
  11159. */
  11160. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11161. /**
  11162. * Strong typing of a Camera related stage step action
  11163. */
  11164. export type CameraStageAction = (camera: Camera) => void;
  11165. /**
  11166. * Strong typing of a Camera Frame buffer related stage step action
  11167. */
  11168. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11169. /**
  11170. * Strong typing of a Render Target related stage step action
  11171. */
  11172. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11173. /**
  11174. * Strong typing of a RenderingGroup related stage step action
  11175. */
  11176. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11177. /**
  11178. * Strong typing of a Mesh Render related stage step action
  11179. */
  11180. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11181. /**
  11182. * Strong typing of a simple stage step action
  11183. */
  11184. export type SimpleStageAction = () => void;
  11185. /**
  11186. * Strong typing of a render target action.
  11187. */
  11188. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11189. /**
  11190. * Strong typing of a pointer move action.
  11191. */
  11192. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11193. /**
  11194. * Strong typing of a pointer up/down action.
  11195. */
  11196. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11197. /**
  11198. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11199. * @hidden
  11200. */
  11201. export class Stage<T extends Function> extends Array<{
  11202. index: number;
  11203. component: ISceneComponent;
  11204. action: T;
  11205. }> {
  11206. /**
  11207. * Hide ctor from the rest of the world.
  11208. * @param items The items to add.
  11209. */
  11210. private constructor();
  11211. /**
  11212. * Creates a new Stage.
  11213. * @returns A new instance of a Stage
  11214. */
  11215. static Create<T extends Function>(): Stage<T>;
  11216. /**
  11217. * Registers a step in an ordered way in the targeted stage.
  11218. * @param index Defines the position to register the step in
  11219. * @param component Defines the component attached to the step
  11220. * @param action Defines the action to launch during the step
  11221. */
  11222. registerStep(index: number, component: ISceneComponent, action: T): void;
  11223. /**
  11224. * Clears all the steps from the stage.
  11225. */
  11226. clear(): void;
  11227. }
  11228. }
  11229. declare module BABYLON {
  11230. interface Scene {
  11231. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11232. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11233. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11234. /**
  11235. * All of the sprite managers added to this scene
  11236. * @see http://doc.babylonjs.com/babylon101/sprites
  11237. */
  11238. spriteManagers: Array<ISpriteManager>;
  11239. /**
  11240. * An event triggered when sprites rendering is about to start
  11241. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11242. */
  11243. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11244. /**
  11245. * An event triggered when sprites rendering is done
  11246. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11247. */
  11248. onAfterSpritesRenderingObservable: Observable<Scene>;
  11249. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11250. /** Launch a ray to try to pick a sprite in the scene
  11251. * @param x position on screen
  11252. * @param y position on screen
  11253. * @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
  11254. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11255. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11256. * @returns a PickingInfo
  11257. */
  11258. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11259. /** Use the given ray to pick a sprite in the scene
  11260. * @param ray The ray (in world space) to use to pick meshes
  11261. * @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
  11262. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11263. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11264. * @returns a PickingInfo
  11265. */
  11266. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11267. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11268. /** Launch a ray to try to pick sprites in the scene
  11269. * @param x position on screen
  11270. * @param y position on screen
  11271. * @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
  11272. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11273. * @returns a PickingInfo array
  11274. */
  11275. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11276. /** Use the given ray to pick sprites in the scene
  11277. * @param ray The ray (in world space) to use to pick meshes
  11278. * @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
  11279. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11280. * @returns a PickingInfo array
  11281. */
  11282. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11283. /**
  11284. * Force the sprite under the pointer
  11285. * @param sprite defines the sprite to use
  11286. */
  11287. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11288. /**
  11289. * Gets the sprite under the pointer
  11290. * @returns a Sprite or null if no sprite is under the pointer
  11291. */
  11292. getPointerOverSprite(): Nullable<Sprite>;
  11293. }
  11294. /**
  11295. * Defines the sprite scene component responsible to manage sprites
  11296. * in a given scene.
  11297. */
  11298. export class SpriteSceneComponent implements ISceneComponent {
  11299. /**
  11300. * The component name helpfull to identify the component in the list of scene components.
  11301. */
  11302. readonly name: string;
  11303. /**
  11304. * The scene the component belongs to.
  11305. */
  11306. scene: Scene;
  11307. /** @hidden */
  11308. private _spritePredicate;
  11309. /**
  11310. * Creates a new instance of the component for the given scene
  11311. * @param scene Defines the scene to register the component in
  11312. */
  11313. constructor(scene: Scene);
  11314. /**
  11315. * Registers the component in a given scene
  11316. */
  11317. register(): void;
  11318. /**
  11319. * Rebuilds the elements related to this component in case of
  11320. * context lost for instance.
  11321. */
  11322. rebuild(): void;
  11323. /**
  11324. * Disposes the component and the associated ressources.
  11325. */
  11326. dispose(): void;
  11327. private _pickSpriteButKeepRay;
  11328. private _pointerMove;
  11329. private _pointerDown;
  11330. private _pointerUp;
  11331. }
  11332. }
  11333. declare module BABYLON {
  11334. /** @hidden */
  11335. export var fogFragmentDeclaration: {
  11336. name: string;
  11337. shader: string;
  11338. };
  11339. }
  11340. declare module BABYLON {
  11341. /** @hidden */
  11342. export var fogFragment: {
  11343. name: string;
  11344. shader: string;
  11345. };
  11346. }
  11347. declare module BABYLON {
  11348. /** @hidden */
  11349. export var spritesPixelShader: {
  11350. name: string;
  11351. shader: string;
  11352. };
  11353. }
  11354. declare module BABYLON {
  11355. /** @hidden */
  11356. export var fogVertexDeclaration: {
  11357. name: string;
  11358. shader: string;
  11359. };
  11360. }
  11361. declare module BABYLON {
  11362. /** @hidden */
  11363. export var spritesVertexShader: {
  11364. name: string;
  11365. shader: string;
  11366. };
  11367. }
  11368. declare module BABYLON {
  11369. /**
  11370. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11371. */
  11372. export interface ISpriteManager extends IDisposable {
  11373. /**
  11374. * Restricts the camera to viewing objects with the same layerMask.
  11375. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11376. */
  11377. layerMask: number;
  11378. /**
  11379. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11380. */
  11381. isPickable: boolean;
  11382. /**
  11383. * Specifies the rendering group id for this mesh (0 by default)
  11384. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11385. */
  11386. renderingGroupId: number;
  11387. /**
  11388. * Defines the list of sprites managed by the manager.
  11389. */
  11390. sprites: Array<Sprite>;
  11391. /**
  11392. * Tests the intersection of a sprite with a specific ray.
  11393. * @param ray The ray we are sending to test the collision
  11394. * @param camera The camera space we are sending rays in
  11395. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11396. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11397. * @returns picking info or null.
  11398. */
  11399. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11400. /**
  11401. * Intersects the sprites with a ray
  11402. * @param ray defines the ray to intersect with
  11403. * @param camera defines the current active camera
  11404. * @param predicate defines a predicate used to select candidate sprites
  11405. * @returns null if no hit or a PickingInfo array
  11406. */
  11407. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11408. /**
  11409. * Renders the list of sprites on screen.
  11410. */
  11411. render(): void;
  11412. }
  11413. /**
  11414. * Class used to manage multiple sprites on the same spritesheet
  11415. * @see http://doc.babylonjs.com/babylon101/sprites
  11416. */
  11417. export class SpriteManager implements ISpriteManager {
  11418. /** defines the manager's name */
  11419. name: string;
  11420. /** Gets the list of sprites */
  11421. sprites: Sprite[];
  11422. /** Gets or sets the rendering group id (0 by default) */
  11423. renderingGroupId: number;
  11424. /** Gets or sets camera layer mask */
  11425. layerMask: number;
  11426. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11427. fogEnabled: boolean;
  11428. /** Gets or sets a boolean indicating if the sprites are pickable */
  11429. isPickable: boolean;
  11430. /** Defines the default width of a cell in the spritesheet */
  11431. cellWidth: number;
  11432. /** Defines the default height of a cell in the spritesheet */
  11433. cellHeight: number;
  11434. /** Associative array from JSON sprite data file */
  11435. private _cellData;
  11436. /** Array of sprite names from JSON sprite data file */
  11437. private _spriteMap;
  11438. /** True when packed cell data from JSON file is ready*/
  11439. private _packedAndReady;
  11440. /**
  11441. * An event triggered when the manager is disposed.
  11442. */
  11443. onDisposeObservable: Observable<SpriteManager>;
  11444. private _onDisposeObserver;
  11445. /**
  11446. * Callback called when the manager is disposed
  11447. */
  11448. onDispose: () => void;
  11449. private _capacity;
  11450. private _fromPacked;
  11451. private _spriteTexture;
  11452. private _epsilon;
  11453. private _scene;
  11454. private _vertexData;
  11455. private _buffer;
  11456. private _vertexBuffers;
  11457. private _indexBuffer;
  11458. private _effectBase;
  11459. private _effectFog;
  11460. /**
  11461. * Gets or sets the spritesheet texture
  11462. */
  11463. texture: Texture;
  11464. /**
  11465. * Creates a new sprite manager
  11466. * @param name defines the manager's name
  11467. * @param imgUrl defines the sprite sheet url
  11468. * @param capacity defines the maximum allowed number of sprites
  11469. * @param cellSize defines the size of a sprite cell
  11470. * @param scene defines the hosting scene
  11471. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11472. * @param samplingMode defines the smapling mode to use with spritesheet
  11473. * @param fromPacked set to false; do not alter
  11474. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11475. */
  11476. constructor(
  11477. /** defines the manager's name */
  11478. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11479. private _makePacked;
  11480. private _appendSpriteVertex;
  11481. /**
  11482. * Intersects the sprites with a ray
  11483. * @param ray defines the ray to intersect with
  11484. * @param camera defines the current active camera
  11485. * @param predicate defines a predicate used to select candidate sprites
  11486. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11487. * @returns null if no hit or a PickingInfo
  11488. */
  11489. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11490. /**
  11491. * Intersects the sprites with a ray
  11492. * @param ray defines the ray to intersect with
  11493. * @param camera defines the current active camera
  11494. * @param predicate defines a predicate used to select candidate sprites
  11495. * @returns null if no hit or a PickingInfo array
  11496. */
  11497. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11498. /**
  11499. * Render all child sprites
  11500. */
  11501. render(): void;
  11502. /**
  11503. * Release associated resources
  11504. */
  11505. dispose(): void;
  11506. }
  11507. }
  11508. declare module BABYLON {
  11509. /**
  11510. * Class used to represent a sprite
  11511. * @see http://doc.babylonjs.com/babylon101/sprites
  11512. */
  11513. export class Sprite {
  11514. /** defines the name */
  11515. name: string;
  11516. /** Gets or sets the current world position */
  11517. position: Vector3;
  11518. /** Gets or sets the main color */
  11519. color: Color4;
  11520. /** Gets or sets the width */
  11521. width: number;
  11522. /** Gets or sets the height */
  11523. height: number;
  11524. /** Gets or sets rotation angle */
  11525. angle: number;
  11526. /** Gets or sets the cell index in the sprite sheet */
  11527. cellIndex: number;
  11528. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11529. cellRef: string;
  11530. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11531. invertU: number;
  11532. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11533. invertV: number;
  11534. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11535. disposeWhenFinishedAnimating: boolean;
  11536. /** Gets the list of attached animations */
  11537. animations: Animation[];
  11538. /** Gets or sets a boolean indicating if the sprite can be picked */
  11539. isPickable: boolean;
  11540. /**
  11541. * Gets or sets the associated action manager
  11542. */
  11543. actionManager: Nullable<ActionManager>;
  11544. private _animationStarted;
  11545. private _loopAnimation;
  11546. private _fromIndex;
  11547. private _toIndex;
  11548. private _delay;
  11549. private _direction;
  11550. private _manager;
  11551. private _time;
  11552. private _onAnimationEnd;
  11553. /**
  11554. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11555. */
  11556. isVisible: boolean;
  11557. /**
  11558. * Gets or sets the sprite size
  11559. */
  11560. size: number;
  11561. /**
  11562. * Creates a new Sprite
  11563. * @param name defines the name
  11564. * @param manager defines the manager
  11565. */
  11566. constructor(
  11567. /** defines the name */
  11568. name: string, manager: ISpriteManager);
  11569. /**
  11570. * Starts an animation
  11571. * @param from defines the initial key
  11572. * @param to defines the end key
  11573. * @param loop defines if the animation must loop
  11574. * @param delay defines the start delay (in ms)
  11575. * @param onAnimationEnd defines a callback to call when animation ends
  11576. */
  11577. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11578. /** Stops current animation (if any) */
  11579. stopAnimation(): void;
  11580. /** @hidden */ private _animate(deltaTime: number): void;
  11581. /** Release associated resources */
  11582. dispose(): void;
  11583. }
  11584. }
  11585. declare module BABYLON {
  11586. /**
  11587. * Information about the result of picking within a scene
  11588. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11589. */
  11590. export class PickingInfo {
  11591. /** @hidden */ private _pickingUnavailable: boolean;
  11592. /**
  11593. * If the pick collided with an object
  11594. */
  11595. hit: boolean;
  11596. /**
  11597. * Distance away where the pick collided
  11598. */
  11599. distance: number;
  11600. /**
  11601. * The location of pick collision
  11602. */
  11603. pickedPoint: Nullable<Vector3>;
  11604. /**
  11605. * The mesh corresponding the the pick collision
  11606. */
  11607. pickedMesh: Nullable<AbstractMesh>;
  11608. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11609. bu: number;
  11610. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11611. bv: number;
  11612. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11613. faceId: number;
  11614. /** Id of the the submesh that was picked */
  11615. subMeshId: number;
  11616. /** If a sprite was picked, this will be the sprite the pick collided with */
  11617. pickedSprite: Nullable<Sprite>;
  11618. /**
  11619. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11620. */
  11621. originMesh: Nullable<AbstractMesh>;
  11622. /**
  11623. * The ray that was used to perform the picking.
  11624. */
  11625. ray: Nullable<Ray>;
  11626. /**
  11627. * Gets the normal correspodning to the face the pick collided with
  11628. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11629. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11630. * @returns The normal correspodning to the face the pick collided with
  11631. */
  11632. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11633. /**
  11634. * Gets the texture coordinates of where the pick occured
  11635. * @returns the vector containing the coordnates of the texture
  11636. */
  11637. getTextureCoordinates(): Nullable<Vector2>;
  11638. }
  11639. }
  11640. declare module BABYLON {
  11641. /**
  11642. * Gather the list of pointer event types as constants.
  11643. */
  11644. export class PointerEventTypes {
  11645. /**
  11646. * 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.
  11647. */
  11648. static readonly POINTERDOWN: number;
  11649. /**
  11650. * The pointerup event is fired when a pointer is no longer active.
  11651. */
  11652. static readonly POINTERUP: number;
  11653. /**
  11654. * The pointermove event is fired when a pointer changes coordinates.
  11655. */
  11656. static readonly POINTERMOVE: number;
  11657. /**
  11658. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11659. */
  11660. static readonly POINTERWHEEL: number;
  11661. /**
  11662. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11663. */
  11664. static readonly POINTERPICK: number;
  11665. /**
  11666. * The pointertap event is fired when a the object has been touched and released without drag.
  11667. */
  11668. static readonly POINTERTAP: number;
  11669. /**
  11670. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11671. */
  11672. static readonly POINTERDOUBLETAP: number;
  11673. }
  11674. /**
  11675. * Base class of pointer info types.
  11676. */
  11677. export class PointerInfoBase {
  11678. /**
  11679. * Defines the type of event (PointerEventTypes)
  11680. */
  11681. type: number;
  11682. /**
  11683. * Defines the related dom event
  11684. */
  11685. event: PointerEvent | MouseWheelEvent;
  11686. /**
  11687. * Instantiates the base class of pointers info.
  11688. * @param type Defines the type of event (PointerEventTypes)
  11689. * @param event Defines the related dom event
  11690. */
  11691. constructor(
  11692. /**
  11693. * Defines the type of event (PointerEventTypes)
  11694. */
  11695. type: number,
  11696. /**
  11697. * Defines the related dom event
  11698. */
  11699. event: PointerEvent | MouseWheelEvent);
  11700. }
  11701. /**
  11702. * This class is used to store pointer related info for the onPrePointerObservable event.
  11703. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11704. */
  11705. export class PointerInfoPre extends PointerInfoBase {
  11706. /**
  11707. * Ray from a pointer if availible (eg. 6dof controller)
  11708. */
  11709. ray: Nullable<Ray>;
  11710. /**
  11711. * Defines the local position of the pointer on the canvas.
  11712. */
  11713. localPosition: Vector2;
  11714. /**
  11715. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11716. */
  11717. skipOnPointerObservable: boolean;
  11718. /**
  11719. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11720. * @param type Defines the type of event (PointerEventTypes)
  11721. * @param event Defines the related dom event
  11722. * @param localX Defines the local x coordinates of the pointer when the event occured
  11723. * @param localY Defines the local y coordinates of the pointer when the event occured
  11724. */
  11725. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11726. }
  11727. /**
  11728. * This type contains all the data related to a pointer event in Babylon.js.
  11729. * 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.
  11730. */
  11731. export class PointerInfo extends PointerInfoBase {
  11732. /**
  11733. * Defines the picking info associated to the info (if any)\
  11734. */
  11735. pickInfo: Nullable<PickingInfo>;
  11736. /**
  11737. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11738. * @param type Defines the type of event (PointerEventTypes)
  11739. * @param event Defines the related dom event
  11740. * @param pickInfo Defines the picking info associated to the info (if any)\
  11741. */
  11742. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11743. /**
  11744. * Defines the picking info associated to the info (if any)\
  11745. */
  11746. pickInfo: Nullable<PickingInfo>);
  11747. }
  11748. /**
  11749. * Data relating to a touch event on the screen.
  11750. */
  11751. export interface PointerTouch {
  11752. /**
  11753. * X coordinate of touch.
  11754. */
  11755. x: number;
  11756. /**
  11757. * Y coordinate of touch.
  11758. */
  11759. y: number;
  11760. /**
  11761. * Id of touch. Unique for each finger.
  11762. */
  11763. pointerId: number;
  11764. /**
  11765. * Event type passed from DOM.
  11766. */
  11767. type: any;
  11768. }
  11769. }
  11770. declare module BABYLON {
  11771. /**
  11772. * Manage the mouse inputs to control the movement of a free camera.
  11773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11774. */
  11775. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11776. /**
  11777. * Define if touch is enabled in the mouse input
  11778. */
  11779. touchEnabled: boolean;
  11780. /**
  11781. * Defines the camera the input is attached to.
  11782. */
  11783. camera: FreeCamera;
  11784. /**
  11785. * Defines the buttons associated with the input to handle camera move.
  11786. */
  11787. buttons: number[];
  11788. /**
  11789. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11790. */
  11791. angularSensibility: number;
  11792. private _pointerInput;
  11793. private _onMouseMove;
  11794. private _observer;
  11795. private previousPosition;
  11796. /**
  11797. * Observable for when a pointer move event occurs containing the move offset
  11798. */
  11799. onPointerMovedObservable: Observable<{
  11800. offsetX: number;
  11801. offsetY: number;
  11802. }>;
  11803. /**
  11804. * @hidden
  11805. * If the camera should be rotated automatically based on pointer movement
  11806. */ private _allowCameraRotation: boolean;
  11807. /**
  11808. * Manage the mouse inputs to control the movement of a free camera.
  11809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11810. * @param touchEnabled Defines if touch is enabled or not
  11811. */
  11812. constructor(
  11813. /**
  11814. * Define if touch is enabled in the mouse input
  11815. */
  11816. touchEnabled?: boolean);
  11817. /**
  11818. * Attach the input controls to a specific dom element to get the input from.
  11819. * @param element Defines the element the controls should be listened from
  11820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11821. */
  11822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11823. /**
  11824. * Called on JS contextmenu event.
  11825. * Override this method to provide functionality.
  11826. */
  11827. protected onContextMenu(evt: PointerEvent): void;
  11828. /**
  11829. * Detach the current controls from the specified dom element.
  11830. * @param element Defines the element to stop listening the inputs from
  11831. */
  11832. detachControl(element: Nullable<HTMLElement>): void;
  11833. /**
  11834. * Gets the class name of the current intput.
  11835. * @returns the class name
  11836. */
  11837. getClassName(): string;
  11838. /**
  11839. * Get the friendly name associated with the input class.
  11840. * @returns the input friendly name
  11841. */
  11842. getSimpleName(): string;
  11843. }
  11844. }
  11845. declare module BABYLON {
  11846. /**
  11847. * Manage the touch inputs to control the movement of a free camera.
  11848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11849. */
  11850. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11851. /**
  11852. * Defines the camera the input is attached to.
  11853. */
  11854. camera: FreeCamera;
  11855. /**
  11856. * Defines the touch sensibility for rotation.
  11857. * The higher the faster.
  11858. */
  11859. touchAngularSensibility: number;
  11860. /**
  11861. * Defines the touch sensibility for move.
  11862. * The higher the faster.
  11863. */
  11864. touchMoveSensibility: number;
  11865. private _offsetX;
  11866. private _offsetY;
  11867. private _pointerPressed;
  11868. private _pointerInput;
  11869. private _observer;
  11870. private _onLostFocus;
  11871. /**
  11872. * Attach the input controls to a specific dom element to get the input from.
  11873. * @param element Defines the element the controls should be listened from
  11874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11875. */
  11876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11877. /**
  11878. * Detach the current controls from the specified dom element.
  11879. * @param element Defines the element to stop listening the inputs from
  11880. */
  11881. detachControl(element: Nullable<HTMLElement>): void;
  11882. /**
  11883. * Update the current camera state depending on the inputs that have been used this frame.
  11884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11885. */
  11886. checkInputs(): void;
  11887. /**
  11888. * Gets the class name of the current intput.
  11889. * @returns the class name
  11890. */
  11891. getClassName(): string;
  11892. /**
  11893. * Get the friendly name associated with the input class.
  11894. * @returns the input friendly name
  11895. */
  11896. getSimpleName(): string;
  11897. }
  11898. }
  11899. declare module BABYLON {
  11900. /**
  11901. * Default Inputs manager for the FreeCamera.
  11902. * It groups all the default supported inputs for ease of use.
  11903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11904. */
  11905. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11906. /**
  11907. * @hidden
  11908. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11909. /**
  11910. * Instantiates a new FreeCameraInputsManager.
  11911. * @param camera Defines the camera the inputs belong to
  11912. */
  11913. constructor(camera: FreeCamera);
  11914. /**
  11915. * Add keyboard input support to the input manager.
  11916. * @returns the current input manager
  11917. */
  11918. addKeyboard(): FreeCameraInputsManager;
  11919. /**
  11920. * Add mouse input support to the input manager.
  11921. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11922. * @returns the current input manager
  11923. */
  11924. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11925. /**
  11926. * Removes the mouse input support from the manager
  11927. * @returns the current input manager
  11928. */
  11929. removeMouse(): FreeCameraInputsManager;
  11930. /**
  11931. * Add touch input support to the input manager.
  11932. * @returns the current input manager
  11933. */
  11934. addTouch(): FreeCameraInputsManager;
  11935. /**
  11936. * Remove all attached input methods from a camera
  11937. */
  11938. clear(): void;
  11939. }
  11940. }
  11941. declare module BABYLON {
  11942. /**
  11943. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11944. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11946. */
  11947. export class FreeCamera extends TargetCamera {
  11948. /**
  11949. * Define the collision ellipsoid of the camera.
  11950. * This is helpful to simulate a camera body like the player body around the camera
  11951. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11952. */
  11953. ellipsoid: Vector3;
  11954. /**
  11955. * Define an offset for the position of the ellipsoid around the camera.
  11956. * This can be helpful to determine the center of the body near the gravity center of the body
  11957. * instead of its head.
  11958. */
  11959. ellipsoidOffset: Vector3;
  11960. /**
  11961. * Enable or disable collisions of the camera with the rest of the scene objects.
  11962. */
  11963. checkCollisions: boolean;
  11964. /**
  11965. * Enable or disable gravity on the camera.
  11966. */
  11967. applyGravity: boolean;
  11968. /**
  11969. * Define the input manager associated to the camera.
  11970. */
  11971. inputs: FreeCameraInputsManager;
  11972. /**
  11973. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11974. * Higher values reduce sensitivity.
  11975. */
  11976. /**
  11977. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11978. * Higher values reduce sensitivity.
  11979. */
  11980. angularSensibility: number;
  11981. /**
  11982. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11983. */
  11984. keysUp: number[];
  11985. /**
  11986. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11987. */
  11988. keysDown: number[];
  11989. /**
  11990. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11991. */
  11992. keysLeft: number[];
  11993. /**
  11994. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11995. */
  11996. keysRight: number[];
  11997. /**
  11998. * Event raised when the camera collide with a mesh in the scene.
  11999. */
  12000. onCollide: (collidedMesh: AbstractMesh) => void;
  12001. private _collider;
  12002. private _needMoveForGravity;
  12003. private _oldPosition;
  12004. private _diffPosition;
  12005. private _newPosition;
  12006. /** @hidden */ private _localDirection: Vector3;
  12007. /** @hidden */ private _transformedDirection: Vector3;
  12008. /**
  12009. * Instantiates a Free Camera.
  12010. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12011. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12012. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12013. * @param name Define the name of the camera in the scene
  12014. * @param position Define the start position of the camera in the scene
  12015. * @param scene Define the scene the camera belongs to
  12016. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12017. */
  12018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12019. /**
  12020. * Attached controls to the current camera.
  12021. * @param element Defines the element the controls should be listened from
  12022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12023. */
  12024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12025. /**
  12026. * Detach the current controls from the camera.
  12027. * The camera will stop reacting to inputs.
  12028. * @param element Defines the element to stop listening the inputs from
  12029. */
  12030. detachControl(element: HTMLElement): void;
  12031. private _collisionMask;
  12032. /**
  12033. * Define a collision mask to limit the list of object the camera can collide with
  12034. */
  12035. collisionMask: number;
  12036. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  12037. private _onCollisionPositionChange;
  12038. /** @hidden */ private _checkInputs(): void;
  12039. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  12040. /** @hidden */ private _updatePosition(): void;
  12041. /**
  12042. * Destroy the camera and release the current resources hold by it.
  12043. */
  12044. dispose(): void;
  12045. /**
  12046. * Gets the current object class name.
  12047. * @return the class name
  12048. */
  12049. getClassName(): string;
  12050. }
  12051. }
  12052. declare module BABYLON {
  12053. /**
  12054. * Represents a gamepad control stick position
  12055. */
  12056. export class StickValues {
  12057. /**
  12058. * The x component of the control stick
  12059. */
  12060. x: number;
  12061. /**
  12062. * The y component of the control stick
  12063. */
  12064. y: number;
  12065. /**
  12066. * Initializes the gamepad x and y control stick values
  12067. * @param x The x component of the gamepad control stick value
  12068. * @param y The y component of the gamepad control stick value
  12069. */
  12070. constructor(
  12071. /**
  12072. * The x component of the control stick
  12073. */
  12074. x: number,
  12075. /**
  12076. * The y component of the control stick
  12077. */
  12078. y: number);
  12079. }
  12080. /**
  12081. * An interface which manages callbacks for gamepad button changes
  12082. */
  12083. export interface GamepadButtonChanges {
  12084. /**
  12085. * Called when a gamepad has been changed
  12086. */
  12087. changed: boolean;
  12088. /**
  12089. * Called when a gamepad press event has been triggered
  12090. */
  12091. pressChanged: boolean;
  12092. /**
  12093. * Called when a touch event has been triggered
  12094. */
  12095. touchChanged: boolean;
  12096. /**
  12097. * Called when a value has changed
  12098. */
  12099. valueChanged: boolean;
  12100. }
  12101. /**
  12102. * Represents a gamepad
  12103. */
  12104. export class Gamepad {
  12105. /**
  12106. * The id of the gamepad
  12107. */
  12108. id: string;
  12109. /**
  12110. * The index of the gamepad
  12111. */
  12112. index: number;
  12113. /**
  12114. * The browser gamepad
  12115. */
  12116. browserGamepad: any;
  12117. /**
  12118. * Specifies what type of gamepad this represents
  12119. */
  12120. type: number;
  12121. private _leftStick;
  12122. private _rightStick;
  12123. /** @hidden */ private _isConnected: boolean;
  12124. private _leftStickAxisX;
  12125. private _leftStickAxisY;
  12126. private _rightStickAxisX;
  12127. private _rightStickAxisY;
  12128. /**
  12129. * Triggered when the left control stick has been changed
  12130. */
  12131. private _onleftstickchanged;
  12132. /**
  12133. * Triggered when the right control stick has been changed
  12134. */
  12135. private _onrightstickchanged;
  12136. /**
  12137. * Represents a gamepad controller
  12138. */
  12139. static GAMEPAD: number;
  12140. /**
  12141. * Represents a generic controller
  12142. */
  12143. static GENERIC: number;
  12144. /**
  12145. * Represents an XBox controller
  12146. */
  12147. static XBOX: number;
  12148. /**
  12149. * Represents a pose-enabled controller
  12150. */
  12151. static POSE_ENABLED: number;
  12152. /**
  12153. * Represents an Dual Shock controller
  12154. */
  12155. static DUALSHOCK: number;
  12156. /**
  12157. * Specifies whether the left control stick should be Y-inverted
  12158. */
  12159. protected _invertLeftStickY: boolean;
  12160. /**
  12161. * Specifies if the gamepad has been connected
  12162. */
  12163. readonly isConnected: boolean;
  12164. /**
  12165. * Initializes the gamepad
  12166. * @param id The id of the gamepad
  12167. * @param index The index of the gamepad
  12168. * @param browserGamepad The browser gamepad
  12169. * @param leftStickX The x component of the left joystick
  12170. * @param leftStickY The y component of the left joystick
  12171. * @param rightStickX The x component of the right joystick
  12172. * @param rightStickY The y component of the right joystick
  12173. */
  12174. constructor(
  12175. /**
  12176. * The id of the gamepad
  12177. */
  12178. id: string,
  12179. /**
  12180. * The index of the gamepad
  12181. */
  12182. index: number,
  12183. /**
  12184. * The browser gamepad
  12185. */
  12186. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12187. /**
  12188. * Callback triggered when the left joystick has changed
  12189. * @param callback
  12190. */
  12191. onleftstickchanged(callback: (values: StickValues) => void): void;
  12192. /**
  12193. * Callback triggered when the right joystick has changed
  12194. * @param callback
  12195. */
  12196. onrightstickchanged(callback: (values: StickValues) => void): void;
  12197. /**
  12198. * Gets the left joystick
  12199. */
  12200. /**
  12201. * Sets the left joystick values
  12202. */
  12203. leftStick: StickValues;
  12204. /**
  12205. * Gets the right joystick
  12206. */
  12207. /**
  12208. * Sets the right joystick value
  12209. */
  12210. rightStick: StickValues;
  12211. /**
  12212. * Updates the gamepad joystick positions
  12213. */
  12214. update(): void;
  12215. /**
  12216. * Disposes the gamepad
  12217. */
  12218. dispose(): void;
  12219. }
  12220. /**
  12221. * Represents a generic gamepad
  12222. */
  12223. export class GenericPad extends Gamepad {
  12224. private _buttons;
  12225. private _onbuttondown;
  12226. private _onbuttonup;
  12227. /**
  12228. * Observable triggered when a button has been pressed
  12229. */
  12230. onButtonDownObservable: Observable<number>;
  12231. /**
  12232. * Observable triggered when a button has been released
  12233. */
  12234. onButtonUpObservable: Observable<number>;
  12235. /**
  12236. * Callback triggered when a button has been pressed
  12237. * @param callback Called when a button has been pressed
  12238. */
  12239. onbuttondown(callback: (buttonPressed: number) => void): void;
  12240. /**
  12241. * Callback triggered when a button has been released
  12242. * @param callback Called when a button has been released
  12243. */
  12244. onbuttonup(callback: (buttonReleased: number) => void): void;
  12245. /**
  12246. * Initializes the generic gamepad
  12247. * @param id The id of the generic gamepad
  12248. * @param index The index of the generic gamepad
  12249. * @param browserGamepad The browser gamepad
  12250. */
  12251. constructor(id: string, index: number, browserGamepad: any);
  12252. private _setButtonValue;
  12253. /**
  12254. * Updates the generic gamepad
  12255. */
  12256. update(): void;
  12257. /**
  12258. * Disposes the generic gamepad
  12259. */
  12260. dispose(): void;
  12261. }
  12262. }
  12263. declare module BABYLON {
  12264. interface Engine {
  12265. /**
  12266. * Creates a raw texture
  12267. * @param data defines the data to store in the texture
  12268. * @param width defines the width of the texture
  12269. * @param height defines the height of the texture
  12270. * @param format defines the format of the data
  12271. * @param generateMipMaps defines if the engine should generate the mip levels
  12272. * @param invertY defines if data must be stored with Y axis inverted
  12273. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12274. * @param compression defines the compression used (null by default)
  12275. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12276. * @returns the raw texture inside an InternalTexture
  12277. */
  12278. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12279. /**
  12280. * Update a raw texture
  12281. * @param texture defines the texture to update
  12282. * @param data defines the data to store in the texture
  12283. * @param format defines the format of the data
  12284. * @param invertY defines if data must be stored with Y axis inverted
  12285. */
  12286. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12287. /**
  12288. * Update a raw texture
  12289. * @param texture defines the texture to update
  12290. * @param data defines the data to store in the texture
  12291. * @param format defines the format of the data
  12292. * @param invertY defines if data must be stored with Y axis inverted
  12293. * @param compression defines the compression used (null by default)
  12294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12295. */
  12296. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12297. /**
  12298. * Creates a new raw cube texture
  12299. * @param data defines the array of data to use to create each face
  12300. * @param size defines the size of the textures
  12301. * @param format defines the format of the data
  12302. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12303. * @param generateMipMaps defines if the engine should generate the mip levels
  12304. * @param invertY defines if data must be stored with Y axis inverted
  12305. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12306. * @param compression defines the compression used (null by default)
  12307. * @returns the cube texture as an InternalTexture
  12308. */
  12309. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12310. /**
  12311. * Update a raw cube texture
  12312. * @param texture defines the texture to udpdate
  12313. * @param data defines the data to store
  12314. * @param format defines the data format
  12315. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12316. * @param invertY defines if data must be stored with Y axis inverted
  12317. */
  12318. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12319. /**
  12320. * Update a raw cube texture
  12321. * @param texture defines the texture to udpdate
  12322. * @param data defines the data to store
  12323. * @param format defines the data format
  12324. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12325. * @param invertY defines if data must be stored with Y axis inverted
  12326. * @param compression defines the compression used (null by default)
  12327. */
  12328. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12329. /**
  12330. * Update a raw cube texture
  12331. * @param texture defines the texture to udpdate
  12332. * @param data defines the data to store
  12333. * @param format defines the data format
  12334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12335. * @param invertY defines if data must be stored with Y axis inverted
  12336. * @param compression defines the compression used (null by default)
  12337. * @param level defines which level of the texture to update
  12338. */
  12339. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12340. /**
  12341. * Creates a new raw cube texture from a specified url
  12342. * @param url defines the url where the data is located
  12343. * @param scene defines the current scene
  12344. * @param size defines the size of the textures
  12345. * @param format defines the format of the data
  12346. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12347. * @param noMipmap defines if the engine should avoid generating the mip levels
  12348. * @param callback defines a callback used to extract texture data from loaded data
  12349. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12350. * @param onLoad defines a callback called when texture is loaded
  12351. * @param onError defines a callback called if there is an error
  12352. * @returns the cube texture as an InternalTexture
  12353. */
  12354. 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;
  12355. /**
  12356. * Creates a new raw cube texture from a specified url
  12357. * @param url defines the url where the data is located
  12358. * @param scene defines the current scene
  12359. * @param size defines the size of the textures
  12360. * @param format defines the format of the data
  12361. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12362. * @param noMipmap defines if the engine should avoid generating the mip levels
  12363. * @param callback defines a callback used to extract texture data from loaded data
  12364. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12365. * @param onLoad defines a callback called when texture is loaded
  12366. * @param onError defines a callback called if there is an error
  12367. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12368. * @param invertY defines if data must be stored with Y axis inverted
  12369. * @returns the cube texture as an InternalTexture
  12370. */
  12371. 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;
  12372. /**
  12373. * Creates a new raw 3D texture
  12374. * @param data defines the data used to create the texture
  12375. * @param width defines the width of the texture
  12376. * @param height defines the height of the texture
  12377. * @param depth defines the depth of the texture
  12378. * @param format defines the format of the texture
  12379. * @param generateMipMaps defines if the engine must generate mip levels
  12380. * @param invertY defines if data must be stored with Y axis inverted
  12381. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12382. * @param compression defines the compressed used (can be null)
  12383. * @param textureType defines the compressed used (can be null)
  12384. * @returns a new raw 3D texture (stored in an InternalTexture)
  12385. */
  12386. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12387. /**
  12388. * Update a raw 3D texture
  12389. * @param texture defines the texture to update
  12390. * @param data defines the data to store
  12391. * @param format defines the data format
  12392. * @param invertY defines if data must be stored with Y axis inverted
  12393. */
  12394. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12395. /**
  12396. * Update a raw 3D texture
  12397. * @param texture defines the texture to update
  12398. * @param data defines the data to store
  12399. * @param format defines the data format
  12400. * @param invertY defines if data must be stored with Y axis inverted
  12401. * @param compression defines the used compression (can be null)
  12402. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12403. */
  12404. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12405. }
  12406. }
  12407. declare module BABYLON {
  12408. /**
  12409. * Raw texture can help creating a texture directly from an array of data.
  12410. * This can be super useful if you either get the data from an uncompressed source or
  12411. * if you wish to create your texture pixel by pixel.
  12412. */
  12413. export class RawTexture extends Texture {
  12414. /**
  12415. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12416. */
  12417. format: number;
  12418. private _engine;
  12419. /**
  12420. * Instantiates a new RawTexture.
  12421. * Raw texture can help creating a texture directly from an array of data.
  12422. * This can be super useful if you either get the data from an uncompressed source or
  12423. * if you wish to create your texture pixel by pixel.
  12424. * @param data define the array of data to use to create the texture
  12425. * @param width define the width of the texture
  12426. * @param height define the height of the texture
  12427. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12428. * @param scene define the scene the texture belongs to
  12429. * @param generateMipMaps define whether mip maps should be generated or not
  12430. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12431. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12432. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12433. */
  12434. constructor(data: ArrayBufferView, width: number, height: number,
  12435. /**
  12436. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12437. */
  12438. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12439. /**
  12440. * Updates the texture underlying data.
  12441. * @param data Define the new data of the texture
  12442. */
  12443. update(data: ArrayBufferView): void;
  12444. /**
  12445. * Creates a luminance texture from some data.
  12446. * @param data Define the texture data
  12447. * @param width Define the width of the texture
  12448. * @param height Define the height of the texture
  12449. * @param scene Define the scene the texture belongs to
  12450. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12451. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12452. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12453. * @returns the luminance texture
  12454. */
  12455. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12456. /**
  12457. * Creates a luminance alpha texture from some data.
  12458. * @param data Define the texture data
  12459. * @param width Define the width of the texture
  12460. * @param height Define the height of the texture
  12461. * @param scene Define the scene the texture belongs to
  12462. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12463. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12464. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12465. * @returns the luminance alpha texture
  12466. */
  12467. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12468. /**
  12469. * Creates an alpha texture from some data.
  12470. * @param data Define the texture data
  12471. * @param width Define the width of the texture
  12472. * @param height Define the height of the texture
  12473. * @param scene Define the scene the texture belongs to
  12474. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12475. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12476. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12477. * @returns the alpha texture
  12478. */
  12479. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12480. /**
  12481. * Creates a RGB texture from some data.
  12482. * @param data Define the texture data
  12483. * @param width Define the width of the texture
  12484. * @param height Define the height of the texture
  12485. * @param scene Define the scene the texture belongs to
  12486. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12489. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12490. * @returns the RGB alpha texture
  12491. */
  12492. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12493. /**
  12494. * Creates a RGBA texture from some data.
  12495. * @param data Define the texture data
  12496. * @param width Define the width of the texture
  12497. * @param height Define the height of the texture
  12498. * @param scene Define the scene the texture belongs to
  12499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12503. * @returns the RGBA texture
  12504. */
  12505. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12506. /**
  12507. * Creates a R texture from some data.
  12508. * @param data Define the texture data
  12509. * @param width Define the width of the texture
  12510. * @param height Define the height of the texture
  12511. * @param scene Define the scene the texture belongs to
  12512. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12513. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12514. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12515. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12516. * @returns the R texture
  12517. */
  12518. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12519. }
  12520. }
  12521. declare module BABYLON {
  12522. /**
  12523. * Interface for the size containing width and height
  12524. */
  12525. export interface ISize {
  12526. /**
  12527. * Width
  12528. */
  12529. width: number;
  12530. /**
  12531. * Heighht
  12532. */
  12533. height: number;
  12534. }
  12535. /**
  12536. * Size containing widht and height
  12537. */
  12538. export class Size implements ISize {
  12539. /**
  12540. * Width
  12541. */
  12542. width: number;
  12543. /**
  12544. * Height
  12545. */
  12546. height: number;
  12547. /**
  12548. * Creates a Size object from the given width and height (floats).
  12549. * @param width width of the new size
  12550. * @param height height of the new size
  12551. */
  12552. constructor(width: number, height: number);
  12553. /**
  12554. * Returns a string with the Size width and height
  12555. * @returns a string with the Size width and height
  12556. */
  12557. toString(): string;
  12558. /**
  12559. * "Size"
  12560. * @returns the string "Size"
  12561. */
  12562. getClassName(): string;
  12563. /**
  12564. * Returns the Size hash code.
  12565. * @returns a hash code for a unique width and height
  12566. */
  12567. getHashCode(): number;
  12568. /**
  12569. * Updates the current size from the given one.
  12570. * @param src the given size
  12571. */
  12572. copyFrom(src: Size): void;
  12573. /**
  12574. * Updates in place the current Size from the given floats.
  12575. * @param width width of the new size
  12576. * @param height height of the new size
  12577. * @returns the updated Size.
  12578. */
  12579. copyFromFloats(width: number, height: number): Size;
  12580. /**
  12581. * Updates in place the current Size from the given floats.
  12582. * @param width width to set
  12583. * @param height height to set
  12584. * @returns the updated Size.
  12585. */
  12586. set(width: number, height: number): Size;
  12587. /**
  12588. * Multiplies the width and height by numbers
  12589. * @param w factor to multiple the width by
  12590. * @param h factor to multiple the height by
  12591. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12592. */
  12593. multiplyByFloats(w: number, h: number): Size;
  12594. /**
  12595. * Clones the size
  12596. * @returns a new Size copied from the given one.
  12597. */
  12598. clone(): Size;
  12599. /**
  12600. * True if the current Size and the given one width and height are strictly equal.
  12601. * @param other the other size to compare against
  12602. * @returns True if the current Size and the given one width and height are strictly equal.
  12603. */
  12604. equals(other: Size): boolean;
  12605. /**
  12606. * The surface of the Size : width * height (float).
  12607. */
  12608. readonly surface: number;
  12609. /**
  12610. * Create a new size of zero
  12611. * @returns a new Size set to (0.0, 0.0)
  12612. */
  12613. static Zero(): Size;
  12614. /**
  12615. * Sums the width and height of two sizes
  12616. * @param otherSize size to add to this size
  12617. * @returns a new Size set as the addition result of the current Size and the given one.
  12618. */
  12619. add(otherSize: Size): Size;
  12620. /**
  12621. * Subtracts the width and height of two
  12622. * @param otherSize size to subtract to this size
  12623. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12624. */
  12625. subtract(otherSize: Size): Size;
  12626. /**
  12627. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12628. * @param start starting size to lerp between
  12629. * @param end end size to lerp between
  12630. * @param amount amount to lerp between the start and end values
  12631. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12632. */
  12633. static Lerp(start: Size, end: Size, amount: number): Size;
  12634. }
  12635. }
  12636. declare module BABYLON {
  12637. /**
  12638. * Defines a runtime animation
  12639. */
  12640. export class RuntimeAnimation {
  12641. private _events;
  12642. /**
  12643. * The current frame of the runtime animation
  12644. */
  12645. private _currentFrame;
  12646. /**
  12647. * The animation used by the runtime animation
  12648. */
  12649. private _animation;
  12650. /**
  12651. * The target of the runtime animation
  12652. */
  12653. private _target;
  12654. /**
  12655. * The initiating animatable
  12656. */
  12657. private _host;
  12658. /**
  12659. * The original value of the runtime animation
  12660. */
  12661. private _originalValue;
  12662. /**
  12663. * The original blend value of the runtime animation
  12664. */
  12665. private _originalBlendValue;
  12666. /**
  12667. * The offsets cache of the runtime animation
  12668. */
  12669. private _offsetsCache;
  12670. /**
  12671. * The high limits cache of the runtime animation
  12672. */
  12673. private _highLimitsCache;
  12674. /**
  12675. * Specifies if the runtime animation has been stopped
  12676. */
  12677. private _stopped;
  12678. /**
  12679. * The blending factor of the runtime animation
  12680. */
  12681. private _blendingFactor;
  12682. /**
  12683. * The BabylonJS scene
  12684. */
  12685. private _scene;
  12686. /**
  12687. * The current value of the runtime animation
  12688. */
  12689. private _currentValue;
  12690. /** @hidden */ private _animationState: _IAnimationState;
  12691. /**
  12692. * The active target of the runtime animation
  12693. */
  12694. private _activeTargets;
  12695. private _currentActiveTarget;
  12696. private _directTarget;
  12697. /**
  12698. * The target path of the runtime animation
  12699. */
  12700. private _targetPath;
  12701. /**
  12702. * The weight of the runtime animation
  12703. */
  12704. private _weight;
  12705. /**
  12706. * The ratio offset of the runtime animation
  12707. */
  12708. private _ratioOffset;
  12709. /**
  12710. * The previous delay of the runtime animation
  12711. */
  12712. private _previousDelay;
  12713. /**
  12714. * The previous ratio of the runtime animation
  12715. */
  12716. private _previousRatio;
  12717. private _enableBlending;
  12718. private _keys;
  12719. private _minFrame;
  12720. private _maxFrame;
  12721. private _minValue;
  12722. private _maxValue;
  12723. private _targetIsArray;
  12724. /**
  12725. * Gets the current frame of the runtime animation
  12726. */
  12727. readonly currentFrame: number;
  12728. /**
  12729. * Gets the weight of the runtime animation
  12730. */
  12731. readonly weight: number;
  12732. /**
  12733. * Gets the current value of the runtime animation
  12734. */
  12735. readonly currentValue: any;
  12736. /**
  12737. * Gets the target path of the runtime animation
  12738. */
  12739. readonly targetPath: string;
  12740. /**
  12741. * Gets the actual target of the runtime animation
  12742. */
  12743. readonly target: any;
  12744. /** @hidden */ private _onLoop: () => void;
  12745. /**
  12746. * Create a new RuntimeAnimation object
  12747. * @param target defines the target of the animation
  12748. * @param animation defines the source animation object
  12749. * @param scene defines the hosting scene
  12750. * @param host defines the initiating Animatable
  12751. */
  12752. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12753. private _preparePath;
  12754. /**
  12755. * Gets the animation from the runtime animation
  12756. */
  12757. readonly animation: Animation;
  12758. /**
  12759. * Resets the runtime animation to the beginning
  12760. * @param restoreOriginal defines whether to restore the target property to the original value
  12761. */
  12762. reset(restoreOriginal?: boolean): void;
  12763. /**
  12764. * Specifies if the runtime animation is stopped
  12765. * @returns Boolean specifying if the runtime animation is stopped
  12766. */
  12767. isStopped(): boolean;
  12768. /**
  12769. * Disposes of the runtime animation
  12770. */
  12771. dispose(): void;
  12772. /**
  12773. * Apply the interpolated value to the target
  12774. * @param currentValue defines the value computed by the animation
  12775. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12776. */
  12777. setValue(currentValue: any, weight: number): void;
  12778. private _getOriginalValues;
  12779. private _setValue;
  12780. /**
  12781. * Gets the loop pmode of the runtime animation
  12782. * @returns Loop Mode
  12783. */
  12784. private _getCorrectLoopMode;
  12785. /**
  12786. * Move the current animation to a given frame
  12787. * @param frame defines the frame to move to
  12788. */
  12789. goToFrame(frame: number): void;
  12790. /**
  12791. * @hidden Internal use only
  12792. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12793. /**
  12794. * Execute the current animation
  12795. * @param delay defines the delay to add to the current frame
  12796. * @param from defines the lower bound of the animation range
  12797. * @param to defines the upper bound of the animation range
  12798. * @param loop defines if the current animation must loop
  12799. * @param speedRatio defines the current speed ratio
  12800. * @param weight defines the weight of the animation (default is -1 so no weight)
  12801. * @param onLoop optional callback called when animation loops
  12802. * @returns a boolean indicating if the animation is running
  12803. */
  12804. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /**
  12809. * Class used to store an actual running animation
  12810. */
  12811. export class Animatable {
  12812. /** defines the target object */
  12813. target: any;
  12814. /** defines the starting frame number (default is 0) */
  12815. fromFrame: number;
  12816. /** defines the ending frame number (default is 100) */
  12817. toFrame: number;
  12818. /** defines if the animation must loop (default is false) */
  12819. loopAnimation: boolean;
  12820. /** defines a callback to call when animation ends if it is not looping */
  12821. onAnimationEnd?: (() => void) | null | undefined;
  12822. /** defines a callback to call when animation loops */
  12823. onAnimationLoop?: (() => void) | null | undefined;
  12824. private _localDelayOffset;
  12825. private _pausedDelay;
  12826. private _runtimeAnimations;
  12827. private _paused;
  12828. private _scene;
  12829. private _speedRatio;
  12830. private _weight;
  12831. private _syncRoot;
  12832. /**
  12833. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12834. * This will only apply for non looping animation (default is true)
  12835. */
  12836. disposeOnEnd: boolean;
  12837. /**
  12838. * Gets a boolean indicating if the animation has started
  12839. */
  12840. animationStarted: boolean;
  12841. /**
  12842. * Observer raised when the animation ends
  12843. */
  12844. onAnimationEndObservable: Observable<Animatable>;
  12845. /**
  12846. * Observer raised when the animation loops
  12847. */
  12848. onAnimationLoopObservable: Observable<Animatable>;
  12849. /**
  12850. * Gets the root Animatable used to synchronize and normalize animations
  12851. */
  12852. readonly syncRoot: Nullable<Animatable>;
  12853. /**
  12854. * Gets the current frame of the first RuntimeAnimation
  12855. * Used to synchronize Animatables
  12856. */
  12857. readonly masterFrame: number;
  12858. /**
  12859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12860. */
  12861. weight: number;
  12862. /**
  12863. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12864. */
  12865. speedRatio: number;
  12866. /**
  12867. * Creates a new Animatable
  12868. * @param scene defines the hosting scene
  12869. * @param target defines the target object
  12870. * @param fromFrame defines the starting frame number (default is 0)
  12871. * @param toFrame defines the ending frame number (default is 100)
  12872. * @param loopAnimation defines if the animation must loop (default is false)
  12873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12875. * @param animations defines a group of animation to add to the new Animatable
  12876. * @param onAnimationLoop defines a callback to call when animation loops
  12877. */
  12878. constructor(scene: Scene,
  12879. /** defines the target object */
  12880. target: any,
  12881. /** defines the starting frame number (default is 0) */
  12882. fromFrame?: number,
  12883. /** defines the ending frame number (default is 100) */
  12884. toFrame?: number,
  12885. /** defines if the animation must loop (default is false) */
  12886. loopAnimation?: boolean, speedRatio?: number,
  12887. /** defines a callback to call when animation ends if it is not looping */
  12888. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12889. /** defines a callback to call when animation loops */
  12890. onAnimationLoop?: (() => void) | null | undefined);
  12891. /**
  12892. * Synchronize and normalize current Animatable with a source Animatable
  12893. * This is useful when using animation weights and when animations are not of the same length
  12894. * @param root defines the root Animatable to synchronize with
  12895. * @returns the current Animatable
  12896. */
  12897. syncWith(root: Animatable): Animatable;
  12898. /**
  12899. * Gets the list of runtime animations
  12900. * @returns an array of RuntimeAnimation
  12901. */
  12902. getAnimations(): RuntimeAnimation[];
  12903. /**
  12904. * Adds more animations to the current animatable
  12905. * @param target defines the target of the animations
  12906. * @param animations defines the new animations to add
  12907. */
  12908. appendAnimations(target: any, animations: Animation[]): void;
  12909. /**
  12910. * Gets the source animation for a specific property
  12911. * @param property defines the propertyu to look for
  12912. * @returns null or the source animation for the given property
  12913. */
  12914. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12915. /**
  12916. * Gets the runtime animation for a specific property
  12917. * @param property defines the propertyu to look for
  12918. * @returns null or the runtime animation for the given property
  12919. */
  12920. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12921. /**
  12922. * Resets the animatable to its original state
  12923. */
  12924. reset(): void;
  12925. /**
  12926. * Allows the animatable to blend with current running animations
  12927. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12928. * @param blendingSpeed defines the blending speed to use
  12929. */
  12930. enableBlending(blendingSpeed: number): void;
  12931. /**
  12932. * Disable animation blending
  12933. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12934. */
  12935. disableBlending(): void;
  12936. /**
  12937. * Jump directly to a given frame
  12938. * @param frame defines the frame to jump to
  12939. */
  12940. goToFrame(frame: number): void;
  12941. /**
  12942. * Pause the animation
  12943. */
  12944. pause(): void;
  12945. /**
  12946. * Restart the animation
  12947. */
  12948. restart(): void;
  12949. private _raiseOnAnimationEnd;
  12950. /**
  12951. * Stop and delete the current animation
  12952. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12953. * @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)
  12954. */
  12955. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12956. /**
  12957. * Wait asynchronously for the animation to end
  12958. * @returns a promise which will be fullfilled when the animation ends
  12959. */
  12960. waitAsync(): Promise<Animatable>;
  12961. /** @hidden */ private _animate(delay: number): boolean;
  12962. }
  12963. interface Scene {
  12964. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12965. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12966. totalWeight: number;
  12967. animations: RuntimeAnimation[];
  12968. originalValue: Matrix;
  12969. }): any;
  12970. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12971. totalWeight: number;
  12972. animations: RuntimeAnimation[];
  12973. originalValue: Quaternion;
  12974. }, refQuaternion: Quaternion): Quaternion;
  12975. /** @hidden */ private _processLateAnimationBindings(): void;
  12976. /**
  12977. * Will start the animation sequence of a given target
  12978. * @param target defines the target
  12979. * @param from defines from which frame should animation start
  12980. * @param to defines until which frame should animation run.
  12981. * @param weight defines the weight to apply to the animation (1.0 by default)
  12982. * @param loop defines if the animation loops
  12983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12984. * @param onAnimationEnd defines the function to be executed when the animation ends
  12985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12986. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12987. * @param onAnimationLoop defines the callback to call when an animation loops
  12988. * @returns the animatable object created for this animation
  12989. */
  12990. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12991. /**
  12992. * Will start the animation sequence of a given target
  12993. * @param target defines the target
  12994. * @param from defines from which frame should animation start
  12995. * @param to defines until which frame should animation run.
  12996. * @param loop defines if the animation loops
  12997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12998. * @param onAnimationEnd defines the function to be executed when the animation ends
  12999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13000. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13001. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13002. * @param onAnimationLoop defines the callback to call when an animation loops
  13003. * @returns the animatable object created for this animation
  13004. */
  13005. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13006. /**
  13007. * Will start the animation sequence of a given target and its hierarchy
  13008. * @param target defines the target
  13009. * @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.
  13010. * @param from defines from which frame should animation start
  13011. * @param to defines until which frame should animation run.
  13012. * @param loop defines if the animation loops
  13013. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13014. * @param onAnimationEnd defines the function to be executed when the animation ends
  13015. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13016. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13017. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13018. * @param onAnimationLoop defines the callback to call when an animation loops
  13019. * @returns the list of created animatables
  13020. */
  13021. 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[];
  13022. /**
  13023. * Begin a new animation on a given node
  13024. * @param target defines the target where the animation will take place
  13025. * @param animations defines the list of animations to start
  13026. * @param from defines the initial value
  13027. * @param to defines the final value
  13028. * @param loop defines if you want animation to loop (off by default)
  13029. * @param speedRatio defines the speed ratio to apply to all animations
  13030. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13031. * @param onAnimationLoop defines the callback to call when an animation loops
  13032. * @returns the list of created animatables
  13033. */
  13034. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13035. /**
  13036. * Begin a new animation on a given node and its hierarchy
  13037. * @param target defines the root node where the animation will take place
  13038. * @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.
  13039. * @param animations defines the list of animations to start
  13040. * @param from defines the initial value
  13041. * @param to defines the final value
  13042. * @param loop defines if you want animation to loop (off by default)
  13043. * @param speedRatio defines the speed ratio to apply to all animations
  13044. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13045. * @param onAnimationLoop defines the callback to call when an animation loops
  13046. * @returns the list of animatables created for all nodes
  13047. */
  13048. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13049. /**
  13050. * Gets the animatable associated with a specific target
  13051. * @param target defines the target of the animatable
  13052. * @returns the required animatable if found
  13053. */
  13054. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13055. /**
  13056. * Gets all animatables associated with a given target
  13057. * @param target defines the target to look animatables for
  13058. * @returns an array of Animatables
  13059. */
  13060. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13061. /**
  13062. * Stops and removes all animations that have been applied to the scene
  13063. */
  13064. stopAllAnimations(): void;
  13065. }
  13066. interface Bone {
  13067. /**
  13068. * Copy an animation range from another bone
  13069. * @param source defines the source bone
  13070. * @param rangeName defines the range name to copy
  13071. * @param frameOffset defines the frame offset
  13072. * @param rescaleAsRequired defines if rescaling must be applied if required
  13073. * @param skelDimensionsRatio defines the scaling ratio
  13074. * @returns true if operation was successful
  13075. */
  13076. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13077. }
  13078. }
  13079. declare module BABYLON {
  13080. /**
  13081. * Class used to override all child animations of a given target
  13082. */
  13083. export class AnimationPropertiesOverride {
  13084. /**
  13085. * Gets or sets a value indicating if animation blending must be used
  13086. */
  13087. enableBlending: boolean;
  13088. /**
  13089. * Gets or sets the blending speed to use when enableBlending is true
  13090. */
  13091. blendingSpeed: number;
  13092. /**
  13093. * Gets or sets the default loop mode to use
  13094. */
  13095. loopMode: number;
  13096. }
  13097. }
  13098. declare module BABYLON {
  13099. /**
  13100. * Class used to handle skinning animations
  13101. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13102. */
  13103. export class Skeleton implements IAnimatable {
  13104. /** defines the skeleton name */
  13105. name: string;
  13106. /** defines the skeleton Id */
  13107. id: string;
  13108. /**
  13109. * Defines the list of child bones
  13110. */
  13111. bones: Bone[];
  13112. /**
  13113. * Defines an estimate of the dimension of the skeleton at rest
  13114. */
  13115. dimensionsAtRest: Vector3;
  13116. /**
  13117. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13118. */
  13119. needInitialSkinMatrix: boolean;
  13120. /**
  13121. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13122. */
  13123. overrideMesh: Nullable<AbstractMesh>;
  13124. /**
  13125. * Gets the list of animations attached to this skeleton
  13126. */
  13127. animations: Array<Animation>;
  13128. private _scene;
  13129. private _isDirty;
  13130. private _transformMatrices;
  13131. private _transformMatrixTexture;
  13132. private _meshesWithPoseMatrix;
  13133. private _animatables;
  13134. private _identity;
  13135. private _synchronizedWithMesh;
  13136. private _ranges;
  13137. private _lastAbsoluteTransformsUpdateId;
  13138. private _canUseTextureForBones;
  13139. private _uniqueId;
  13140. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13141. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13142. /**
  13143. * Specifies if the skeleton should be serialized
  13144. */
  13145. doNotSerialize: boolean;
  13146. private _useTextureToStoreBoneMatrices;
  13147. /**
  13148. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13149. * Please note that this option is not available if the hardware does not support it
  13150. */
  13151. useTextureToStoreBoneMatrices: boolean;
  13152. private _animationPropertiesOverride;
  13153. /**
  13154. * Gets or sets the animation properties override
  13155. */
  13156. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13157. /**
  13158. * List of inspectable custom properties (used by the Inspector)
  13159. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13160. */
  13161. inspectableCustomProperties: IInspectable[];
  13162. /**
  13163. * An observable triggered before computing the skeleton's matrices
  13164. */
  13165. onBeforeComputeObservable: Observable<Skeleton>;
  13166. /**
  13167. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13168. */
  13169. readonly isUsingTextureForMatrices: boolean;
  13170. /**
  13171. * Gets the unique ID of this skeleton
  13172. */
  13173. readonly uniqueId: number;
  13174. /**
  13175. * Creates a new skeleton
  13176. * @param name defines the skeleton name
  13177. * @param id defines the skeleton Id
  13178. * @param scene defines the hosting scene
  13179. */
  13180. constructor(
  13181. /** defines the skeleton name */
  13182. name: string,
  13183. /** defines the skeleton Id */
  13184. id: string, scene: Scene);
  13185. /**
  13186. * Gets the current object class name.
  13187. * @return the class name
  13188. */
  13189. getClassName(): string;
  13190. /**
  13191. * Returns an array containing the root bones
  13192. * @returns an array containing the root bones
  13193. */
  13194. getChildren(): Array<Bone>;
  13195. /**
  13196. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13197. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13198. * @returns a Float32Array containing matrices data
  13199. */
  13200. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13201. /**
  13202. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13203. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13204. * @returns a raw texture containing the data
  13205. */
  13206. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13207. /**
  13208. * Gets the current hosting scene
  13209. * @returns a scene object
  13210. */
  13211. getScene(): Scene;
  13212. /**
  13213. * Gets a string representing the current skeleton data
  13214. * @param fullDetails defines a boolean indicating if we want a verbose version
  13215. * @returns a string representing the current skeleton data
  13216. */
  13217. toString(fullDetails?: boolean): string;
  13218. /**
  13219. * Get bone's index searching by name
  13220. * @param name defines bone's name to search for
  13221. * @return the indice of the bone. Returns -1 if not found
  13222. */
  13223. getBoneIndexByName(name: string): number;
  13224. /**
  13225. * Creater a new animation range
  13226. * @param name defines the name of the range
  13227. * @param from defines the start key
  13228. * @param to defines the end key
  13229. */
  13230. createAnimationRange(name: string, from: number, to: number): void;
  13231. /**
  13232. * Delete a specific animation range
  13233. * @param name defines the name of the range
  13234. * @param deleteFrames defines if frames must be removed as well
  13235. */
  13236. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13237. /**
  13238. * Gets a specific animation range
  13239. * @param name defines the name of the range to look for
  13240. * @returns the requested animation range or null if not found
  13241. */
  13242. getAnimationRange(name: string): Nullable<AnimationRange>;
  13243. /**
  13244. * Gets the list of all animation ranges defined on this skeleton
  13245. * @returns an array
  13246. */
  13247. getAnimationRanges(): Nullable<AnimationRange>[];
  13248. /**
  13249. * Copy animation range from a source skeleton.
  13250. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13251. * @param source defines the source skeleton
  13252. * @param name defines the name of the range to copy
  13253. * @param rescaleAsRequired defines if rescaling must be applied if required
  13254. * @returns true if operation was successful
  13255. */
  13256. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13257. /**
  13258. * Forces the skeleton to go to rest pose
  13259. */
  13260. returnToRest(): void;
  13261. private _getHighestAnimationFrame;
  13262. /**
  13263. * Begin a specific animation range
  13264. * @param name defines the name of the range to start
  13265. * @param loop defines if looping must be turned on (false by default)
  13266. * @param speedRatio defines the speed ratio to apply (1 by default)
  13267. * @param onAnimationEnd defines a callback which will be called when animation will end
  13268. * @returns a new animatable
  13269. */
  13270. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13271. /** @hidden */ private _markAsDirty(): void;
  13272. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13273. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13274. private _computeTransformMatrices;
  13275. /**
  13276. * Build all resources required to render a skeleton
  13277. */
  13278. prepare(): void;
  13279. /**
  13280. * Gets the list of animatables currently running for this skeleton
  13281. * @returns an array of animatables
  13282. */
  13283. getAnimatables(): IAnimatable[];
  13284. /**
  13285. * Clone the current skeleton
  13286. * @param name defines the name of the new skeleton
  13287. * @param id defines the id of the new skeleton
  13288. * @returns the new skeleton
  13289. */
  13290. clone(name: string, id: string): Skeleton;
  13291. /**
  13292. * Enable animation blending for this skeleton
  13293. * @param blendingSpeed defines the blending speed to apply
  13294. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13295. */
  13296. enableBlending(blendingSpeed?: number): void;
  13297. /**
  13298. * Releases all resources associated with the current skeleton
  13299. */
  13300. dispose(): void;
  13301. /**
  13302. * Serialize the skeleton in a JSON object
  13303. * @returns a JSON object
  13304. */
  13305. serialize(): any;
  13306. /**
  13307. * Creates a new skeleton from serialized data
  13308. * @param parsedSkeleton defines the serialized data
  13309. * @param scene defines the hosting scene
  13310. * @returns a new skeleton
  13311. */
  13312. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13313. /**
  13314. * Compute all node absolute transforms
  13315. * @param forceUpdate defines if computation must be done even if cache is up to date
  13316. */
  13317. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13318. /**
  13319. * Gets the root pose matrix
  13320. * @returns a matrix
  13321. */
  13322. getPoseMatrix(): Nullable<Matrix>;
  13323. /**
  13324. * Sorts bones per internal index
  13325. */
  13326. sortBones(): void;
  13327. private _sortBones;
  13328. }
  13329. }
  13330. declare module BABYLON {
  13331. /**
  13332. * Class used to store bone information
  13333. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13334. */
  13335. export class Bone extends Node {
  13336. /**
  13337. * defines the bone name
  13338. */
  13339. name: string;
  13340. private static _tmpVecs;
  13341. private static _tmpQuat;
  13342. private static _tmpMats;
  13343. /**
  13344. * Gets the list of child bones
  13345. */
  13346. children: Bone[];
  13347. /** Gets the animations associated with this bone */
  13348. animations: Animation[];
  13349. /**
  13350. * Gets or sets bone length
  13351. */
  13352. length: number;
  13353. /**
  13354. * @hidden Internal only
  13355. * Set this value to map this bone to a different index in the transform matrices
  13356. * Set this value to -1 to exclude the bone from the transform matrices
  13357. */ private _index: Nullable<number>;
  13358. private _skeleton;
  13359. private _localMatrix;
  13360. private _restPose;
  13361. private _baseMatrix;
  13362. private _absoluteTransform;
  13363. private _invertedAbsoluteTransform;
  13364. private _parent;
  13365. private _scalingDeterminant;
  13366. private _worldTransform;
  13367. private _localScaling;
  13368. private _localRotation;
  13369. private _localPosition;
  13370. private _needToDecompose;
  13371. private _needToCompose;
  13372. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13373. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13374. /** @hidden */
  13375. /** @hidden */ private _matrix: Matrix;
  13376. /**
  13377. * Create a new bone
  13378. * @param name defines the bone name
  13379. * @param skeleton defines the parent skeleton
  13380. * @param parentBone defines the parent (can be null if the bone is the root)
  13381. * @param localMatrix defines the local matrix
  13382. * @param restPose defines the rest pose matrix
  13383. * @param baseMatrix defines the base matrix
  13384. * @param index defines index of the bone in the hiearchy
  13385. */
  13386. constructor(
  13387. /**
  13388. * defines the bone name
  13389. */
  13390. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13391. /**
  13392. * Gets the current object class name.
  13393. * @return the class name
  13394. */
  13395. getClassName(): string;
  13396. /**
  13397. * Gets the parent skeleton
  13398. * @returns a skeleton
  13399. */
  13400. getSkeleton(): Skeleton;
  13401. /**
  13402. * Gets parent bone
  13403. * @returns a bone or null if the bone is the root of the bone hierarchy
  13404. */
  13405. getParent(): Nullable<Bone>;
  13406. /**
  13407. * Returns an array containing the root bones
  13408. * @returns an array containing the root bones
  13409. */
  13410. getChildren(): Array<Bone>;
  13411. /**
  13412. * Sets the parent bone
  13413. * @param parent defines the parent (can be null if the bone is the root)
  13414. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13415. */
  13416. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13417. /**
  13418. * Gets the local matrix
  13419. * @returns a matrix
  13420. */
  13421. getLocalMatrix(): Matrix;
  13422. /**
  13423. * Gets the base matrix (initial matrix which remains unchanged)
  13424. * @returns a matrix
  13425. */
  13426. getBaseMatrix(): Matrix;
  13427. /**
  13428. * Gets the rest pose matrix
  13429. * @returns a matrix
  13430. */
  13431. getRestPose(): Matrix;
  13432. /**
  13433. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13434. */
  13435. getWorldMatrix(): Matrix;
  13436. /**
  13437. * Sets the local matrix to rest pose matrix
  13438. */
  13439. returnToRest(): void;
  13440. /**
  13441. * Gets the inverse of the absolute transform matrix.
  13442. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13443. * @returns a matrix
  13444. */
  13445. getInvertedAbsoluteTransform(): Matrix;
  13446. /**
  13447. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13448. * @returns a matrix
  13449. */
  13450. getAbsoluteTransform(): Matrix;
  13451. /**
  13452. * Links with the given transform node.
  13453. * The local matrix of this bone is copied from the transform node every frame.
  13454. * @param transformNode defines the transform node to link to
  13455. */
  13456. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13457. /**
  13458. * Gets the node used to drive the bone's transformation
  13459. * @returns a transform node or null
  13460. */
  13461. getTransformNode(): Nullable<TransformNode>;
  13462. /** Gets or sets current position (in local space) */
  13463. position: Vector3;
  13464. /** Gets or sets current rotation (in local space) */
  13465. rotation: Vector3;
  13466. /** Gets or sets current rotation quaternion (in local space) */
  13467. rotationQuaternion: Quaternion;
  13468. /** Gets or sets current scaling (in local space) */
  13469. scaling: Vector3;
  13470. /**
  13471. * Gets the animation properties override
  13472. */
  13473. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13474. private _decompose;
  13475. private _compose;
  13476. /**
  13477. * Update the base and local matrices
  13478. * @param matrix defines the new base or local matrix
  13479. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13480. * @param updateLocalMatrix defines if the local matrix should be updated
  13481. */
  13482. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13483. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13484. /**
  13485. * Flag the bone as dirty (Forcing it to update everything)
  13486. */
  13487. markAsDirty(): void;
  13488. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13489. private _markAsDirtyAndDecompose;
  13490. /**
  13491. * Translate the bone in local or world space
  13492. * @param vec The amount to translate the bone
  13493. * @param space The space that the translation is in
  13494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13495. */
  13496. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13497. /**
  13498. * Set the postion of the bone in local or world space
  13499. * @param position The position to set the bone
  13500. * @param space The space that the position is in
  13501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13502. */
  13503. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13504. /**
  13505. * Set the absolute position of the bone (world space)
  13506. * @param position The position to set the bone
  13507. * @param mesh The mesh that this bone is attached to
  13508. */
  13509. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13510. /**
  13511. * Scale the bone on the x, y and z axes (in local space)
  13512. * @param x The amount to scale the bone on the x axis
  13513. * @param y The amount to scale the bone on the y axis
  13514. * @param z The amount to scale the bone on the z axis
  13515. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13516. */
  13517. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13518. /**
  13519. * Set the bone scaling in local space
  13520. * @param scale defines the scaling vector
  13521. */
  13522. setScale(scale: Vector3): void;
  13523. /**
  13524. * Gets the current scaling in local space
  13525. * @returns the current scaling vector
  13526. */
  13527. getScale(): Vector3;
  13528. /**
  13529. * Gets the current scaling in local space and stores it in a target vector
  13530. * @param result defines the target vector
  13531. */
  13532. getScaleToRef(result: Vector3): void;
  13533. /**
  13534. * Set the yaw, pitch, and roll of the bone in local or world space
  13535. * @param yaw The rotation of the bone on the y axis
  13536. * @param pitch The rotation of the bone on the x axis
  13537. * @param roll The rotation of the bone on the z axis
  13538. * @param space The space that the axes of rotation are in
  13539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13540. */
  13541. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13542. /**
  13543. * Add a rotation to the bone on an axis in local or world space
  13544. * @param axis The axis to rotate the bone on
  13545. * @param amount The amount to rotate the bone
  13546. * @param space The space that the axis is in
  13547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13548. */
  13549. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13550. /**
  13551. * Set the rotation of the bone to a particular axis angle in local or world space
  13552. * @param axis The axis to rotate the bone on
  13553. * @param angle The angle that the bone should be rotated to
  13554. * @param space The space that the axis is in
  13555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13556. */
  13557. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13558. /**
  13559. * Set the euler rotation of the bone in local of world space
  13560. * @param rotation The euler rotation that the bone should be set to
  13561. * @param space The space that the rotation is in
  13562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13563. */
  13564. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13565. /**
  13566. * Set the quaternion rotation of the bone in local of world space
  13567. * @param quat The quaternion rotation that the bone should be set to
  13568. * @param space The space that the rotation is in
  13569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13570. */
  13571. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13572. /**
  13573. * Set the rotation matrix of the bone in local of world space
  13574. * @param rotMat The rotation matrix that the bone should be set to
  13575. * @param space The space that the rotation is in
  13576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13577. */
  13578. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13579. private _rotateWithMatrix;
  13580. private _getNegativeRotationToRef;
  13581. /**
  13582. * Get the position of the bone in local or world space
  13583. * @param space The space that the returned position is in
  13584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13585. * @returns The position of the bone
  13586. */
  13587. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13588. /**
  13589. * Copy the position of the bone to a vector3 in local or world space
  13590. * @param space The space that the returned position is in
  13591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13592. * @param result The vector3 to copy the position to
  13593. */
  13594. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13595. /**
  13596. * Get the absolute position of the bone (world space)
  13597. * @param mesh The mesh that this bone is attached to
  13598. * @returns The absolute position of the bone
  13599. */
  13600. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13601. /**
  13602. * Copy the absolute position of the bone (world space) to the result param
  13603. * @param mesh The mesh that this bone is attached to
  13604. * @param result The vector3 to copy the absolute position to
  13605. */
  13606. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13607. /**
  13608. * Compute the absolute transforms of this bone and its children
  13609. */
  13610. computeAbsoluteTransforms(): void;
  13611. /**
  13612. * Get the world direction from an axis that is in the local space of the bone
  13613. * @param localAxis The local direction that is used to compute the world direction
  13614. * @param mesh The mesh that this bone is attached to
  13615. * @returns The world direction
  13616. */
  13617. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13618. /**
  13619. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13620. * @param localAxis The local direction that is used to compute the world direction
  13621. * @param mesh The mesh that this bone is attached to
  13622. * @param result The vector3 that the world direction will be copied to
  13623. */
  13624. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13625. /**
  13626. * Get the euler rotation of the bone in local or world space
  13627. * @param space The space that the rotation should be in
  13628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13629. * @returns The euler rotation
  13630. */
  13631. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13632. /**
  13633. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13634. * @param space The space that the rotation should be in
  13635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13636. * @param result The vector3 that the rotation should be copied to
  13637. */
  13638. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13639. /**
  13640. * Get the quaternion rotation of the bone in either local or world space
  13641. * @param space The space that the rotation should be in
  13642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13643. * @returns The quaternion rotation
  13644. */
  13645. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13646. /**
  13647. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13648. * @param space The space that the rotation should be in
  13649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13650. * @param result The quaternion that the rotation should be copied to
  13651. */
  13652. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13653. /**
  13654. * Get the rotation matrix of the bone in local or world space
  13655. * @param space The space that the rotation should be in
  13656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13657. * @returns The rotation matrix
  13658. */
  13659. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13660. /**
  13661. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13662. * @param space The space that the rotation should be in
  13663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13664. * @param result The quaternion that the rotation should be copied to
  13665. */
  13666. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13667. /**
  13668. * Get the world position of a point that is in the local space of the bone
  13669. * @param position The local position
  13670. * @param mesh The mesh that this bone is attached to
  13671. * @returns The world position
  13672. */
  13673. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13674. /**
  13675. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13676. * @param position The local position
  13677. * @param mesh The mesh that this bone is attached to
  13678. * @param result The vector3 that the world position should be copied to
  13679. */
  13680. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13681. /**
  13682. * Get the local position of a point that is in world space
  13683. * @param position The world position
  13684. * @param mesh The mesh that this bone is attached to
  13685. * @returns The local position
  13686. */
  13687. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13688. /**
  13689. * Get the local position of a point that is in world space and copy it to the result param
  13690. * @param position The world position
  13691. * @param mesh The mesh that this bone is attached to
  13692. * @param result The vector3 that the local position should be copied to
  13693. */
  13694. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13695. }
  13696. }
  13697. declare module BABYLON {
  13698. /**
  13699. * 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.
  13700. * @see https://doc.babylonjs.com/how_to/transformnode
  13701. */
  13702. export class TransformNode extends Node {
  13703. /**
  13704. * Object will not rotate to face the camera
  13705. */
  13706. static BILLBOARDMODE_NONE: number;
  13707. /**
  13708. * Object will rotate to face the camera but only on the x axis
  13709. */
  13710. static BILLBOARDMODE_X: number;
  13711. /**
  13712. * Object will rotate to face the camera but only on the y axis
  13713. */
  13714. static BILLBOARDMODE_Y: number;
  13715. /**
  13716. * Object will rotate to face the camera but only on the z axis
  13717. */
  13718. static BILLBOARDMODE_Z: number;
  13719. /**
  13720. * Object will rotate to face the camera
  13721. */
  13722. static BILLBOARDMODE_ALL: number;
  13723. /**
  13724. * Object will rotate to face the camera's position instead of orientation
  13725. */
  13726. static BILLBOARDMODE_USE_POSITION: number;
  13727. private _forward;
  13728. private _forwardInverted;
  13729. private _up;
  13730. private _right;
  13731. private _rightInverted;
  13732. private _position;
  13733. private _rotation;
  13734. private _rotationQuaternion;
  13735. protected _scaling: Vector3;
  13736. protected _isDirty: boolean;
  13737. private _transformToBoneReferal;
  13738. private _isAbsoluteSynced;
  13739. private _billboardMode;
  13740. /**
  13741. * Gets or sets the billboard mode. Default is 0.
  13742. *
  13743. * | Value | Type | Description |
  13744. * | --- | --- | --- |
  13745. * | 0 | BILLBOARDMODE_NONE | |
  13746. * | 1 | BILLBOARDMODE_X | |
  13747. * | 2 | BILLBOARDMODE_Y | |
  13748. * | 4 | BILLBOARDMODE_Z | |
  13749. * | 7 | BILLBOARDMODE_ALL | |
  13750. *
  13751. */
  13752. billboardMode: number;
  13753. private _preserveParentRotationForBillboard;
  13754. /**
  13755. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13756. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13757. */
  13758. preserveParentRotationForBillboard: boolean;
  13759. /**
  13760. * 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
  13761. */
  13762. scalingDeterminant: number;
  13763. private _infiniteDistance;
  13764. /**
  13765. * Gets or sets the distance of the object to max, often used by skybox
  13766. */
  13767. infiniteDistance: boolean;
  13768. /**
  13769. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13770. * By default the system will update normals to compensate
  13771. */
  13772. ignoreNonUniformScaling: boolean;
  13773. /**
  13774. * 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
  13775. */
  13776. reIntegrateRotationIntoRotationQuaternion: boolean;
  13777. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13778. /** @hidden */ private _localMatrix: Matrix;
  13779. private _usePivotMatrix;
  13780. private _absolutePosition;
  13781. private _absoluteScaling;
  13782. private _absoluteRotationQuaternion;
  13783. private _pivotMatrix;
  13784. private _pivotMatrixInverse;
  13785. protected _postMultiplyPivotMatrix: boolean;
  13786. protected _isWorldMatrixFrozen: boolean;
  13787. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13788. /**
  13789. * An event triggered after the world matrix is updated
  13790. */
  13791. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13792. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13793. /**
  13794. * Gets a string identifying the name of the class
  13795. * @returns "TransformNode" string
  13796. */
  13797. getClassName(): string;
  13798. /**
  13799. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13800. */
  13801. position: Vector3;
  13802. /**
  13803. * 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)).
  13804. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13805. */
  13806. rotation: Vector3;
  13807. /**
  13808. * 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)).
  13809. */
  13810. scaling: Vector3;
  13811. /**
  13812. * 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).
  13813. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13814. */
  13815. rotationQuaternion: Nullable<Quaternion>;
  13816. /**
  13817. * The forward direction of that transform in world space.
  13818. */
  13819. readonly forward: Vector3;
  13820. /**
  13821. * The up direction of that transform in world space.
  13822. */
  13823. readonly up: Vector3;
  13824. /**
  13825. * The right direction of that transform in world space.
  13826. */
  13827. readonly right: Vector3;
  13828. /**
  13829. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13830. * @param matrix the matrix to copy the pose from
  13831. * @returns this TransformNode.
  13832. */
  13833. updatePoseMatrix(matrix: Matrix): TransformNode;
  13834. /**
  13835. * Returns the mesh Pose matrix.
  13836. * @returns the pose matrix
  13837. */
  13838. getPoseMatrix(): Matrix;
  13839. /** @hidden */ private _isSynchronized(): boolean;
  13840. /** @hidden */ private _initCache(): void;
  13841. /**
  13842. * Flag the transform node as dirty (Forcing it to update everything)
  13843. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13844. * @returns this transform node
  13845. */
  13846. markAsDirty(property: string): TransformNode;
  13847. /**
  13848. * Returns the current mesh absolute position.
  13849. * Returns a Vector3.
  13850. */
  13851. readonly absolutePosition: Vector3;
  13852. /**
  13853. * Returns the current mesh absolute scaling.
  13854. * Returns a Vector3.
  13855. */
  13856. readonly absoluteScaling: Vector3;
  13857. /**
  13858. * Returns the current mesh absolute rotation.
  13859. * Returns a Quaternion.
  13860. */
  13861. readonly absoluteRotationQuaternion: Quaternion;
  13862. /**
  13863. * Sets a new matrix to apply before all other transformation
  13864. * @param matrix defines the transform matrix
  13865. * @returns the current TransformNode
  13866. */
  13867. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13868. /**
  13869. * Sets a new pivot matrix to the current node
  13870. * @param matrix defines the new pivot matrix to use
  13871. * @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
  13872. * @returns the current TransformNode
  13873. */
  13874. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13875. /**
  13876. * Returns the mesh pivot matrix.
  13877. * Default : Identity.
  13878. * @returns the matrix
  13879. */
  13880. getPivotMatrix(): Matrix;
  13881. /**
  13882. * Instantiate (when possible) or clone that node with its hierarchy
  13883. * @param newParent defines the new parent to use for the instance (or clone)
  13884. * @returns an instance (or a clone) of the current node with its hiearchy
  13885. */
  13886. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13887. /**
  13888. * Prevents the World matrix to be computed any longer
  13889. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13890. * @returns the TransformNode.
  13891. */
  13892. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13893. /**
  13894. * Allows back the World matrix computation.
  13895. * @returns the TransformNode.
  13896. */
  13897. unfreezeWorldMatrix(): this;
  13898. /**
  13899. * True if the World matrix has been frozen.
  13900. */
  13901. readonly isWorldMatrixFrozen: boolean;
  13902. /**
  13903. * Retuns the mesh absolute position in the World.
  13904. * @returns a Vector3.
  13905. */
  13906. getAbsolutePosition(): Vector3;
  13907. /**
  13908. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13909. * @param absolutePosition the absolute position to set
  13910. * @returns the TransformNode.
  13911. */
  13912. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13913. /**
  13914. * Sets the mesh position in its local space.
  13915. * @param vector3 the position to set in localspace
  13916. * @returns the TransformNode.
  13917. */
  13918. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13919. /**
  13920. * Returns the mesh position in the local space from the current World matrix values.
  13921. * @returns a new Vector3.
  13922. */
  13923. getPositionExpressedInLocalSpace(): Vector3;
  13924. /**
  13925. * Translates the mesh along the passed Vector3 in its local space.
  13926. * @param vector3 the distance to translate in localspace
  13927. * @returns the TransformNode.
  13928. */
  13929. locallyTranslate(vector3: Vector3): TransformNode;
  13930. private static _lookAtVectorCache;
  13931. /**
  13932. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13933. * @param targetPoint the position (must be in same space as current mesh) to look at
  13934. * @param yawCor optional yaw (y-axis) correction in radians
  13935. * @param pitchCor optional pitch (x-axis) correction in radians
  13936. * @param rollCor optional roll (z-axis) correction in radians
  13937. * @param space the choosen space of the target
  13938. * @returns the TransformNode.
  13939. */
  13940. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13941. /**
  13942. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13943. * This Vector3 is expressed in the World space.
  13944. * @param localAxis axis to rotate
  13945. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13946. */
  13947. getDirection(localAxis: Vector3): Vector3;
  13948. /**
  13949. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13950. * localAxis is expressed in the mesh local space.
  13951. * result is computed in the Wordl space from the mesh World matrix.
  13952. * @param localAxis axis to rotate
  13953. * @param result the resulting transformnode
  13954. * @returns this TransformNode.
  13955. */
  13956. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13957. /**
  13958. * Sets this transform node rotation to the given local axis.
  13959. * @param localAxis the axis in local space
  13960. * @param yawCor optional yaw (y-axis) correction in radians
  13961. * @param pitchCor optional pitch (x-axis) correction in radians
  13962. * @param rollCor optional roll (z-axis) correction in radians
  13963. * @returns this TransformNode
  13964. */
  13965. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13966. /**
  13967. * Sets a new pivot point to the current node
  13968. * @param point defines the new pivot point to use
  13969. * @param space defines if the point is in world or local space (local by default)
  13970. * @returns the current TransformNode
  13971. */
  13972. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13973. /**
  13974. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13975. * @returns the pivot point
  13976. */
  13977. getPivotPoint(): Vector3;
  13978. /**
  13979. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13980. * @param result the vector3 to store the result
  13981. * @returns this TransformNode.
  13982. */
  13983. getPivotPointToRef(result: Vector3): TransformNode;
  13984. /**
  13985. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13986. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13987. */
  13988. getAbsolutePivotPoint(): Vector3;
  13989. /**
  13990. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13991. * @param result vector3 to store the result
  13992. * @returns this TransformNode.
  13993. */
  13994. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13995. /**
  13996. * Defines the passed node as the parent of the current node.
  13997. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13998. * @see https://doc.babylonjs.com/how_to/parenting
  13999. * @param node the node ot set as the parent
  14000. * @returns this TransformNode.
  14001. */
  14002. setParent(node: Nullable<Node>): TransformNode;
  14003. private _nonUniformScaling;
  14004. /**
  14005. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14006. */
  14007. readonly nonUniformScaling: boolean;
  14008. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  14009. /**
  14010. * Attach the current TransformNode to another TransformNode associated with a bone
  14011. * @param bone Bone affecting the TransformNode
  14012. * @param affectedTransformNode TransformNode associated with the bone
  14013. * @returns this object
  14014. */
  14015. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14016. /**
  14017. * Detach the transform node if its associated with a bone
  14018. * @returns this object
  14019. */
  14020. detachFromBone(): TransformNode;
  14021. private static _rotationAxisCache;
  14022. /**
  14023. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14024. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14025. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14026. * The passed axis is also normalized.
  14027. * @param axis the axis to rotate around
  14028. * @param amount the amount to rotate in radians
  14029. * @param space Space to rotate in (Default: local)
  14030. * @returns the TransformNode.
  14031. */
  14032. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14033. /**
  14034. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14035. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14036. * The passed axis is also normalized. .
  14037. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14038. * @param point the point to rotate around
  14039. * @param axis the axis to rotate around
  14040. * @param amount the amount to rotate in radians
  14041. * @returns the TransformNode
  14042. */
  14043. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14044. /**
  14045. * Translates the mesh along the axis vector for the passed distance in the given space.
  14046. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14047. * @param axis the axis to translate in
  14048. * @param distance the distance to translate
  14049. * @param space Space to rotate in (Default: local)
  14050. * @returns the TransformNode.
  14051. */
  14052. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14053. /**
  14054. * Adds a rotation step to the mesh current rotation.
  14055. * x, y, z are Euler angles expressed in radians.
  14056. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14057. * This means this rotation is made in the mesh local space only.
  14058. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14059. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14060. * ```javascript
  14061. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14062. * ```
  14063. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14064. * 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.
  14065. * @param x Rotation to add
  14066. * @param y Rotation to add
  14067. * @param z Rotation to add
  14068. * @returns the TransformNode.
  14069. */
  14070. addRotation(x: number, y: number, z: number): TransformNode;
  14071. /**
  14072. * @hidden
  14073. */
  14074. protected _getEffectiveParent(): Nullable<Node>;
  14075. /**
  14076. * Computes the world matrix of the node
  14077. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14078. * @returns the world matrix
  14079. */
  14080. computeWorldMatrix(force?: boolean): Matrix;
  14081. protected _afterComputeWorldMatrix(): void;
  14082. /**
  14083. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14084. * @param func callback function to add
  14085. *
  14086. * @returns the TransformNode.
  14087. */
  14088. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14089. /**
  14090. * Removes a registered callback function.
  14091. * @param func callback function to remove
  14092. * @returns the TransformNode.
  14093. */
  14094. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14095. /**
  14096. * Gets the position of the current mesh in camera space
  14097. * @param camera defines the camera to use
  14098. * @returns a position
  14099. */
  14100. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14101. /**
  14102. * Returns the distance from the mesh to the active camera
  14103. * @param camera defines the camera to use
  14104. * @returns the distance
  14105. */
  14106. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14107. /**
  14108. * Clone the current transform node
  14109. * @param name Name of the new clone
  14110. * @param newParent New parent for the clone
  14111. * @param doNotCloneChildren Do not clone children hierarchy
  14112. * @returns the new transform node
  14113. */
  14114. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14115. /**
  14116. * Serializes the objects information.
  14117. * @param currentSerializationObject defines the object to serialize in
  14118. * @returns the serialized object
  14119. */
  14120. serialize(currentSerializationObject?: any): any;
  14121. /**
  14122. * Returns a new TransformNode object parsed from the source provided.
  14123. * @param parsedTransformNode is the source.
  14124. * @param scene the scne the object belongs to
  14125. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14126. * @returns a new TransformNode object parsed from the source provided.
  14127. */
  14128. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14129. /**
  14130. * Get all child-transformNodes of this node
  14131. * @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
  14132. * @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
  14133. * @returns an array of TransformNode
  14134. */
  14135. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14136. /**
  14137. * Releases resources associated with this transform node.
  14138. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14139. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14140. */
  14141. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14142. /**
  14143. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14144. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14145. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14146. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14147. * @returns the current mesh
  14148. */
  14149. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14150. private _syncAbsoluteScalingAndRotation;
  14151. }
  14152. }
  14153. declare module BABYLON {
  14154. /**
  14155. * Defines the types of pose enabled controllers that are supported
  14156. */
  14157. export enum PoseEnabledControllerType {
  14158. /**
  14159. * HTC Vive
  14160. */
  14161. VIVE = 0,
  14162. /**
  14163. * Oculus Rift
  14164. */
  14165. OCULUS = 1,
  14166. /**
  14167. * Windows mixed reality
  14168. */
  14169. WINDOWS = 2,
  14170. /**
  14171. * Samsung gear VR
  14172. */
  14173. GEAR_VR = 3,
  14174. /**
  14175. * Google Daydream
  14176. */
  14177. DAYDREAM = 4,
  14178. /**
  14179. * Generic
  14180. */
  14181. GENERIC = 5
  14182. }
  14183. /**
  14184. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14185. */
  14186. export interface MutableGamepadButton {
  14187. /**
  14188. * Value of the button/trigger
  14189. */
  14190. value: number;
  14191. /**
  14192. * If the button/trigger is currently touched
  14193. */
  14194. touched: boolean;
  14195. /**
  14196. * If the button/trigger is currently pressed
  14197. */
  14198. pressed: boolean;
  14199. }
  14200. /**
  14201. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14202. * @hidden
  14203. */
  14204. export interface ExtendedGamepadButton extends GamepadButton {
  14205. /**
  14206. * If the button/trigger is currently pressed
  14207. */
  14208. readonly pressed: boolean;
  14209. /**
  14210. * If the button/trigger is currently touched
  14211. */
  14212. readonly touched: boolean;
  14213. /**
  14214. * Value of the button/trigger
  14215. */
  14216. readonly value: number;
  14217. }
  14218. /** @hidden */
  14219. export interface _GamePadFactory {
  14220. /**
  14221. * Returns wether or not the current gamepad can be created for this type of controller.
  14222. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14223. * @returns true if it can be created, otherwise false
  14224. */
  14225. canCreate(gamepadInfo: any): boolean;
  14226. /**
  14227. * Creates a new instance of the Gamepad.
  14228. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14229. * @returns the new gamepad instance
  14230. */
  14231. create(gamepadInfo: any): Gamepad;
  14232. }
  14233. /**
  14234. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14235. */
  14236. export class PoseEnabledControllerHelper {
  14237. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14238. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14239. /**
  14240. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14241. * @param vrGamepad the gamepad to initialized
  14242. * @returns a vr controller of the type the gamepad identified as
  14243. */
  14244. static InitiateController(vrGamepad: any): Gamepad;
  14245. }
  14246. /**
  14247. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14248. */
  14249. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14250. /**
  14251. * If the controller is used in a webXR session
  14252. */
  14253. isXR: boolean;
  14254. private _deviceRoomPosition;
  14255. private _deviceRoomRotationQuaternion;
  14256. /**
  14257. * The device position in babylon space
  14258. */
  14259. devicePosition: Vector3;
  14260. /**
  14261. * The device rotation in babylon space
  14262. */
  14263. deviceRotationQuaternion: Quaternion;
  14264. /**
  14265. * The scale factor of the device in babylon space
  14266. */
  14267. deviceScaleFactor: number;
  14268. /**
  14269. * (Likely devicePosition should be used instead) The device position in its room space
  14270. */
  14271. position: Vector3;
  14272. /**
  14273. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14274. */
  14275. rotationQuaternion: Quaternion;
  14276. /**
  14277. * The type of controller (Eg. Windows mixed reality)
  14278. */
  14279. controllerType: PoseEnabledControllerType;
  14280. protected _calculatedPosition: Vector3;
  14281. private _calculatedRotation;
  14282. /**
  14283. * The raw pose from the device
  14284. */
  14285. rawPose: DevicePose;
  14286. private _trackPosition;
  14287. private _maxRotationDistFromHeadset;
  14288. private _draggedRoomRotation;
  14289. /**
  14290. * @hidden
  14291. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14292. /**
  14293. * Internal, the mesh attached to the controller
  14294. * @hidden
  14295. */ private _mesh: Nullable<AbstractMesh>;
  14296. private _poseControlledCamera;
  14297. private _leftHandSystemQuaternion;
  14298. /**
  14299. * Internal, matrix used to convert room space to babylon space
  14300. * @hidden
  14301. */ private _deviceToWorld: Matrix;
  14302. /**
  14303. * Node to be used when casting a ray from the controller
  14304. * @hidden
  14305. */ private _pointingPoseNode: Nullable<TransformNode>;
  14306. /**
  14307. * Name of the child mesh that can be used to cast a ray from the controller
  14308. */
  14309. static readonly POINTING_POSE: string;
  14310. /**
  14311. * Creates a new PoseEnabledController from a gamepad
  14312. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14313. */
  14314. constructor(browserGamepad: any);
  14315. private _workingMatrix;
  14316. /**
  14317. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14318. */
  14319. update(): void;
  14320. /**
  14321. * Updates only the pose device and mesh without doing any button event checking
  14322. */
  14323. protected _updatePoseAndMesh(): void;
  14324. /**
  14325. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14326. * @param poseData raw pose fromthe device
  14327. */
  14328. updateFromDevice(poseData: DevicePose): void;
  14329. /**
  14330. * @hidden
  14331. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14332. /**
  14333. * Attaches a mesh to the controller
  14334. * @param mesh the mesh to be attached
  14335. */
  14336. attachToMesh(mesh: AbstractMesh): void;
  14337. /**
  14338. * Attaches the controllers mesh to a camera
  14339. * @param camera the camera the mesh should be attached to
  14340. */
  14341. attachToPoseControlledCamera(camera: TargetCamera): void;
  14342. /**
  14343. * Disposes of the controller
  14344. */
  14345. dispose(): void;
  14346. /**
  14347. * The mesh that is attached to the controller
  14348. */
  14349. readonly mesh: Nullable<AbstractMesh>;
  14350. /**
  14351. * Gets the ray of the controller in the direction the controller is pointing
  14352. * @param length the length the resulting ray should be
  14353. * @returns a ray in the direction the controller is pointing
  14354. */
  14355. getForwardRay(length?: number): Ray;
  14356. }
  14357. }
  14358. declare module BABYLON {
  14359. /**
  14360. * Defines the WebVRController object that represents controllers tracked in 3D space
  14361. */
  14362. export abstract class WebVRController extends PoseEnabledController {
  14363. /**
  14364. * Internal, the default controller model for the controller
  14365. */
  14366. protected _defaultModel: Nullable<AbstractMesh>;
  14367. /**
  14368. * Fired when the trigger state has changed
  14369. */
  14370. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14371. /**
  14372. * Fired when the main button state has changed
  14373. */
  14374. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14375. /**
  14376. * Fired when the secondary button state has changed
  14377. */
  14378. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14379. /**
  14380. * Fired when the pad state has changed
  14381. */
  14382. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14383. /**
  14384. * Fired when controllers stick values have changed
  14385. */
  14386. onPadValuesChangedObservable: Observable<StickValues>;
  14387. /**
  14388. * Array of button availible on the controller
  14389. */
  14390. protected _buttons: Array<MutableGamepadButton>;
  14391. private _onButtonStateChange;
  14392. /**
  14393. * Fired when a controller button's state has changed
  14394. * @param callback the callback containing the button that was modified
  14395. */
  14396. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14397. /**
  14398. * X and Y axis corresponding to the controllers joystick
  14399. */
  14400. pad: StickValues;
  14401. /**
  14402. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14403. */
  14404. hand: string;
  14405. /**
  14406. * The default controller model for the controller
  14407. */
  14408. readonly defaultModel: Nullable<AbstractMesh>;
  14409. /**
  14410. * Creates a new WebVRController from a gamepad
  14411. * @param vrGamepad the gamepad that the WebVRController should be created from
  14412. */
  14413. constructor(vrGamepad: any);
  14414. /**
  14415. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14416. */
  14417. update(): void;
  14418. /**
  14419. * Function to be called when a button is modified
  14420. */
  14421. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14422. /**
  14423. * Loads a mesh and attaches it to the controller
  14424. * @param scene the scene the mesh should be added to
  14425. * @param meshLoaded callback for when the mesh has been loaded
  14426. */
  14427. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14428. private _setButtonValue;
  14429. private _changes;
  14430. private _checkChanges;
  14431. /**
  14432. * Disposes of th webVRCOntroller
  14433. */
  14434. dispose(): void;
  14435. }
  14436. }
  14437. declare module BABYLON {
  14438. /**
  14439. * The HemisphericLight simulates the ambient environment light,
  14440. * so the passed direction is the light reflection direction, not the incoming direction.
  14441. */
  14442. export class HemisphericLight extends Light {
  14443. /**
  14444. * The groundColor is the light in the opposite direction to the one specified during creation.
  14445. * 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.
  14446. */
  14447. groundColor: Color3;
  14448. /**
  14449. * The light reflection direction, not the incoming direction.
  14450. */
  14451. direction: Vector3;
  14452. /**
  14453. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14454. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14455. * The HemisphericLight can't cast shadows.
  14456. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14457. * @param name The friendly name of the light
  14458. * @param direction The direction of the light reflection
  14459. * @param scene The scene the light belongs to
  14460. */
  14461. constructor(name: string, direction: Vector3, scene: Scene);
  14462. protected _buildUniformLayout(): void;
  14463. /**
  14464. * Returns the string "HemisphericLight".
  14465. * @return The class name
  14466. */
  14467. getClassName(): string;
  14468. /**
  14469. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14470. * Returns the updated direction.
  14471. * @param target The target the direction should point to
  14472. * @return The computed direction
  14473. */
  14474. setDirectionToTarget(target: Vector3): Vector3;
  14475. /**
  14476. * Returns the shadow generator associated to the light.
  14477. * @returns Always null for hemispheric lights because it does not support shadows.
  14478. */
  14479. getShadowGenerator(): Nullable<IShadowGenerator>;
  14480. /**
  14481. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14482. * @param effect The effect to update
  14483. * @param lightIndex The index of the light in the effect to update
  14484. * @returns The hemispheric light
  14485. */
  14486. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14487. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14488. /**
  14489. * Computes the world matrix of the node
  14490. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14491. * @param useWasUpdatedFlag defines a reserved property
  14492. * @returns the world matrix
  14493. */
  14494. computeWorldMatrix(): Matrix;
  14495. /**
  14496. * Returns the integer 3.
  14497. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14498. */
  14499. getTypeID(): number;
  14500. /**
  14501. * Prepares the list of defines specific to the light type.
  14502. * @param defines the list of defines
  14503. * @param lightIndex defines the index of the light for the effect
  14504. */
  14505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14506. }
  14507. }
  14508. declare module BABYLON {
  14509. /** @hidden */
  14510. export var vrMultiviewToSingleviewPixelShader: {
  14511. name: string;
  14512. shader: string;
  14513. };
  14514. }
  14515. declare module BABYLON {
  14516. /**
  14517. * Renders to multiple views with a single draw call
  14518. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14519. */
  14520. export class MultiviewRenderTarget extends RenderTargetTexture {
  14521. /**
  14522. * Creates a multiview render target
  14523. * @param scene scene used with the render target
  14524. * @param size the size of the render target (used for each view)
  14525. */
  14526. constructor(scene: Scene, size?: number | {
  14527. width: number;
  14528. height: number;
  14529. } | {
  14530. ratio: number;
  14531. });
  14532. /**
  14533. * @hidden
  14534. * @param faceIndex the face index, if its a cube texture
  14535. */ private _bindFrameBuffer(faceIndex?: number): void;
  14536. /**
  14537. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14538. * @returns the view count
  14539. */
  14540. getViewCount(): number;
  14541. }
  14542. }
  14543. declare module BABYLON {
  14544. /**
  14545. * Represents a camera frustum
  14546. */
  14547. export class Frustum {
  14548. /**
  14549. * Gets the planes representing the frustum
  14550. * @param transform matrix to be applied to the returned planes
  14551. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14552. */
  14553. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14554. /**
  14555. * Gets the near frustum plane transformed by the transform matrix
  14556. * @param transform transformation matrix to be applied to the resulting frustum plane
  14557. * @param frustumPlane the resuling frustum plane
  14558. */
  14559. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14560. /**
  14561. * Gets the far frustum plane transformed by the transform matrix
  14562. * @param transform transformation matrix to be applied to the resulting frustum plane
  14563. * @param frustumPlane the resuling frustum plane
  14564. */
  14565. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14566. /**
  14567. * Gets the left frustum plane transformed by the transform matrix
  14568. * @param transform transformation matrix to be applied to the resulting frustum plane
  14569. * @param frustumPlane the resuling frustum plane
  14570. */
  14571. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14572. /**
  14573. * Gets the right frustum plane transformed by the transform matrix
  14574. * @param transform transformation matrix to be applied to the resulting frustum plane
  14575. * @param frustumPlane the resuling frustum plane
  14576. */
  14577. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14578. /**
  14579. * Gets the top frustum plane transformed by the transform matrix
  14580. * @param transform transformation matrix to be applied to the resulting frustum plane
  14581. * @param frustumPlane the resuling frustum plane
  14582. */
  14583. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14584. /**
  14585. * Gets the bottom frustum plane transformed by the transform matrix
  14586. * @param transform transformation matrix to be applied to the resulting frustum plane
  14587. * @param frustumPlane the resuling frustum plane
  14588. */
  14589. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14590. /**
  14591. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14592. * @param transform transformation matrix to be applied to the resulting frustum planes
  14593. * @param frustumPlanes the resuling frustum planes
  14594. */
  14595. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14596. }
  14597. }
  14598. declare module BABYLON {
  14599. interface Engine {
  14600. /**
  14601. * Creates a new multiview render target
  14602. * @param width defines the width of the texture
  14603. * @param height defines the height of the texture
  14604. * @returns the created multiview texture
  14605. */
  14606. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14607. /**
  14608. * Binds a multiview framebuffer to be drawn to
  14609. * @param multiviewTexture texture to bind
  14610. */
  14611. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14612. }
  14613. interface Camera {
  14614. /**
  14615. * @hidden
  14616. * 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)
  14617. */ private _useMultiviewToSingleView: boolean;
  14618. /**
  14619. * @hidden
  14620. * 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)
  14621. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14622. /**
  14623. * @hidden
  14624. * ensures the multiview texture of the camera exists and has the specified width/height
  14625. * @param width height to set on the multiview texture
  14626. * @param height width to set on the multiview texture
  14627. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14628. }
  14629. interface Scene {
  14630. /** @hidden */ private _transformMatrixR: Matrix;
  14631. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14632. /** @hidden */ private _createMultiviewUbo(): void;
  14633. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14634. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14635. }
  14636. }
  14637. declare module BABYLON {
  14638. /**
  14639. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14640. * This will not be used for webXR as it supports displaying texture arrays directly
  14641. */
  14642. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14643. /**
  14644. * Initializes a VRMultiviewToSingleview
  14645. * @param name name of the post process
  14646. * @param camera camera to be applied to
  14647. * @param scaleFactor scaling factor to the size of the output texture
  14648. */
  14649. constructor(name: string, camera: Camera, scaleFactor: number);
  14650. }
  14651. }
  14652. declare module BABYLON {
  14653. interface Engine {
  14654. /** @hidden */ private _vrDisplay: any;
  14655. /** @hidden */ private _vrSupported: boolean;
  14656. /** @hidden */ private _oldSize: Size;
  14657. /** @hidden */ private _oldHardwareScaleFactor: number;
  14658. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14659. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14660. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14661. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14662. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14663. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14664. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14665. /**
  14666. * Observable signaled when VR display mode changes
  14667. */
  14668. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14669. /**
  14670. * Observable signaled when VR request present is complete
  14671. */
  14672. onVRRequestPresentComplete: Observable<boolean>;
  14673. /**
  14674. * Observable signaled when VR request present starts
  14675. */
  14676. onVRRequestPresentStart: Observable<Engine>;
  14677. /**
  14678. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14679. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14680. */
  14681. isInVRExclusivePointerMode: boolean;
  14682. /**
  14683. * Gets a boolean indicating if a webVR device was detected
  14684. * @returns true if a webVR device was detected
  14685. */
  14686. isVRDevicePresent(): boolean;
  14687. /**
  14688. * Gets the current webVR device
  14689. * @returns the current webVR device (or null)
  14690. */
  14691. getVRDevice(): any;
  14692. /**
  14693. * Initializes a webVR display and starts listening to display change events
  14694. * The onVRDisplayChangedObservable will be notified upon these changes
  14695. * @returns A promise containing a VRDisplay and if vr is supported
  14696. */
  14697. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14698. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14699. /**
  14700. * Call this function to switch to webVR mode
  14701. * Will do nothing if webVR is not supported or if there is no webVR device
  14702. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14703. */
  14704. enableVR(): void;
  14705. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14706. }
  14707. }
  14708. declare module BABYLON {
  14709. /**
  14710. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14711. * IMPORTANT!! The data is right-hand data.
  14712. * @export
  14713. * @interface DevicePose
  14714. */
  14715. export interface DevicePose {
  14716. /**
  14717. * The position of the device, values in array are [x,y,z].
  14718. */
  14719. readonly position: Nullable<Float32Array>;
  14720. /**
  14721. * The linearVelocity of the device, values in array are [x,y,z].
  14722. */
  14723. readonly linearVelocity: Nullable<Float32Array>;
  14724. /**
  14725. * The linearAcceleration of the device, values in array are [x,y,z].
  14726. */
  14727. readonly linearAcceleration: Nullable<Float32Array>;
  14728. /**
  14729. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14730. */
  14731. readonly orientation: Nullable<Float32Array>;
  14732. /**
  14733. * The angularVelocity of the device, values in array are [x,y,z].
  14734. */
  14735. readonly angularVelocity: Nullable<Float32Array>;
  14736. /**
  14737. * The angularAcceleration of the device, values in array are [x,y,z].
  14738. */
  14739. readonly angularAcceleration: Nullable<Float32Array>;
  14740. }
  14741. /**
  14742. * Interface representing a pose controlled object in Babylon.
  14743. * A pose controlled object has both regular pose values as well as pose values
  14744. * from an external device such as a VR head mounted display
  14745. */
  14746. export interface PoseControlled {
  14747. /**
  14748. * The position of the object in babylon space.
  14749. */
  14750. position: Vector3;
  14751. /**
  14752. * The rotation quaternion of the object in babylon space.
  14753. */
  14754. rotationQuaternion: Quaternion;
  14755. /**
  14756. * The position of the device in babylon space.
  14757. */
  14758. devicePosition?: Vector3;
  14759. /**
  14760. * The rotation quaternion of the device in babylon space.
  14761. */
  14762. deviceRotationQuaternion: Quaternion;
  14763. /**
  14764. * The raw pose coming from the device.
  14765. */
  14766. rawPose: Nullable<DevicePose>;
  14767. /**
  14768. * The scale of the device to be used when translating from device space to babylon space.
  14769. */
  14770. deviceScaleFactor: number;
  14771. /**
  14772. * Updates the poseControlled values based on the input device pose.
  14773. * @param poseData the pose data to update the object with
  14774. */
  14775. updateFromDevice(poseData: DevicePose): void;
  14776. }
  14777. /**
  14778. * Set of options to customize the webVRCamera
  14779. */
  14780. export interface WebVROptions {
  14781. /**
  14782. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14783. */
  14784. trackPosition?: boolean;
  14785. /**
  14786. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14787. */
  14788. positionScale?: number;
  14789. /**
  14790. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14791. */
  14792. displayName?: string;
  14793. /**
  14794. * Should the native controller meshes be initialized. (default: true)
  14795. */
  14796. controllerMeshes?: boolean;
  14797. /**
  14798. * Creating a default HemiLight only on controllers. (default: true)
  14799. */
  14800. defaultLightingOnControllers?: boolean;
  14801. /**
  14802. * If you don't want to use the default VR button of the helper. (default: false)
  14803. */
  14804. useCustomVRButton?: boolean;
  14805. /**
  14806. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14807. */
  14808. customVRButton?: HTMLButtonElement;
  14809. /**
  14810. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14811. */
  14812. rayLength?: number;
  14813. /**
  14814. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14815. */
  14816. defaultHeight?: number;
  14817. /**
  14818. * If multiview should be used if availible (default: false)
  14819. */
  14820. useMultiview?: boolean;
  14821. }
  14822. /**
  14823. * This represents a WebVR camera.
  14824. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14825. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14826. */
  14827. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14828. private webVROptions;
  14829. /**
  14830. * @hidden
  14831. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14832. */ private _vrDevice: any;
  14833. /**
  14834. * The rawPose of the vrDevice.
  14835. */
  14836. rawPose: Nullable<DevicePose>;
  14837. private _onVREnabled;
  14838. private _specsVersion;
  14839. private _attached;
  14840. private _frameData;
  14841. protected _descendants: Array<Node>;
  14842. private _deviceRoomPosition;
  14843. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14844. private _standingMatrix;
  14845. /**
  14846. * Represents device position in babylon space.
  14847. */
  14848. devicePosition: Vector3;
  14849. /**
  14850. * Represents device rotation in babylon space.
  14851. */
  14852. deviceRotationQuaternion: Quaternion;
  14853. /**
  14854. * The scale of the device to be used when translating from device space to babylon space.
  14855. */
  14856. deviceScaleFactor: number;
  14857. private _deviceToWorld;
  14858. private _worldToDevice;
  14859. /**
  14860. * References to the webVR controllers for the vrDevice.
  14861. */
  14862. controllers: Array<WebVRController>;
  14863. /**
  14864. * Emits an event when a controller is attached.
  14865. */
  14866. onControllersAttachedObservable: Observable<WebVRController[]>;
  14867. /**
  14868. * Emits an event when a controller's mesh has been loaded;
  14869. */
  14870. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14871. /**
  14872. * Emits an event when the HMD's pose has been updated.
  14873. */
  14874. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14875. private _poseSet;
  14876. /**
  14877. * If the rig cameras be used as parent instead of this camera.
  14878. */
  14879. rigParenting: boolean;
  14880. private _lightOnControllers;
  14881. private _defaultHeight?;
  14882. /**
  14883. * Instantiates a WebVRFreeCamera.
  14884. * @param name The name of the WebVRFreeCamera
  14885. * @param position The starting anchor position for the camera
  14886. * @param scene The scene the camera belongs to
  14887. * @param webVROptions a set of customizable options for the webVRCamera
  14888. */
  14889. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14890. /**
  14891. * Gets the device distance from the ground in meters.
  14892. * @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.
  14893. */
  14894. deviceDistanceToRoomGround(): number;
  14895. /**
  14896. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14897. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14898. */
  14899. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14900. /**
  14901. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14902. * @returns A promise with a boolean set to if the standing matrix is supported.
  14903. */
  14904. useStandingMatrixAsync(): Promise<boolean>;
  14905. /**
  14906. * Disposes the camera
  14907. */
  14908. dispose(): void;
  14909. /**
  14910. * Gets a vrController by name.
  14911. * @param name The name of the controller to retreive
  14912. * @returns the controller matching the name specified or null if not found
  14913. */
  14914. getControllerByName(name: string): Nullable<WebVRController>;
  14915. private _leftController;
  14916. /**
  14917. * The controller corresponding to the users left hand.
  14918. */
  14919. readonly leftController: Nullable<WebVRController>;
  14920. private _rightController;
  14921. /**
  14922. * The controller corresponding to the users right hand.
  14923. */
  14924. readonly rightController: Nullable<WebVRController>;
  14925. /**
  14926. * Casts a ray forward from the vrCamera's gaze.
  14927. * @param length Length of the ray (default: 100)
  14928. * @returns the ray corresponding to the gaze
  14929. */
  14930. getForwardRay(length?: number): Ray;
  14931. /**
  14932. * @hidden
  14933. * Updates the camera based on device's frame data
  14934. */ private _checkInputs(): void;
  14935. /**
  14936. * Updates the poseControlled values based on the input device pose.
  14937. * @param poseData Pose coming from the device
  14938. */
  14939. updateFromDevice(poseData: DevicePose): void;
  14940. private _htmlElementAttached;
  14941. private _detachIfAttached;
  14942. /**
  14943. * WebVR's attach control will start broadcasting frames to the device.
  14944. * Note that in certain browsers (chrome for example) this function must be called
  14945. * within a user-interaction callback. Example:
  14946. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14947. *
  14948. * @param element html element to attach the vrDevice to
  14949. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14950. */
  14951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14952. /**
  14953. * Detaches the camera from the html element and disables VR
  14954. *
  14955. * @param element html element to detach from
  14956. */
  14957. detachControl(element: HTMLElement): void;
  14958. /**
  14959. * @returns the name of this class
  14960. */
  14961. getClassName(): string;
  14962. /**
  14963. * Calls resetPose on the vrDisplay
  14964. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14965. */
  14966. resetToCurrentRotation(): void;
  14967. /**
  14968. * @hidden
  14969. * Updates the rig cameras (left and right eye)
  14970. */ private _updateRigCameras(): void;
  14971. private _workingVector;
  14972. private _oneVector;
  14973. private _workingMatrix;
  14974. private updateCacheCalled;
  14975. private _correctPositionIfNotTrackPosition;
  14976. /**
  14977. * @hidden
  14978. * Updates the cached values of the camera
  14979. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14980. */ private _updateCache(ignoreParentClass?: boolean): void;
  14981. /**
  14982. * @hidden
  14983. * Get current device position in babylon world
  14984. */ private _computeDevicePosition(): void;
  14985. /**
  14986. * Updates the current device position and rotation in the babylon world
  14987. */
  14988. update(): void;
  14989. /**
  14990. * @hidden
  14991. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14992. * @returns an identity matrix
  14993. */ private _getViewMatrix(): Matrix;
  14994. private _tmpMatrix;
  14995. /**
  14996. * This function is called by the two RIG cameras.
  14997. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14998. * @hidden
  14999. */ private _getWebVRViewMatrix(): Matrix;
  15000. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  15001. private _onGamepadConnectedObserver;
  15002. private _onGamepadDisconnectedObserver;
  15003. private _updateCacheWhenTrackingDisabledObserver;
  15004. /**
  15005. * Initializes the controllers and their meshes
  15006. */
  15007. initControllers(): void;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Size options for a post process
  15013. */
  15014. export type PostProcessOptions = {
  15015. width: number;
  15016. height: number;
  15017. };
  15018. /**
  15019. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15020. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15021. */
  15022. export class PostProcess {
  15023. /** Name of the PostProcess. */
  15024. name: string;
  15025. /**
  15026. * Gets or sets the unique id of the post process
  15027. */
  15028. uniqueId: number;
  15029. /**
  15030. * Width of the texture to apply the post process on
  15031. */
  15032. width: number;
  15033. /**
  15034. * Height of the texture to apply the post process on
  15035. */
  15036. height: number;
  15037. /**
  15038. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15039. * @hidden
  15040. */ private _outputTexture: Nullable<InternalTexture>;
  15041. /**
  15042. * Sampling mode used by the shader
  15043. * See https://doc.babylonjs.com/classes/3.1/texture
  15044. */
  15045. renderTargetSamplingMode: number;
  15046. /**
  15047. * Clear color to use when screen clearing
  15048. */
  15049. clearColor: Color4;
  15050. /**
  15051. * If the buffer needs to be cleared before applying the post process. (default: true)
  15052. * Should be set to false if shader will overwrite all previous pixels.
  15053. */
  15054. autoClear: boolean;
  15055. /**
  15056. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15057. */
  15058. alphaMode: number;
  15059. /**
  15060. * Sets the setAlphaBlendConstants of the babylon engine
  15061. */
  15062. alphaConstants: Color4;
  15063. /**
  15064. * Animations to be used for the post processing
  15065. */
  15066. animations: Animation[];
  15067. /**
  15068. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15069. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15070. */
  15071. enablePixelPerfectMode: boolean;
  15072. /**
  15073. * Force the postprocess to be applied without taking in account viewport
  15074. */
  15075. forceFullscreenViewport: boolean;
  15076. /**
  15077. * List of inspectable custom properties (used by the Inspector)
  15078. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15079. */
  15080. inspectableCustomProperties: IInspectable[];
  15081. /**
  15082. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15083. *
  15084. * | Value | Type | Description |
  15085. * | ----- | ----------------------------------- | ----------- |
  15086. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15087. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15088. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15089. *
  15090. */
  15091. scaleMode: number;
  15092. /**
  15093. * Force textures to be a power of two (default: false)
  15094. */
  15095. alwaysForcePOT: boolean;
  15096. private _samples;
  15097. /**
  15098. * Number of sample textures (default: 1)
  15099. */
  15100. samples: number;
  15101. /**
  15102. * Modify the scale of the post process to be the same as the viewport (default: false)
  15103. */
  15104. adaptScaleToCurrentViewport: boolean;
  15105. private _camera;
  15106. private _scene;
  15107. private _engine;
  15108. private _options;
  15109. private _reusable;
  15110. private _textureType;
  15111. /**
  15112. * Smart array of input and output textures for the post process.
  15113. * @hidden
  15114. */ private _textures: SmartArray<InternalTexture>;
  15115. /**
  15116. * The index in _textures that corresponds to the output texture.
  15117. * @hidden
  15118. */ private _currentRenderTextureInd: number;
  15119. private _effect;
  15120. private _samplers;
  15121. private _fragmentUrl;
  15122. private _vertexUrl;
  15123. private _parameters;
  15124. private _scaleRatio;
  15125. protected _indexParameters: any;
  15126. private _shareOutputWithPostProcess;
  15127. private _texelSize;
  15128. private _forcedOutputTexture;
  15129. /**
  15130. * Returns the fragment url or shader name used in the post process.
  15131. * @returns the fragment url or name in the shader store.
  15132. */
  15133. getEffectName(): string;
  15134. /**
  15135. * An event triggered when the postprocess is activated.
  15136. */
  15137. onActivateObservable: Observable<Camera>;
  15138. private _onActivateObserver;
  15139. /**
  15140. * A function that is added to the onActivateObservable
  15141. */
  15142. onActivate: Nullable<(camera: Camera) => void>;
  15143. /**
  15144. * An event triggered when the postprocess changes its size.
  15145. */
  15146. onSizeChangedObservable: Observable<PostProcess>;
  15147. private _onSizeChangedObserver;
  15148. /**
  15149. * A function that is added to the onSizeChangedObservable
  15150. */
  15151. onSizeChanged: (postProcess: PostProcess) => void;
  15152. /**
  15153. * An event triggered when the postprocess applies its effect.
  15154. */
  15155. onApplyObservable: Observable<Effect>;
  15156. private _onApplyObserver;
  15157. /**
  15158. * A function that is added to the onApplyObservable
  15159. */
  15160. onApply: (effect: Effect) => void;
  15161. /**
  15162. * An event triggered before rendering the postprocess
  15163. */
  15164. onBeforeRenderObservable: Observable<Effect>;
  15165. private _onBeforeRenderObserver;
  15166. /**
  15167. * A function that is added to the onBeforeRenderObservable
  15168. */
  15169. onBeforeRender: (effect: Effect) => void;
  15170. /**
  15171. * An event triggered after rendering the postprocess
  15172. */
  15173. onAfterRenderObservable: Observable<Effect>;
  15174. private _onAfterRenderObserver;
  15175. /**
  15176. * A function that is added to the onAfterRenderObservable
  15177. */
  15178. onAfterRender: (efect: Effect) => void;
  15179. /**
  15180. * 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
  15181. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15182. */
  15183. inputTexture: InternalTexture;
  15184. /**
  15185. * Gets the camera which post process is applied to.
  15186. * @returns The camera the post process is applied to.
  15187. */
  15188. getCamera(): Camera;
  15189. /**
  15190. * Gets the texel size of the postprocess.
  15191. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15192. */
  15193. readonly texelSize: Vector2;
  15194. /**
  15195. * Creates a new instance PostProcess
  15196. * @param name The name of the PostProcess.
  15197. * @param fragmentUrl The url of the fragment shader to be used.
  15198. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15199. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15200. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15201. * @param camera The camera to apply the render pass to.
  15202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15203. * @param engine The engine which the post process will be applied. (default: current engine)
  15204. * @param reusable If the post process can be reused on the same frame. (default: false)
  15205. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15206. * @param textureType Type of textures used when performing the post process. (default: 0)
  15207. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15208. * @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
  15209. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15210. */
  15211. constructor(
  15212. /** Name of the PostProcess. */
  15213. 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);
  15214. /**
  15215. * Gets a string idenfifying the name of the class
  15216. * @returns "PostProcess" string
  15217. */
  15218. getClassName(): string;
  15219. /**
  15220. * Gets the engine which this post process belongs to.
  15221. * @returns The engine the post process was enabled with.
  15222. */
  15223. getEngine(): Engine;
  15224. /**
  15225. * The effect that is created when initializing the post process.
  15226. * @returns The created effect corresponding the the postprocess.
  15227. */
  15228. getEffect(): Effect;
  15229. /**
  15230. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15231. * @param postProcess The post process to share the output with.
  15232. * @returns This post process.
  15233. */
  15234. shareOutputWith(postProcess: PostProcess): PostProcess;
  15235. /**
  15236. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15237. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15238. */
  15239. useOwnOutput(): void;
  15240. /**
  15241. * Updates the effect with the current post process compile time values and recompiles the shader.
  15242. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15243. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15244. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15245. * @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
  15246. * @param onCompiled Called when the shader has been compiled.
  15247. * @param onError Called if there is an error when compiling a shader.
  15248. */
  15249. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15250. /**
  15251. * The post process is reusable if it can be used multiple times within one frame.
  15252. * @returns If the post process is reusable
  15253. */
  15254. isReusable(): boolean;
  15255. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15256. markTextureDirty(): void;
  15257. /**
  15258. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15259. * 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.
  15260. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15261. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15262. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15263. * @returns The target texture that was bound to be written to.
  15264. */
  15265. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15266. /**
  15267. * If the post process is supported.
  15268. */
  15269. readonly isSupported: boolean;
  15270. /**
  15271. * The aspect ratio of the output texture.
  15272. */
  15273. readonly aspectRatio: number;
  15274. /**
  15275. * Get a value indicating if the post-process is ready to be used
  15276. * @returns true if the post-process is ready (shader is compiled)
  15277. */
  15278. isReady(): boolean;
  15279. /**
  15280. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15281. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15282. */
  15283. apply(): Nullable<Effect>;
  15284. private _disposeTextures;
  15285. /**
  15286. * Disposes the post process.
  15287. * @param camera The camera to dispose the post process on.
  15288. */
  15289. dispose(camera?: Camera): void;
  15290. }
  15291. }
  15292. declare module BABYLON {
  15293. /** @hidden */
  15294. export var kernelBlurVaryingDeclaration: {
  15295. name: string;
  15296. shader: string;
  15297. };
  15298. }
  15299. declare module BABYLON {
  15300. /** @hidden */
  15301. export var kernelBlurFragment: {
  15302. name: string;
  15303. shader: string;
  15304. };
  15305. }
  15306. declare module BABYLON {
  15307. /** @hidden */
  15308. export var kernelBlurFragment2: {
  15309. name: string;
  15310. shader: string;
  15311. };
  15312. }
  15313. declare module BABYLON {
  15314. /** @hidden */
  15315. export var kernelBlurPixelShader: {
  15316. name: string;
  15317. shader: string;
  15318. };
  15319. }
  15320. declare module BABYLON {
  15321. /** @hidden */
  15322. export var kernelBlurVertex: {
  15323. name: string;
  15324. shader: string;
  15325. };
  15326. }
  15327. declare module BABYLON {
  15328. /** @hidden */
  15329. export var kernelBlurVertexShader: {
  15330. name: string;
  15331. shader: string;
  15332. };
  15333. }
  15334. declare module BABYLON {
  15335. /**
  15336. * The Blur Post Process which blurs an image based on a kernel and direction.
  15337. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15338. */
  15339. export class BlurPostProcess extends PostProcess {
  15340. /** The direction in which to blur the image. */
  15341. direction: Vector2;
  15342. private blockCompilation;
  15343. protected _kernel: number;
  15344. protected _idealKernel: number;
  15345. protected _packedFloat: boolean;
  15346. private _staticDefines;
  15347. /**
  15348. * Sets the length in pixels of the blur sample region
  15349. */
  15350. /**
  15351. * Gets the length in pixels of the blur sample region
  15352. */
  15353. kernel: number;
  15354. /**
  15355. * Sets wether or not the blur needs to unpack/repack floats
  15356. */
  15357. /**
  15358. * Gets wether or not the blur is unpacking/repacking floats
  15359. */
  15360. packedFloat: boolean;
  15361. /**
  15362. * Creates a new instance BlurPostProcess
  15363. * @param name The name of the effect.
  15364. * @param direction The direction in which to blur the image.
  15365. * @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.
  15366. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15367. * @param camera The camera to apply the render pass to.
  15368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15369. * @param engine The engine which the post process will be applied. (default: current engine)
  15370. * @param reusable If the post process can be reused on the same frame. (default: false)
  15371. * @param textureType Type of textures used when performing the post process. (default: 0)
  15372. * @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)
  15373. */
  15374. constructor(name: string,
  15375. /** The direction in which to blur the image. */
  15376. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15377. /**
  15378. * Updates the effect with the current post process compile time values and recompiles the shader.
  15379. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15380. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15381. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15382. * @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
  15383. * @param onCompiled Called when the shader has been compiled.
  15384. * @param onError Called if there is an error when compiling a shader.
  15385. */
  15386. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15387. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15388. /**
  15389. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15390. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15391. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15392. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15393. * The gaps between physical kernels are compensated for in the weighting of the samples
  15394. * @param idealKernel Ideal blur kernel.
  15395. * @return Nearest best kernel.
  15396. */
  15397. protected _nearestBestKernel(idealKernel: number): number;
  15398. /**
  15399. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15400. * @param x The point on the Gaussian distribution to sample.
  15401. * @return the value of the Gaussian function at x.
  15402. */
  15403. protected _gaussianWeight(x: number): number;
  15404. /**
  15405. * Generates a string that can be used as a floating point number in GLSL.
  15406. * @param x Value to print.
  15407. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15408. * @return GLSL float string.
  15409. */
  15410. protected _glslFloat(x: number, decimalFigures?: number): string;
  15411. }
  15412. }
  15413. declare module BABYLON {
  15414. /**
  15415. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15416. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15417. * You can then easily use it as a reflectionTexture on a flat surface.
  15418. * In case the surface is not a plane, please consider relying on reflection probes.
  15419. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15420. */
  15421. export class MirrorTexture extends RenderTargetTexture {
  15422. private scene;
  15423. /**
  15424. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15425. * 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.
  15426. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15427. */
  15428. mirrorPlane: Plane;
  15429. /**
  15430. * Define the blur ratio used to blur the reflection if needed.
  15431. */
  15432. blurRatio: number;
  15433. /**
  15434. * Define the adaptive blur kernel used to blur the reflection if needed.
  15435. * This will autocompute the closest best match for the `blurKernel`
  15436. */
  15437. adaptiveBlurKernel: number;
  15438. /**
  15439. * Define the blur kernel used to blur the reflection if needed.
  15440. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15441. */
  15442. blurKernel: number;
  15443. /**
  15444. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15445. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15446. */
  15447. blurKernelX: number;
  15448. /**
  15449. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15450. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15451. */
  15452. blurKernelY: number;
  15453. private _autoComputeBlurKernel;
  15454. protected _onRatioRescale(): void;
  15455. private _updateGammaSpace;
  15456. private _imageProcessingConfigChangeObserver;
  15457. private _transformMatrix;
  15458. private _mirrorMatrix;
  15459. private _savedViewMatrix;
  15460. private _blurX;
  15461. private _blurY;
  15462. private _adaptiveBlurKernel;
  15463. private _blurKernelX;
  15464. private _blurKernelY;
  15465. private _blurRatio;
  15466. /**
  15467. * Instantiates a Mirror Texture.
  15468. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15469. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15470. * You can then easily use it as a reflectionTexture on a flat surface.
  15471. * In case the surface is not a plane, please consider relying on reflection probes.
  15472. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15473. * @param name
  15474. * @param size
  15475. * @param scene
  15476. * @param generateMipMaps
  15477. * @param type
  15478. * @param samplingMode
  15479. * @param generateDepthBuffer
  15480. */
  15481. constructor(name: string, size: number | {
  15482. width: number;
  15483. height: number;
  15484. } | {
  15485. ratio: number;
  15486. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15487. private _preparePostProcesses;
  15488. /**
  15489. * Clone the mirror texture.
  15490. * @returns the cloned texture
  15491. */
  15492. clone(): MirrorTexture;
  15493. /**
  15494. * Serialize the texture to a JSON representation you could use in Parse later on
  15495. * @returns the serialized JSON representation
  15496. */
  15497. serialize(): any;
  15498. /**
  15499. * Dispose the texture and release its associated resources.
  15500. */
  15501. dispose(): void;
  15502. }
  15503. }
  15504. declare module BABYLON {
  15505. /**
  15506. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15507. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15508. */
  15509. export class Texture extends BaseTexture {
  15510. /**
  15511. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15512. */
  15513. static SerializeBuffers: boolean;
  15514. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15515. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15516. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15517. /** nearest is mag = nearest and min = nearest and mip = linear */
  15518. static readonly NEAREST_SAMPLINGMODE: number;
  15519. /** nearest is mag = nearest and min = nearest and mip = linear */
  15520. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15521. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15522. static readonly BILINEAR_SAMPLINGMODE: number;
  15523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15524. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15525. /** Trilinear is mag = linear and min = linear and mip = linear */
  15526. static readonly TRILINEAR_SAMPLINGMODE: number;
  15527. /** Trilinear is mag = linear and min = linear and mip = linear */
  15528. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15529. /** mag = nearest and min = nearest and mip = nearest */
  15530. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15531. /** mag = nearest and min = linear and mip = nearest */
  15532. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15533. /** mag = nearest and min = linear and mip = linear */
  15534. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15535. /** mag = nearest and min = linear and mip = none */
  15536. static readonly NEAREST_LINEAR: number;
  15537. /** mag = nearest and min = nearest and mip = none */
  15538. static readonly NEAREST_NEAREST: number;
  15539. /** mag = linear and min = nearest and mip = nearest */
  15540. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15541. /** mag = linear and min = nearest and mip = linear */
  15542. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15543. /** mag = linear and min = linear and mip = none */
  15544. static readonly LINEAR_LINEAR: number;
  15545. /** mag = linear and min = nearest and mip = none */
  15546. static readonly LINEAR_NEAREST: number;
  15547. /** Explicit coordinates mode */
  15548. static readonly EXPLICIT_MODE: number;
  15549. /** Spherical coordinates mode */
  15550. static readonly SPHERICAL_MODE: number;
  15551. /** Planar coordinates mode */
  15552. static readonly PLANAR_MODE: number;
  15553. /** Cubic coordinates mode */
  15554. static readonly CUBIC_MODE: number;
  15555. /** Projection coordinates mode */
  15556. static readonly PROJECTION_MODE: number;
  15557. /** Inverse Cubic coordinates mode */
  15558. static readonly SKYBOX_MODE: number;
  15559. /** Inverse Cubic coordinates mode */
  15560. static readonly INVCUBIC_MODE: number;
  15561. /** Equirectangular coordinates mode */
  15562. static readonly EQUIRECTANGULAR_MODE: number;
  15563. /** Equirectangular Fixed coordinates mode */
  15564. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15565. /** Equirectangular Fixed Mirrored coordinates mode */
  15566. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15567. /** Texture is not repeating outside of 0..1 UVs */
  15568. static readonly CLAMP_ADDRESSMODE: number;
  15569. /** Texture is repeating outside of 0..1 UVs */
  15570. static readonly WRAP_ADDRESSMODE: number;
  15571. /** Texture is repeating and mirrored */
  15572. static readonly MIRROR_ADDRESSMODE: number;
  15573. /**
  15574. * 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
  15575. */
  15576. static UseSerializedUrlIfAny: boolean;
  15577. /**
  15578. * Define the url of the texture.
  15579. */
  15580. url: Nullable<string>;
  15581. /**
  15582. * Define an offset on the texture to offset the u coordinates of the UVs
  15583. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15584. */
  15585. uOffset: number;
  15586. /**
  15587. * Define an offset on the texture to offset the v coordinates of the UVs
  15588. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15589. */
  15590. vOffset: number;
  15591. /**
  15592. * Define an offset on the texture to scale the u coordinates of the UVs
  15593. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15594. */
  15595. uScale: number;
  15596. /**
  15597. * Define an offset on the texture to scale the v coordinates of the UVs
  15598. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15599. */
  15600. vScale: number;
  15601. /**
  15602. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15603. * @see http://doc.babylonjs.com/how_to/more_materials
  15604. */
  15605. uAng: number;
  15606. /**
  15607. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15608. * @see http://doc.babylonjs.com/how_to/more_materials
  15609. */
  15610. vAng: number;
  15611. /**
  15612. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15613. * @see http://doc.babylonjs.com/how_to/more_materials
  15614. */
  15615. wAng: number;
  15616. /**
  15617. * Defines the center of rotation (U)
  15618. */
  15619. uRotationCenter: number;
  15620. /**
  15621. * Defines the center of rotation (V)
  15622. */
  15623. vRotationCenter: number;
  15624. /**
  15625. * Defines the center of rotation (W)
  15626. */
  15627. wRotationCenter: number;
  15628. /**
  15629. * Are mip maps generated for this texture or not.
  15630. */
  15631. readonly noMipmap: boolean;
  15632. /**
  15633. * List of inspectable custom properties (used by the Inspector)
  15634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15635. */
  15636. inspectableCustomProperties: Nullable<IInspectable[]>;
  15637. private _noMipmap;
  15638. /** @hidden */ private _invertY: boolean;
  15639. private _rowGenerationMatrix;
  15640. private _cachedTextureMatrix;
  15641. private _projectionModeMatrix;
  15642. private _t0;
  15643. private _t1;
  15644. private _t2;
  15645. private _cachedUOffset;
  15646. private _cachedVOffset;
  15647. private _cachedUScale;
  15648. private _cachedVScale;
  15649. private _cachedUAng;
  15650. private _cachedVAng;
  15651. private _cachedWAng;
  15652. private _cachedProjectionMatrixId;
  15653. private _cachedCoordinatesMode;
  15654. /** @hidden */
  15655. protected _initialSamplingMode: number;
  15656. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15657. private _deleteBuffer;
  15658. protected _format: Nullable<number>;
  15659. private _delayedOnLoad;
  15660. private _delayedOnError;
  15661. /**
  15662. * Observable triggered once the texture has been loaded.
  15663. */
  15664. onLoadObservable: Observable<Texture>;
  15665. protected _isBlocking: boolean;
  15666. /**
  15667. * Is the texture preventing material to render while loading.
  15668. * If false, a default texture will be used instead of the loading one during the preparation step.
  15669. */
  15670. isBlocking: boolean;
  15671. /**
  15672. * Get the current sampling mode associated with the texture.
  15673. */
  15674. readonly samplingMode: number;
  15675. /**
  15676. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15677. */
  15678. readonly invertY: boolean;
  15679. /**
  15680. * Instantiates a new texture.
  15681. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15682. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15683. * @param url define the url of the picture to load as a texture
  15684. * @param scene define the scene or engine the texture will belong to
  15685. * @param noMipmap define if the texture will require mip maps or not
  15686. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15687. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15688. * @param onLoad define a callback triggered when the texture has been loaded
  15689. * @param onError define a callback triggered when an error occurred during the loading session
  15690. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15691. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15692. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15693. */
  15694. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15695. /**
  15696. * Update the url (and optional buffer) of this texture if url was null during construction.
  15697. * @param url the url of the texture
  15698. * @param buffer the buffer of the texture (defaults to null)
  15699. * @param onLoad callback called when the texture is loaded (defaults to null)
  15700. */
  15701. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15702. /**
  15703. * Finish the loading sequence of a texture flagged as delayed load.
  15704. * @hidden
  15705. */
  15706. delayLoad(): void;
  15707. private _prepareRowForTextureGeneration;
  15708. /**
  15709. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15710. * @returns the transform matrix of the texture.
  15711. */
  15712. getTextureMatrix(): Matrix;
  15713. /**
  15714. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15715. * @returns The reflection texture transform
  15716. */
  15717. getReflectionTextureMatrix(): Matrix;
  15718. /**
  15719. * Clones the texture.
  15720. * @returns the cloned texture
  15721. */
  15722. clone(): Texture;
  15723. /**
  15724. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15725. * @returns The JSON representation of the texture
  15726. */
  15727. serialize(): any;
  15728. /**
  15729. * Get the current class name of the texture useful for serialization or dynamic coding.
  15730. * @returns "Texture"
  15731. */
  15732. getClassName(): string;
  15733. /**
  15734. * Dispose the texture and release its associated resources.
  15735. */
  15736. dispose(): void;
  15737. /**
  15738. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15739. * @param parsedTexture Define the JSON representation of the texture
  15740. * @param scene Define the scene the parsed texture should be instantiated in
  15741. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15742. * @returns The parsed texture if successful
  15743. */
  15744. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15745. /**
  15746. * Creates a texture from its base 64 representation.
  15747. * @param data Define the base64 payload without the data: prefix
  15748. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15749. * @param scene Define the scene the texture should belong to
  15750. * @param noMipmap Forces the texture to not create mip map information if true
  15751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15753. * @param onLoad define a callback triggered when the texture has been loaded
  15754. * @param onError define a callback triggered when an error occurred during the loading session
  15755. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15756. * @returns the created texture
  15757. */
  15758. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15759. /**
  15760. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15761. * @param data Define the base64 payload without the data: prefix
  15762. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15763. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15764. * @param scene Define the scene the texture should belong to
  15765. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15766. * @param noMipmap Forces the texture to not create mip map information if true
  15767. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15768. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15769. * @param onLoad define a callback triggered when the texture has been loaded
  15770. * @param onError define a callback triggered when an error occurred during the loading session
  15771. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15772. * @returns the created texture
  15773. */
  15774. 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;
  15775. }
  15776. }
  15777. declare module BABYLON {
  15778. /**
  15779. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15780. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15781. */
  15782. export class PostProcessManager {
  15783. private _scene;
  15784. private _indexBuffer;
  15785. private _vertexBuffers;
  15786. /**
  15787. * Creates a new instance PostProcess
  15788. * @param scene The scene that the post process is associated with.
  15789. */
  15790. constructor(scene: Scene);
  15791. private _prepareBuffers;
  15792. private _buildIndexBuffer;
  15793. /**
  15794. * Rebuilds the vertex buffers of the manager.
  15795. * @hidden
  15796. */ private _rebuild(): void;
  15797. /**
  15798. * Prepares a frame to be run through a post process.
  15799. * @param sourceTexture The input texture to the post procesess. (default: null)
  15800. * @param postProcesses An array of post processes to be run. (default: null)
  15801. * @returns True if the post processes were able to be run.
  15802. * @hidden
  15803. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15804. /**
  15805. * Manually render a set of post processes to a texture.
  15806. * @param postProcesses An array of post processes to be run.
  15807. * @param targetTexture The target texture to render to.
  15808. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15809. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15810. * @param lodLevel defines which lod of the texture to render to
  15811. */
  15812. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15813. /**
  15814. * Finalize the result of the output of the postprocesses.
  15815. * @param doNotPresent If true the result will not be displayed to the screen.
  15816. * @param targetTexture The target texture to render to.
  15817. * @param faceIndex The index of the face to bind the target texture to.
  15818. * @param postProcesses The array of post processes to render.
  15819. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15820. * @hidden
  15821. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15822. /**
  15823. * Disposes of the post process manager.
  15824. */
  15825. dispose(): void;
  15826. }
  15827. }
  15828. declare module BABYLON {
  15829. /** Interface used by value gradients (color, factor, ...) */
  15830. export interface IValueGradient {
  15831. /**
  15832. * Gets or sets the gradient value (between 0 and 1)
  15833. */
  15834. gradient: number;
  15835. }
  15836. /** Class used to store color4 gradient */
  15837. export class ColorGradient implements IValueGradient {
  15838. /**
  15839. * Gets or sets the gradient value (between 0 and 1)
  15840. */
  15841. gradient: number;
  15842. /**
  15843. * Gets or sets first associated color
  15844. */
  15845. color1: Color4;
  15846. /**
  15847. * Gets or sets second associated color
  15848. */
  15849. color2?: Color4;
  15850. /**
  15851. * Will get a color picked randomly between color1 and color2.
  15852. * If color2 is undefined then color1 will be used
  15853. * @param result defines the target Color4 to store the result in
  15854. */
  15855. getColorToRef(result: Color4): void;
  15856. }
  15857. /** Class used to store color 3 gradient */
  15858. export class Color3Gradient implements IValueGradient {
  15859. /**
  15860. * Gets or sets the gradient value (between 0 and 1)
  15861. */
  15862. gradient: number;
  15863. /**
  15864. * Gets or sets the associated color
  15865. */
  15866. color: Color3;
  15867. }
  15868. /** Class used to store factor gradient */
  15869. export class FactorGradient implements IValueGradient {
  15870. /**
  15871. * Gets or sets the gradient value (between 0 and 1)
  15872. */
  15873. gradient: number;
  15874. /**
  15875. * Gets or sets first associated factor
  15876. */
  15877. factor1: number;
  15878. /**
  15879. * Gets or sets second associated factor
  15880. */
  15881. factor2?: number;
  15882. /**
  15883. * Will get a number picked randomly between factor1 and factor2.
  15884. * If factor2 is undefined then factor1 will be used
  15885. * @returns the picked number
  15886. */
  15887. getFactor(): number;
  15888. }
  15889. /**
  15890. * Helper used to simplify some generic gradient tasks
  15891. */
  15892. export class GradientHelper {
  15893. /**
  15894. * Gets the current gradient from an array of IValueGradient
  15895. * @param ratio defines the current ratio to get
  15896. * @param gradients defines the array of IValueGradient
  15897. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15898. */
  15899. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15900. }
  15901. }
  15902. declare module BABYLON {
  15903. interface ThinEngine {
  15904. /**
  15905. * Creates a dynamic texture
  15906. * @param width defines the width of the texture
  15907. * @param height defines the height of the texture
  15908. * @param generateMipMaps defines if the engine should generate the mip levels
  15909. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15910. * @returns the dynamic texture inside an InternalTexture
  15911. */
  15912. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15913. /**
  15914. * Update the content of a dynamic texture
  15915. * @param texture defines the texture to update
  15916. * @param canvas defines the canvas containing the source
  15917. * @param invertY defines if data must be stored with Y axis inverted
  15918. * @param premulAlpha defines if alpha is stored as premultiplied
  15919. * @param format defines the format of the data
  15920. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15921. */
  15922. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15923. }
  15924. }
  15925. declare module BABYLON {
  15926. /**
  15927. * A class extending Texture allowing drawing on a texture
  15928. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15929. */
  15930. export class DynamicTexture extends Texture {
  15931. private _generateMipMaps;
  15932. private _canvas;
  15933. private _context;
  15934. private _engine;
  15935. /**
  15936. * Creates a DynamicTexture
  15937. * @param name defines the name of the texture
  15938. * @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
  15939. * @param scene defines the scene where you want the texture
  15940. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15941. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15942. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15943. */
  15944. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15945. /**
  15946. * Get the current class name of the texture useful for serialization or dynamic coding.
  15947. * @returns "DynamicTexture"
  15948. */
  15949. getClassName(): string;
  15950. /**
  15951. * Gets the current state of canRescale
  15952. */
  15953. readonly canRescale: boolean;
  15954. private _recreate;
  15955. /**
  15956. * Scales the texture
  15957. * @param ratio the scale factor to apply to both width and height
  15958. */
  15959. scale(ratio: number): void;
  15960. /**
  15961. * Resizes the texture
  15962. * @param width the new width
  15963. * @param height the new height
  15964. */
  15965. scaleTo(width: number, height: number): void;
  15966. /**
  15967. * Gets the context of the canvas used by the texture
  15968. * @returns the canvas context of the dynamic texture
  15969. */
  15970. getContext(): CanvasRenderingContext2D;
  15971. /**
  15972. * Clears the texture
  15973. */
  15974. clear(): void;
  15975. /**
  15976. * Updates the texture
  15977. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15978. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15979. */
  15980. update(invertY?: boolean, premulAlpha?: boolean): void;
  15981. /**
  15982. * Draws text onto the texture
  15983. * @param text defines the text to be drawn
  15984. * @param x defines the placement of the text from the left
  15985. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15986. * @param font defines the font to be used with font-style, font-size, font-name
  15987. * @param color defines the color used for the text
  15988. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15989. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15990. * @param update defines whether texture is immediately update (default is true)
  15991. */
  15992. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15993. /**
  15994. * Clones the texture
  15995. * @returns the clone of the texture.
  15996. */
  15997. clone(): DynamicTexture;
  15998. /**
  15999. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16000. * @returns a serialized dynamic texture object
  16001. */
  16002. serialize(): any;
  16003. /** @hidden */ private _rebuild(): void;
  16004. }
  16005. }
  16006. declare module BABYLON {
  16007. interface AbstractScene {
  16008. /**
  16009. * The list of procedural textures added to the scene
  16010. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16011. */
  16012. proceduralTextures: Array<ProceduralTexture>;
  16013. }
  16014. /**
  16015. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16016. * in a given scene.
  16017. */
  16018. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16019. /**
  16020. * The component name helpfull to identify the component in the list of scene components.
  16021. */
  16022. readonly name: string;
  16023. /**
  16024. * The scene the component belongs to.
  16025. */
  16026. scene: Scene;
  16027. /**
  16028. * Creates a new instance of the component for the given scene
  16029. * @param scene Defines the scene to register the component in
  16030. */
  16031. constructor(scene: Scene);
  16032. /**
  16033. * Registers the component in a given scene
  16034. */
  16035. register(): void;
  16036. /**
  16037. * Rebuilds the elements related to this component in case of
  16038. * context lost for instance.
  16039. */
  16040. rebuild(): void;
  16041. /**
  16042. * Disposes the component and the associated ressources.
  16043. */
  16044. dispose(): void;
  16045. private _beforeClear;
  16046. }
  16047. }
  16048. declare module BABYLON {
  16049. interface ThinEngine {
  16050. /**
  16051. * Creates a new render target cube texture
  16052. * @param size defines the size of the texture
  16053. * @param options defines the options used to create the texture
  16054. * @returns a new render target cube texture stored in an InternalTexture
  16055. */
  16056. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16057. }
  16058. }
  16059. declare module BABYLON {
  16060. /** @hidden */
  16061. export var proceduralVertexShader: {
  16062. name: string;
  16063. shader: string;
  16064. };
  16065. }
  16066. declare module BABYLON {
  16067. /**
  16068. * 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.
  16069. * This is the base class of any Procedural texture and contains most of the shareable code.
  16070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16071. */
  16072. export class ProceduralTexture extends Texture {
  16073. isCube: boolean;
  16074. /**
  16075. * Define if the texture is enabled or not (disabled texture will not render)
  16076. */
  16077. isEnabled: boolean;
  16078. /**
  16079. * Define if the texture must be cleared before rendering (default is true)
  16080. */
  16081. autoClear: boolean;
  16082. /**
  16083. * Callback called when the texture is generated
  16084. */
  16085. onGenerated: () => void;
  16086. /**
  16087. * Event raised when the texture is generated
  16088. */
  16089. onGeneratedObservable: Observable<ProceduralTexture>;
  16090. /** @hidden */ private _generateMipMaps: boolean;
  16091. /** @hidden **/ private _effect: Effect;
  16092. /** @hidden */ private _textures: {
  16093. [key: string]: Texture;
  16094. };
  16095. private _size;
  16096. private _currentRefreshId;
  16097. private _refreshRate;
  16098. private _vertexBuffers;
  16099. private _indexBuffer;
  16100. private _uniforms;
  16101. private _samplers;
  16102. private _fragment;
  16103. private _floats;
  16104. private _ints;
  16105. private _floatsArrays;
  16106. private _colors3;
  16107. private _colors4;
  16108. private _vectors2;
  16109. private _vectors3;
  16110. private _matrices;
  16111. private _fallbackTexture;
  16112. private _fallbackTextureUsed;
  16113. private _engine;
  16114. private _cachedDefines;
  16115. private _contentUpdateId;
  16116. private _contentData;
  16117. /**
  16118. * Instantiates a new procedural texture.
  16119. * 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.
  16120. * This is the base class of any Procedural texture and contains most of the shareable code.
  16121. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16122. * @param name Define the name of the texture
  16123. * @param size Define the size of the texture to create
  16124. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16125. * @param scene Define the scene the texture belongs to
  16126. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16127. * @param generateMipMaps Define if the texture should creates mip maps or not
  16128. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16129. */
  16130. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16131. /**
  16132. * The effect that is created when initializing the post process.
  16133. * @returns The created effect corresponding the the postprocess.
  16134. */
  16135. getEffect(): Effect;
  16136. /**
  16137. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16138. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16139. */
  16140. getContent(): Nullable<ArrayBufferView>;
  16141. private _createIndexBuffer;
  16142. /** @hidden */ private _rebuild(): void;
  16143. /**
  16144. * Resets the texture in order to recreate its associated resources.
  16145. * This can be called in case of context loss
  16146. */
  16147. reset(): void;
  16148. protected _getDefines(): string;
  16149. /**
  16150. * Is the texture ready to be used ? (rendered at least once)
  16151. * @returns true if ready, otherwise, false.
  16152. */
  16153. isReady(): boolean;
  16154. /**
  16155. * Resets the refresh counter of the texture and start bak from scratch.
  16156. * Could be useful to regenerate the texture if it is setup to render only once.
  16157. */
  16158. resetRefreshCounter(): void;
  16159. /**
  16160. * Set the fragment shader to use in order to render the texture.
  16161. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16162. */
  16163. setFragment(fragment: any): void;
  16164. /**
  16165. * Define the refresh rate of the texture or the rendering frequency.
  16166. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16167. */
  16168. refreshRate: number;
  16169. /** @hidden */ private _shouldRender(): boolean;
  16170. /**
  16171. * Get the size the texture is rendering at.
  16172. * @returns the size (texture is always squared)
  16173. */
  16174. getRenderSize(): number;
  16175. /**
  16176. * Resize the texture to new value.
  16177. * @param size Define the new size the texture should have
  16178. * @param generateMipMaps Define whether the new texture should create mip maps
  16179. */
  16180. resize(size: number, generateMipMaps: boolean): void;
  16181. private _checkUniform;
  16182. /**
  16183. * Set a texture in the shader program used to render.
  16184. * @param name Define the name of the uniform samplers as defined in the shader
  16185. * @param texture Define the texture to bind to this sampler
  16186. * @return the texture itself allowing "fluent" like uniform updates
  16187. */
  16188. setTexture(name: string, texture: Texture): ProceduralTexture;
  16189. /**
  16190. * Set a float in the shader.
  16191. * @param name Define the name of the uniform as defined in the shader
  16192. * @param value Define the value to give to the uniform
  16193. * @return the texture itself allowing "fluent" like uniform updates
  16194. */
  16195. setFloat(name: string, value: number): ProceduralTexture;
  16196. /**
  16197. * Set a int in the shader.
  16198. * @param name Define the name of the uniform as defined in the shader
  16199. * @param value Define the value to give to the uniform
  16200. * @return the texture itself allowing "fluent" like uniform updates
  16201. */
  16202. setInt(name: string, value: number): ProceduralTexture;
  16203. /**
  16204. * Set an array of floats in the shader.
  16205. * @param name Define the name of the uniform as defined in the shader
  16206. * @param value Define the value to give to the uniform
  16207. * @return the texture itself allowing "fluent" like uniform updates
  16208. */
  16209. setFloats(name: string, value: number[]): ProceduralTexture;
  16210. /**
  16211. * Set a vec3 in the shader from a Color3.
  16212. * @param name Define the name of the uniform as defined in the shader
  16213. * @param value Define the value to give to the uniform
  16214. * @return the texture itself allowing "fluent" like uniform updates
  16215. */
  16216. setColor3(name: string, value: Color3): ProceduralTexture;
  16217. /**
  16218. * Set a vec4 in the shader from a Color4.
  16219. * @param name Define the name of the uniform as defined in the shader
  16220. * @param value Define the value to give to the uniform
  16221. * @return the texture itself allowing "fluent" like uniform updates
  16222. */
  16223. setColor4(name: string, value: Color4): ProceduralTexture;
  16224. /**
  16225. * Set a vec2 in the shader from a Vector2.
  16226. * @param name Define the name of the uniform as defined in the shader
  16227. * @param value Define the value to give to the uniform
  16228. * @return the texture itself allowing "fluent" like uniform updates
  16229. */
  16230. setVector2(name: string, value: Vector2): ProceduralTexture;
  16231. /**
  16232. * Set a vec3 in the shader from a Vector3.
  16233. * @param name Define the name of the uniform as defined in the shader
  16234. * @param value Define the value to give to the uniform
  16235. * @return the texture itself allowing "fluent" like uniform updates
  16236. */
  16237. setVector3(name: string, value: Vector3): ProceduralTexture;
  16238. /**
  16239. * Set a mat4 in the shader from a MAtrix.
  16240. * @param name Define the name of the uniform as defined in the shader
  16241. * @param value Define the value to give to the uniform
  16242. * @return the texture itself allowing "fluent" like uniform updates
  16243. */
  16244. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16245. /**
  16246. * Render the texture to its associated render target.
  16247. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16248. */
  16249. render(useCameraPostProcess?: boolean): void;
  16250. /**
  16251. * Clone the texture.
  16252. * @returns the cloned texture
  16253. */
  16254. clone(): ProceduralTexture;
  16255. /**
  16256. * Dispose the texture and release its asoociated resources.
  16257. */
  16258. dispose(): void;
  16259. }
  16260. }
  16261. declare module BABYLON {
  16262. /**
  16263. * This represents the base class for particle system in Babylon.
  16264. * 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.
  16265. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16266. * @example https://doc.babylonjs.com/babylon101/particles
  16267. */
  16268. export class BaseParticleSystem {
  16269. /**
  16270. * Source color is added to the destination color without alpha affecting the result
  16271. */
  16272. static BLENDMODE_ONEONE: number;
  16273. /**
  16274. * Blend current color and particle color using particle’s alpha
  16275. */
  16276. static BLENDMODE_STANDARD: number;
  16277. /**
  16278. * Add current color and particle color multiplied by particle’s alpha
  16279. */
  16280. static BLENDMODE_ADD: number;
  16281. /**
  16282. * Multiply current color with particle color
  16283. */
  16284. static BLENDMODE_MULTIPLY: number;
  16285. /**
  16286. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16287. */
  16288. static BLENDMODE_MULTIPLYADD: number;
  16289. /**
  16290. * List of animations used by the particle system.
  16291. */
  16292. animations: Animation[];
  16293. /**
  16294. * The id of the Particle system.
  16295. */
  16296. id: string;
  16297. /**
  16298. * The friendly name of the Particle system.
  16299. */
  16300. name: string;
  16301. /**
  16302. * The rendering group used by the Particle system to chose when to render.
  16303. */
  16304. renderingGroupId: number;
  16305. /**
  16306. * The emitter represents the Mesh or position we are attaching the particle system to.
  16307. */
  16308. emitter: Nullable<AbstractMesh | Vector3>;
  16309. /**
  16310. * The maximum number of particles to emit per frame
  16311. */
  16312. emitRate: number;
  16313. /**
  16314. * If you want to launch only a few particles at once, that can be done, as well.
  16315. */
  16316. manualEmitCount: number;
  16317. /**
  16318. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16319. */
  16320. updateSpeed: number;
  16321. /**
  16322. * The amount of time the particle system is running (depends of the overall update speed).
  16323. */
  16324. targetStopDuration: number;
  16325. /**
  16326. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16327. */
  16328. disposeOnStop: boolean;
  16329. /**
  16330. * Minimum power of emitting particles.
  16331. */
  16332. minEmitPower: number;
  16333. /**
  16334. * Maximum power of emitting particles.
  16335. */
  16336. maxEmitPower: number;
  16337. /**
  16338. * Minimum life time of emitting particles.
  16339. */
  16340. minLifeTime: number;
  16341. /**
  16342. * Maximum life time of emitting particles.
  16343. */
  16344. maxLifeTime: number;
  16345. /**
  16346. * Minimum Size of emitting particles.
  16347. */
  16348. minSize: number;
  16349. /**
  16350. * Maximum Size of emitting particles.
  16351. */
  16352. maxSize: number;
  16353. /**
  16354. * Minimum scale of emitting particles on X axis.
  16355. */
  16356. minScaleX: number;
  16357. /**
  16358. * Maximum scale of emitting particles on X axis.
  16359. */
  16360. maxScaleX: number;
  16361. /**
  16362. * Minimum scale of emitting particles on Y axis.
  16363. */
  16364. minScaleY: number;
  16365. /**
  16366. * Maximum scale of emitting particles on Y axis.
  16367. */
  16368. maxScaleY: number;
  16369. /**
  16370. * Gets or sets the minimal initial rotation in radians.
  16371. */
  16372. minInitialRotation: number;
  16373. /**
  16374. * Gets or sets the maximal initial rotation in radians.
  16375. */
  16376. maxInitialRotation: number;
  16377. /**
  16378. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16379. */
  16380. minAngularSpeed: number;
  16381. /**
  16382. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16383. */
  16384. maxAngularSpeed: number;
  16385. /**
  16386. * The texture used to render each particle. (this can be a spritesheet)
  16387. */
  16388. particleTexture: Nullable<Texture>;
  16389. /**
  16390. * The layer mask we are rendering the particles through.
  16391. */
  16392. layerMask: number;
  16393. /**
  16394. * This can help using your own shader to render the particle system.
  16395. * The according effect will be created
  16396. */
  16397. customShader: any;
  16398. /**
  16399. * By default particle system starts as soon as they are created. This prevents the
  16400. * automatic start to happen and let you decide when to start emitting particles.
  16401. */
  16402. preventAutoStart: boolean;
  16403. private _noiseTexture;
  16404. /**
  16405. * Gets or sets a texture used to add random noise to particle positions
  16406. */
  16407. noiseTexture: Nullable<ProceduralTexture>;
  16408. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16409. noiseStrength: Vector3;
  16410. /**
  16411. * Callback triggered when the particle animation is ending.
  16412. */
  16413. onAnimationEnd: Nullable<() => void>;
  16414. /**
  16415. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16416. */
  16417. blendMode: number;
  16418. /**
  16419. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16420. * to override the particles.
  16421. */
  16422. forceDepthWrite: boolean;
  16423. /** 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 */
  16424. preWarmCycles: number;
  16425. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16426. preWarmStepOffset: number;
  16427. /**
  16428. * 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)
  16429. */
  16430. spriteCellChangeSpeed: number;
  16431. /**
  16432. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16433. */
  16434. startSpriteCellID: number;
  16435. /**
  16436. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16437. */
  16438. endSpriteCellID: number;
  16439. /**
  16440. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16441. */
  16442. spriteCellWidth: number;
  16443. /**
  16444. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16445. */
  16446. spriteCellHeight: number;
  16447. /**
  16448. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16449. */
  16450. spriteRandomStartCell: boolean;
  16451. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16452. translationPivot: Vector2;
  16453. /** @hidden */
  16454. protected _isAnimationSheetEnabled: boolean;
  16455. /**
  16456. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16457. */
  16458. beginAnimationOnStart: boolean;
  16459. /**
  16460. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16461. */
  16462. beginAnimationFrom: number;
  16463. /**
  16464. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16465. */
  16466. beginAnimationTo: number;
  16467. /**
  16468. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16469. */
  16470. beginAnimationLoop: boolean;
  16471. /**
  16472. * Gets or sets a world offset applied to all particles
  16473. */
  16474. worldOffset: Vector3;
  16475. /**
  16476. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16477. */
  16478. isAnimationSheetEnabled: boolean;
  16479. /**
  16480. * Get hosting scene
  16481. * @returns the scene
  16482. */
  16483. getScene(): Scene;
  16484. /**
  16485. * You can use gravity if you want to give an orientation to your particles.
  16486. */
  16487. gravity: Vector3;
  16488. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16489. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16490. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16491. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16492. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16493. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16494. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16495. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16496. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16497. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16498. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16499. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16500. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16501. /**
  16502. * Defines the delay in milliseconds before starting the system (0 by default)
  16503. */
  16504. startDelay: number;
  16505. /**
  16506. * Gets the current list of drag gradients.
  16507. * You must use addDragGradient and removeDragGradient to udpate this list
  16508. * @returns the list of drag gradients
  16509. */
  16510. getDragGradients(): Nullable<Array<FactorGradient>>;
  16511. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16512. limitVelocityDamping: number;
  16513. /**
  16514. * Gets the current list of limit velocity gradients.
  16515. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16516. * @returns the list of limit velocity gradients
  16517. */
  16518. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16519. /**
  16520. * Gets the current list of color gradients.
  16521. * You must use addColorGradient and removeColorGradient to udpate this list
  16522. * @returns the list of color gradients
  16523. */
  16524. getColorGradients(): Nullable<Array<ColorGradient>>;
  16525. /**
  16526. * Gets the current list of size gradients.
  16527. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16528. * @returns the list of size gradients
  16529. */
  16530. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16531. /**
  16532. * Gets the current list of color remap gradients.
  16533. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16534. * @returns the list of color remap gradients
  16535. */
  16536. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16537. /**
  16538. * Gets the current list of alpha remap gradients.
  16539. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16540. * @returns the list of alpha remap gradients
  16541. */
  16542. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16543. /**
  16544. * Gets the current list of life time gradients.
  16545. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16546. * @returns the list of life time gradients
  16547. */
  16548. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16549. /**
  16550. * Gets the current list of angular speed gradients.
  16551. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16552. * @returns the list of angular speed gradients
  16553. */
  16554. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16555. /**
  16556. * Gets the current list of velocity gradients.
  16557. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16558. * @returns the list of velocity gradients
  16559. */
  16560. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16561. /**
  16562. * Gets the current list of start size gradients.
  16563. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16564. * @returns the list of start size gradients
  16565. */
  16566. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16567. /**
  16568. * Gets the current list of emit rate gradients.
  16569. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16570. * @returns the list of emit rate gradients
  16571. */
  16572. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16573. /**
  16574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16576. */
  16577. direction1: Vector3;
  16578. /**
  16579. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16581. */
  16582. direction2: Vector3;
  16583. /**
  16584. * 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.
  16585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16586. */
  16587. minEmitBox: Vector3;
  16588. /**
  16589. * 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.
  16590. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16591. */
  16592. maxEmitBox: Vector3;
  16593. /**
  16594. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16595. */
  16596. color1: Color4;
  16597. /**
  16598. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16599. */
  16600. color2: Color4;
  16601. /**
  16602. * Color the particle will have at the end of its lifetime
  16603. */
  16604. colorDead: Color4;
  16605. /**
  16606. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16607. */
  16608. textureMask: Color4;
  16609. /**
  16610. * The particle emitter type defines the emitter used by the particle system.
  16611. * It can be for example box, sphere, or cone...
  16612. */
  16613. particleEmitterType: IParticleEmitterType;
  16614. /** @hidden */ private _isSubEmitter: boolean;
  16615. /**
  16616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16618. */
  16619. billboardMode: number;
  16620. protected _isBillboardBased: boolean;
  16621. /**
  16622. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16623. */
  16624. isBillboardBased: boolean;
  16625. /**
  16626. * The scene the particle system belongs to.
  16627. */
  16628. protected _scene: Scene;
  16629. /**
  16630. * Local cache of defines for image processing.
  16631. */
  16632. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16633. /**
  16634. * Default configuration related to image processing available in the standard Material.
  16635. */
  16636. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16637. /**
  16638. * Gets the image processing configuration used either in this material.
  16639. */
  16640. /**
  16641. * Sets the Default image processing configuration used either in the this material.
  16642. *
  16643. * If sets to null, the scene one is in use.
  16644. */
  16645. imageProcessingConfiguration: ImageProcessingConfiguration;
  16646. /**
  16647. * Attaches a new image processing configuration to the Standard Material.
  16648. * @param configuration
  16649. */
  16650. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16651. /** @hidden */
  16652. protected _reset(): void;
  16653. /** @hidden */
  16654. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16655. /**
  16656. * Instantiates a particle system.
  16657. * 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.
  16658. * @param name The name of the particle system
  16659. */
  16660. constructor(name: string);
  16661. /**
  16662. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16665. * @returns the emitter
  16666. */
  16667. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16668. /**
  16669. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16670. * @param radius The radius of the hemisphere to emit from
  16671. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16672. * @returns the emitter
  16673. */
  16674. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16675. /**
  16676. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16677. * @param radius The radius of the sphere to emit from
  16678. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16679. * @returns the emitter
  16680. */
  16681. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16682. /**
  16683. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16684. * @param radius The radius of the sphere to emit from
  16685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16687. * @returns the emitter
  16688. */
  16689. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16690. /**
  16691. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16692. * @param radius The radius of the emission cylinder
  16693. * @param height The height of the emission cylinder
  16694. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16695. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16696. * @returns the emitter
  16697. */
  16698. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16699. /**
  16700. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16701. * @param radius The radius of the cylinder to emit from
  16702. * @param height The height of the emission cylinder
  16703. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16704. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16705. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16706. * @returns the emitter
  16707. */
  16708. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16709. /**
  16710. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16711. * @param radius The radius of the cone to emit from
  16712. * @param angle The base angle of the cone
  16713. * @returns the emitter
  16714. */
  16715. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16716. /**
  16717. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16720. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16721. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16722. * @returns the emitter
  16723. */
  16724. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16725. }
  16726. }
  16727. declare module BABYLON {
  16728. /**
  16729. * Type of sub emitter
  16730. */
  16731. export enum SubEmitterType {
  16732. /**
  16733. * Attached to the particle over it's lifetime
  16734. */
  16735. ATTACHED = 0,
  16736. /**
  16737. * Created when the particle dies
  16738. */
  16739. END = 1
  16740. }
  16741. /**
  16742. * Sub emitter class used to emit particles from an existing particle
  16743. */
  16744. export class SubEmitter {
  16745. /**
  16746. * the particle system to be used by the sub emitter
  16747. */
  16748. particleSystem: ParticleSystem;
  16749. /**
  16750. * Type of the submitter (Default: END)
  16751. */
  16752. type: SubEmitterType;
  16753. /**
  16754. * 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)
  16755. * Note: This only is supported when using an emitter of type Mesh
  16756. */
  16757. inheritDirection: boolean;
  16758. /**
  16759. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16760. */
  16761. inheritedVelocityAmount: number;
  16762. /**
  16763. * Creates a sub emitter
  16764. * @param particleSystem the particle system to be used by the sub emitter
  16765. */
  16766. constructor(
  16767. /**
  16768. * the particle system to be used by the sub emitter
  16769. */
  16770. particleSystem: ParticleSystem);
  16771. /**
  16772. * Clones the sub emitter
  16773. * @returns the cloned sub emitter
  16774. */
  16775. clone(): SubEmitter;
  16776. /**
  16777. * Serialize current object to a JSON object
  16778. * @returns the serialized object
  16779. */
  16780. serialize(): any;
  16781. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16782. /**
  16783. * Creates a new SubEmitter from a serialized JSON version
  16784. * @param serializationObject defines the JSON object to read from
  16785. * @param scene defines the hosting scene
  16786. * @param rootUrl defines the rootUrl for data loading
  16787. * @returns a new SubEmitter
  16788. */
  16789. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16790. /** Release associated resources */
  16791. dispose(): void;
  16792. }
  16793. }
  16794. declare module BABYLON {
  16795. /** @hidden */
  16796. export var clipPlaneFragmentDeclaration: {
  16797. name: string;
  16798. shader: string;
  16799. };
  16800. }
  16801. declare module BABYLON {
  16802. /** @hidden */
  16803. export var imageProcessingDeclaration: {
  16804. name: string;
  16805. shader: string;
  16806. };
  16807. }
  16808. declare module BABYLON {
  16809. /** @hidden */
  16810. export var imageProcessingFunctions: {
  16811. name: string;
  16812. shader: string;
  16813. };
  16814. }
  16815. declare module BABYLON {
  16816. /** @hidden */
  16817. export var clipPlaneFragment: {
  16818. name: string;
  16819. shader: string;
  16820. };
  16821. }
  16822. declare module BABYLON {
  16823. /** @hidden */
  16824. export var particlesPixelShader: {
  16825. name: string;
  16826. shader: string;
  16827. };
  16828. }
  16829. declare module BABYLON {
  16830. /** @hidden */
  16831. export var clipPlaneVertexDeclaration: {
  16832. name: string;
  16833. shader: string;
  16834. };
  16835. }
  16836. declare module BABYLON {
  16837. /** @hidden */
  16838. export var clipPlaneVertex: {
  16839. name: string;
  16840. shader: string;
  16841. };
  16842. }
  16843. declare module BABYLON {
  16844. /** @hidden */
  16845. export var particlesVertexShader: {
  16846. name: string;
  16847. shader: string;
  16848. };
  16849. }
  16850. declare module BABYLON {
  16851. /**
  16852. * This represents a particle system in Babylon.
  16853. * 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.
  16854. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16855. * @example https://doc.babylonjs.com/babylon101/particles
  16856. */
  16857. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16858. /**
  16859. * Billboard mode will only apply to Y axis
  16860. */
  16861. static readonly BILLBOARDMODE_Y: number;
  16862. /**
  16863. * Billboard mode will apply to all axes
  16864. */
  16865. static readonly BILLBOARDMODE_ALL: number;
  16866. /**
  16867. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16868. */
  16869. static readonly BILLBOARDMODE_STRETCHED: number;
  16870. /**
  16871. * This function can be defined to provide custom update for active particles.
  16872. * This function will be called instead of regular update (age, position, color, etc.).
  16873. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16874. */
  16875. updateFunction: (particles: Particle[]) => void;
  16876. private _emitterWorldMatrix;
  16877. /**
  16878. * This function can be defined to specify initial direction for every new particle.
  16879. * It by default use the emitterType defined function
  16880. */
  16881. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16882. /**
  16883. * This function can be defined to specify initial position for every new particle.
  16884. * It by default use the emitterType defined function
  16885. */
  16886. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16887. /**
  16888. * @hidden
  16889. */ private _inheritedVelocityOffset: Vector3;
  16890. /**
  16891. * An event triggered when the system is disposed
  16892. */
  16893. onDisposeObservable: Observable<ParticleSystem>;
  16894. private _onDisposeObserver;
  16895. /**
  16896. * Sets a callback that will be triggered when the system is disposed
  16897. */
  16898. onDispose: () => void;
  16899. private _particles;
  16900. private _epsilon;
  16901. private _capacity;
  16902. private _stockParticles;
  16903. private _newPartsExcess;
  16904. private _vertexData;
  16905. private _vertexBuffer;
  16906. private _vertexBuffers;
  16907. private _spriteBuffer;
  16908. private _indexBuffer;
  16909. private _effect;
  16910. private _customEffect;
  16911. private _cachedDefines;
  16912. private _scaledColorStep;
  16913. private _colorDiff;
  16914. private _scaledDirection;
  16915. private _scaledGravity;
  16916. private _currentRenderId;
  16917. private _alive;
  16918. private _useInstancing;
  16919. private _started;
  16920. private _stopped;
  16921. private _actualFrame;
  16922. private _scaledUpdateSpeed;
  16923. private _vertexBufferSize;
  16924. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16925. /** @hidden */ private _currentEmitRate1: number;
  16926. /** @hidden */ private _currentEmitRate2: number;
  16927. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16928. /** @hidden */ private _currentStartSize1: number;
  16929. /** @hidden */ private _currentStartSize2: number;
  16930. private readonly _rawTextureWidth;
  16931. private _rampGradientsTexture;
  16932. private _useRampGradients;
  16933. /** Gets or sets a boolean indicating that ramp gradients must be used
  16934. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16935. */
  16936. useRampGradients: boolean;
  16937. /**
  16938. * 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.
  16939. * 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: [])
  16940. */
  16941. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16942. private _subEmitters;
  16943. /**
  16944. * @hidden
  16945. * If the particle systems emitter should be disposed when the particle system is disposed
  16946. */ private _disposeEmitterOnDispose: boolean;
  16947. /**
  16948. * The current active Sub-systems, this property is used by the root particle system only.
  16949. */
  16950. activeSubSystems: Array<ParticleSystem>;
  16951. private _rootParticleSystem;
  16952. /**
  16953. * Gets the current list of active particles
  16954. */
  16955. readonly particles: Particle[];
  16956. /**
  16957. * Returns the string "ParticleSystem"
  16958. * @returns a string containing the class name
  16959. */
  16960. getClassName(): string;
  16961. /**
  16962. * Instantiates a particle system.
  16963. * 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.
  16964. * @param name The name of the particle system
  16965. * @param capacity The max number of particles alive at the same time
  16966. * @param scene The scene the particle system belongs to
  16967. * @param customEffect a custom effect used to change the way particles are rendered by default
  16968. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16969. * @param epsilon Offset used to render the particles
  16970. */
  16971. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16972. private _addFactorGradient;
  16973. private _removeFactorGradient;
  16974. /**
  16975. * Adds a new life time gradient
  16976. * @param gradient defines the gradient to use (between 0 and 1)
  16977. * @param factor defines the life time factor to affect to the specified gradient
  16978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16979. * @returns the current particle system
  16980. */
  16981. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16982. /**
  16983. * Remove a specific life time gradient
  16984. * @param gradient defines the gradient to remove
  16985. * @returns the current particle system
  16986. */
  16987. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16988. /**
  16989. * Adds a new size gradient
  16990. * @param gradient defines the gradient to use (between 0 and 1)
  16991. * @param factor defines the size factor to affect to the specified gradient
  16992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16993. * @returns the current particle system
  16994. */
  16995. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16996. /**
  16997. * Remove a specific size gradient
  16998. * @param gradient defines the gradient to remove
  16999. * @returns the current particle system
  17000. */
  17001. removeSizeGradient(gradient: number): IParticleSystem;
  17002. /**
  17003. * Adds a new color remap gradient
  17004. * @param gradient defines the gradient to use (between 0 and 1)
  17005. * @param min defines the color remap minimal range
  17006. * @param max defines the color remap maximal range
  17007. * @returns the current particle system
  17008. */
  17009. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17010. /**
  17011. * Remove a specific color remap gradient
  17012. * @param gradient defines the gradient to remove
  17013. * @returns the current particle system
  17014. */
  17015. removeColorRemapGradient(gradient: number): IParticleSystem;
  17016. /**
  17017. * Adds a new alpha remap gradient
  17018. * @param gradient defines the gradient to use (between 0 and 1)
  17019. * @param min defines the alpha remap minimal range
  17020. * @param max defines the alpha remap maximal range
  17021. * @returns the current particle system
  17022. */
  17023. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17024. /**
  17025. * Remove a specific alpha remap gradient
  17026. * @param gradient defines the gradient to remove
  17027. * @returns the current particle system
  17028. */
  17029. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17030. /**
  17031. * Adds a new angular speed gradient
  17032. * @param gradient defines the gradient to use (between 0 and 1)
  17033. * @param factor defines the angular speed to affect to the specified gradient
  17034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17035. * @returns the current particle system
  17036. */
  17037. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17038. /**
  17039. * Remove a specific angular speed gradient
  17040. * @param gradient defines the gradient to remove
  17041. * @returns the current particle system
  17042. */
  17043. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17044. /**
  17045. * Adds a new velocity gradient
  17046. * @param gradient defines the gradient to use (between 0 and 1)
  17047. * @param factor defines the velocity to affect to the specified gradient
  17048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17049. * @returns the current particle system
  17050. */
  17051. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17052. /**
  17053. * Remove a specific velocity gradient
  17054. * @param gradient defines the gradient to remove
  17055. * @returns the current particle system
  17056. */
  17057. removeVelocityGradient(gradient: number): IParticleSystem;
  17058. /**
  17059. * Adds a new limit velocity gradient
  17060. * @param gradient defines the gradient to use (between 0 and 1)
  17061. * @param factor defines the limit velocity value to affect to the specified gradient
  17062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17063. * @returns the current particle system
  17064. */
  17065. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17066. /**
  17067. * Remove a specific limit velocity gradient
  17068. * @param gradient defines the gradient to remove
  17069. * @returns the current particle system
  17070. */
  17071. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17072. /**
  17073. * Adds a new drag gradient
  17074. * @param gradient defines the gradient to use (between 0 and 1)
  17075. * @param factor defines the drag value to affect to the specified gradient
  17076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17077. * @returns the current particle system
  17078. */
  17079. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17080. /**
  17081. * Remove a specific drag gradient
  17082. * @param gradient defines the gradient to remove
  17083. * @returns the current particle system
  17084. */
  17085. removeDragGradient(gradient: number): IParticleSystem;
  17086. /**
  17087. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17088. * @param gradient defines the gradient to use (between 0 and 1)
  17089. * @param factor defines the emit rate value to affect to the specified gradient
  17090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17091. * @returns the current particle system
  17092. */
  17093. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17094. /**
  17095. * Remove a specific emit rate gradient
  17096. * @param gradient defines the gradient to remove
  17097. * @returns the current particle system
  17098. */
  17099. removeEmitRateGradient(gradient: number): IParticleSystem;
  17100. /**
  17101. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17102. * @param gradient defines the gradient to use (between 0 and 1)
  17103. * @param factor defines the start size value to affect to the specified gradient
  17104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17105. * @returns the current particle system
  17106. */
  17107. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17108. /**
  17109. * Remove a specific start size gradient
  17110. * @param gradient defines the gradient to remove
  17111. * @returns the current particle system
  17112. */
  17113. removeStartSizeGradient(gradient: number): IParticleSystem;
  17114. private _createRampGradientTexture;
  17115. /**
  17116. * Gets the current list of ramp gradients.
  17117. * You must use addRampGradient and removeRampGradient to udpate this list
  17118. * @returns the list of ramp gradients
  17119. */
  17120. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17121. /**
  17122. * Adds a new ramp gradient used to remap particle colors
  17123. * @param gradient defines the gradient to use (between 0 and 1)
  17124. * @param color defines the color to affect to the specified gradient
  17125. * @returns the current particle system
  17126. */
  17127. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17128. /**
  17129. * Remove a specific ramp gradient
  17130. * @param gradient defines the gradient to remove
  17131. * @returns the current particle system
  17132. */
  17133. removeRampGradient(gradient: number): ParticleSystem;
  17134. /**
  17135. * Adds a new color gradient
  17136. * @param gradient defines the gradient to use (between 0 and 1)
  17137. * @param color1 defines the color to affect to the specified gradient
  17138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17139. * @returns this particle system
  17140. */
  17141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17142. /**
  17143. * Remove a specific color gradient
  17144. * @param gradient defines the gradient to remove
  17145. * @returns this particle system
  17146. */
  17147. removeColorGradient(gradient: number): IParticleSystem;
  17148. private _fetchR;
  17149. protected _reset(): void;
  17150. private _resetEffect;
  17151. private _createVertexBuffers;
  17152. private _createIndexBuffer;
  17153. /**
  17154. * Gets the maximum number of particles active at the same time.
  17155. * @returns The max number of active particles.
  17156. */
  17157. getCapacity(): number;
  17158. /**
  17159. * Gets whether there are still active particles in the system.
  17160. * @returns True if it is alive, otherwise false.
  17161. */
  17162. isAlive(): boolean;
  17163. /**
  17164. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17165. * @returns True if it has been started, otherwise false.
  17166. */
  17167. isStarted(): boolean;
  17168. private _prepareSubEmitterInternalArray;
  17169. /**
  17170. * Starts the particle system and begins to emit
  17171. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17172. */
  17173. start(delay?: number): void;
  17174. /**
  17175. * Stops the particle system.
  17176. * @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.
  17177. */
  17178. stop(stopSubEmitters?: boolean): void;
  17179. /**
  17180. * Remove all active particles
  17181. */
  17182. reset(): void;
  17183. /**
  17184. * @hidden (for internal use only)
  17185. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17186. /**
  17187. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17188. * Its lifetime will start back at 0.
  17189. */
  17190. recycleParticle: (particle: Particle) => void;
  17191. private _stopSubEmitters;
  17192. private _createParticle;
  17193. private _removeFromRoot;
  17194. private _emitFromParticle;
  17195. private _update;
  17196. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17197. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17198. /** @hidden */
  17199. private _getEffect;
  17200. /**
  17201. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17202. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17203. */
  17204. animate(preWarmOnly?: boolean): void;
  17205. private _appendParticleVertices;
  17206. /**
  17207. * Rebuilds the particle system.
  17208. */
  17209. rebuild(): void;
  17210. /**
  17211. * Is this system ready to be used/rendered
  17212. * @return true if the system is ready
  17213. */
  17214. isReady(): boolean;
  17215. private _render;
  17216. /**
  17217. * Renders the particle system in its current state.
  17218. * @returns the current number of particles
  17219. */
  17220. render(): number;
  17221. /**
  17222. * Disposes the particle system and free the associated resources
  17223. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17224. */
  17225. dispose(disposeTexture?: boolean): void;
  17226. /**
  17227. * Clones the particle system.
  17228. * @param name The name of the cloned object
  17229. * @param newEmitter The new emitter to use
  17230. * @returns the cloned particle system
  17231. */
  17232. clone(name: string, newEmitter: any): ParticleSystem;
  17233. /**
  17234. * Serializes the particle system to a JSON object.
  17235. * @returns the JSON object
  17236. */
  17237. serialize(): any;
  17238. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17239. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17240. /**
  17241. * Parses a JSON object to create a particle system.
  17242. * @param parsedParticleSystem The JSON object to parse
  17243. * @param scene The scene to create the particle system in
  17244. * @param rootUrl The root url to use to load external dependencies like texture
  17245. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17246. * @returns the Parsed particle system
  17247. */
  17248. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17249. }
  17250. }
  17251. declare module BABYLON {
  17252. /**
  17253. * A particle represents one of the element emitted by a particle system.
  17254. * This is mainly define by its coordinates, direction, velocity and age.
  17255. */
  17256. export class Particle {
  17257. /**
  17258. * The particle system the particle belongs to.
  17259. */
  17260. particleSystem: ParticleSystem;
  17261. private static _Count;
  17262. /**
  17263. * Unique ID of the particle
  17264. */
  17265. id: number;
  17266. /**
  17267. * The world position of the particle in the scene.
  17268. */
  17269. position: Vector3;
  17270. /**
  17271. * The world direction of the particle in the scene.
  17272. */
  17273. direction: Vector3;
  17274. /**
  17275. * The color of the particle.
  17276. */
  17277. color: Color4;
  17278. /**
  17279. * The color change of the particle per step.
  17280. */
  17281. colorStep: Color4;
  17282. /**
  17283. * Defines how long will the life of the particle be.
  17284. */
  17285. lifeTime: number;
  17286. /**
  17287. * The current age of the particle.
  17288. */
  17289. age: number;
  17290. /**
  17291. * The current size of the particle.
  17292. */
  17293. size: number;
  17294. /**
  17295. * The current scale of the particle.
  17296. */
  17297. scale: Vector2;
  17298. /**
  17299. * The current angle of the particle.
  17300. */
  17301. angle: number;
  17302. /**
  17303. * Defines how fast is the angle changing.
  17304. */
  17305. angularSpeed: number;
  17306. /**
  17307. * Defines the cell index used by the particle to be rendered from a sprite.
  17308. */
  17309. cellIndex: number;
  17310. /**
  17311. * The information required to support color remapping
  17312. */
  17313. remapData: Vector4;
  17314. /** @hidden */ private _randomCellOffset?: number;
  17315. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17316. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17317. /** @hidden */ private _initialStartSpriteCellID: number;
  17318. /** @hidden */ private _initialEndSpriteCellID: number;
  17319. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17320. /** @hidden */ private _currentColor1: Color4;
  17321. /** @hidden */ private _currentColor2: Color4;
  17322. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17323. /** @hidden */ private _currentSize1: number;
  17324. /** @hidden */ private _currentSize2: number;
  17325. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17326. /** @hidden */ private _currentAngularSpeed1: number;
  17327. /** @hidden */ private _currentAngularSpeed2: number;
  17328. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17329. /** @hidden */ private _currentVelocity1: number;
  17330. /** @hidden */ private _currentVelocity2: number;
  17331. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17332. /** @hidden */ private _currentLimitVelocity1: number;
  17333. /** @hidden */ private _currentLimitVelocity2: number;
  17334. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17335. /** @hidden */ private _currentDrag1: number;
  17336. /** @hidden */ private _currentDrag2: number;
  17337. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17338. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17339. /**
  17340. * Creates a new instance Particle
  17341. * @param particleSystem the particle system the particle belongs to
  17342. */
  17343. constructor(
  17344. /**
  17345. * The particle system the particle belongs to.
  17346. */
  17347. particleSystem: ParticleSystem);
  17348. private updateCellInfoFromSystem;
  17349. /**
  17350. * Defines how the sprite cell index is updated for the particle
  17351. */
  17352. updateCellIndex(): void;
  17353. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17354. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17355. /** @hidden */ private _reset(): void;
  17356. /**
  17357. * Copy the properties of particle to another one.
  17358. * @param other the particle to copy the information to.
  17359. */
  17360. copyTo(other: Particle): void;
  17361. }
  17362. }
  17363. declare module BABYLON {
  17364. /**
  17365. * Particle emitter represents a volume emitting particles.
  17366. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17367. */
  17368. export interface IParticleEmitterType {
  17369. /**
  17370. * Called by the particle System when the direction is computed for the created particle.
  17371. * @param worldMatrix is the world matrix of the particle system
  17372. * @param directionToUpdate is the direction vector to update with the result
  17373. * @param particle is the particle we are computed the direction for
  17374. */
  17375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17376. /**
  17377. * Called by the particle System when the position is computed for the created particle.
  17378. * @param worldMatrix is the world matrix of the particle system
  17379. * @param positionToUpdate is the position vector to update with the result
  17380. * @param particle is the particle we are computed the position for
  17381. */
  17382. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17383. /**
  17384. * Clones the current emitter and returns a copy of it
  17385. * @returns the new emitter
  17386. */
  17387. clone(): IParticleEmitterType;
  17388. /**
  17389. * Called by the GPUParticleSystem to setup the update shader
  17390. * @param effect defines the update shader
  17391. */
  17392. applyToShader(effect: Effect): void;
  17393. /**
  17394. * Returns a string to use to update the GPU particles update shader
  17395. * @returns the effect defines string
  17396. */
  17397. getEffectDefines(): string;
  17398. /**
  17399. * Returns a string representing the class name
  17400. * @returns a string containing the class name
  17401. */
  17402. getClassName(): string;
  17403. /**
  17404. * Serializes the particle system to a JSON object.
  17405. * @returns the JSON object
  17406. */
  17407. serialize(): any;
  17408. /**
  17409. * Parse properties from a JSON object
  17410. * @param serializationObject defines the JSON object
  17411. */
  17412. parse(serializationObject: any): void;
  17413. }
  17414. }
  17415. declare module BABYLON {
  17416. /**
  17417. * Particle emitter emitting particles from the inside of a box.
  17418. * It emits the particles randomly between 2 given directions.
  17419. */
  17420. export class BoxParticleEmitter implements IParticleEmitterType {
  17421. /**
  17422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17423. */
  17424. direction1: Vector3;
  17425. /**
  17426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17427. */
  17428. direction2: Vector3;
  17429. /**
  17430. * 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.
  17431. */
  17432. minEmitBox: Vector3;
  17433. /**
  17434. * 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.
  17435. */
  17436. maxEmitBox: Vector3;
  17437. /**
  17438. * Creates a new instance BoxParticleEmitter
  17439. */
  17440. constructor();
  17441. /**
  17442. * Called by the particle System when the direction is computed for the created particle.
  17443. * @param worldMatrix is the world matrix of the particle system
  17444. * @param directionToUpdate is the direction vector to update with the result
  17445. * @param particle is the particle we are computed the direction for
  17446. */
  17447. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17448. /**
  17449. * Called by the particle System when the position is computed for the created particle.
  17450. * @param worldMatrix is the world matrix of the particle system
  17451. * @param positionToUpdate is the position vector to update with the result
  17452. * @param particle is the particle we are computed the position for
  17453. */
  17454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17455. /**
  17456. * Clones the current emitter and returns a copy of it
  17457. * @returns the new emitter
  17458. */
  17459. clone(): BoxParticleEmitter;
  17460. /**
  17461. * Called by the GPUParticleSystem to setup the update shader
  17462. * @param effect defines the update shader
  17463. */
  17464. applyToShader(effect: Effect): void;
  17465. /**
  17466. * Returns a string to use to update the GPU particles update shader
  17467. * @returns a string containng the defines string
  17468. */
  17469. getEffectDefines(): string;
  17470. /**
  17471. * Returns the string "BoxParticleEmitter"
  17472. * @returns a string containing the class name
  17473. */
  17474. getClassName(): string;
  17475. /**
  17476. * Serializes the particle system to a JSON object.
  17477. * @returns the JSON object
  17478. */
  17479. serialize(): any;
  17480. /**
  17481. * Parse properties from a JSON object
  17482. * @param serializationObject defines the JSON object
  17483. */
  17484. parse(serializationObject: any): void;
  17485. }
  17486. }
  17487. declare module BABYLON {
  17488. /**
  17489. * Particle emitter emitting particles from the inside of a cone.
  17490. * It emits the particles alongside the cone volume from the base to the particle.
  17491. * The emission direction might be randomized.
  17492. */
  17493. export class ConeParticleEmitter implements IParticleEmitterType {
  17494. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17495. directionRandomizer: number;
  17496. private _radius;
  17497. private _angle;
  17498. private _height;
  17499. /**
  17500. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17501. */
  17502. radiusRange: number;
  17503. /**
  17504. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17505. */
  17506. heightRange: number;
  17507. /**
  17508. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17509. */
  17510. emitFromSpawnPointOnly: boolean;
  17511. /**
  17512. * Gets or sets the radius of the emission cone
  17513. */
  17514. radius: number;
  17515. /**
  17516. * Gets or sets the angle of the emission cone
  17517. */
  17518. angle: number;
  17519. private _buildHeight;
  17520. /**
  17521. * Creates a new instance ConeParticleEmitter
  17522. * @param radius the radius of the emission cone (1 by default)
  17523. * @param angle the cone base angle (PI by default)
  17524. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17525. */
  17526. constructor(radius?: number, angle?: number,
  17527. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17528. directionRandomizer?: number);
  17529. /**
  17530. * Called by the particle System when the direction is computed for the created particle.
  17531. * @param worldMatrix is the world matrix of the particle system
  17532. * @param directionToUpdate is the direction vector to update with the result
  17533. * @param particle is the particle we are computed the direction for
  17534. */
  17535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17536. /**
  17537. * Called by the particle System when the position is computed for the created particle.
  17538. * @param worldMatrix is the world matrix of the particle system
  17539. * @param positionToUpdate is the position vector to update with the result
  17540. * @param particle is the particle we are computed the position for
  17541. */
  17542. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17543. /**
  17544. * Clones the current emitter and returns a copy of it
  17545. * @returns the new emitter
  17546. */
  17547. clone(): ConeParticleEmitter;
  17548. /**
  17549. * Called by the GPUParticleSystem to setup the update shader
  17550. * @param effect defines the update shader
  17551. */
  17552. applyToShader(effect: Effect): void;
  17553. /**
  17554. * Returns a string to use to update the GPU particles update shader
  17555. * @returns a string containng the defines string
  17556. */
  17557. getEffectDefines(): string;
  17558. /**
  17559. * Returns the string "ConeParticleEmitter"
  17560. * @returns a string containing the class name
  17561. */
  17562. getClassName(): string;
  17563. /**
  17564. * Serializes the particle system to a JSON object.
  17565. * @returns the JSON object
  17566. */
  17567. serialize(): any;
  17568. /**
  17569. * Parse properties from a JSON object
  17570. * @param serializationObject defines the JSON object
  17571. */
  17572. parse(serializationObject: any): void;
  17573. }
  17574. }
  17575. declare module BABYLON {
  17576. /**
  17577. * Particle emitter emitting particles from the inside of a cylinder.
  17578. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17579. */
  17580. export class CylinderParticleEmitter implements IParticleEmitterType {
  17581. /**
  17582. * The radius of the emission cylinder.
  17583. */
  17584. radius: number;
  17585. /**
  17586. * The height of the emission cylinder.
  17587. */
  17588. height: number;
  17589. /**
  17590. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17591. */
  17592. radiusRange: number;
  17593. /**
  17594. * How much to randomize the particle direction [0-1].
  17595. */
  17596. directionRandomizer: number;
  17597. /**
  17598. * Creates a new instance CylinderParticleEmitter
  17599. * @param radius the radius of the emission cylinder (1 by default)
  17600. * @param height the height of the emission cylinder (1 by default)
  17601. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17602. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17603. */
  17604. constructor(
  17605. /**
  17606. * The radius of the emission cylinder.
  17607. */
  17608. radius?: number,
  17609. /**
  17610. * The height of the emission cylinder.
  17611. */
  17612. height?: number,
  17613. /**
  17614. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17615. */
  17616. radiusRange?: number,
  17617. /**
  17618. * How much to randomize the particle direction [0-1].
  17619. */
  17620. directionRandomizer?: number);
  17621. /**
  17622. * Called by the particle System when the direction is computed for the created particle.
  17623. * @param worldMatrix is the world matrix of the particle system
  17624. * @param directionToUpdate is the direction vector to update with the result
  17625. * @param particle is the particle we are computed the direction for
  17626. */
  17627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17628. /**
  17629. * Called by the particle System when the position is computed for the created particle.
  17630. * @param worldMatrix is the world matrix of the particle system
  17631. * @param positionToUpdate is the position vector to update with the result
  17632. * @param particle is the particle we are computed the position for
  17633. */
  17634. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17635. /**
  17636. * Clones the current emitter and returns a copy of it
  17637. * @returns the new emitter
  17638. */
  17639. clone(): CylinderParticleEmitter;
  17640. /**
  17641. * Called by the GPUParticleSystem to setup the update shader
  17642. * @param effect defines the update shader
  17643. */
  17644. applyToShader(effect: Effect): void;
  17645. /**
  17646. * Returns a string to use to update the GPU particles update shader
  17647. * @returns a string containng the defines string
  17648. */
  17649. getEffectDefines(): string;
  17650. /**
  17651. * Returns the string "CylinderParticleEmitter"
  17652. * @returns a string containing the class name
  17653. */
  17654. getClassName(): string;
  17655. /**
  17656. * Serializes the particle system to a JSON object.
  17657. * @returns the JSON object
  17658. */
  17659. serialize(): any;
  17660. /**
  17661. * Parse properties from a JSON object
  17662. * @param serializationObject defines the JSON object
  17663. */
  17664. parse(serializationObject: any): void;
  17665. }
  17666. /**
  17667. * Particle emitter emitting particles from the inside of a cylinder.
  17668. * It emits the particles randomly between two vectors.
  17669. */
  17670. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17671. /**
  17672. * The min limit of the emission direction.
  17673. */
  17674. direction1: Vector3;
  17675. /**
  17676. * The max limit of the emission direction.
  17677. */
  17678. direction2: Vector3;
  17679. /**
  17680. * Creates a new instance CylinderDirectedParticleEmitter
  17681. * @param radius the radius of the emission cylinder (1 by default)
  17682. * @param height the height of the emission cylinder (1 by default)
  17683. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17684. * @param direction1 the min limit of the emission direction (up vector by default)
  17685. * @param direction2 the max limit of the emission direction (up vector by default)
  17686. */
  17687. constructor(radius?: number, height?: number, radiusRange?: number,
  17688. /**
  17689. * The min limit of the emission direction.
  17690. */
  17691. direction1?: Vector3,
  17692. /**
  17693. * The max limit of the emission direction.
  17694. */
  17695. direction2?: Vector3);
  17696. /**
  17697. * Called by the particle System when the direction is computed for the created particle.
  17698. * @param worldMatrix is the world matrix of the particle system
  17699. * @param directionToUpdate is the direction vector to update with the result
  17700. * @param particle is the particle we are computed the direction for
  17701. */
  17702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17703. /**
  17704. * Clones the current emitter and returns a copy of it
  17705. * @returns the new emitter
  17706. */
  17707. clone(): CylinderDirectedParticleEmitter;
  17708. /**
  17709. * Called by the GPUParticleSystem to setup the update shader
  17710. * @param effect defines the update shader
  17711. */
  17712. applyToShader(effect: Effect): void;
  17713. /**
  17714. * Returns a string to use to update the GPU particles update shader
  17715. * @returns a string containng the defines string
  17716. */
  17717. getEffectDefines(): string;
  17718. /**
  17719. * Returns the string "CylinderDirectedParticleEmitter"
  17720. * @returns a string containing the class name
  17721. */
  17722. getClassName(): string;
  17723. /**
  17724. * Serializes the particle system to a JSON object.
  17725. * @returns the JSON object
  17726. */
  17727. serialize(): any;
  17728. /**
  17729. * Parse properties from a JSON object
  17730. * @param serializationObject defines the JSON object
  17731. */
  17732. parse(serializationObject: any): void;
  17733. }
  17734. }
  17735. declare module BABYLON {
  17736. /**
  17737. * Particle emitter emitting particles from the inside of a hemisphere.
  17738. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17739. */
  17740. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17741. /**
  17742. * The radius of the emission hemisphere.
  17743. */
  17744. radius: number;
  17745. /**
  17746. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17747. */
  17748. radiusRange: number;
  17749. /**
  17750. * How much to randomize the particle direction [0-1].
  17751. */
  17752. directionRandomizer: number;
  17753. /**
  17754. * Creates a new instance HemisphericParticleEmitter
  17755. * @param radius the radius of the emission hemisphere (1 by default)
  17756. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17757. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17758. */
  17759. constructor(
  17760. /**
  17761. * The radius of the emission hemisphere.
  17762. */
  17763. radius?: number,
  17764. /**
  17765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17766. */
  17767. radiusRange?: number,
  17768. /**
  17769. * How much to randomize the particle direction [0-1].
  17770. */
  17771. directionRandomizer?: number);
  17772. /**
  17773. * Called by the particle System when the direction is computed for the created particle.
  17774. * @param worldMatrix is the world matrix of the particle system
  17775. * @param directionToUpdate is the direction vector to update with the result
  17776. * @param particle is the particle we are computed the direction for
  17777. */
  17778. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17779. /**
  17780. * Called by the particle System when the position is computed for the created particle.
  17781. * @param worldMatrix is the world matrix of the particle system
  17782. * @param positionToUpdate is the position vector to update with the result
  17783. * @param particle is the particle we are computed the position for
  17784. */
  17785. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17786. /**
  17787. * Clones the current emitter and returns a copy of it
  17788. * @returns the new emitter
  17789. */
  17790. clone(): HemisphericParticleEmitter;
  17791. /**
  17792. * Called by the GPUParticleSystem to setup the update shader
  17793. * @param effect defines the update shader
  17794. */
  17795. applyToShader(effect: Effect): void;
  17796. /**
  17797. * Returns a string to use to update the GPU particles update shader
  17798. * @returns a string containng the defines string
  17799. */
  17800. getEffectDefines(): string;
  17801. /**
  17802. * Returns the string "HemisphericParticleEmitter"
  17803. * @returns a string containing the class name
  17804. */
  17805. getClassName(): string;
  17806. /**
  17807. * Serializes the particle system to a JSON object.
  17808. * @returns the JSON object
  17809. */
  17810. serialize(): any;
  17811. /**
  17812. * Parse properties from a JSON object
  17813. * @param serializationObject defines the JSON object
  17814. */
  17815. parse(serializationObject: any): void;
  17816. }
  17817. }
  17818. declare module BABYLON {
  17819. /**
  17820. * Particle emitter emitting particles from a point.
  17821. * It emits the particles randomly between 2 given directions.
  17822. */
  17823. export class PointParticleEmitter implements IParticleEmitterType {
  17824. /**
  17825. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17826. */
  17827. direction1: Vector3;
  17828. /**
  17829. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17830. */
  17831. direction2: Vector3;
  17832. /**
  17833. * Creates a new instance PointParticleEmitter
  17834. */
  17835. constructor();
  17836. /**
  17837. * Called by the particle System when the direction is computed for the created particle.
  17838. * @param worldMatrix is the world matrix of the particle system
  17839. * @param directionToUpdate is the direction vector to update with the result
  17840. * @param particle is the particle we are computed the direction for
  17841. */
  17842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17843. /**
  17844. * Called by the particle System when the position is computed for the created particle.
  17845. * @param worldMatrix is the world matrix of the particle system
  17846. * @param positionToUpdate is the position vector to update with the result
  17847. * @param particle is the particle we are computed the position for
  17848. */
  17849. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17850. /**
  17851. * Clones the current emitter and returns a copy of it
  17852. * @returns the new emitter
  17853. */
  17854. clone(): PointParticleEmitter;
  17855. /**
  17856. * Called by the GPUParticleSystem to setup the update shader
  17857. * @param effect defines the update shader
  17858. */
  17859. applyToShader(effect: Effect): void;
  17860. /**
  17861. * Returns a string to use to update the GPU particles update shader
  17862. * @returns a string containng the defines string
  17863. */
  17864. getEffectDefines(): string;
  17865. /**
  17866. * Returns the string "PointParticleEmitter"
  17867. * @returns a string containing the class name
  17868. */
  17869. getClassName(): string;
  17870. /**
  17871. * Serializes the particle system to a JSON object.
  17872. * @returns the JSON object
  17873. */
  17874. serialize(): any;
  17875. /**
  17876. * Parse properties from a JSON object
  17877. * @param serializationObject defines the JSON object
  17878. */
  17879. parse(serializationObject: any): void;
  17880. }
  17881. }
  17882. declare module BABYLON {
  17883. /**
  17884. * Particle emitter emitting particles from the inside of a sphere.
  17885. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17886. */
  17887. export class SphereParticleEmitter implements IParticleEmitterType {
  17888. /**
  17889. * The radius of the emission sphere.
  17890. */
  17891. radius: number;
  17892. /**
  17893. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17894. */
  17895. radiusRange: number;
  17896. /**
  17897. * How much to randomize the particle direction [0-1].
  17898. */
  17899. directionRandomizer: number;
  17900. /**
  17901. * Creates a new instance SphereParticleEmitter
  17902. * @param radius the radius of the emission sphere (1 by default)
  17903. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17904. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17905. */
  17906. constructor(
  17907. /**
  17908. * The radius of the emission sphere.
  17909. */
  17910. radius?: number,
  17911. /**
  17912. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17913. */
  17914. radiusRange?: number,
  17915. /**
  17916. * How much to randomize the particle direction [0-1].
  17917. */
  17918. directionRandomizer?: number);
  17919. /**
  17920. * Called by the particle System when the direction is computed for the created particle.
  17921. * @param worldMatrix is the world matrix of the particle system
  17922. * @param directionToUpdate is the direction vector to update with the result
  17923. * @param particle is the particle we are computed the direction for
  17924. */
  17925. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17926. /**
  17927. * Called by the particle System when the position is computed for the created particle.
  17928. * @param worldMatrix is the world matrix of the particle system
  17929. * @param positionToUpdate is the position vector to update with the result
  17930. * @param particle is the particle we are computed the position for
  17931. */
  17932. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17933. /**
  17934. * Clones the current emitter and returns a copy of it
  17935. * @returns the new emitter
  17936. */
  17937. clone(): SphereParticleEmitter;
  17938. /**
  17939. * Called by the GPUParticleSystem to setup the update shader
  17940. * @param effect defines the update shader
  17941. */
  17942. applyToShader(effect: Effect): void;
  17943. /**
  17944. * Returns a string to use to update the GPU particles update shader
  17945. * @returns a string containng the defines string
  17946. */
  17947. getEffectDefines(): string;
  17948. /**
  17949. * Returns the string "SphereParticleEmitter"
  17950. * @returns a string containing the class name
  17951. */
  17952. getClassName(): string;
  17953. /**
  17954. * Serializes the particle system to a JSON object.
  17955. * @returns the JSON object
  17956. */
  17957. serialize(): any;
  17958. /**
  17959. * Parse properties from a JSON object
  17960. * @param serializationObject defines the JSON object
  17961. */
  17962. parse(serializationObject: any): void;
  17963. }
  17964. /**
  17965. * Particle emitter emitting particles from the inside of a sphere.
  17966. * It emits the particles randomly between two vectors.
  17967. */
  17968. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17969. /**
  17970. * The min limit of the emission direction.
  17971. */
  17972. direction1: Vector3;
  17973. /**
  17974. * The max limit of the emission direction.
  17975. */
  17976. direction2: Vector3;
  17977. /**
  17978. * Creates a new instance SphereDirectedParticleEmitter
  17979. * @param radius the radius of the emission sphere (1 by default)
  17980. * @param direction1 the min limit of the emission direction (up vector by default)
  17981. * @param direction2 the max limit of the emission direction (up vector by default)
  17982. */
  17983. constructor(radius?: number,
  17984. /**
  17985. * The min limit of the emission direction.
  17986. */
  17987. direction1?: Vector3,
  17988. /**
  17989. * The max limit of the emission direction.
  17990. */
  17991. direction2?: Vector3);
  17992. /**
  17993. * Called by the particle System when the direction is computed for the created particle.
  17994. * @param worldMatrix is the world matrix of the particle system
  17995. * @param directionToUpdate is the direction vector to update with the result
  17996. * @param particle is the particle we are computed the direction for
  17997. */
  17998. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17999. /**
  18000. * Clones the current emitter and returns a copy of it
  18001. * @returns the new emitter
  18002. */
  18003. clone(): SphereDirectedParticleEmitter;
  18004. /**
  18005. * Called by the GPUParticleSystem to setup the update shader
  18006. * @param effect defines the update shader
  18007. */
  18008. applyToShader(effect: Effect): void;
  18009. /**
  18010. * Returns a string to use to update the GPU particles update shader
  18011. * @returns a string containng the defines string
  18012. */
  18013. getEffectDefines(): string;
  18014. /**
  18015. * Returns the string "SphereDirectedParticleEmitter"
  18016. * @returns a string containing the class name
  18017. */
  18018. getClassName(): string;
  18019. /**
  18020. * Serializes the particle system to a JSON object.
  18021. * @returns the JSON object
  18022. */
  18023. serialize(): any;
  18024. /**
  18025. * Parse properties from a JSON object
  18026. * @param serializationObject defines the JSON object
  18027. */
  18028. parse(serializationObject: any): void;
  18029. }
  18030. }
  18031. declare module BABYLON {
  18032. /**
  18033. * Interface representing a particle system in Babylon.js.
  18034. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18035. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18036. */
  18037. export interface IParticleSystem {
  18038. /**
  18039. * List of animations used by the particle system.
  18040. */
  18041. animations: Animation[];
  18042. /**
  18043. * The id of the Particle system.
  18044. */
  18045. id: string;
  18046. /**
  18047. * The name of the Particle system.
  18048. */
  18049. name: string;
  18050. /**
  18051. * The emitter represents the Mesh or position we are attaching the particle system to.
  18052. */
  18053. emitter: Nullable<AbstractMesh | Vector3>;
  18054. /**
  18055. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18056. */
  18057. isBillboardBased: boolean;
  18058. /**
  18059. * The rendering group used by the Particle system to chose when to render.
  18060. */
  18061. renderingGroupId: number;
  18062. /**
  18063. * The layer mask we are rendering the particles through.
  18064. */
  18065. layerMask: number;
  18066. /**
  18067. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18068. */
  18069. updateSpeed: number;
  18070. /**
  18071. * The amount of time the particle system is running (depends of the overall update speed).
  18072. */
  18073. targetStopDuration: number;
  18074. /**
  18075. * The texture used to render each particle. (this can be a spritesheet)
  18076. */
  18077. particleTexture: Nullable<Texture>;
  18078. /**
  18079. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18080. */
  18081. blendMode: number;
  18082. /**
  18083. * Minimum life time of emitting particles.
  18084. */
  18085. minLifeTime: number;
  18086. /**
  18087. * Maximum life time of emitting particles.
  18088. */
  18089. maxLifeTime: number;
  18090. /**
  18091. * Minimum Size of emitting particles.
  18092. */
  18093. minSize: number;
  18094. /**
  18095. * Maximum Size of emitting particles.
  18096. */
  18097. maxSize: number;
  18098. /**
  18099. * Minimum scale of emitting particles on X axis.
  18100. */
  18101. minScaleX: number;
  18102. /**
  18103. * Maximum scale of emitting particles on X axis.
  18104. */
  18105. maxScaleX: number;
  18106. /**
  18107. * Minimum scale of emitting particles on Y axis.
  18108. */
  18109. minScaleY: number;
  18110. /**
  18111. * Maximum scale of emitting particles on Y axis.
  18112. */
  18113. maxScaleY: number;
  18114. /**
  18115. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18116. */
  18117. color1: Color4;
  18118. /**
  18119. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18120. */
  18121. color2: Color4;
  18122. /**
  18123. * Color the particle will have at the end of its lifetime.
  18124. */
  18125. colorDead: Color4;
  18126. /**
  18127. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18128. */
  18129. emitRate: number;
  18130. /**
  18131. * You can use gravity if you want to give an orientation to your particles.
  18132. */
  18133. gravity: Vector3;
  18134. /**
  18135. * Minimum power of emitting particles.
  18136. */
  18137. minEmitPower: number;
  18138. /**
  18139. * Maximum power of emitting particles.
  18140. */
  18141. maxEmitPower: number;
  18142. /**
  18143. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18144. */
  18145. minAngularSpeed: number;
  18146. /**
  18147. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18148. */
  18149. maxAngularSpeed: number;
  18150. /**
  18151. * Gets or sets the minimal initial rotation in radians.
  18152. */
  18153. minInitialRotation: number;
  18154. /**
  18155. * Gets or sets the maximal initial rotation in radians.
  18156. */
  18157. maxInitialRotation: number;
  18158. /**
  18159. * The particle emitter type defines the emitter used by the particle system.
  18160. * It can be for example box, sphere, or cone...
  18161. */
  18162. particleEmitterType: Nullable<IParticleEmitterType>;
  18163. /**
  18164. * Defines the delay in milliseconds before starting the system (0 by default)
  18165. */
  18166. startDelay: number;
  18167. /**
  18168. * 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
  18169. */
  18170. preWarmCycles: number;
  18171. /**
  18172. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18173. */
  18174. preWarmStepOffset: number;
  18175. /**
  18176. * 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)
  18177. */
  18178. spriteCellChangeSpeed: number;
  18179. /**
  18180. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18181. */
  18182. startSpriteCellID: number;
  18183. /**
  18184. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18185. */
  18186. endSpriteCellID: number;
  18187. /**
  18188. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18189. */
  18190. spriteCellWidth: number;
  18191. /**
  18192. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18193. */
  18194. spriteCellHeight: number;
  18195. /**
  18196. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18197. */
  18198. spriteRandomStartCell: boolean;
  18199. /**
  18200. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18201. */
  18202. isAnimationSheetEnabled: boolean;
  18203. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18204. translationPivot: Vector2;
  18205. /**
  18206. * Gets or sets a texture used to add random noise to particle positions
  18207. */
  18208. noiseTexture: Nullable<BaseTexture>;
  18209. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18210. noiseStrength: Vector3;
  18211. /**
  18212. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18213. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18214. */
  18215. billboardMode: number;
  18216. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18217. limitVelocityDamping: number;
  18218. /**
  18219. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18220. */
  18221. beginAnimationOnStart: boolean;
  18222. /**
  18223. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18224. */
  18225. beginAnimationFrom: number;
  18226. /**
  18227. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18228. */
  18229. beginAnimationTo: number;
  18230. /**
  18231. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18232. */
  18233. beginAnimationLoop: boolean;
  18234. /**
  18235. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18236. */
  18237. disposeOnStop: boolean;
  18238. /**
  18239. * Gets the maximum number of particles active at the same time.
  18240. * @returns The max number of active particles.
  18241. */
  18242. getCapacity(): number;
  18243. /**
  18244. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18245. * @returns True if it has been started, otherwise false.
  18246. */
  18247. isStarted(): boolean;
  18248. /**
  18249. * Animates the particle system for this frame.
  18250. */
  18251. animate(): void;
  18252. /**
  18253. * Renders the particle system in its current state.
  18254. * @returns the current number of particles
  18255. */
  18256. render(): number;
  18257. /**
  18258. * Dispose the particle system and frees its associated resources.
  18259. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18260. */
  18261. dispose(disposeTexture?: boolean): void;
  18262. /**
  18263. * Clones the particle system.
  18264. * @param name The name of the cloned object
  18265. * @param newEmitter The new emitter to use
  18266. * @returns the cloned particle system
  18267. */
  18268. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18269. /**
  18270. * Serializes the particle system to a JSON object.
  18271. * @returns the JSON object
  18272. */
  18273. serialize(): any;
  18274. /**
  18275. * Rebuild the particle system
  18276. */
  18277. rebuild(): void;
  18278. /**
  18279. * Starts the particle system and begins to emit
  18280. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18281. */
  18282. start(delay?: number): void;
  18283. /**
  18284. * Stops the particle system.
  18285. */
  18286. stop(): void;
  18287. /**
  18288. * Remove all active particles
  18289. */
  18290. reset(): void;
  18291. /**
  18292. * Is this system ready to be used/rendered
  18293. * @return true if the system is ready
  18294. */
  18295. isReady(): boolean;
  18296. /**
  18297. * Adds a new color gradient
  18298. * @param gradient defines the gradient to use (between 0 and 1)
  18299. * @param color1 defines the color to affect to the specified gradient
  18300. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18301. * @returns the current particle system
  18302. */
  18303. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18304. /**
  18305. * Remove a specific color gradient
  18306. * @param gradient defines the gradient to remove
  18307. * @returns the current particle system
  18308. */
  18309. removeColorGradient(gradient: number): IParticleSystem;
  18310. /**
  18311. * Adds a new size gradient
  18312. * @param gradient defines the gradient to use (between 0 and 1)
  18313. * @param factor defines the size factor to affect to the specified gradient
  18314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18315. * @returns the current particle system
  18316. */
  18317. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18318. /**
  18319. * Remove a specific size gradient
  18320. * @param gradient defines the gradient to remove
  18321. * @returns the current particle system
  18322. */
  18323. removeSizeGradient(gradient: number): IParticleSystem;
  18324. /**
  18325. * Gets the current list of color gradients.
  18326. * You must use addColorGradient and removeColorGradient to udpate this list
  18327. * @returns the list of color gradients
  18328. */
  18329. getColorGradients(): Nullable<Array<ColorGradient>>;
  18330. /**
  18331. * Gets the current list of size gradients.
  18332. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18333. * @returns the list of size gradients
  18334. */
  18335. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18336. /**
  18337. * Gets the current list of angular speed gradients.
  18338. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18339. * @returns the list of angular speed gradients
  18340. */
  18341. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18342. /**
  18343. * Adds a new angular speed gradient
  18344. * @param gradient defines the gradient to use (between 0 and 1)
  18345. * @param factor defines the angular speed to affect to the specified gradient
  18346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18347. * @returns the current particle system
  18348. */
  18349. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18350. /**
  18351. * Remove a specific angular speed gradient
  18352. * @param gradient defines the gradient to remove
  18353. * @returns the current particle system
  18354. */
  18355. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18356. /**
  18357. * Gets the current list of velocity gradients.
  18358. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18359. * @returns the list of velocity gradients
  18360. */
  18361. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18362. /**
  18363. * Adds a new velocity gradient
  18364. * @param gradient defines the gradient to use (between 0 and 1)
  18365. * @param factor defines the velocity to affect to the specified gradient
  18366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18367. * @returns the current particle system
  18368. */
  18369. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18370. /**
  18371. * Remove a specific velocity gradient
  18372. * @param gradient defines the gradient to remove
  18373. * @returns the current particle system
  18374. */
  18375. removeVelocityGradient(gradient: number): IParticleSystem;
  18376. /**
  18377. * Gets the current list of limit velocity gradients.
  18378. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18379. * @returns the list of limit velocity gradients
  18380. */
  18381. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18382. /**
  18383. * Adds a new limit velocity gradient
  18384. * @param gradient defines the gradient to use (between 0 and 1)
  18385. * @param factor defines the limit velocity to affect to the specified gradient
  18386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18387. * @returns the current particle system
  18388. */
  18389. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18390. /**
  18391. * Remove a specific limit velocity gradient
  18392. * @param gradient defines the gradient to remove
  18393. * @returns the current particle system
  18394. */
  18395. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18396. /**
  18397. * Adds a new drag gradient
  18398. * @param gradient defines the gradient to use (between 0 and 1)
  18399. * @param factor defines the drag to affect to the specified gradient
  18400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18401. * @returns the current particle system
  18402. */
  18403. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18404. /**
  18405. * Remove a specific drag gradient
  18406. * @param gradient defines the gradient to remove
  18407. * @returns the current particle system
  18408. */
  18409. removeDragGradient(gradient: number): IParticleSystem;
  18410. /**
  18411. * Gets the current list of drag gradients.
  18412. * You must use addDragGradient and removeDragGradient to udpate this list
  18413. * @returns the list of drag gradients
  18414. */
  18415. getDragGradients(): Nullable<Array<FactorGradient>>;
  18416. /**
  18417. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18418. * @param gradient defines the gradient to use (between 0 and 1)
  18419. * @param factor defines the emit rate to affect to the specified gradient
  18420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18421. * @returns the current particle system
  18422. */
  18423. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18424. /**
  18425. * Remove a specific emit rate gradient
  18426. * @param gradient defines the gradient to remove
  18427. * @returns the current particle system
  18428. */
  18429. removeEmitRateGradient(gradient: number): IParticleSystem;
  18430. /**
  18431. * Gets the current list of emit rate gradients.
  18432. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18433. * @returns the list of emit rate gradients
  18434. */
  18435. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18436. /**
  18437. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18438. * @param gradient defines the gradient to use (between 0 and 1)
  18439. * @param factor defines the start size to affect to the specified gradient
  18440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18441. * @returns the current particle system
  18442. */
  18443. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18444. /**
  18445. * Remove a specific start size gradient
  18446. * @param gradient defines the gradient to remove
  18447. * @returns the current particle system
  18448. */
  18449. removeStartSizeGradient(gradient: number): IParticleSystem;
  18450. /**
  18451. * Gets the current list of start size gradients.
  18452. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18453. * @returns the list of start size gradients
  18454. */
  18455. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18456. /**
  18457. * Adds a new life time gradient
  18458. * @param gradient defines the gradient to use (between 0 and 1)
  18459. * @param factor defines the life time factor to affect to the specified gradient
  18460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18461. * @returns the current particle system
  18462. */
  18463. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18464. /**
  18465. * Remove a specific life time gradient
  18466. * @param gradient defines the gradient to remove
  18467. * @returns the current particle system
  18468. */
  18469. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18470. /**
  18471. * Gets the current list of life time gradients.
  18472. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18473. * @returns the list of life time gradients
  18474. */
  18475. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18476. /**
  18477. * Gets the current list of color gradients.
  18478. * You must use addColorGradient and removeColorGradient to udpate this list
  18479. * @returns the list of color gradients
  18480. */
  18481. getColorGradients(): Nullable<Array<ColorGradient>>;
  18482. /**
  18483. * Adds a new ramp gradient used to remap particle colors
  18484. * @param gradient defines the gradient to use (between 0 and 1)
  18485. * @param color defines the color to affect to the specified gradient
  18486. * @returns the current particle system
  18487. */
  18488. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18489. /**
  18490. * Gets the current list of ramp gradients.
  18491. * You must use addRampGradient and removeRampGradient to udpate this list
  18492. * @returns the list of ramp gradients
  18493. */
  18494. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18495. /** Gets or sets a boolean indicating that ramp gradients must be used
  18496. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18497. */
  18498. useRampGradients: boolean;
  18499. /**
  18500. * Adds a new color remap gradient
  18501. * @param gradient defines the gradient to use (between 0 and 1)
  18502. * @param min defines the color remap minimal range
  18503. * @param max defines the color remap maximal range
  18504. * @returns the current particle system
  18505. */
  18506. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18507. /**
  18508. * Gets the current list of color remap gradients.
  18509. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18510. * @returns the list of color remap gradients
  18511. */
  18512. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18513. /**
  18514. * Adds a new alpha remap gradient
  18515. * @param gradient defines the gradient to use (between 0 and 1)
  18516. * @param min defines the alpha remap minimal range
  18517. * @param max defines the alpha remap maximal range
  18518. * @returns the current particle system
  18519. */
  18520. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18521. /**
  18522. * Gets the current list of alpha remap gradients.
  18523. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18524. * @returns the list of alpha remap gradients
  18525. */
  18526. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18527. /**
  18528. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18531. * @returns the emitter
  18532. */
  18533. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18534. /**
  18535. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18536. * @param radius The radius of the hemisphere to emit from
  18537. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18538. * @returns the emitter
  18539. */
  18540. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18541. /**
  18542. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18543. * @param radius The radius of the sphere to emit from
  18544. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18545. * @returns the emitter
  18546. */
  18547. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18548. /**
  18549. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18550. * @param radius The radius of the sphere to emit from
  18551. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18552. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18553. * @returns the emitter
  18554. */
  18555. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18556. /**
  18557. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18558. * @param radius The radius of the emission cylinder
  18559. * @param height The height of the emission cylinder
  18560. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18561. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18562. * @returns the emitter
  18563. */
  18564. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18565. /**
  18566. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18567. * @param radius The radius of the cylinder to emit from
  18568. * @param height The height of the emission cylinder
  18569. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18572. * @returns the emitter
  18573. */
  18574. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18575. /**
  18576. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18577. * @param radius The radius of the cone to emit from
  18578. * @param angle The base angle of the cone
  18579. * @returns the emitter
  18580. */
  18581. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18582. /**
  18583. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18584. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18585. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18586. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18587. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18588. * @returns the emitter
  18589. */
  18590. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18591. /**
  18592. * Get hosting scene
  18593. * @returns the scene
  18594. */
  18595. getScene(): Scene;
  18596. }
  18597. }
  18598. declare module BABYLON {
  18599. /**
  18600. * Creates an instance based on a source mesh.
  18601. */
  18602. export class InstancedMesh extends AbstractMesh {
  18603. private _sourceMesh;
  18604. private _currentLOD;
  18605. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18606. constructor(name: string, source: Mesh);
  18607. /**
  18608. * Returns the string "InstancedMesh".
  18609. */
  18610. getClassName(): string;
  18611. /** Gets the list of lights affecting that mesh */
  18612. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18613. /**
  18614. * If the source mesh receives shadows
  18615. */
  18616. readonly receiveShadows: boolean;
  18617. /**
  18618. * The material of the source mesh
  18619. */
  18620. readonly material: Nullable<Material>;
  18621. /**
  18622. * Visibility of the source mesh
  18623. */
  18624. readonly visibility: number;
  18625. /**
  18626. * Skeleton of the source mesh
  18627. */
  18628. readonly skeleton: Nullable<Skeleton>;
  18629. /**
  18630. * Rendering ground id of the source mesh
  18631. */
  18632. renderingGroupId: number;
  18633. /**
  18634. * Returns the total number of vertices (integer).
  18635. */
  18636. getTotalVertices(): number;
  18637. /**
  18638. * Returns a positive integer : the total number of indices in this mesh geometry.
  18639. * @returns the numner of indices or zero if the mesh has no geometry.
  18640. */
  18641. getTotalIndices(): number;
  18642. /**
  18643. * The source mesh of the instance
  18644. */
  18645. readonly sourceMesh: Mesh;
  18646. /**
  18647. * Is this node ready to be used/rendered
  18648. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18649. * @return {boolean} is it ready
  18650. */
  18651. isReady(completeCheck?: boolean): boolean;
  18652. /**
  18653. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18654. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18655. * @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.
  18656. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18657. */
  18658. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18659. /**
  18660. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18661. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18662. * The `data` are either a numeric array either a Float32Array.
  18663. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18664. * 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).
  18665. * Note that a new underlying VertexBuffer object is created each call.
  18666. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18667. *
  18668. * Possible `kind` values :
  18669. * - VertexBuffer.PositionKind
  18670. * - VertexBuffer.UVKind
  18671. * - VertexBuffer.UV2Kind
  18672. * - VertexBuffer.UV3Kind
  18673. * - VertexBuffer.UV4Kind
  18674. * - VertexBuffer.UV5Kind
  18675. * - VertexBuffer.UV6Kind
  18676. * - VertexBuffer.ColorKind
  18677. * - VertexBuffer.MatricesIndicesKind
  18678. * - VertexBuffer.MatricesIndicesExtraKind
  18679. * - VertexBuffer.MatricesWeightsKind
  18680. * - VertexBuffer.MatricesWeightsExtraKind
  18681. *
  18682. * Returns the Mesh.
  18683. */
  18684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18685. /**
  18686. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18687. * If the mesh has no geometry, it is simply returned as it is.
  18688. * The `data` are either a numeric array either a Float32Array.
  18689. * No new underlying VertexBuffer object is created.
  18690. * 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.
  18691. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18692. *
  18693. * Possible `kind` values :
  18694. * - VertexBuffer.PositionKind
  18695. * - VertexBuffer.UVKind
  18696. * - VertexBuffer.UV2Kind
  18697. * - VertexBuffer.UV3Kind
  18698. * - VertexBuffer.UV4Kind
  18699. * - VertexBuffer.UV5Kind
  18700. * - VertexBuffer.UV6Kind
  18701. * - VertexBuffer.ColorKind
  18702. * - VertexBuffer.MatricesIndicesKind
  18703. * - VertexBuffer.MatricesIndicesExtraKind
  18704. * - VertexBuffer.MatricesWeightsKind
  18705. * - VertexBuffer.MatricesWeightsExtraKind
  18706. *
  18707. * Returns the Mesh.
  18708. */
  18709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18710. /**
  18711. * Sets the mesh indices.
  18712. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18713. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18714. * This method creates a new index buffer each call.
  18715. * Returns the Mesh.
  18716. */
  18717. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18718. /**
  18719. * Boolean : True if the mesh owns the requested kind of data.
  18720. */
  18721. isVerticesDataPresent(kind: string): boolean;
  18722. /**
  18723. * Returns an array of indices (IndicesArray).
  18724. */
  18725. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18726. /**
  18727. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18728. * This means the mesh underlying bounding box and sphere are recomputed.
  18729. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18730. * @returns the current mesh
  18731. */
  18732. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18733. /** @hidden */ private _preActivate(): InstancedMesh;
  18734. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18735. /** @hidden */ private _postActivate(): void;
  18736. getWorldMatrix(): Matrix;
  18737. readonly isAnInstance: boolean;
  18738. /**
  18739. * Returns the current associated LOD AbstractMesh.
  18740. */
  18741. getLOD(camera: Camera): AbstractMesh;
  18742. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18743. /** @hidden */ private _generatePointsArray(): boolean;
  18744. /**
  18745. * Creates a new InstancedMesh from the current mesh.
  18746. * - name (string) : the cloned mesh name
  18747. * - newParent (optional Node) : the optional Node to parent the clone to.
  18748. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18749. *
  18750. * Returns the clone.
  18751. */
  18752. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18753. /**
  18754. * Disposes the InstancedMesh.
  18755. * Returns nothing.
  18756. */
  18757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18758. }
  18759. }
  18760. declare module BABYLON {
  18761. /**
  18762. * Defines the options associated with the creation of a shader material.
  18763. */
  18764. export interface IShaderMaterialOptions {
  18765. /**
  18766. * Does the material work in alpha blend mode
  18767. */
  18768. needAlphaBlending: boolean;
  18769. /**
  18770. * Does the material work in alpha test mode
  18771. */
  18772. needAlphaTesting: boolean;
  18773. /**
  18774. * The list of attribute names used in the shader
  18775. */
  18776. attributes: string[];
  18777. /**
  18778. * The list of unifrom names used in the shader
  18779. */
  18780. uniforms: string[];
  18781. /**
  18782. * The list of UBO names used in the shader
  18783. */
  18784. uniformBuffers: string[];
  18785. /**
  18786. * The list of sampler names used in the shader
  18787. */
  18788. samplers: string[];
  18789. /**
  18790. * The list of defines used in the shader
  18791. */
  18792. defines: string[];
  18793. }
  18794. /**
  18795. * 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.
  18796. *
  18797. * This returned material effects how the mesh will look based on the code in the shaders.
  18798. *
  18799. * @see http://doc.babylonjs.com/how_to/shader_material
  18800. */
  18801. export class ShaderMaterial extends Material {
  18802. private _shaderPath;
  18803. private _options;
  18804. private _textures;
  18805. private _textureArrays;
  18806. private _floats;
  18807. private _ints;
  18808. private _floatsArrays;
  18809. private _colors3;
  18810. private _colors3Arrays;
  18811. private _colors4;
  18812. private _colors4Arrays;
  18813. private _vectors2;
  18814. private _vectors3;
  18815. private _vectors4;
  18816. private _matrices;
  18817. private _matrices3x3;
  18818. private _matrices2x2;
  18819. private _vectors2Arrays;
  18820. private _vectors3Arrays;
  18821. private _vectors4Arrays;
  18822. private _cachedWorldViewMatrix;
  18823. private _cachedWorldViewProjectionMatrix;
  18824. private _renderId;
  18825. /**
  18826. * Instantiate a new shader material.
  18827. * 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.
  18828. * This returned material effects how the mesh will look based on the code in the shaders.
  18829. * @see http://doc.babylonjs.com/how_to/shader_material
  18830. * @param name Define the name of the material in the scene
  18831. * @param scene Define the scene the material belongs to
  18832. * @param shaderPath Defines the route to the shader code in one of three ways:
  18833. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18834. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18835. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18836. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18837. * @param options Define the options used to create the shader
  18838. */
  18839. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18840. /**
  18841. * Gets the options used to compile the shader.
  18842. * They can be modified to trigger a new compilation
  18843. */
  18844. readonly options: IShaderMaterialOptions;
  18845. /**
  18846. * Gets the current class name of the material e.g. "ShaderMaterial"
  18847. * Mainly use in serialization.
  18848. * @returns the class name
  18849. */
  18850. getClassName(): string;
  18851. /**
  18852. * Specifies if the material will require alpha blending
  18853. * @returns a boolean specifying if alpha blending is needed
  18854. */
  18855. needAlphaBlending(): boolean;
  18856. /**
  18857. * Specifies if this material should be rendered in alpha test mode
  18858. * @returns a boolean specifying if an alpha test is needed.
  18859. */
  18860. needAlphaTesting(): boolean;
  18861. private _checkUniform;
  18862. /**
  18863. * Set a texture in the shader.
  18864. * @param name Define the name of the uniform samplers as defined in the shader
  18865. * @param texture Define the texture to bind to this sampler
  18866. * @return the material itself allowing "fluent" like uniform updates
  18867. */
  18868. setTexture(name: string, texture: Texture): ShaderMaterial;
  18869. /**
  18870. * Set a texture array in the shader.
  18871. * @param name Define the name of the uniform sampler array as defined in the shader
  18872. * @param textures Define the list of textures to bind to this sampler
  18873. * @return the material itself allowing "fluent" like uniform updates
  18874. */
  18875. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18876. /**
  18877. * Set a float in the shader.
  18878. * @param name Define the name of the uniform as defined in the shader
  18879. * @param value Define the value to give to the uniform
  18880. * @return the material itself allowing "fluent" like uniform updates
  18881. */
  18882. setFloat(name: string, value: number): ShaderMaterial;
  18883. /**
  18884. * Set a int in the shader.
  18885. * @param name Define the name of the uniform as defined in the shader
  18886. * @param value Define the value to give to the uniform
  18887. * @return the material itself allowing "fluent" like uniform updates
  18888. */
  18889. setInt(name: string, value: number): ShaderMaterial;
  18890. /**
  18891. * Set an array of floats in the shader.
  18892. * @param name Define the name of the uniform as defined in the shader
  18893. * @param value Define the value to give to the uniform
  18894. * @return the material itself allowing "fluent" like uniform updates
  18895. */
  18896. setFloats(name: string, value: number[]): ShaderMaterial;
  18897. /**
  18898. * Set a vec3 in the shader from a Color3.
  18899. * @param name Define the name of the uniform as defined in the shader
  18900. * @param value Define the value to give to the uniform
  18901. * @return the material itself allowing "fluent" like uniform updates
  18902. */
  18903. setColor3(name: string, value: Color3): ShaderMaterial;
  18904. /**
  18905. * Set a vec3 array in the shader from a Color3 array.
  18906. * @param name Define the name of the uniform as defined in the shader
  18907. * @param value Define the value to give to the uniform
  18908. * @return the material itself allowing "fluent" like uniform updates
  18909. */
  18910. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18911. /**
  18912. * Set a vec4 in the shader from a Color4.
  18913. * @param name Define the name of the uniform as defined in the shader
  18914. * @param value Define the value to give to the uniform
  18915. * @return the material itself allowing "fluent" like uniform updates
  18916. */
  18917. setColor4(name: string, value: Color4): ShaderMaterial;
  18918. /**
  18919. * Set a vec4 array in the shader from a Color4 array.
  18920. * @param name Define the name of the uniform as defined in the shader
  18921. * @param value Define the value to give to the uniform
  18922. * @return the material itself allowing "fluent" like uniform updates
  18923. */
  18924. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18925. /**
  18926. * Set a vec2 in the shader from a Vector2.
  18927. * @param name Define the name of the uniform as defined in the shader
  18928. * @param value Define the value to give to the uniform
  18929. * @return the material itself allowing "fluent" like uniform updates
  18930. */
  18931. setVector2(name: string, value: Vector2): ShaderMaterial;
  18932. /**
  18933. * Set a vec3 in the shader from a Vector3.
  18934. * @param name Define the name of the uniform as defined in the shader
  18935. * @param value Define the value to give to the uniform
  18936. * @return the material itself allowing "fluent" like uniform updates
  18937. */
  18938. setVector3(name: string, value: Vector3): ShaderMaterial;
  18939. /**
  18940. * Set a vec4 in the shader from a Vector4.
  18941. * @param name Define the name of the uniform as defined in the shader
  18942. * @param value Define the value to give to the uniform
  18943. * @return the material itself allowing "fluent" like uniform updates
  18944. */
  18945. setVector4(name: string, value: Vector4): ShaderMaterial;
  18946. /**
  18947. * Set a mat4 in the shader from a Matrix.
  18948. * @param name Define the name of the uniform as defined in the shader
  18949. * @param value Define the value to give to the uniform
  18950. * @return the material itself allowing "fluent" like uniform updates
  18951. */
  18952. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18953. /**
  18954. * Set a mat3 in the shader from a Float32Array.
  18955. * @param name Define the name of the uniform as defined in the shader
  18956. * @param value Define the value to give to the uniform
  18957. * @return the material itself allowing "fluent" like uniform updates
  18958. */
  18959. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18960. /**
  18961. * Set a mat2 in the shader from a Float32Array.
  18962. * @param name Define the name of the uniform as defined in the shader
  18963. * @param value Define the value to give to the uniform
  18964. * @return the material itself allowing "fluent" like uniform updates
  18965. */
  18966. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18967. /**
  18968. * Set a vec2 array in the shader from a number array.
  18969. * @param name Define the name of the uniform as defined in the shader
  18970. * @param value Define the value to give to the uniform
  18971. * @return the material itself allowing "fluent" like uniform updates
  18972. */
  18973. setArray2(name: string, value: number[]): ShaderMaterial;
  18974. /**
  18975. * Set a vec3 array in the shader from a number array.
  18976. * @param name Define the name of the uniform as defined in the shader
  18977. * @param value Define the value to give to the uniform
  18978. * @return the material itself allowing "fluent" like uniform updates
  18979. */
  18980. setArray3(name: string, value: number[]): ShaderMaterial;
  18981. /**
  18982. * Set a vec4 array in the shader from a number array.
  18983. * @param name Define the name of the uniform as defined in the shader
  18984. * @param value Define the value to give to the uniform
  18985. * @return the material itself allowing "fluent" like uniform updates
  18986. */
  18987. setArray4(name: string, value: number[]): ShaderMaterial;
  18988. private _checkCache;
  18989. /**
  18990. * Specifies that the submesh is ready to be used
  18991. * @param mesh defines the mesh to check
  18992. * @param subMesh defines which submesh to check
  18993. * @param useInstances specifies that instances should be used
  18994. * @returns a boolean indicating that the submesh is ready or not
  18995. */
  18996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18997. /**
  18998. * Checks if the material is ready to render the requested mesh
  18999. * @param mesh Define the mesh to render
  19000. * @param useInstances Define whether or not the material is used with instances
  19001. * @returns true if ready, otherwise false
  19002. */
  19003. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19004. /**
  19005. * Binds the world matrix to the material
  19006. * @param world defines the world transformation matrix
  19007. */
  19008. bindOnlyWorldMatrix(world: Matrix): void;
  19009. /**
  19010. * Binds the material to the mesh
  19011. * @param world defines the world transformation matrix
  19012. * @param mesh defines the mesh to bind the material to
  19013. */
  19014. bind(world: Matrix, mesh?: Mesh): void;
  19015. /**
  19016. * Gets the active textures from the material
  19017. * @returns an array of textures
  19018. */
  19019. getActiveTextures(): BaseTexture[];
  19020. /**
  19021. * Specifies if the material uses a texture
  19022. * @param texture defines the texture to check against the material
  19023. * @returns a boolean specifying if the material uses the texture
  19024. */
  19025. hasTexture(texture: BaseTexture): boolean;
  19026. /**
  19027. * Makes a duplicate of the material, and gives it a new name
  19028. * @param name defines the new name for the duplicated material
  19029. * @returns the cloned material
  19030. */
  19031. clone(name: string): ShaderMaterial;
  19032. /**
  19033. * Disposes the material
  19034. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19035. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19036. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19037. */
  19038. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19039. /**
  19040. * Serializes this material in a JSON representation
  19041. * @returns the serialized material object
  19042. */
  19043. serialize(): any;
  19044. /**
  19045. * Creates a shader material from parsed shader material data
  19046. * @param source defines the JSON represnetation of the material
  19047. * @param scene defines the hosting scene
  19048. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19049. * @returns a new material
  19050. */
  19051. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19052. }
  19053. }
  19054. declare module BABYLON {
  19055. /** @hidden */
  19056. export var colorPixelShader: {
  19057. name: string;
  19058. shader: string;
  19059. };
  19060. }
  19061. declare module BABYLON {
  19062. /** @hidden */
  19063. export var colorVertexShader: {
  19064. name: string;
  19065. shader: string;
  19066. };
  19067. }
  19068. declare module BABYLON {
  19069. /**
  19070. * Line mesh
  19071. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19072. */
  19073. export class LinesMesh extends Mesh {
  19074. /**
  19075. * If vertex color should be applied to the mesh
  19076. */
  19077. readonly useVertexColor?: boolean | undefined;
  19078. /**
  19079. * If vertex alpha should be applied to the mesh
  19080. */
  19081. readonly useVertexAlpha?: boolean | undefined;
  19082. /**
  19083. * Color of the line (Default: White)
  19084. */
  19085. color: Color3;
  19086. /**
  19087. * Alpha of the line (Default: 1)
  19088. */
  19089. alpha: number;
  19090. /**
  19091. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19092. * This margin is expressed in world space coordinates, so its value may vary.
  19093. * Default value is 0.1
  19094. */
  19095. intersectionThreshold: number;
  19096. private _colorShader;
  19097. private color4;
  19098. /**
  19099. * Creates a new LinesMesh
  19100. * @param name defines the name
  19101. * @param scene defines the hosting scene
  19102. * @param parent defines the parent mesh if any
  19103. * @param source defines the optional source LinesMesh used to clone data from
  19104. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19105. * When false, achieved by calling a clone(), also passing False.
  19106. * This will make creation of children, recursive.
  19107. * @param useVertexColor defines if this LinesMesh supports vertex color
  19108. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19109. */
  19110. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19111. /**
  19112. * If vertex color should be applied to the mesh
  19113. */
  19114. useVertexColor?: boolean | undefined,
  19115. /**
  19116. * If vertex alpha should be applied to the mesh
  19117. */
  19118. useVertexAlpha?: boolean | undefined);
  19119. private _addClipPlaneDefine;
  19120. private _removeClipPlaneDefine;
  19121. isReady(): boolean;
  19122. /**
  19123. * Returns the string "LineMesh"
  19124. */
  19125. getClassName(): string;
  19126. /**
  19127. * @hidden
  19128. */
  19129. /**
  19130. * @hidden
  19131. */
  19132. material: Material;
  19133. /**
  19134. * @hidden
  19135. */
  19136. readonly checkCollisions: boolean;
  19137. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19138. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19139. /**
  19140. * Disposes of the line mesh
  19141. * @param doNotRecurse If children should be disposed
  19142. */
  19143. dispose(doNotRecurse?: boolean): void;
  19144. /**
  19145. * Returns a new LineMesh object cloned from the current one.
  19146. */
  19147. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19148. /**
  19149. * Creates a new InstancedLinesMesh object from the mesh model.
  19150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19151. * @param name defines the name of the new instance
  19152. * @returns a new InstancedLinesMesh
  19153. */
  19154. createInstance(name: string): InstancedLinesMesh;
  19155. }
  19156. /**
  19157. * Creates an instance based on a source LinesMesh
  19158. */
  19159. export class InstancedLinesMesh extends InstancedMesh {
  19160. /**
  19161. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19162. * This margin is expressed in world space coordinates, so its value may vary.
  19163. * Initilized with the intersectionThreshold value of the source LinesMesh
  19164. */
  19165. intersectionThreshold: number;
  19166. constructor(name: string, source: LinesMesh);
  19167. /**
  19168. * Returns the string "InstancedLinesMesh".
  19169. */
  19170. getClassName(): string;
  19171. }
  19172. }
  19173. declare module BABYLON {
  19174. /** @hidden */
  19175. export var linePixelShader: {
  19176. name: string;
  19177. shader: string;
  19178. };
  19179. }
  19180. declare module BABYLON {
  19181. /** @hidden */
  19182. export var lineVertexShader: {
  19183. name: string;
  19184. shader: string;
  19185. };
  19186. }
  19187. declare module BABYLON {
  19188. interface AbstractMesh {
  19189. /**
  19190. * Gets the edgesRenderer associated with the mesh
  19191. */
  19192. edgesRenderer: Nullable<EdgesRenderer>;
  19193. }
  19194. interface LinesMesh {
  19195. /**
  19196. * Enables the edge rendering mode on the mesh.
  19197. * This mode makes the mesh edges visible
  19198. * @param epsilon defines the maximal distance between two angles to detect a face
  19199. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19200. * @returns the currentAbstractMesh
  19201. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19202. */
  19203. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19204. }
  19205. interface InstancedLinesMesh {
  19206. /**
  19207. * Enables the edge rendering mode on the mesh.
  19208. * This mode makes the mesh edges visible
  19209. * @param epsilon defines the maximal distance between two angles to detect a face
  19210. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19211. * @returns the current InstancedLinesMesh
  19212. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19213. */
  19214. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19215. }
  19216. /**
  19217. * Defines the minimum contract an Edges renderer should follow.
  19218. */
  19219. export interface IEdgesRenderer extends IDisposable {
  19220. /**
  19221. * Gets or sets a boolean indicating if the edgesRenderer is active
  19222. */
  19223. isEnabled: boolean;
  19224. /**
  19225. * Renders the edges of the attached mesh,
  19226. */
  19227. render(): void;
  19228. /**
  19229. * Checks wether or not the edges renderer is ready to render.
  19230. * @return true if ready, otherwise false.
  19231. */
  19232. isReady(): boolean;
  19233. }
  19234. /**
  19235. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19236. */
  19237. export class EdgesRenderer implements IEdgesRenderer {
  19238. /**
  19239. * Define the size of the edges with an orthographic camera
  19240. */
  19241. edgesWidthScalerForOrthographic: number;
  19242. /**
  19243. * Define the size of the edges with a perspective camera
  19244. */
  19245. edgesWidthScalerForPerspective: number;
  19246. protected _source: AbstractMesh;
  19247. protected _linesPositions: number[];
  19248. protected _linesNormals: number[];
  19249. protected _linesIndices: number[];
  19250. protected _epsilon: number;
  19251. protected _indicesCount: number;
  19252. protected _lineShader: ShaderMaterial;
  19253. protected _ib: DataBuffer;
  19254. protected _buffers: {
  19255. [key: string]: Nullable<VertexBuffer>;
  19256. };
  19257. protected _checkVerticesInsteadOfIndices: boolean;
  19258. private _meshRebuildObserver;
  19259. private _meshDisposeObserver;
  19260. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19261. isEnabled: boolean;
  19262. /**
  19263. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19264. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19265. * @param source Mesh used to create edges
  19266. * @param epsilon sum of angles in adjacency to check for edge
  19267. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19268. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19269. */
  19270. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19271. protected _prepareRessources(): void;
  19272. /** @hidden */ private _rebuild(): void;
  19273. /**
  19274. * Releases the required resources for the edges renderer
  19275. */
  19276. dispose(): void;
  19277. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19278. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19279. /**
  19280. * Checks if the pair of p0 and p1 is en edge
  19281. * @param faceIndex
  19282. * @param edge
  19283. * @param faceNormals
  19284. * @param p0
  19285. * @param p1
  19286. * @private
  19287. */
  19288. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19289. /**
  19290. * push line into the position, normal and index buffer
  19291. * @protected
  19292. */
  19293. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19294. /**
  19295. * Generates lines edges from adjacencjes
  19296. * @private
  19297. */ private _generateEdgesLines(): void;
  19298. /**
  19299. * Checks wether or not the edges renderer is ready to render.
  19300. * @return true if ready, otherwise false.
  19301. */
  19302. isReady(): boolean;
  19303. /**
  19304. * Renders the edges of the attached mesh,
  19305. */
  19306. render(): void;
  19307. }
  19308. /**
  19309. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19310. */
  19311. export class LineEdgesRenderer extends EdgesRenderer {
  19312. /**
  19313. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19314. * @param source LineMesh used to generate edges
  19315. * @param epsilon not important (specified angle for edge detection)
  19316. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19317. */
  19318. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19319. /**
  19320. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19321. */ private _generateEdgesLines(): void;
  19322. }
  19323. }
  19324. declare module BABYLON {
  19325. /**
  19326. * This represents the object necessary to create a rendering group.
  19327. * This is exclusively used and created by the rendering manager.
  19328. * To modify the behavior, you use the available helpers in your scene or meshes.
  19329. * @hidden
  19330. */
  19331. export class RenderingGroup {
  19332. index: number;
  19333. private static _zeroVector;
  19334. private _scene;
  19335. private _opaqueSubMeshes;
  19336. private _transparentSubMeshes;
  19337. private _alphaTestSubMeshes;
  19338. private _depthOnlySubMeshes;
  19339. private _particleSystems;
  19340. private _spriteManagers;
  19341. private _opaqueSortCompareFn;
  19342. private _alphaTestSortCompareFn;
  19343. private _transparentSortCompareFn;
  19344. private _renderOpaque;
  19345. private _renderAlphaTest;
  19346. private _renderTransparent;
  19347. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19348. onBeforeTransparentRendering: () => void;
  19349. /**
  19350. * Set the opaque sort comparison function.
  19351. * If null the sub meshes will be render in the order they were created
  19352. */
  19353. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19354. /**
  19355. * Set the alpha test sort comparison function.
  19356. * If null the sub meshes will be render in the order they were created
  19357. */
  19358. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19359. /**
  19360. * Set the transparent sort comparison function.
  19361. * If null the sub meshes will be render in the order they were created
  19362. */
  19363. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19364. /**
  19365. * Creates a new rendering group.
  19366. * @param index The rendering group index
  19367. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19368. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19369. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19370. */
  19371. 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>);
  19372. /**
  19373. * Render all the sub meshes contained in the group.
  19374. * @param customRenderFunction Used to override the default render behaviour of the group.
  19375. * @returns true if rendered some submeshes.
  19376. */
  19377. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19378. /**
  19379. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19380. * @param subMeshes The submeshes to render
  19381. */
  19382. private renderOpaqueSorted;
  19383. /**
  19384. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19385. * @param subMeshes The submeshes to render
  19386. */
  19387. private renderAlphaTestSorted;
  19388. /**
  19389. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19390. * @param subMeshes The submeshes to render
  19391. */
  19392. private renderTransparentSorted;
  19393. /**
  19394. * Renders the submeshes in a specified order.
  19395. * @param subMeshes The submeshes to sort before render
  19396. * @param sortCompareFn The comparison function use to sort
  19397. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19398. * @param transparent Specifies to activate blending if true
  19399. */
  19400. private static renderSorted;
  19401. /**
  19402. * Renders the submeshes in the order they were dispatched (no sort applied).
  19403. * @param subMeshes The submeshes to render
  19404. */
  19405. private static renderUnsorted;
  19406. /**
  19407. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19408. * are rendered back to front if in the same alpha index.
  19409. *
  19410. * @param a The first submesh
  19411. * @param b The second submesh
  19412. * @returns The result of the comparison
  19413. */
  19414. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19415. /**
  19416. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19417. * are rendered back to front.
  19418. *
  19419. * @param a The first submesh
  19420. * @param b The second submesh
  19421. * @returns The result of the comparison
  19422. */
  19423. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19424. /**
  19425. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19426. * are rendered front to back (prevent overdraw).
  19427. *
  19428. * @param a The first submesh
  19429. * @param b The second submesh
  19430. * @returns The result of the comparison
  19431. */
  19432. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19433. /**
  19434. * Resets the different lists of submeshes to prepare a new frame.
  19435. */
  19436. prepare(): void;
  19437. dispose(): void;
  19438. /**
  19439. * Inserts the submesh in its correct queue depending on its material.
  19440. * @param subMesh The submesh to dispatch
  19441. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19442. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19443. */
  19444. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19445. dispatchSprites(spriteManager: ISpriteManager): void;
  19446. dispatchParticles(particleSystem: IParticleSystem): void;
  19447. private _renderParticles;
  19448. private _renderSprites;
  19449. }
  19450. }
  19451. declare module BABYLON {
  19452. /**
  19453. * Interface describing the different options available in the rendering manager
  19454. * regarding Auto Clear between groups.
  19455. */
  19456. export interface IRenderingManagerAutoClearSetup {
  19457. /**
  19458. * Defines whether or not autoclear is enable.
  19459. */
  19460. autoClear: boolean;
  19461. /**
  19462. * Defines whether or not to autoclear the depth buffer.
  19463. */
  19464. depth: boolean;
  19465. /**
  19466. * Defines whether or not to autoclear the stencil buffer.
  19467. */
  19468. stencil: boolean;
  19469. }
  19470. /**
  19471. * This class is used by the onRenderingGroupObservable
  19472. */
  19473. export class RenderingGroupInfo {
  19474. /**
  19475. * The Scene that being rendered
  19476. */
  19477. scene: Scene;
  19478. /**
  19479. * The camera currently used for the rendering pass
  19480. */
  19481. camera: Nullable<Camera>;
  19482. /**
  19483. * The ID of the renderingGroup being processed
  19484. */
  19485. renderingGroupId: number;
  19486. }
  19487. /**
  19488. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19489. * It is enable to manage the different groups as well as the different necessary sort functions.
  19490. * This should not be used directly aside of the few static configurations
  19491. */
  19492. export class RenderingManager {
  19493. /**
  19494. * The max id used for rendering groups (not included)
  19495. */
  19496. static MAX_RENDERINGGROUPS: number;
  19497. /**
  19498. * The min id used for rendering groups (included)
  19499. */
  19500. static MIN_RENDERINGGROUPS: number;
  19501. /**
  19502. * Used to globally prevent autoclearing scenes.
  19503. */
  19504. static AUTOCLEAR: boolean;
  19505. /**
  19506. * @hidden
  19507. */ private _useSceneAutoClearSetup: boolean;
  19508. private _scene;
  19509. private _renderingGroups;
  19510. private _depthStencilBufferAlreadyCleaned;
  19511. private _autoClearDepthStencil;
  19512. private _customOpaqueSortCompareFn;
  19513. private _customAlphaTestSortCompareFn;
  19514. private _customTransparentSortCompareFn;
  19515. private _renderingGroupInfo;
  19516. /**
  19517. * Instantiates a new rendering group for a particular scene
  19518. * @param scene Defines the scene the groups belongs to
  19519. */
  19520. constructor(scene: Scene);
  19521. private _clearDepthStencilBuffer;
  19522. /**
  19523. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19524. * @hidden
  19525. */
  19526. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19527. /**
  19528. * Resets the different information of the group to prepare a new frame
  19529. * @hidden
  19530. */
  19531. reset(): void;
  19532. /**
  19533. * Dispose and release the group and its associated resources.
  19534. * @hidden
  19535. */
  19536. dispose(): void;
  19537. /**
  19538. * Clear the info related to rendering groups preventing retention points during dispose.
  19539. */
  19540. freeRenderingGroups(): void;
  19541. private _prepareRenderingGroup;
  19542. /**
  19543. * Add a sprite manager to the rendering manager in order to render it this frame.
  19544. * @param spriteManager Define the sprite manager to render
  19545. */
  19546. dispatchSprites(spriteManager: ISpriteManager): void;
  19547. /**
  19548. * Add a particle system to the rendering manager in order to render it this frame.
  19549. * @param particleSystem Define the particle system to render
  19550. */
  19551. dispatchParticles(particleSystem: IParticleSystem): void;
  19552. /**
  19553. * Add a submesh to the manager in order to render it this frame
  19554. * @param subMesh The submesh to dispatch
  19555. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19556. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19557. */
  19558. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19559. /**
  19560. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19561. * This allowed control for front to back rendering or reversly depending of the special needs.
  19562. *
  19563. * @param renderingGroupId The rendering group id corresponding to its index
  19564. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19565. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19566. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19567. */
  19568. 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;
  19569. /**
  19570. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19571. *
  19572. * @param renderingGroupId The rendering group id corresponding to its index
  19573. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19574. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19575. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19576. */
  19577. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19578. /**
  19579. * Gets the current auto clear configuration for one rendering group of the rendering
  19580. * manager.
  19581. * @param index the rendering group index to get the information for
  19582. * @returns The auto clear setup for the requested rendering group
  19583. */
  19584. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19585. }
  19586. }
  19587. declare module BABYLON {
  19588. /**
  19589. * This Helps creating a texture that will be created from a camera in your scene.
  19590. * It is basically a dynamic texture that could be used to create special effects for instance.
  19591. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19592. */
  19593. export class RenderTargetTexture extends Texture {
  19594. isCube: boolean;
  19595. /**
  19596. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19597. */
  19598. static readonly REFRESHRATE_RENDER_ONCE: number;
  19599. /**
  19600. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19601. */
  19602. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19603. /**
  19604. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19605. * the central point of your effect and can save a lot of performances.
  19606. */
  19607. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19608. /**
  19609. * Use this predicate to dynamically define the list of mesh you want to render.
  19610. * If set, the renderList property will be overwritten.
  19611. */
  19612. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19613. private _renderList;
  19614. /**
  19615. * Use this list to define the list of mesh you want to render.
  19616. */
  19617. renderList: Nullable<Array<AbstractMesh>>;
  19618. private _hookArray;
  19619. /**
  19620. * Define if particles should be rendered in your texture.
  19621. */
  19622. renderParticles: boolean;
  19623. /**
  19624. * Define if sprites should be rendered in your texture.
  19625. */
  19626. renderSprites: boolean;
  19627. /**
  19628. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19629. */
  19630. coordinatesMode: number;
  19631. /**
  19632. * Define the camera used to render the texture.
  19633. */
  19634. activeCamera: Nullable<Camera>;
  19635. /**
  19636. * Override the render function of the texture with your own one.
  19637. */
  19638. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19639. /**
  19640. * Define if camera post processes should be use while rendering the texture.
  19641. */
  19642. useCameraPostProcesses: boolean;
  19643. /**
  19644. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19645. */
  19646. ignoreCameraViewport: boolean;
  19647. private _postProcessManager;
  19648. private _postProcesses;
  19649. private _resizeObserver;
  19650. /**
  19651. * An event triggered when the texture is unbind.
  19652. */
  19653. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19654. /**
  19655. * An event triggered when the texture is unbind.
  19656. */
  19657. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19658. private _onAfterUnbindObserver;
  19659. /**
  19660. * Set a after unbind callback in the texture.
  19661. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19662. */
  19663. onAfterUnbind: () => void;
  19664. /**
  19665. * An event triggered before rendering the texture
  19666. */
  19667. onBeforeRenderObservable: Observable<number>;
  19668. private _onBeforeRenderObserver;
  19669. /**
  19670. * Set a before render callback in the texture.
  19671. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19672. */
  19673. onBeforeRender: (faceIndex: number) => void;
  19674. /**
  19675. * An event triggered after rendering the texture
  19676. */
  19677. onAfterRenderObservable: Observable<number>;
  19678. private _onAfterRenderObserver;
  19679. /**
  19680. * Set a after render callback in the texture.
  19681. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19682. */
  19683. onAfterRender: (faceIndex: number) => void;
  19684. /**
  19685. * An event triggered after the texture clear
  19686. */
  19687. onClearObservable: Observable<Engine>;
  19688. private _onClearObserver;
  19689. /**
  19690. * Set a clear callback in the texture.
  19691. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19692. */
  19693. onClear: (Engine: Engine) => void;
  19694. /**
  19695. * An event triggered when the texture is resized.
  19696. */
  19697. onResizeObservable: Observable<RenderTargetTexture>;
  19698. /**
  19699. * Define the clear color of the Render Target if it should be different from the scene.
  19700. */
  19701. clearColor: Color4;
  19702. protected _size: number | {
  19703. width: number;
  19704. height: number;
  19705. };
  19706. protected _initialSizeParameter: number | {
  19707. width: number;
  19708. height: number;
  19709. } | {
  19710. ratio: number;
  19711. };
  19712. protected _sizeRatio: Nullable<number>;
  19713. /** @hidden */ private _generateMipMaps: boolean;
  19714. protected _renderingManager: RenderingManager;
  19715. /** @hidden */ private _waitingRenderList: string[];
  19716. protected _doNotChangeAspectRatio: boolean;
  19717. protected _currentRefreshId: number;
  19718. protected _refreshRate: number;
  19719. protected _textureMatrix: Matrix;
  19720. protected _samples: number;
  19721. protected _renderTargetOptions: RenderTargetCreationOptions;
  19722. /**
  19723. * Gets render target creation options that were used.
  19724. */
  19725. readonly renderTargetOptions: RenderTargetCreationOptions;
  19726. protected _engine: Engine;
  19727. protected _onRatioRescale(): void;
  19728. /**
  19729. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19730. * It must define where the camera used to render the texture is set
  19731. */
  19732. boundingBoxPosition: Vector3;
  19733. private _boundingBoxSize;
  19734. /**
  19735. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19736. * When defined, the cubemap will switch to local mode
  19737. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19738. * @example https://www.babylonjs-playground.com/#RNASML
  19739. */
  19740. boundingBoxSize: Vector3;
  19741. /**
  19742. * In case the RTT has been created with a depth texture, get the associated
  19743. * depth texture.
  19744. * Otherwise, return null.
  19745. */
  19746. depthStencilTexture: Nullable<InternalTexture>;
  19747. /**
  19748. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19749. * or used a shadow, depth texture...
  19750. * @param name The friendly name of the texture
  19751. * @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)
  19752. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19753. * @param generateMipMaps True if mip maps need to be generated after render.
  19754. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19755. * @param type The type of the buffer in the RTT (int, half float, float...)
  19756. * @param isCube True if a cube texture needs to be created
  19757. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19758. * @param generateDepthBuffer True to generate a depth buffer
  19759. * @param generateStencilBuffer True to generate a stencil buffer
  19760. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19761. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19762. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19763. */
  19764. constructor(name: string, size: number | {
  19765. width: number;
  19766. height: number;
  19767. } | {
  19768. ratio: number;
  19769. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19770. /**
  19771. * Creates a depth stencil texture.
  19772. * This is only available in WebGL 2 or with the depth texture extension available.
  19773. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19774. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19775. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19776. */
  19777. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19778. private _processSizeParameter;
  19779. /**
  19780. * Define the number of samples to use in case of MSAA.
  19781. * It defaults to one meaning no MSAA has been enabled.
  19782. */
  19783. samples: number;
  19784. /**
  19785. * Resets the refresh counter of the texture and start bak from scratch.
  19786. * Could be useful to regenerate the texture if it is setup to render only once.
  19787. */
  19788. resetRefreshCounter(): void;
  19789. /**
  19790. * Define the refresh rate of the texture or the rendering frequency.
  19791. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19792. */
  19793. refreshRate: number;
  19794. /**
  19795. * Adds a post process to the render target rendering passes.
  19796. * @param postProcess define the post process to add
  19797. */
  19798. addPostProcess(postProcess: PostProcess): void;
  19799. /**
  19800. * Clear all the post processes attached to the render target
  19801. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19802. */
  19803. clearPostProcesses(dispose?: boolean): void;
  19804. /**
  19805. * Remove one of the post process from the list of attached post processes to the texture
  19806. * @param postProcess define the post process to remove from the list
  19807. */
  19808. removePostProcess(postProcess: PostProcess): void;
  19809. /** @hidden */ private _shouldRender(): boolean;
  19810. /**
  19811. * Gets the actual render size of the texture.
  19812. * @returns the width of the render size
  19813. */
  19814. getRenderSize(): number;
  19815. /**
  19816. * Gets the actual render width of the texture.
  19817. * @returns the width of the render size
  19818. */
  19819. getRenderWidth(): number;
  19820. /**
  19821. * Gets the actual render height of the texture.
  19822. * @returns the height of the render size
  19823. */
  19824. getRenderHeight(): number;
  19825. /**
  19826. * Get if the texture can be rescaled or not.
  19827. */
  19828. readonly canRescale: boolean;
  19829. /**
  19830. * Resize the texture using a ratio.
  19831. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19832. */
  19833. scale(ratio: number): void;
  19834. /**
  19835. * Get the texture reflection matrix used to rotate/transform the reflection.
  19836. * @returns the reflection matrix
  19837. */
  19838. getReflectionTextureMatrix(): Matrix;
  19839. /**
  19840. * Resize the texture to a new desired size.
  19841. * Be carrefull as it will recreate all the data in the new texture.
  19842. * @param size Define the new size. It can be:
  19843. * - a number for squared texture,
  19844. * - an object containing { width: number, height: number }
  19845. * - or an object containing a ratio { ratio: number }
  19846. */
  19847. resize(size: number | {
  19848. width: number;
  19849. height: number;
  19850. } | {
  19851. ratio: number;
  19852. }): void;
  19853. /**
  19854. * Renders all the objects from the render list into the texture.
  19855. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19856. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19857. */
  19858. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19859. private _bestReflectionRenderTargetDimension;
  19860. /**
  19861. * @hidden
  19862. * @param faceIndex face index to bind to if this is a cubetexture
  19863. */ private _bindFrameBuffer(faceIndex?: number): void;
  19864. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19865. private renderToTarget;
  19866. /**
  19867. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19868. * This allowed control for front to back rendering or reversly depending of the special needs.
  19869. *
  19870. * @param renderingGroupId The rendering group id corresponding to its index
  19871. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19872. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19873. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19874. */
  19875. 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;
  19876. /**
  19877. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19878. *
  19879. * @param renderingGroupId The rendering group id corresponding to its index
  19880. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19881. */
  19882. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19883. /**
  19884. * Clones the texture.
  19885. * @returns the cloned texture
  19886. */
  19887. clone(): RenderTargetTexture;
  19888. /**
  19889. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19890. * @returns The JSON representation of the texture
  19891. */
  19892. serialize(): any;
  19893. /**
  19894. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19895. */
  19896. disposeFramebufferObjects(): void;
  19897. /**
  19898. * Dispose the texture and release its associated resources.
  19899. */
  19900. dispose(): void;
  19901. /** @hidden */ private _rebuild(): void;
  19902. /**
  19903. * Clear the info related to rendering groups preventing retention point in material dispose.
  19904. */
  19905. freeRenderingGroups(): void;
  19906. /**
  19907. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19908. * @returns the view count
  19909. */
  19910. getViewCount(): number;
  19911. }
  19912. }
  19913. declare module BABYLON {
  19914. /**
  19915. * Base class for the main features of a material in Babylon.js
  19916. */
  19917. export class Material implements IAnimatable {
  19918. /**
  19919. * Returns the triangle fill mode
  19920. */
  19921. static readonly TriangleFillMode: number;
  19922. /**
  19923. * Returns the wireframe mode
  19924. */
  19925. static readonly WireFrameFillMode: number;
  19926. /**
  19927. * Returns the point fill mode
  19928. */
  19929. static readonly PointFillMode: number;
  19930. /**
  19931. * Returns the point list draw mode
  19932. */
  19933. static readonly PointListDrawMode: number;
  19934. /**
  19935. * Returns the line list draw mode
  19936. */
  19937. static readonly LineListDrawMode: number;
  19938. /**
  19939. * Returns the line loop draw mode
  19940. */
  19941. static readonly LineLoopDrawMode: number;
  19942. /**
  19943. * Returns the line strip draw mode
  19944. */
  19945. static readonly LineStripDrawMode: number;
  19946. /**
  19947. * Returns the triangle strip draw mode
  19948. */
  19949. static readonly TriangleStripDrawMode: number;
  19950. /**
  19951. * Returns the triangle fan draw mode
  19952. */
  19953. static readonly TriangleFanDrawMode: number;
  19954. /**
  19955. * Stores the clock-wise side orientation
  19956. */
  19957. static readonly ClockWiseSideOrientation: number;
  19958. /**
  19959. * Stores the counter clock-wise side orientation
  19960. */
  19961. static readonly CounterClockWiseSideOrientation: number;
  19962. /**
  19963. * The dirty texture flag value
  19964. */
  19965. static readonly TextureDirtyFlag: number;
  19966. /**
  19967. * The dirty light flag value
  19968. */
  19969. static readonly LightDirtyFlag: number;
  19970. /**
  19971. * The dirty fresnel flag value
  19972. */
  19973. static readonly FresnelDirtyFlag: number;
  19974. /**
  19975. * The dirty attribute flag value
  19976. */
  19977. static readonly AttributesDirtyFlag: number;
  19978. /**
  19979. * The dirty misc flag value
  19980. */
  19981. static readonly MiscDirtyFlag: number;
  19982. /**
  19983. * The all dirty flag value
  19984. */
  19985. static readonly AllDirtyFlag: number;
  19986. /**
  19987. * The ID of the material
  19988. */
  19989. id: string;
  19990. /**
  19991. * Gets or sets the unique id of the material
  19992. */
  19993. uniqueId: number;
  19994. /**
  19995. * The name of the material
  19996. */
  19997. name: string;
  19998. /**
  19999. * Gets or sets user defined metadata
  20000. */
  20001. metadata: any;
  20002. /**
  20003. * For internal use only. Please do not use.
  20004. */
  20005. reservedDataStore: any;
  20006. /**
  20007. * Specifies if the ready state should be checked on each call
  20008. */
  20009. checkReadyOnEveryCall: boolean;
  20010. /**
  20011. * Specifies if the ready state should be checked once
  20012. */
  20013. checkReadyOnlyOnce: boolean;
  20014. /**
  20015. * The state of the material
  20016. */
  20017. state: string;
  20018. /**
  20019. * The alpha value of the material
  20020. */
  20021. protected _alpha: number;
  20022. /**
  20023. * List of inspectable custom properties (used by the Inspector)
  20024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20025. */
  20026. inspectableCustomProperties: IInspectable[];
  20027. /**
  20028. * Sets the alpha value of the material
  20029. */
  20030. /**
  20031. * Gets the alpha value of the material
  20032. */
  20033. alpha: number;
  20034. /**
  20035. * Specifies if back face culling is enabled
  20036. */
  20037. protected _backFaceCulling: boolean;
  20038. /**
  20039. * Sets the back-face culling state
  20040. */
  20041. /**
  20042. * Gets the back-face culling state
  20043. */
  20044. backFaceCulling: boolean;
  20045. /**
  20046. * Stores the value for side orientation
  20047. */
  20048. sideOrientation: number;
  20049. /**
  20050. * Callback triggered when the material is compiled
  20051. */
  20052. onCompiled: Nullable<(effect: Effect) => void>;
  20053. /**
  20054. * Callback triggered when an error occurs
  20055. */
  20056. onError: Nullable<(effect: Effect, errors: string) => void>;
  20057. /**
  20058. * Callback triggered to get the render target textures
  20059. */
  20060. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20061. /**
  20062. * Gets a boolean indicating that current material needs to register RTT
  20063. */
  20064. readonly hasRenderTargetTextures: boolean;
  20065. /**
  20066. * Specifies if the material should be serialized
  20067. */
  20068. doNotSerialize: boolean;
  20069. /**
  20070. * @hidden
  20071. */ private _storeEffectOnSubMeshes: boolean;
  20072. /**
  20073. * Stores the animations for the material
  20074. */
  20075. animations: Nullable<Array<Animation>>;
  20076. /**
  20077. * An event triggered when the material is disposed
  20078. */
  20079. onDisposeObservable: Observable<Material>;
  20080. /**
  20081. * An observer which watches for dispose events
  20082. */
  20083. private _onDisposeObserver;
  20084. private _onUnBindObservable;
  20085. /**
  20086. * Called during a dispose event
  20087. */
  20088. onDispose: () => void;
  20089. private _onBindObservable;
  20090. /**
  20091. * An event triggered when the material is bound
  20092. */
  20093. readonly onBindObservable: Observable<AbstractMesh>;
  20094. /**
  20095. * An observer which watches for bind events
  20096. */
  20097. private _onBindObserver;
  20098. /**
  20099. * Called during a bind event
  20100. */
  20101. onBind: (Mesh: AbstractMesh) => void;
  20102. /**
  20103. * An event triggered when the material is unbound
  20104. */
  20105. readonly onUnBindObservable: Observable<Material>;
  20106. /**
  20107. * Stores the value of the alpha mode
  20108. */
  20109. private _alphaMode;
  20110. /**
  20111. * Sets the value of the alpha mode.
  20112. *
  20113. * | Value | Type | Description |
  20114. * | --- | --- | --- |
  20115. * | 0 | ALPHA_DISABLE | |
  20116. * | 1 | ALPHA_ADD | |
  20117. * | 2 | ALPHA_COMBINE | |
  20118. * | 3 | ALPHA_SUBTRACT | |
  20119. * | 4 | ALPHA_MULTIPLY | |
  20120. * | 5 | ALPHA_MAXIMIZED | |
  20121. * | 6 | ALPHA_ONEONE | |
  20122. * | 7 | ALPHA_PREMULTIPLIED | |
  20123. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20124. * | 9 | ALPHA_INTERPOLATE | |
  20125. * | 10 | ALPHA_SCREENMODE | |
  20126. *
  20127. */
  20128. /**
  20129. * Gets the value of the alpha mode
  20130. */
  20131. alphaMode: number;
  20132. /**
  20133. * Stores the state of the need depth pre-pass value
  20134. */
  20135. private _needDepthPrePass;
  20136. /**
  20137. * Sets the need depth pre-pass value
  20138. */
  20139. /**
  20140. * Gets the depth pre-pass value
  20141. */
  20142. needDepthPrePass: boolean;
  20143. /**
  20144. * Specifies if depth writing should be disabled
  20145. */
  20146. disableDepthWrite: boolean;
  20147. /**
  20148. * Specifies if depth writing should be forced
  20149. */
  20150. forceDepthWrite: boolean;
  20151. /**
  20152. * Specifies if there should be a separate pass for culling
  20153. */
  20154. separateCullingPass: boolean;
  20155. /**
  20156. * Stores the state specifing if fog should be enabled
  20157. */
  20158. private _fogEnabled;
  20159. /**
  20160. * Sets the state for enabling fog
  20161. */
  20162. /**
  20163. * Gets the value of the fog enabled state
  20164. */
  20165. fogEnabled: boolean;
  20166. /**
  20167. * Stores the size of points
  20168. */
  20169. pointSize: number;
  20170. /**
  20171. * Stores the z offset value
  20172. */
  20173. zOffset: number;
  20174. /**
  20175. * Gets a value specifying if wireframe mode is enabled
  20176. */
  20177. /**
  20178. * Sets the state of wireframe mode
  20179. */
  20180. wireframe: boolean;
  20181. /**
  20182. * Gets the value specifying if point clouds are enabled
  20183. */
  20184. /**
  20185. * Sets the state of point cloud mode
  20186. */
  20187. pointsCloud: boolean;
  20188. /**
  20189. * Gets the material fill mode
  20190. */
  20191. /**
  20192. * Sets the material fill mode
  20193. */
  20194. fillMode: number;
  20195. /**
  20196. * @hidden
  20197. * Stores the effects for the material
  20198. */ private _effect: Nullable<Effect>;
  20199. /**
  20200. * @hidden
  20201. * Specifies if the material was previously ready
  20202. */ private _wasPreviouslyReady: boolean;
  20203. /**
  20204. * Specifies if uniform buffers should be used
  20205. */
  20206. private _useUBO;
  20207. /**
  20208. * Stores a reference to the scene
  20209. */
  20210. private _scene;
  20211. /**
  20212. * Stores the fill mode state
  20213. */
  20214. private _fillMode;
  20215. /**
  20216. * Specifies if the depth write state should be cached
  20217. */
  20218. private _cachedDepthWriteState;
  20219. /**
  20220. * Stores the uniform buffer
  20221. */
  20222. protected _uniformBuffer: UniformBuffer;
  20223. /** @hidden */ private _indexInSceneMaterialArray: number;
  20224. /** @hidden */
  20225. meshMap: Nullable<{
  20226. [id: string]: AbstractMesh | undefined;
  20227. }>;
  20228. /**
  20229. * Creates a material instance
  20230. * @param name defines the name of the material
  20231. * @param scene defines the scene to reference
  20232. * @param doNotAdd specifies if the material should be added to the scene
  20233. */
  20234. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20235. /**
  20236. * Returns a string representation of the current material
  20237. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20238. * @returns a string with material information
  20239. */
  20240. toString(fullDetails?: boolean): string;
  20241. /**
  20242. * Gets the class name of the material
  20243. * @returns a string with the class name of the material
  20244. */
  20245. getClassName(): string;
  20246. /**
  20247. * Specifies if updates for the material been locked
  20248. */
  20249. readonly isFrozen: boolean;
  20250. /**
  20251. * Locks updates for the material
  20252. */
  20253. freeze(): void;
  20254. /**
  20255. * Unlocks updates for the material
  20256. */
  20257. unfreeze(): void;
  20258. /**
  20259. * Specifies if the material is ready to be used
  20260. * @param mesh defines the mesh to check
  20261. * @param useInstances specifies if instances should be used
  20262. * @returns a boolean indicating if the material is ready to be used
  20263. */
  20264. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20265. /**
  20266. * Specifies that the submesh is ready to be used
  20267. * @param mesh defines the mesh to check
  20268. * @param subMesh defines which submesh to check
  20269. * @param useInstances specifies that instances should be used
  20270. * @returns a boolean indicating that the submesh is ready or not
  20271. */
  20272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20273. /**
  20274. * Returns the material effect
  20275. * @returns the effect associated with the material
  20276. */
  20277. getEffect(): Nullable<Effect>;
  20278. /**
  20279. * Returns the current scene
  20280. * @returns a Scene
  20281. */
  20282. getScene(): Scene;
  20283. /**
  20284. * Specifies if the material will require alpha blending
  20285. * @returns a boolean specifying if alpha blending is needed
  20286. */
  20287. needAlphaBlending(): boolean;
  20288. /**
  20289. * Specifies if the mesh will require alpha blending
  20290. * @param mesh defines the mesh to check
  20291. * @returns a boolean specifying if alpha blending is needed for the mesh
  20292. */
  20293. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20294. /**
  20295. * Specifies if this material should be rendered in alpha test mode
  20296. * @returns a boolean specifying if an alpha test is needed.
  20297. */
  20298. needAlphaTesting(): boolean;
  20299. /**
  20300. * Gets the texture used for the alpha test
  20301. * @returns the texture to use for alpha testing
  20302. */
  20303. getAlphaTestTexture(): Nullable<BaseTexture>;
  20304. /**
  20305. * Marks the material to indicate that it needs to be re-calculated
  20306. */
  20307. markDirty(): void;
  20308. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20309. /**
  20310. * Binds the material to the mesh
  20311. * @param world defines the world transformation matrix
  20312. * @param mesh defines the mesh to bind the material to
  20313. */
  20314. bind(world: Matrix, mesh?: Mesh): void;
  20315. /**
  20316. * Binds the submesh to the material
  20317. * @param world defines the world transformation matrix
  20318. * @param mesh defines the mesh containing the submesh
  20319. * @param subMesh defines the submesh to bind the material to
  20320. */
  20321. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20322. /**
  20323. * Binds the world matrix to the material
  20324. * @param world defines the world transformation matrix
  20325. */
  20326. bindOnlyWorldMatrix(world: Matrix): void;
  20327. /**
  20328. * Binds the scene's uniform buffer to the effect.
  20329. * @param effect defines the effect to bind to the scene uniform buffer
  20330. * @param sceneUbo defines the uniform buffer storing scene data
  20331. */
  20332. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20333. /**
  20334. * Binds the view matrix to the effect
  20335. * @param effect defines the effect to bind the view matrix to
  20336. */
  20337. bindView(effect: Effect): void;
  20338. /**
  20339. * Binds the view projection matrix to the effect
  20340. * @param effect defines the effect to bind the view projection matrix to
  20341. */
  20342. bindViewProjection(effect: Effect): void;
  20343. /**
  20344. * Specifies if material alpha testing should be turned on for the mesh
  20345. * @param mesh defines the mesh to check
  20346. */
  20347. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20348. /**
  20349. * Processes to execute after binding the material to a mesh
  20350. * @param mesh defines the rendered mesh
  20351. */
  20352. protected _afterBind(mesh?: Mesh): void;
  20353. /**
  20354. * Unbinds the material from the mesh
  20355. */
  20356. unbind(): void;
  20357. /**
  20358. * Gets the active textures from the material
  20359. * @returns an array of textures
  20360. */
  20361. getActiveTextures(): BaseTexture[];
  20362. /**
  20363. * Specifies if the material uses a texture
  20364. * @param texture defines the texture to check against the material
  20365. * @returns a boolean specifying if the material uses the texture
  20366. */
  20367. hasTexture(texture: BaseTexture): boolean;
  20368. /**
  20369. * Makes a duplicate of the material, and gives it a new name
  20370. * @param name defines the new name for the duplicated material
  20371. * @returns the cloned material
  20372. */
  20373. clone(name: string): Nullable<Material>;
  20374. /**
  20375. * Gets the meshes bound to the material
  20376. * @returns an array of meshes bound to the material
  20377. */
  20378. getBindedMeshes(): AbstractMesh[];
  20379. /**
  20380. * Force shader compilation
  20381. * @param mesh defines the mesh associated with this material
  20382. * @param onCompiled defines a function to execute once the material is compiled
  20383. * @param options defines the options to configure the compilation
  20384. */
  20385. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20386. clipPlane: boolean;
  20387. }>): void;
  20388. /**
  20389. * Force shader compilation
  20390. * @param mesh defines the mesh that will use this material
  20391. * @param options defines additional options for compiling the shaders
  20392. * @returns a promise that resolves when the compilation completes
  20393. */
  20394. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20395. clipPlane: boolean;
  20396. }>): Promise<void>;
  20397. private static readonly _AllDirtyCallBack;
  20398. private static readonly _ImageProcessingDirtyCallBack;
  20399. private static readonly _TextureDirtyCallBack;
  20400. private static readonly _FresnelDirtyCallBack;
  20401. private static readonly _MiscDirtyCallBack;
  20402. private static readonly _LightsDirtyCallBack;
  20403. private static readonly _AttributeDirtyCallBack;
  20404. private static _FresnelAndMiscDirtyCallBack;
  20405. private static _TextureAndMiscDirtyCallBack;
  20406. private static readonly _DirtyCallbackArray;
  20407. private static readonly _RunDirtyCallBacks;
  20408. /**
  20409. * Marks a define in the material to indicate that it needs to be re-computed
  20410. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20411. */
  20412. markAsDirty(flag: number): void;
  20413. /**
  20414. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20415. * @param func defines a function which checks material defines against the submeshes
  20416. */
  20417. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20418. /**
  20419. * Indicates that we need to re-calculated for all submeshes
  20420. */
  20421. protected _markAllSubMeshesAsAllDirty(): void;
  20422. /**
  20423. * Indicates that image processing needs to be re-calculated for all submeshes
  20424. */
  20425. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20426. /**
  20427. * Indicates that textures need to be re-calculated for all submeshes
  20428. */
  20429. protected _markAllSubMeshesAsTexturesDirty(): void;
  20430. /**
  20431. * Indicates that fresnel needs to be re-calculated for all submeshes
  20432. */
  20433. protected _markAllSubMeshesAsFresnelDirty(): void;
  20434. /**
  20435. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20436. */
  20437. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20438. /**
  20439. * Indicates that lights need to be re-calculated for all submeshes
  20440. */
  20441. protected _markAllSubMeshesAsLightsDirty(): void;
  20442. /**
  20443. * Indicates that attributes need to be re-calculated for all submeshes
  20444. */
  20445. protected _markAllSubMeshesAsAttributesDirty(): void;
  20446. /**
  20447. * Indicates that misc needs to be re-calculated for all submeshes
  20448. */
  20449. protected _markAllSubMeshesAsMiscDirty(): void;
  20450. /**
  20451. * Indicates that textures and misc need to be re-calculated for all submeshes
  20452. */
  20453. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20454. /**
  20455. * Disposes the material
  20456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20459. */
  20460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20461. /** @hidden */
  20462. private releaseVertexArrayObject;
  20463. /**
  20464. * Serializes this material
  20465. * @returns the serialized material object
  20466. */
  20467. serialize(): any;
  20468. /**
  20469. * Creates a material from parsed material data
  20470. * @param parsedMaterial defines parsed material data
  20471. * @param scene defines the hosting scene
  20472. * @param rootUrl defines the root URL to use to load textures
  20473. * @returns a new material
  20474. */
  20475. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20476. }
  20477. }
  20478. declare module BABYLON {
  20479. /**
  20480. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20481. * separate meshes. This can be use to improve performances.
  20482. * @see http://doc.babylonjs.com/how_to/multi_materials
  20483. */
  20484. export class MultiMaterial extends Material {
  20485. private _subMaterials;
  20486. /**
  20487. * Gets or Sets the list of Materials used within the multi material.
  20488. * They need to be ordered according to the submeshes order in the associated mesh
  20489. */
  20490. subMaterials: Nullable<Material>[];
  20491. /**
  20492. * Function used to align with Node.getChildren()
  20493. * @returns the list of Materials used within the multi material
  20494. */
  20495. getChildren(): Nullable<Material>[];
  20496. /**
  20497. * Instantiates a new Multi Material
  20498. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20499. * separate meshes. This can be use to improve performances.
  20500. * @see http://doc.babylonjs.com/how_to/multi_materials
  20501. * @param name Define the name in the scene
  20502. * @param scene Define the scene the material belongs to
  20503. */
  20504. constructor(name: string, scene: Scene);
  20505. private _hookArray;
  20506. /**
  20507. * Get one of the submaterial by its index in the submaterials array
  20508. * @param index The index to look the sub material at
  20509. * @returns The Material if the index has been defined
  20510. */
  20511. getSubMaterial(index: number): Nullable<Material>;
  20512. /**
  20513. * Get the list of active textures for the whole sub materials list.
  20514. * @returns All the textures that will be used during the rendering
  20515. */
  20516. getActiveTextures(): BaseTexture[];
  20517. /**
  20518. * Gets the current class name of the material e.g. "MultiMaterial"
  20519. * Mainly use in serialization.
  20520. * @returns the class name
  20521. */
  20522. getClassName(): string;
  20523. /**
  20524. * Checks if the material is ready to render the requested sub mesh
  20525. * @param mesh Define the mesh the submesh belongs to
  20526. * @param subMesh Define the sub mesh to look readyness for
  20527. * @param useInstances Define whether or not the material is used with instances
  20528. * @returns true if ready, otherwise false
  20529. */
  20530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20531. /**
  20532. * Clones the current material and its related sub materials
  20533. * @param name Define the name of the newly cloned material
  20534. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20535. * @returns the cloned material
  20536. */
  20537. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20538. /**
  20539. * Serializes the materials into a JSON representation.
  20540. * @returns the JSON representation
  20541. */
  20542. serialize(): any;
  20543. /**
  20544. * Dispose the material and release its associated resources
  20545. * @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)
  20546. * @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)
  20547. * @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)
  20548. */
  20549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20550. /**
  20551. * Creates a MultiMaterial from parsed MultiMaterial data.
  20552. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20553. * @param scene defines the hosting scene
  20554. * @returns a new MultiMaterial
  20555. */
  20556. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20557. }
  20558. }
  20559. declare module BABYLON {
  20560. /**
  20561. * Base class for submeshes
  20562. */
  20563. export class BaseSubMesh {
  20564. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20565. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20566. /**
  20567. * Gets associated effect
  20568. */
  20569. readonly effect: Nullable<Effect>;
  20570. /**
  20571. * Sets associated effect (effect used to render this submesh)
  20572. * @param effect defines the effect to associate with
  20573. * @param defines defines the set of defines used to compile this effect
  20574. */
  20575. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20576. }
  20577. /**
  20578. * Defines a subdivision inside a mesh
  20579. */
  20580. export class SubMesh extends BaseSubMesh implements ICullable {
  20581. /** the material index to use */
  20582. materialIndex: number;
  20583. /** vertex index start */
  20584. verticesStart: number;
  20585. /** vertices count */
  20586. verticesCount: number;
  20587. /** index start */
  20588. indexStart: number;
  20589. /** indices count */
  20590. indexCount: number;
  20591. /** @hidden */ private _linesIndexCount: number;
  20592. private _mesh;
  20593. private _renderingMesh;
  20594. private _boundingInfo;
  20595. private _linesIndexBuffer;
  20596. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20597. /** @hidden */ private _trianglePlanes: Plane[];
  20598. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20599. /** @hidden */ private _renderId: number;
  20600. /** @hidden */ private _alphaIndex: number;
  20601. /** @hidden */ private _distanceToCamera: number;
  20602. /** @hidden */ private _id: number;
  20603. private _currentMaterial;
  20604. /**
  20605. * Add a new submesh to a mesh
  20606. * @param materialIndex defines the material index to use
  20607. * @param verticesStart defines vertex index start
  20608. * @param verticesCount defines vertices count
  20609. * @param indexStart defines index start
  20610. * @param indexCount defines indices count
  20611. * @param mesh defines the parent mesh
  20612. * @param renderingMesh defines an optional rendering mesh
  20613. * @param createBoundingBox defines if bounding box should be created for this submesh
  20614. * @returns the new submesh
  20615. */
  20616. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20617. /**
  20618. * Creates a new submesh
  20619. * @param materialIndex defines the material index to use
  20620. * @param verticesStart defines vertex index start
  20621. * @param verticesCount defines vertices count
  20622. * @param indexStart defines index start
  20623. * @param indexCount defines indices count
  20624. * @param mesh defines the parent mesh
  20625. * @param renderingMesh defines an optional rendering mesh
  20626. * @param createBoundingBox defines if bounding box should be created for this submesh
  20627. */
  20628. constructor(
  20629. /** the material index to use */
  20630. materialIndex: number,
  20631. /** vertex index start */
  20632. verticesStart: number,
  20633. /** vertices count */
  20634. verticesCount: number,
  20635. /** index start */
  20636. indexStart: number,
  20637. /** indices count */
  20638. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20639. /**
  20640. * Returns true if this submesh covers the entire parent mesh
  20641. * @ignorenaming
  20642. */
  20643. readonly IsGlobal: boolean;
  20644. /**
  20645. * Returns the submesh BoudingInfo object
  20646. * @returns current bounding info (or mesh's one if the submesh is global)
  20647. */
  20648. getBoundingInfo(): BoundingInfo;
  20649. /**
  20650. * Sets the submesh BoundingInfo
  20651. * @param boundingInfo defines the new bounding info to use
  20652. * @returns the SubMesh
  20653. */
  20654. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20655. /**
  20656. * Returns the mesh of the current submesh
  20657. * @return the parent mesh
  20658. */
  20659. getMesh(): AbstractMesh;
  20660. /**
  20661. * Returns the rendering mesh of the submesh
  20662. * @returns the rendering mesh (could be different from parent mesh)
  20663. */
  20664. getRenderingMesh(): Mesh;
  20665. /**
  20666. * Returns the submesh material
  20667. * @returns null or the current material
  20668. */
  20669. getMaterial(): Nullable<Material>;
  20670. /**
  20671. * Sets a new updated BoundingInfo object to the submesh
  20672. * @param data defines an optional position array to use to determine the bounding info
  20673. * @returns the SubMesh
  20674. */
  20675. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20676. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20677. /**
  20678. * Updates the submesh BoundingInfo
  20679. * @param world defines the world matrix to use to update the bounding info
  20680. * @returns the submesh
  20681. */
  20682. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20683. /**
  20684. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20685. * @param frustumPlanes defines the frustum planes
  20686. * @returns true if the submesh is intersecting with the frustum
  20687. */
  20688. isInFrustum(frustumPlanes: Plane[]): boolean;
  20689. /**
  20690. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20691. * @param frustumPlanes defines the frustum planes
  20692. * @returns true if the submesh is inside the frustum
  20693. */
  20694. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20695. /**
  20696. * Renders the submesh
  20697. * @param enableAlphaMode defines if alpha needs to be used
  20698. * @returns the submesh
  20699. */
  20700. render(enableAlphaMode: boolean): SubMesh;
  20701. /**
  20702. * @hidden
  20703. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20704. /**
  20705. * Checks if the submesh intersects with a ray
  20706. * @param ray defines the ray to test
  20707. * @returns true is the passed ray intersects the submesh bounding box
  20708. */
  20709. canIntersects(ray: Ray): boolean;
  20710. /**
  20711. * Intersects current submesh with a ray
  20712. * @param ray defines the ray to test
  20713. * @param positions defines mesh's positions array
  20714. * @param indices defines mesh's indices array
  20715. * @param fastCheck defines if only bounding info should be used
  20716. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20717. * @returns intersection info or null if no intersection
  20718. */
  20719. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20720. /** @hidden */
  20721. private _intersectLines;
  20722. /** @hidden */
  20723. private _intersectUnIndexedLines;
  20724. /** @hidden */
  20725. private _intersectTriangles;
  20726. /** @hidden */
  20727. private _intersectUnIndexedTriangles;
  20728. /** @hidden */ private _rebuild(): void;
  20729. /**
  20730. * Creates a new submesh from the passed mesh
  20731. * @param newMesh defines the new hosting mesh
  20732. * @param newRenderingMesh defines an optional rendering mesh
  20733. * @returns the new submesh
  20734. */
  20735. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20736. /**
  20737. * Release associated resources
  20738. */
  20739. dispose(): void;
  20740. /**
  20741. * Gets the class name
  20742. * @returns the string "SubMesh".
  20743. */
  20744. getClassName(): string;
  20745. /**
  20746. * Creates a new submesh from indices data
  20747. * @param materialIndex the index of the main mesh material
  20748. * @param startIndex the index where to start the copy in the mesh indices array
  20749. * @param indexCount the number of indices to copy then from the startIndex
  20750. * @param mesh the main mesh to create the submesh from
  20751. * @param renderingMesh the optional rendering mesh
  20752. * @returns a new submesh
  20753. */
  20754. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20755. }
  20756. }
  20757. declare module BABYLON {
  20758. /**
  20759. * Class used to represent data loading progression
  20760. */
  20761. export class SceneLoaderFlags {
  20762. private static _ForceFullSceneLoadingForIncremental;
  20763. private static _ShowLoadingScreen;
  20764. private static _CleanBoneMatrixWeights;
  20765. private static _loggingLevel;
  20766. /**
  20767. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20768. */
  20769. static ForceFullSceneLoadingForIncremental: boolean;
  20770. /**
  20771. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20772. */
  20773. static ShowLoadingScreen: boolean;
  20774. /**
  20775. * Defines the current logging level (while loading the scene)
  20776. * @ignorenaming
  20777. */
  20778. static loggingLevel: number;
  20779. /**
  20780. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20781. */
  20782. static CleanBoneMatrixWeights: boolean;
  20783. }
  20784. }
  20785. declare module BABYLON {
  20786. /**
  20787. * Class used to store geometry data (vertex buffers + index buffer)
  20788. */
  20789. export class Geometry implements IGetSetVerticesData {
  20790. /**
  20791. * Gets or sets the ID of the geometry
  20792. */
  20793. id: string;
  20794. /**
  20795. * Gets or sets the unique ID of the geometry
  20796. */
  20797. uniqueId: number;
  20798. /**
  20799. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20800. */
  20801. delayLoadState: number;
  20802. /**
  20803. * Gets the file containing the data to load when running in delay load state
  20804. */
  20805. delayLoadingFile: Nullable<string>;
  20806. /**
  20807. * Callback called when the geometry is updated
  20808. */
  20809. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20810. private _scene;
  20811. private _engine;
  20812. private _meshes;
  20813. private _totalVertices;
  20814. /** @hidden */ private _indices: IndicesArray;
  20815. /** @hidden */ private _vertexBuffers: {
  20816. [key: string]: VertexBuffer;
  20817. };
  20818. private _isDisposed;
  20819. private _extend;
  20820. private _boundingBias;
  20821. /** @hidden */ private _delayInfo: Array<string>;
  20822. private _indexBuffer;
  20823. private _indexBufferIsUpdatable;
  20824. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20825. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20826. /** @hidden */ private _softwareSkinningFrameId: number;
  20827. private _vertexArrayObjects;
  20828. private _updatable;
  20829. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20830. /**
  20831. * 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
  20832. */
  20833. /**
  20834. * 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
  20835. */
  20836. boundingBias: Vector2;
  20837. /**
  20838. * Static function used to attach a new empty geometry to a mesh
  20839. * @param mesh defines the mesh to attach the geometry to
  20840. * @returns the new Geometry
  20841. */
  20842. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20843. /**
  20844. * Creates a new geometry
  20845. * @param id defines the unique ID
  20846. * @param scene defines the hosting scene
  20847. * @param vertexData defines the VertexData used to get geometry data
  20848. * @param updatable defines if geometry must be updatable (false by default)
  20849. * @param mesh defines the mesh that will be associated with the geometry
  20850. */
  20851. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20852. /**
  20853. * Gets the current extend of the geometry
  20854. */
  20855. readonly extend: {
  20856. minimum: Vector3;
  20857. maximum: Vector3;
  20858. };
  20859. /**
  20860. * Gets the hosting scene
  20861. * @returns the hosting Scene
  20862. */
  20863. getScene(): Scene;
  20864. /**
  20865. * Gets the hosting engine
  20866. * @returns the hosting Engine
  20867. */
  20868. getEngine(): Engine;
  20869. /**
  20870. * Defines if the geometry is ready to use
  20871. * @returns true if the geometry is ready to be used
  20872. */
  20873. isReady(): boolean;
  20874. /**
  20875. * Gets a value indicating that the geometry should not be serialized
  20876. */
  20877. readonly doNotSerialize: boolean;
  20878. /** @hidden */ private _rebuild(): void;
  20879. /**
  20880. * Affects all geometry data in one call
  20881. * @param vertexData defines the geometry data
  20882. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20883. */
  20884. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20885. /**
  20886. * Set specific vertex data
  20887. * @param kind defines the data kind (Position, normal, etc...)
  20888. * @param data defines the vertex data to use
  20889. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20890. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20891. */
  20892. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20893. /**
  20894. * Removes a specific vertex data
  20895. * @param kind defines the data kind (Position, normal, etc...)
  20896. */
  20897. removeVerticesData(kind: string): void;
  20898. /**
  20899. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20900. * @param buffer defines the vertex buffer to use
  20901. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20902. */
  20903. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20904. /**
  20905. * Update a specific vertex buffer
  20906. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20907. * It will do nothing if the buffer is not updatable
  20908. * @param kind defines the data kind (Position, normal, etc...)
  20909. * @param data defines the data to use
  20910. * @param offset defines the offset in the target buffer where to store the data
  20911. * @param useBytes set to true if the offset is in bytes
  20912. */
  20913. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20914. /**
  20915. * Update a specific vertex buffer
  20916. * This function will create a new buffer if the current one is not updatable
  20917. * @param kind defines the data kind (Position, normal, etc...)
  20918. * @param data defines the data to use
  20919. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20920. */
  20921. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20922. private _updateBoundingInfo;
  20923. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20924. /**
  20925. * Gets total number of vertices
  20926. * @returns the total number of vertices
  20927. */
  20928. getTotalVertices(): number;
  20929. /**
  20930. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20931. * @param kind defines the data kind (Position, normal, etc...)
  20932. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20933. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20934. * @returns a float array containing vertex data
  20935. */
  20936. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20937. /**
  20938. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20939. * @param kind defines the data kind (Position, normal, etc...)
  20940. * @returns true if the vertex buffer with the specified kind is updatable
  20941. */
  20942. isVertexBufferUpdatable(kind: string): boolean;
  20943. /**
  20944. * Gets a specific vertex buffer
  20945. * @param kind defines the data kind (Position, normal, etc...)
  20946. * @returns a VertexBuffer
  20947. */
  20948. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20949. /**
  20950. * Returns all vertex buffers
  20951. * @return an object holding all vertex buffers indexed by kind
  20952. */
  20953. getVertexBuffers(): Nullable<{
  20954. [key: string]: VertexBuffer;
  20955. }>;
  20956. /**
  20957. * Gets a boolean indicating if specific vertex buffer is present
  20958. * @param kind defines the data kind (Position, normal, etc...)
  20959. * @returns true if data is present
  20960. */
  20961. isVerticesDataPresent(kind: string): boolean;
  20962. /**
  20963. * Gets a list of all attached data kinds (Position, normal, etc...)
  20964. * @returns a list of string containing all kinds
  20965. */
  20966. getVerticesDataKinds(): string[];
  20967. /**
  20968. * Update index buffer
  20969. * @param indices defines the indices to store in the index buffer
  20970. * @param offset defines the offset in the target buffer where to store the data
  20971. * @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)
  20972. */
  20973. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20974. /**
  20975. * Creates a new index buffer
  20976. * @param indices defines the indices to store in the index buffer
  20977. * @param totalVertices defines the total number of vertices (could be null)
  20978. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20979. */
  20980. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20981. /**
  20982. * Return the total number of indices
  20983. * @returns the total number of indices
  20984. */
  20985. getTotalIndices(): number;
  20986. /**
  20987. * Gets the index buffer array
  20988. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20990. * @returns the index buffer array
  20991. */
  20992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20993. /**
  20994. * Gets the index buffer
  20995. * @return the index buffer
  20996. */
  20997. getIndexBuffer(): Nullable<DataBuffer>;
  20998. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20999. /**
  21000. * Release the associated resources for a specific mesh
  21001. * @param mesh defines the source mesh
  21002. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21003. */
  21004. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21005. /**
  21006. * Apply current geometry to a given mesh
  21007. * @param mesh defines the mesh to apply geometry to
  21008. */
  21009. applyToMesh(mesh: Mesh): void;
  21010. private _updateExtend;
  21011. private _applyToMesh;
  21012. private notifyUpdate;
  21013. /**
  21014. * Load the geometry if it was flagged as delay loaded
  21015. * @param scene defines the hosting scene
  21016. * @param onLoaded defines a callback called when the geometry is loaded
  21017. */
  21018. load(scene: Scene, onLoaded?: () => void): void;
  21019. private _queueLoad;
  21020. /**
  21021. * Invert the geometry to move from a right handed system to a left handed one.
  21022. */
  21023. toLeftHanded(): void;
  21024. /** @hidden */ private _resetPointsArrayCache(): void;
  21025. /** @hidden */ private _generatePointsArray(): boolean;
  21026. /**
  21027. * Gets a value indicating if the geometry is disposed
  21028. * @returns true if the geometry was disposed
  21029. */
  21030. isDisposed(): boolean;
  21031. private _disposeVertexArrayObjects;
  21032. /**
  21033. * Free all associated resources
  21034. */
  21035. dispose(): void;
  21036. /**
  21037. * Clone the current geometry into a new geometry
  21038. * @param id defines the unique ID of the new geometry
  21039. * @returns a new geometry object
  21040. */
  21041. copy(id: string): Geometry;
  21042. /**
  21043. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21044. * @return a JSON representation of the current geometry data (without the vertices data)
  21045. */
  21046. serialize(): any;
  21047. private toNumberArray;
  21048. /**
  21049. * Serialize all vertices data into a JSON oject
  21050. * @returns a JSON representation of the current geometry data
  21051. */
  21052. serializeVerticeData(): any;
  21053. /**
  21054. * Extracts a clone of a mesh geometry
  21055. * @param mesh defines the source mesh
  21056. * @param id defines the unique ID of the new geometry object
  21057. * @returns the new geometry object
  21058. */
  21059. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21060. /**
  21061. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21062. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21063. * Be aware Math.random() could cause collisions, but:
  21064. * "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"
  21065. * @returns a string containing a new GUID
  21066. */
  21067. static RandomId(): string;
  21068. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21069. private static _CleanMatricesWeights;
  21070. /**
  21071. * Create a new geometry from persisted data (Using .babylon file format)
  21072. * @param parsedVertexData defines the persisted data
  21073. * @param scene defines the hosting scene
  21074. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21075. * @returns the new geometry object
  21076. */
  21077. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21078. }
  21079. }
  21080. declare module BABYLON {
  21081. /**
  21082. * Define an interface for all classes that will get and set the data on vertices
  21083. */
  21084. export interface IGetSetVerticesData {
  21085. /**
  21086. * Gets a boolean indicating if specific vertex data is present
  21087. * @param kind defines the vertex data kind to use
  21088. * @returns true is data kind is present
  21089. */
  21090. isVerticesDataPresent(kind: string): boolean;
  21091. /**
  21092. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21093. * @param kind defines the data kind (Position, normal, etc...)
  21094. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21095. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21096. * @returns a float array containing vertex data
  21097. */
  21098. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21099. /**
  21100. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21101. * @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.
  21102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21103. * @returns the indices array or an empty array if the mesh has no geometry
  21104. */
  21105. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21106. /**
  21107. * Set specific vertex data
  21108. * @param kind defines the data kind (Position, normal, etc...)
  21109. * @param data defines the vertex data to use
  21110. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21111. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21112. */
  21113. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21114. /**
  21115. * Update a specific associated vertex buffer
  21116. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21117. * - VertexBuffer.PositionKind
  21118. * - VertexBuffer.UVKind
  21119. * - VertexBuffer.UV2Kind
  21120. * - VertexBuffer.UV3Kind
  21121. * - VertexBuffer.UV4Kind
  21122. * - VertexBuffer.UV5Kind
  21123. * - VertexBuffer.UV6Kind
  21124. * - VertexBuffer.ColorKind
  21125. * - VertexBuffer.MatricesIndicesKind
  21126. * - VertexBuffer.MatricesIndicesExtraKind
  21127. * - VertexBuffer.MatricesWeightsKind
  21128. * - VertexBuffer.MatricesWeightsExtraKind
  21129. * @param data defines the data source
  21130. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21131. * @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)
  21132. */
  21133. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21134. /**
  21135. * Creates a new index buffer
  21136. * @param indices defines the indices to store in the index buffer
  21137. * @param totalVertices defines the total number of vertices (could be null)
  21138. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21139. */
  21140. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21141. }
  21142. /**
  21143. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21144. */
  21145. export class VertexData {
  21146. /**
  21147. * Mesh side orientation : usually the external or front surface
  21148. */
  21149. static readonly FRONTSIDE: number;
  21150. /**
  21151. * Mesh side orientation : usually the internal or back surface
  21152. */
  21153. static readonly BACKSIDE: number;
  21154. /**
  21155. * Mesh side orientation : both internal and external or front and back surfaces
  21156. */
  21157. static readonly DOUBLESIDE: number;
  21158. /**
  21159. * Mesh side orientation : by default, `FRONTSIDE`
  21160. */
  21161. static readonly DEFAULTSIDE: number;
  21162. /**
  21163. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21164. */
  21165. positions: Nullable<FloatArray>;
  21166. /**
  21167. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21168. */
  21169. normals: Nullable<FloatArray>;
  21170. /**
  21171. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21172. */
  21173. tangents: Nullable<FloatArray>;
  21174. /**
  21175. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21176. */
  21177. uvs: Nullable<FloatArray>;
  21178. /**
  21179. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21180. */
  21181. uvs2: Nullable<FloatArray>;
  21182. /**
  21183. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21184. */
  21185. uvs3: Nullable<FloatArray>;
  21186. /**
  21187. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21188. */
  21189. uvs4: Nullable<FloatArray>;
  21190. /**
  21191. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21192. */
  21193. uvs5: Nullable<FloatArray>;
  21194. /**
  21195. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21196. */
  21197. uvs6: Nullable<FloatArray>;
  21198. /**
  21199. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21200. */
  21201. colors: Nullable<FloatArray>;
  21202. /**
  21203. * 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).
  21204. */
  21205. matricesIndices: Nullable<FloatArray>;
  21206. /**
  21207. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21208. */
  21209. matricesWeights: Nullable<FloatArray>;
  21210. /**
  21211. * An array extending the number of possible indices
  21212. */
  21213. matricesIndicesExtra: Nullable<FloatArray>;
  21214. /**
  21215. * An array extending the number of possible weights when the number of indices is extended
  21216. */
  21217. matricesWeightsExtra: Nullable<FloatArray>;
  21218. /**
  21219. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21220. */
  21221. indices: Nullable<IndicesArray>;
  21222. /**
  21223. * Uses the passed data array to set the set the values for the specified kind of data
  21224. * @param data a linear array of floating numbers
  21225. * @param kind the type of data that is being set, eg positions, colors etc
  21226. */
  21227. set(data: FloatArray, kind: string): void;
  21228. /**
  21229. * Associates the vertexData to the passed Mesh.
  21230. * Sets it as updatable or not (default `false`)
  21231. * @param mesh the mesh the vertexData is applied to
  21232. * @param updatable when used and having the value true allows new data to update the vertexData
  21233. * @returns the VertexData
  21234. */
  21235. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21236. /**
  21237. * Associates the vertexData to the passed Geometry.
  21238. * Sets it as updatable or not (default `false`)
  21239. * @param geometry the geometry the vertexData is applied to
  21240. * @param updatable when used and having the value true allows new data to update the vertexData
  21241. * @returns VertexData
  21242. */
  21243. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21244. /**
  21245. * Updates the associated mesh
  21246. * @param mesh the mesh to be updated
  21247. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21248. * @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
  21249. * @returns VertexData
  21250. */
  21251. updateMesh(mesh: Mesh): VertexData;
  21252. /**
  21253. * Updates the associated geometry
  21254. * @param geometry the geometry to be updated
  21255. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21256. * @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
  21257. * @returns VertexData.
  21258. */
  21259. updateGeometry(geometry: Geometry): VertexData;
  21260. private _applyTo;
  21261. private _update;
  21262. /**
  21263. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21264. * @param matrix the transforming matrix
  21265. * @returns the VertexData
  21266. */
  21267. transform(matrix: Matrix): VertexData;
  21268. /**
  21269. * Merges the passed VertexData into the current one
  21270. * @param other the VertexData to be merged into the current one
  21271. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21272. * @returns the modified VertexData
  21273. */
  21274. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21275. private _mergeElement;
  21276. private _validate;
  21277. /**
  21278. * Serializes the VertexData
  21279. * @returns a serialized object
  21280. */
  21281. serialize(): any;
  21282. /**
  21283. * Extracts the vertexData from a mesh
  21284. * @param mesh the mesh from which to extract the VertexData
  21285. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21286. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21287. * @returns the object VertexData associated to the passed mesh
  21288. */
  21289. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21290. /**
  21291. * Extracts the vertexData from the geometry
  21292. * @param geometry the geometry from which to extract the VertexData
  21293. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21294. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21295. * @returns the object VertexData associated to the passed mesh
  21296. */
  21297. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21298. private static _ExtractFrom;
  21299. /**
  21300. * Creates the VertexData for a Ribbon
  21301. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21302. * * pathArray array of paths, each of which an array of successive Vector3
  21303. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21304. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21305. * * 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
  21306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21307. * * 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)
  21308. * * 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)
  21309. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21310. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21311. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21312. * @returns the VertexData of the ribbon
  21313. */
  21314. static CreateRibbon(options: {
  21315. pathArray: Vector3[][];
  21316. closeArray?: boolean;
  21317. closePath?: boolean;
  21318. offset?: number;
  21319. sideOrientation?: number;
  21320. frontUVs?: Vector4;
  21321. backUVs?: Vector4;
  21322. invertUV?: boolean;
  21323. uvs?: Vector2[];
  21324. colors?: Color4[];
  21325. }): VertexData;
  21326. /**
  21327. * Creates the VertexData for a box
  21328. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21329. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21330. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21331. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21332. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21333. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21334. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21336. * * 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)
  21337. * * 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)
  21338. * @returns the VertexData of the box
  21339. */
  21340. static CreateBox(options: {
  21341. size?: number;
  21342. width?: number;
  21343. height?: number;
  21344. depth?: number;
  21345. faceUV?: Vector4[];
  21346. faceColors?: Color4[];
  21347. sideOrientation?: number;
  21348. frontUVs?: Vector4;
  21349. backUVs?: Vector4;
  21350. }): VertexData;
  21351. /**
  21352. * Creates the VertexData for a tiled box
  21353. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21354. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21355. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21356. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21358. * @returns the VertexData of the box
  21359. */
  21360. static CreateTiledBox(options: {
  21361. pattern?: number;
  21362. width?: number;
  21363. height?: number;
  21364. depth?: number;
  21365. tileSize?: number;
  21366. tileWidth?: number;
  21367. tileHeight?: number;
  21368. alignHorizontal?: number;
  21369. alignVertical?: number;
  21370. faceUV?: Vector4[];
  21371. faceColors?: Color4[];
  21372. sideOrientation?: number;
  21373. }): VertexData;
  21374. /**
  21375. * Creates the VertexData for a tiled plane
  21376. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21377. * * pattern a limited pattern arrangement depending on the number
  21378. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21379. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21380. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21382. * * 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)
  21383. * * 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)
  21384. * @returns the VertexData of the tiled plane
  21385. */
  21386. static CreateTiledPlane(options: {
  21387. pattern?: number;
  21388. tileSize?: number;
  21389. tileWidth?: number;
  21390. tileHeight?: number;
  21391. size?: number;
  21392. width?: number;
  21393. height?: number;
  21394. alignHorizontal?: number;
  21395. alignVertical?: number;
  21396. sideOrientation?: number;
  21397. frontUVs?: Vector4;
  21398. backUVs?: Vector4;
  21399. }): VertexData;
  21400. /**
  21401. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21402. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21403. * * segments sets the number of horizontal strips optional, default 32
  21404. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21405. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21406. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21407. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21408. * * 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
  21409. * * 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
  21410. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21411. * * 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)
  21412. * * 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)
  21413. * @returns the VertexData of the ellipsoid
  21414. */
  21415. static CreateSphere(options: {
  21416. segments?: number;
  21417. diameter?: number;
  21418. diameterX?: number;
  21419. diameterY?: number;
  21420. diameterZ?: number;
  21421. arc?: number;
  21422. slice?: number;
  21423. sideOrientation?: number;
  21424. frontUVs?: Vector4;
  21425. backUVs?: Vector4;
  21426. }): VertexData;
  21427. /**
  21428. * Creates the VertexData for a cylinder, cone or prism
  21429. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21430. * * height sets the height (y direction) of the cylinder, optional, default 2
  21431. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21432. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21433. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21434. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21435. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21436. * * 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
  21437. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21438. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21439. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21440. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21442. * * 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)
  21443. * * 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)
  21444. * @returns the VertexData of the cylinder, cone or prism
  21445. */
  21446. static CreateCylinder(options: {
  21447. height?: number;
  21448. diameterTop?: number;
  21449. diameterBottom?: number;
  21450. diameter?: number;
  21451. tessellation?: number;
  21452. subdivisions?: number;
  21453. arc?: number;
  21454. faceColors?: Color4[];
  21455. faceUV?: Vector4[];
  21456. hasRings?: boolean;
  21457. enclose?: boolean;
  21458. sideOrientation?: number;
  21459. frontUVs?: Vector4;
  21460. backUVs?: Vector4;
  21461. }): VertexData;
  21462. /**
  21463. * Creates the VertexData for a torus
  21464. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21465. * * diameter the diameter of the torus, optional default 1
  21466. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21467. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21469. * * 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)
  21470. * * 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)
  21471. * @returns the VertexData of the torus
  21472. */
  21473. static CreateTorus(options: {
  21474. diameter?: number;
  21475. thickness?: number;
  21476. tessellation?: number;
  21477. sideOrientation?: number;
  21478. frontUVs?: Vector4;
  21479. backUVs?: Vector4;
  21480. }): VertexData;
  21481. /**
  21482. * Creates the VertexData of the LineSystem
  21483. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21484. * - lines an array of lines, each line being an array of successive Vector3
  21485. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21486. * @returns the VertexData of the LineSystem
  21487. */
  21488. static CreateLineSystem(options: {
  21489. lines: Vector3[][];
  21490. colors?: Nullable<Color4[][]>;
  21491. }): VertexData;
  21492. /**
  21493. * Create the VertexData for a DashedLines
  21494. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21495. * - points an array successive Vector3
  21496. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21497. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21498. * - dashNb the intended total number of dashes, optional, default 200
  21499. * @returns the VertexData for the DashedLines
  21500. */
  21501. static CreateDashedLines(options: {
  21502. points: Vector3[];
  21503. dashSize?: number;
  21504. gapSize?: number;
  21505. dashNb?: number;
  21506. }): VertexData;
  21507. /**
  21508. * Creates the VertexData for a Ground
  21509. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21510. * - width the width (x direction) of the ground, optional, default 1
  21511. * - height the height (z direction) of the ground, optional, default 1
  21512. * - subdivisions the number of subdivisions per side, optional, default 1
  21513. * @returns the VertexData of the Ground
  21514. */
  21515. static CreateGround(options: {
  21516. width?: number;
  21517. height?: number;
  21518. subdivisions?: number;
  21519. subdivisionsX?: number;
  21520. subdivisionsY?: number;
  21521. }): VertexData;
  21522. /**
  21523. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21524. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21525. * * xmin the ground minimum X coordinate, optional, default -1
  21526. * * zmin the ground minimum Z coordinate, optional, default -1
  21527. * * xmax the ground maximum X coordinate, optional, default 1
  21528. * * zmax the ground maximum Z coordinate, optional, default 1
  21529. * * 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}
  21530. * * 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}
  21531. * @returns the VertexData of the TiledGround
  21532. */
  21533. static CreateTiledGround(options: {
  21534. xmin: number;
  21535. zmin: number;
  21536. xmax: number;
  21537. zmax: number;
  21538. subdivisions?: {
  21539. w: number;
  21540. h: number;
  21541. };
  21542. precision?: {
  21543. w: number;
  21544. h: number;
  21545. };
  21546. }): VertexData;
  21547. /**
  21548. * Creates the VertexData of the Ground designed from a heightmap
  21549. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21550. * * width the width (x direction) of the ground
  21551. * * height the height (z direction) of the ground
  21552. * * subdivisions the number of subdivisions per side
  21553. * * minHeight the minimum altitude on the ground, optional, default 0
  21554. * * maxHeight the maximum altitude on the ground, optional default 1
  21555. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21556. * * buffer the array holding the image color data
  21557. * * bufferWidth the width of image
  21558. * * bufferHeight the height of image
  21559. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21560. * @returns the VertexData of the Ground designed from a heightmap
  21561. */
  21562. static CreateGroundFromHeightMap(options: {
  21563. width: number;
  21564. height: number;
  21565. subdivisions: number;
  21566. minHeight: number;
  21567. maxHeight: number;
  21568. colorFilter: Color3;
  21569. buffer: Uint8Array;
  21570. bufferWidth: number;
  21571. bufferHeight: number;
  21572. alphaFilter: number;
  21573. }): VertexData;
  21574. /**
  21575. * Creates the VertexData for a Plane
  21576. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21577. * * size sets the width and height of the plane to the value of size, optional default 1
  21578. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21579. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21581. * * 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)
  21582. * * 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)
  21583. * @returns the VertexData of the box
  21584. */
  21585. static CreatePlane(options: {
  21586. size?: number;
  21587. width?: number;
  21588. height?: number;
  21589. sideOrientation?: number;
  21590. frontUVs?: Vector4;
  21591. backUVs?: Vector4;
  21592. }): VertexData;
  21593. /**
  21594. * Creates the VertexData of the Disc or regular Polygon
  21595. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21596. * * radius the radius of the disc, optional default 0.5
  21597. * * tessellation the number of polygon sides, optional, default 64
  21598. * * 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
  21599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21600. * * 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)
  21601. * * 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)
  21602. * @returns the VertexData of the box
  21603. */
  21604. static CreateDisc(options: {
  21605. radius?: number;
  21606. tessellation?: number;
  21607. arc?: number;
  21608. sideOrientation?: number;
  21609. frontUVs?: Vector4;
  21610. backUVs?: Vector4;
  21611. }): VertexData;
  21612. /**
  21613. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21614. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21615. * @param polygon a mesh built from polygonTriangulation.build()
  21616. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21617. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21618. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21619. * @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)
  21620. * @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)
  21621. * @returns the VertexData of the Polygon
  21622. */
  21623. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21624. /**
  21625. * Creates the VertexData of the IcoSphere
  21626. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21627. * * radius the radius of the IcoSphere, optional default 1
  21628. * * radiusX allows stretching in the x direction, optional, default radius
  21629. * * radiusY allows stretching in the y direction, optional, default radius
  21630. * * radiusZ allows stretching in the z direction, optional, default radius
  21631. * * flat when true creates a flat shaded mesh, optional, default true
  21632. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21634. * * 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)
  21635. * * 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)
  21636. * @returns the VertexData of the IcoSphere
  21637. */
  21638. static CreateIcoSphere(options: {
  21639. radius?: number;
  21640. radiusX?: number;
  21641. radiusY?: number;
  21642. radiusZ?: number;
  21643. flat?: boolean;
  21644. subdivisions?: number;
  21645. sideOrientation?: number;
  21646. frontUVs?: Vector4;
  21647. backUVs?: Vector4;
  21648. }): VertexData;
  21649. /**
  21650. * Creates the VertexData for a Polyhedron
  21651. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21652. * * type provided types are:
  21653. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21654. * * 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)
  21655. * * size the size of the IcoSphere, optional default 1
  21656. * * sizeX allows stretching in the x direction, optional, default size
  21657. * * sizeY allows stretching in the y direction, optional, default size
  21658. * * sizeZ allows stretching in the z direction, optional, default size
  21659. * * 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
  21660. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21661. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21662. * * flat when true creates a flat shaded mesh, optional, default true
  21663. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21665. * * 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)
  21666. * * 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)
  21667. * @returns the VertexData of the Polyhedron
  21668. */
  21669. static CreatePolyhedron(options: {
  21670. type?: number;
  21671. size?: number;
  21672. sizeX?: number;
  21673. sizeY?: number;
  21674. sizeZ?: number;
  21675. custom?: any;
  21676. faceUV?: Vector4[];
  21677. faceColors?: Color4[];
  21678. flat?: boolean;
  21679. sideOrientation?: number;
  21680. frontUVs?: Vector4;
  21681. backUVs?: Vector4;
  21682. }): VertexData;
  21683. /**
  21684. * Creates the VertexData for a TorusKnot
  21685. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21686. * * radius the radius of the torus knot, optional, default 2
  21687. * * tube the thickness of the tube, optional, default 0.5
  21688. * * radialSegments the number of sides on each tube segments, optional, default 32
  21689. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21690. * * p the number of windings around the z axis, optional, default 2
  21691. * * q the number of windings around the x axis, optional, default 3
  21692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21693. * * 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)
  21694. * * 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)
  21695. * @returns the VertexData of the Torus Knot
  21696. */
  21697. static CreateTorusKnot(options: {
  21698. radius?: number;
  21699. tube?: number;
  21700. radialSegments?: number;
  21701. tubularSegments?: number;
  21702. p?: number;
  21703. q?: number;
  21704. sideOrientation?: number;
  21705. frontUVs?: Vector4;
  21706. backUVs?: Vector4;
  21707. }): VertexData;
  21708. /**
  21709. * Compute normals for given positions and indices
  21710. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21711. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21712. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21713. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21714. * * facetNormals : optional array of facet normals (vector3)
  21715. * * facetPositions : optional array of facet positions (vector3)
  21716. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21717. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21718. * * bInfo : optional bounding info, required for facetPartitioning computation
  21719. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21720. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21721. * * useRightHandedSystem: optional boolean to for right handed system computation
  21722. * * depthSort : optional boolean to enable the facet depth sort computation
  21723. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21724. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21725. */
  21726. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21727. facetNormals?: any;
  21728. facetPositions?: any;
  21729. facetPartitioning?: any;
  21730. ratio?: number;
  21731. bInfo?: any;
  21732. bbSize?: Vector3;
  21733. subDiv?: any;
  21734. useRightHandedSystem?: boolean;
  21735. depthSort?: boolean;
  21736. distanceTo?: Vector3;
  21737. depthSortedFacets?: any;
  21738. }): void;
  21739. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21740. /**
  21741. * Applies VertexData created from the imported parameters to the geometry
  21742. * @param parsedVertexData the parsed data from an imported file
  21743. * @param geometry the geometry to apply the VertexData to
  21744. */
  21745. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21746. }
  21747. }
  21748. declare module BABYLON {
  21749. /**
  21750. * Defines a target to use with MorphTargetManager
  21751. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21752. */
  21753. export class MorphTarget implements IAnimatable {
  21754. /** defines the name of the target */
  21755. name: string;
  21756. /**
  21757. * Gets or sets the list of animations
  21758. */
  21759. animations: Animation[];
  21760. private _scene;
  21761. private _positions;
  21762. private _normals;
  21763. private _tangents;
  21764. private _uvs;
  21765. private _influence;
  21766. /**
  21767. * Observable raised when the influence changes
  21768. */
  21769. onInfluenceChanged: Observable<boolean>;
  21770. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21771. /**
  21772. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21773. */
  21774. influence: number;
  21775. /**
  21776. * Gets or sets the id of the morph Target
  21777. */
  21778. id: string;
  21779. private _animationPropertiesOverride;
  21780. /**
  21781. * Gets or sets the animation properties override
  21782. */
  21783. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21784. /**
  21785. * Creates a new MorphTarget
  21786. * @param name defines the name of the target
  21787. * @param influence defines the influence to use
  21788. * @param scene defines the scene the morphtarget belongs to
  21789. */
  21790. constructor(
  21791. /** defines the name of the target */
  21792. name: string, influence?: number, scene?: Nullable<Scene>);
  21793. /**
  21794. * Gets a boolean defining if the target contains position data
  21795. */
  21796. readonly hasPositions: boolean;
  21797. /**
  21798. * Gets a boolean defining if the target contains normal data
  21799. */
  21800. readonly hasNormals: boolean;
  21801. /**
  21802. * Gets a boolean defining if the target contains tangent data
  21803. */
  21804. readonly hasTangents: boolean;
  21805. /**
  21806. * Gets a boolean defining if the target contains texture coordinates data
  21807. */
  21808. readonly hasUVs: boolean;
  21809. /**
  21810. * Affects position data to this target
  21811. * @param data defines the position data to use
  21812. */
  21813. setPositions(data: Nullable<FloatArray>): void;
  21814. /**
  21815. * Gets the position data stored in this target
  21816. * @returns a FloatArray containing the position data (or null if not present)
  21817. */
  21818. getPositions(): Nullable<FloatArray>;
  21819. /**
  21820. * Affects normal data to this target
  21821. * @param data defines the normal data to use
  21822. */
  21823. setNormals(data: Nullable<FloatArray>): void;
  21824. /**
  21825. * Gets the normal data stored in this target
  21826. * @returns a FloatArray containing the normal data (or null if not present)
  21827. */
  21828. getNormals(): Nullable<FloatArray>;
  21829. /**
  21830. * Affects tangent data to this target
  21831. * @param data defines the tangent data to use
  21832. */
  21833. setTangents(data: Nullable<FloatArray>): void;
  21834. /**
  21835. * Gets the tangent data stored in this target
  21836. * @returns a FloatArray containing the tangent data (or null if not present)
  21837. */
  21838. getTangents(): Nullable<FloatArray>;
  21839. /**
  21840. * Affects texture coordinates data to this target
  21841. * @param data defines the texture coordinates data to use
  21842. */
  21843. setUVs(data: Nullable<FloatArray>): void;
  21844. /**
  21845. * Gets the texture coordinates data stored in this target
  21846. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21847. */
  21848. getUVs(): Nullable<FloatArray>;
  21849. /**
  21850. * Serializes the current target into a Serialization object
  21851. * @returns the serialized object
  21852. */
  21853. serialize(): any;
  21854. /**
  21855. * Returns the string "MorphTarget"
  21856. * @returns "MorphTarget"
  21857. */
  21858. getClassName(): string;
  21859. /**
  21860. * Creates a new target from serialized data
  21861. * @param serializationObject defines the serialized data to use
  21862. * @returns a new MorphTarget
  21863. */
  21864. static Parse(serializationObject: any): MorphTarget;
  21865. /**
  21866. * Creates a MorphTarget from mesh data
  21867. * @param mesh defines the source mesh
  21868. * @param name defines the name to use for the new target
  21869. * @param influence defines the influence to attach to the target
  21870. * @returns a new MorphTarget
  21871. */
  21872. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21873. }
  21874. }
  21875. declare module BABYLON {
  21876. /**
  21877. * This class is used to deform meshes using morphing between different targets
  21878. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21879. */
  21880. export class MorphTargetManager {
  21881. private _targets;
  21882. private _targetInfluenceChangedObservers;
  21883. private _targetDataLayoutChangedObservers;
  21884. private _activeTargets;
  21885. private _scene;
  21886. private _influences;
  21887. private _supportsNormals;
  21888. private _supportsTangents;
  21889. private _supportsUVs;
  21890. private _vertexCount;
  21891. private _uniqueId;
  21892. private _tempInfluences;
  21893. /**
  21894. * Gets or sets a boolean indicating if normals must be morphed
  21895. */
  21896. enableNormalMorphing: boolean;
  21897. /**
  21898. * Gets or sets a boolean indicating if tangents must be morphed
  21899. */
  21900. enableTangentMorphing: boolean;
  21901. /**
  21902. * Gets or sets a boolean indicating if UV must be morphed
  21903. */
  21904. enableUVMorphing: boolean;
  21905. /**
  21906. * Creates a new MorphTargetManager
  21907. * @param scene defines the current scene
  21908. */
  21909. constructor(scene?: Nullable<Scene>);
  21910. /**
  21911. * Gets the unique ID of this manager
  21912. */
  21913. readonly uniqueId: number;
  21914. /**
  21915. * Gets the number of vertices handled by this manager
  21916. */
  21917. readonly vertexCount: number;
  21918. /**
  21919. * Gets a boolean indicating if this manager supports morphing of normals
  21920. */
  21921. readonly supportsNormals: boolean;
  21922. /**
  21923. * Gets a boolean indicating if this manager supports morphing of tangents
  21924. */
  21925. readonly supportsTangents: boolean;
  21926. /**
  21927. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21928. */
  21929. readonly supportsUVs: boolean;
  21930. /**
  21931. * Gets the number of targets stored in this manager
  21932. */
  21933. readonly numTargets: number;
  21934. /**
  21935. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21936. */
  21937. readonly numInfluencers: number;
  21938. /**
  21939. * Gets the list of influences (one per target)
  21940. */
  21941. readonly influences: Float32Array;
  21942. /**
  21943. * Gets the active target at specified index. An active target is a target with an influence > 0
  21944. * @param index defines the index to check
  21945. * @returns the requested target
  21946. */
  21947. getActiveTarget(index: number): MorphTarget;
  21948. /**
  21949. * Gets the target at specified index
  21950. * @param index defines the index to check
  21951. * @returns the requested target
  21952. */
  21953. getTarget(index: number): MorphTarget;
  21954. /**
  21955. * Add a new target to this manager
  21956. * @param target defines the target to add
  21957. */
  21958. addTarget(target: MorphTarget): void;
  21959. /**
  21960. * Removes a target from the manager
  21961. * @param target defines the target to remove
  21962. */
  21963. removeTarget(target: MorphTarget): void;
  21964. /**
  21965. * Serializes the current manager into a Serialization object
  21966. * @returns the serialized object
  21967. */
  21968. serialize(): any;
  21969. private _syncActiveTargets;
  21970. /**
  21971. * Syncrhonize the targets with all the meshes using this morph target manager
  21972. */
  21973. synchronize(): void;
  21974. /**
  21975. * Creates a new MorphTargetManager from serialized data
  21976. * @param serializationObject defines the serialized data
  21977. * @param scene defines the hosting scene
  21978. * @returns the new MorphTargetManager
  21979. */
  21980. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21981. }
  21982. }
  21983. declare module BABYLON {
  21984. /**
  21985. * Class used to represent a specific level of detail of a mesh
  21986. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21987. */
  21988. export class MeshLODLevel {
  21989. /** Defines the distance where this level should start being displayed */
  21990. distance: number;
  21991. /** Defines the mesh to use to render this level */
  21992. mesh: Nullable<Mesh>;
  21993. /**
  21994. * Creates a new LOD level
  21995. * @param distance defines the distance where this level should star being displayed
  21996. * @param mesh defines the mesh to use to render this level
  21997. */
  21998. constructor(
  21999. /** Defines the distance where this level should start being displayed */
  22000. distance: number,
  22001. /** Defines the mesh to use to render this level */
  22002. mesh: Nullable<Mesh>);
  22003. }
  22004. }
  22005. declare module BABYLON {
  22006. /**
  22007. * Mesh representing the gorund
  22008. */
  22009. export class GroundMesh extends Mesh {
  22010. /** If octree should be generated */
  22011. generateOctree: boolean;
  22012. private _heightQuads;
  22013. /** @hidden */ private _subdivisionsX: number;
  22014. /** @hidden */ private _subdivisionsY: number;
  22015. /** @hidden */ private _width: number;
  22016. /** @hidden */ private _height: number;
  22017. /** @hidden */ private _minX: number;
  22018. /** @hidden */ private _maxX: number;
  22019. /** @hidden */ private _minZ: number;
  22020. /** @hidden */ private _maxZ: number;
  22021. constructor(name: string, scene: Scene);
  22022. /**
  22023. * "GroundMesh"
  22024. * @returns "GroundMesh"
  22025. */
  22026. getClassName(): string;
  22027. /**
  22028. * The minimum of x and y subdivisions
  22029. */
  22030. readonly subdivisions: number;
  22031. /**
  22032. * X subdivisions
  22033. */
  22034. readonly subdivisionsX: number;
  22035. /**
  22036. * Y subdivisions
  22037. */
  22038. readonly subdivisionsY: number;
  22039. /**
  22040. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22041. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22042. * @param chunksCount the number of subdivisions for x and y
  22043. * @param octreeBlocksSize (Default: 32)
  22044. */
  22045. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22046. /**
  22047. * Returns a height (y) value in the Worl system :
  22048. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22049. * @param x x coordinate
  22050. * @param z z coordinate
  22051. * @returns the ground y position if (x, z) are outside the ground surface.
  22052. */
  22053. getHeightAtCoordinates(x: number, z: number): number;
  22054. /**
  22055. * Returns a normalized vector (Vector3) orthogonal to the ground
  22056. * at the ground coordinates (x, z) expressed in the World system.
  22057. * @param x x coordinate
  22058. * @param z z coordinate
  22059. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22060. */
  22061. getNormalAtCoordinates(x: number, z: number): Vector3;
  22062. /**
  22063. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22064. * at the ground coordinates (x, z) expressed in the World system.
  22065. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22066. * @param x x coordinate
  22067. * @param z z coordinate
  22068. * @param ref vector to store the result
  22069. * @returns the GroundMesh.
  22070. */
  22071. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22072. /**
  22073. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22074. * if the ground has been updated.
  22075. * This can be used in the render loop.
  22076. * @returns the GroundMesh.
  22077. */
  22078. updateCoordinateHeights(): GroundMesh;
  22079. private _getFacetAt;
  22080. private _initHeightQuads;
  22081. private _computeHeightQuads;
  22082. /**
  22083. * Serializes this ground mesh
  22084. * @param serializationObject object to write serialization to
  22085. */
  22086. serialize(serializationObject: any): void;
  22087. /**
  22088. * Parses a serialized ground mesh
  22089. * @param parsedMesh the serialized mesh
  22090. * @param scene the scene to create the ground mesh in
  22091. * @returns the created ground mesh
  22092. */
  22093. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22094. }
  22095. }
  22096. declare module BABYLON {
  22097. /**
  22098. * Interface for Physics-Joint data
  22099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22100. */
  22101. export interface PhysicsJointData {
  22102. /**
  22103. * The main pivot of the joint
  22104. */
  22105. mainPivot?: Vector3;
  22106. /**
  22107. * The connected pivot of the joint
  22108. */
  22109. connectedPivot?: Vector3;
  22110. /**
  22111. * The main axis of the joint
  22112. */
  22113. mainAxis?: Vector3;
  22114. /**
  22115. * The connected axis of the joint
  22116. */
  22117. connectedAxis?: Vector3;
  22118. /**
  22119. * The collision of the joint
  22120. */
  22121. collision?: boolean;
  22122. /**
  22123. * Native Oimo/Cannon/Energy data
  22124. */
  22125. nativeParams?: any;
  22126. }
  22127. /**
  22128. * This is a holder class for the physics joint created by the physics plugin
  22129. * It holds a set of functions to control the underlying joint
  22130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22131. */
  22132. export class PhysicsJoint {
  22133. /**
  22134. * The type of the physics joint
  22135. */
  22136. type: number;
  22137. /**
  22138. * The data for the physics joint
  22139. */
  22140. jointData: PhysicsJointData;
  22141. private _physicsJoint;
  22142. protected _physicsPlugin: IPhysicsEnginePlugin;
  22143. /**
  22144. * Initializes the physics joint
  22145. * @param type The type of the physics joint
  22146. * @param jointData The data for the physics joint
  22147. */
  22148. constructor(
  22149. /**
  22150. * The type of the physics joint
  22151. */
  22152. type: number,
  22153. /**
  22154. * The data for the physics joint
  22155. */
  22156. jointData: PhysicsJointData);
  22157. /**
  22158. * Gets the physics joint
  22159. */
  22160. /**
  22161. * Sets the physics joint
  22162. */
  22163. physicsJoint: any;
  22164. /**
  22165. * Sets the physics plugin
  22166. */
  22167. physicsPlugin: IPhysicsEnginePlugin;
  22168. /**
  22169. * Execute a function that is physics-plugin specific.
  22170. * @param {Function} func the function that will be executed.
  22171. * It accepts two parameters: the physics world and the physics joint
  22172. */
  22173. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22174. /**
  22175. * Distance-Joint type
  22176. */
  22177. static DistanceJoint: number;
  22178. /**
  22179. * Hinge-Joint type
  22180. */
  22181. static HingeJoint: number;
  22182. /**
  22183. * Ball-and-Socket joint type
  22184. */
  22185. static BallAndSocketJoint: number;
  22186. /**
  22187. * Wheel-Joint type
  22188. */
  22189. static WheelJoint: number;
  22190. /**
  22191. * Slider-Joint type
  22192. */
  22193. static SliderJoint: number;
  22194. /**
  22195. * Prismatic-Joint type
  22196. */
  22197. static PrismaticJoint: number;
  22198. /**
  22199. * Universal-Joint type
  22200. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22201. */
  22202. static UniversalJoint: number;
  22203. /**
  22204. * Hinge-Joint 2 type
  22205. */
  22206. static Hinge2Joint: number;
  22207. /**
  22208. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22209. */
  22210. static PointToPointJoint: number;
  22211. /**
  22212. * Spring-Joint type
  22213. */
  22214. static SpringJoint: number;
  22215. /**
  22216. * Lock-Joint type
  22217. */
  22218. static LockJoint: number;
  22219. }
  22220. /**
  22221. * A class representing a physics distance joint
  22222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22223. */
  22224. export class DistanceJoint extends PhysicsJoint {
  22225. /**
  22226. *
  22227. * @param jointData The data for the Distance-Joint
  22228. */
  22229. constructor(jointData: DistanceJointData);
  22230. /**
  22231. * Update the predefined distance.
  22232. * @param maxDistance The maximum preferred distance
  22233. * @param minDistance The minimum preferred distance
  22234. */
  22235. updateDistance(maxDistance: number, minDistance?: number): void;
  22236. }
  22237. /**
  22238. * Represents a Motor-Enabled Joint
  22239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22240. */
  22241. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22242. /**
  22243. * Initializes the Motor-Enabled Joint
  22244. * @param type The type of the joint
  22245. * @param jointData The physica joint data for the joint
  22246. */
  22247. constructor(type: number, jointData: PhysicsJointData);
  22248. /**
  22249. * Set the motor values.
  22250. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22251. * @param force the force to apply
  22252. * @param maxForce max force for this motor.
  22253. */
  22254. setMotor(force?: number, maxForce?: number): void;
  22255. /**
  22256. * Set the motor's limits.
  22257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22258. * @param upperLimit The upper limit of the motor
  22259. * @param lowerLimit The lower limit of the motor
  22260. */
  22261. setLimit(upperLimit: number, lowerLimit?: number): void;
  22262. }
  22263. /**
  22264. * This class represents a single physics Hinge-Joint
  22265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22266. */
  22267. export class HingeJoint extends MotorEnabledJoint {
  22268. /**
  22269. * Initializes the Hinge-Joint
  22270. * @param jointData The joint data for the Hinge-Joint
  22271. */
  22272. constructor(jointData: PhysicsJointData);
  22273. /**
  22274. * Set the motor values.
  22275. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22276. * @param {number} force the force to apply
  22277. * @param {number} maxForce max force for this motor.
  22278. */
  22279. setMotor(force?: number, maxForce?: number): void;
  22280. /**
  22281. * Set the motor's limits.
  22282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22283. * @param upperLimit The upper limit of the motor
  22284. * @param lowerLimit The lower limit of the motor
  22285. */
  22286. setLimit(upperLimit: number, lowerLimit?: number): void;
  22287. }
  22288. /**
  22289. * This class represents a dual hinge physics joint (same as wheel joint)
  22290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22291. */
  22292. export class Hinge2Joint extends MotorEnabledJoint {
  22293. /**
  22294. * Initializes the Hinge2-Joint
  22295. * @param jointData The joint data for the Hinge2-Joint
  22296. */
  22297. constructor(jointData: PhysicsJointData);
  22298. /**
  22299. * Set the motor values.
  22300. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22301. * @param {number} targetSpeed the speed the motor is to reach
  22302. * @param {number} maxForce max force for this motor.
  22303. * @param {motorIndex} the motor's index, 0 or 1.
  22304. */
  22305. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22306. /**
  22307. * Set the motor limits.
  22308. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22309. * @param {number} upperLimit the upper limit
  22310. * @param {number} lowerLimit lower limit
  22311. * @param {motorIndex} the motor's index, 0 or 1.
  22312. */
  22313. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22314. }
  22315. /**
  22316. * Interface for a motor enabled joint
  22317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22318. */
  22319. export interface IMotorEnabledJoint {
  22320. /**
  22321. * Physics joint
  22322. */
  22323. physicsJoint: any;
  22324. /**
  22325. * Sets the motor of the motor-enabled joint
  22326. * @param force The force of the motor
  22327. * @param maxForce The maximum force of the motor
  22328. * @param motorIndex The index of the motor
  22329. */
  22330. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22331. /**
  22332. * Sets the limit of the motor
  22333. * @param upperLimit The upper limit of the motor
  22334. * @param lowerLimit The lower limit of the motor
  22335. * @param motorIndex The index of the motor
  22336. */
  22337. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22338. }
  22339. /**
  22340. * Joint data for a Distance-Joint
  22341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22342. */
  22343. export interface DistanceJointData extends PhysicsJointData {
  22344. /**
  22345. * Max distance the 2 joint objects can be apart
  22346. */
  22347. maxDistance: number;
  22348. }
  22349. /**
  22350. * Joint data from a spring joint
  22351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22352. */
  22353. export interface SpringJointData extends PhysicsJointData {
  22354. /**
  22355. * Length of the spring
  22356. */
  22357. length: number;
  22358. /**
  22359. * Stiffness of the spring
  22360. */
  22361. stiffness: number;
  22362. /**
  22363. * Damping of the spring
  22364. */
  22365. damping: number;
  22366. /** this callback will be called when applying the force to the impostors. */
  22367. forceApplicationCallback: () => void;
  22368. }
  22369. }
  22370. declare module BABYLON {
  22371. /**
  22372. * Holds the data for the raycast result
  22373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22374. */
  22375. export class PhysicsRaycastResult {
  22376. private _hasHit;
  22377. private _hitDistance;
  22378. private _hitNormalWorld;
  22379. private _hitPointWorld;
  22380. private _rayFromWorld;
  22381. private _rayToWorld;
  22382. /**
  22383. * Gets if there was a hit
  22384. */
  22385. readonly hasHit: boolean;
  22386. /**
  22387. * Gets the distance from the hit
  22388. */
  22389. readonly hitDistance: number;
  22390. /**
  22391. * Gets the hit normal/direction in the world
  22392. */
  22393. readonly hitNormalWorld: Vector3;
  22394. /**
  22395. * Gets the hit point in the world
  22396. */
  22397. readonly hitPointWorld: Vector3;
  22398. /**
  22399. * Gets the ray "start point" of the ray in the world
  22400. */
  22401. readonly rayFromWorld: Vector3;
  22402. /**
  22403. * Gets the ray "end point" of the ray in the world
  22404. */
  22405. readonly rayToWorld: Vector3;
  22406. /**
  22407. * Sets the hit data (normal & point in world space)
  22408. * @param hitNormalWorld defines the normal in world space
  22409. * @param hitPointWorld defines the point in world space
  22410. */
  22411. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22412. /**
  22413. * Sets the distance from the start point to the hit point
  22414. * @param distance
  22415. */
  22416. setHitDistance(distance: number): void;
  22417. /**
  22418. * Calculates the distance manually
  22419. */
  22420. calculateHitDistance(): void;
  22421. /**
  22422. * Resets all the values to default
  22423. * @param from The from point on world space
  22424. * @param to The to point on world space
  22425. */
  22426. reset(from?: Vector3, to?: Vector3): void;
  22427. }
  22428. /**
  22429. * Interface for the size containing width and height
  22430. */
  22431. interface IXYZ {
  22432. /**
  22433. * X
  22434. */
  22435. x: number;
  22436. /**
  22437. * Y
  22438. */
  22439. y: number;
  22440. /**
  22441. * Z
  22442. */
  22443. z: number;
  22444. }
  22445. }
  22446. declare module BABYLON {
  22447. /**
  22448. * Interface used to describe a physics joint
  22449. */
  22450. export interface PhysicsImpostorJoint {
  22451. /** Defines the main impostor to which the joint is linked */
  22452. mainImpostor: PhysicsImpostor;
  22453. /** Defines the impostor that is connected to the main impostor using this joint */
  22454. connectedImpostor: PhysicsImpostor;
  22455. /** Defines the joint itself */
  22456. joint: PhysicsJoint;
  22457. }
  22458. /** @hidden */
  22459. export interface IPhysicsEnginePlugin {
  22460. world: any;
  22461. name: string;
  22462. setGravity(gravity: Vector3): void;
  22463. setTimeStep(timeStep: number): void;
  22464. getTimeStep(): number;
  22465. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22466. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22467. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22468. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22469. removePhysicsBody(impostor: PhysicsImpostor): void;
  22470. generateJoint(joint: PhysicsImpostorJoint): void;
  22471. removeJoint(joint: PhysicsImpostorJoint): void;
  22472. isSupported(): boolean;
  22473. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22474. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22475. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22476. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22477. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22478. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22479. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22480. getBodyMass(impostor: PhysicsImpostor): number;
  22481. getBodyFriction(impostor: PhysicsImpostor): number;
  22482. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22483. getBodyRestitution(impostor: PhysicsImpostor): number;
  22484. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22485. getBodyPressure?(impostor: PhysicsImpostor): number;
  22486. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22487. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22488. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22489. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22490. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22491. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22492. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22493. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22494. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22495. sleepBody(impostor: PhysicsImpostor): void;
  22496. wakeUpBody(impostor: PhysicsImpostor): void;
  22497. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22498. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22499. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22500. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22501. getRadius(impostor: PhysicsImpostor): number;
  22502. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22503. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22504. dispose(): void;
  22505. }
  22506. /**
  22507. * Interface used to define a physics engine
  22508. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22509. */
  22510. export interface IPhysicsEngine {
  22511. /**
  22512. * Gets the gravity vector used by the simulation
  22513. */
  22514. gravity: Vector3;
  22515. /**
  22516. * Sets the gravity vector used by the simulation
  22517. * @param gravity defines the gravity vector to use
  22518. */
  22519. setGravity(gravity: Vector3): void;
  22520. /**
  22521. * Set the time step of the physics engine.
  22522. * Default is 1/60.
  22523. * To slow it down, enter 1/600 for example.
  22524. * To speed it up, 1/30
  22525. * @param newTimeStep the new timestep to apply to this world.
  22526. */
  22527. setTimeStep(newTimeStep: number): void;
  22528. /**
  22529. * Get the time step of the physics engine.
  22530. * @returns the current time step
  22531. */
  22532. getTimeStep(): number;
  22533. /**
  22534. * Release all resources
  22535. */
  22536. dispose(): void;
  22537. /**
  22538. * Gets the name of the current physics plugin
  22539. * @returns the name of the plugin
  22540. */
  22541. getPhysicsPluginName(): string;
  22542. /**
  22543. * Adding a new impostor for the impostor tracking.
  22544. * This will be done by the impostor itself.
  22545. * @param impostor the impostor to add
  22546. */
  22547. addImpostor(impostor: PhysicsImpostor): void;
  22548. /**
  22549. * Remove an impostor from the engine.
  22550. * This impostor and its mesh will not longer be updated by the physics engine.
  22551. * @param impostor the impostor to remove
  22552. */
  22553. removeImpostor(impostor: PhysicsImpostor): void;
  22554. /**
  22555. * Add a joint to the physics engine
  22556. * @param mainImpostor defines the main impostor to which the joint is added.
  22557. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22558. * @param joint defines the joint that will connect both impostors.
  22559. */
  22560. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22561. /**
  22562. * Removes a joint from the simulation
  22563. * @param mainImpostor defines the impostor used with the joint
  22564. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22565. * @param joint defines the joint to remove
  22566. */
  22567. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22568. /**
  22569. * Gets the current plugin used to run the simulation
  22570. * @returns current plugin
  22571. */
  22572. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22573. /**
  22574. * Gets the list of physic impostors
  22575. * @returns an array of PhysicsImpostor
  22576. */
  22577. getImpostors(): Array<PhysicsImpostor>;
  22578. /**
  22579. * Gets the impostor for a physics enabled object
  22580. * @param object defines the object impersonated by the impostor
  22581. * @returns the PhysicsImpostor or null if not found
  22582. */
  22583. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22584. /**
  22585. * Gets the impostor for a physics body object
  22586. * @param body defines physics body used by the impostor
  22587. * @returns the PhysicsImpostor or null if not found
  22588. */
  22589. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22590. /**
  22591. * Does a raycast in the physics world
  22592. * @param from when should the ray start?
  22593. * @param to when should the ray end?
  22594. * @returns PhysicsRaycastResult
  22595. */
  22596. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22597. /**
  22598. * Called by the scene. No need to call it.
  22599. * @param delta defines the timespam between frames
  22600. */ private _step(delta: number): void;
  22601. }
  22602. }
  22603. declare module BABYLON {
  22604. /**
  22605. * The interface for the physics imposter parameters
  22606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22607. */
  22608. export interface PhysicsImpostorParameters {
  22609. /**
  22610. * The mass of the physics imposter
  22611. */
  22612. mass: number;
  22613. /**
  22614. * The friction of the physics imposter
  22615. */
  22616. friction?: number;
  22617. /**
  22618. * The coefficient of restitution of the physics imposter
  22619. */
  22620. restitution?: number;
  22621. /**
  22622. * The native options of the physics imposter
  22623. */
  22624. nativeOptions?: any;
  22625. /**
  22626. * Specifies if the parent should be ignored
  22627. */
  22628. ignoreParent?: boolean;
  22629. /**
  22630. * Specifies if bi-directional transformations should be disabled
  22631. */
  22632. disableBidirectionalTransformation?: boolean;
  22633. /**
  22634. * The pressure inside the physics imposter, soft object only
  22635. */
  22636. pressure?: number;
  22637. /**
  22638. * The stiffness the physics imposter, soft object only
  22639. */
  22640. stiffness?: number;
  22641. /**
  22642. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22643. */
  22644. velocityIterations?: number;
  22645. /**
  22646. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22647. */
  22648. positionIterations?: number;
  22649. /**
  22650. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22651. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22652. * Add to fix multiple points
  22653. */
  22654. fixedPoints?: number;
  22655. /**
  22656. * The collision margin around a soft object
  22657. */
  22658. margin?: number;
  22659. /**
  22660. * The collision margin around a soft object
  22661. */
  22662. damping?: number;
  22663. /**
  22664. * The path for a rope based on an extrusion
  22665. */
  22666. path?: any;
  22667. /**
  22668. * The shape of an extrusion used for a rope based on an extrusion
  22669. */
  22670. shape?: any;
  22671. }
  22672. /**
  22673. * Interface for a physics-enabled object
  22674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22675. */
  22676. export interface IPhysicsEnabledObject {
  22677. /**
  22678. * The position of the physics-enabled object
  22679. */
  22680. position: Vector3;
  22681. /**
  22682. * The rotation of the physics-enabled object
  22683. */
  22684. rotationQuaternion: Nullable<Quaternion>;
  22685. /**
  22686. * The scale of the physics-enabled object
  22687. */
  22688. scaling: Vector3;
  22689. /**
  22690. * The rotation of the physics-enabled object
  22691. */
  22692. rotation?: Vector3;
  22693. /**
  22694. * The parent of the physics-enabled object
  22695. */
  22696. parent?: any;
  22697. /**
  22698. * The bounding info of the physics-enabled object
  22699. * @returns The bounding info of the physics-enabled object
  22700. */
  22701. getBoundingInfo(): BoundingInfo;
  22702. /**
  22703. * Computes the world matrix
  22704. * @param force Specifies if the world matrix should be computed by force
  22705. * @returns A world matrix
  22706. */
  22707. computeWorldMatrix(force: boolean): Matrix;
  22708. /**
  22709. * Gets the world matrix
  22710. * @returns A world matrix
  22711. */
  22712. getWorldMatrix?(): Matrix;
  22713. /**
  22714. * Gets the child meshes
  22715. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22716. * @returns An array of abstract meshes
  22717. */
  22718. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22719. /**
  22720. * Gets the vertex data
  22721. * @param kind The type of vertex data
  22722. * @returns A nullable array of numbers, or a float32 array
  22723. */
  22724. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22725. /**
  22726. * Gets the indices from the mesh
  22727. * @returns A nullable array of index arrays
  22728. */
  22729. getIndices?(): Nullable<IndicesArray>;
  22730. /**
  22731. * Gets the scene from the mesh
  22732. * @returns the indices array or null
  22733. */
  22734. getScene?(): Scene;
  22735. /**
  22736. * Gets the absolute position from the mesh
  22737. * @returns the absolute position
  22738. */
  22739. getAbsolutePosition(): Vector3;
  22740. /**
  22741. * Gets the absolute pivot point from the mesh
  22742. * @returns the absolute pivot point
  22743. */
  22744. getAbsolutePivotPoint(): Vector3;
  22745. /**
  22746. * Rotates the mesh
  22747. * @param axis The axis of rotation
  22748. * @param amount The amount of rotation
  22749. * @param space The space of the rotation
  22750. * @returns The rotation transform node
  22751. */
  22752. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22753. /**
  22754. * Translates the mesh
  22755. * @param axis The axis of translation
  22756. * @param distance The distance of translation
  22757. * @param space The space of the translation
  22758. * @returns The transform node
  22759. */
  22760. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22761. /**
  22762. * Sets the absolute position of the mesh
  22763. * @param absolutePosition The absolute position of the mesh
  22764. * @returns The transform node
  22765. */
  22766. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22767. /**
  22768. * Gets the class name of the mesh
  22769. * @returns The class name
  22770. */
  22771. getClassName(): string;
  22772. }
  22773. /**
  22774. * Represents a physics imposter
  22775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22776. */
  22777. export class PhysicsImpostor {
  22778. /**
  22779. * The physics-enabled object used as the physics imposter
  22780. */
  22781. object: IPhysicsEnabledObject;
  22782. /**
  22783. * The type of the physics imposter
  22784. */
  22785. type: number;
  22786. private _options;
  22787. private _scene?;
  22788. /**
  22789. * The default object size of the imposter
  22790. */
  22791. static DEFAULT_OBJECT_SIZE: Vector3;
  22792. /**
  22793. * The identity quaternion of the imposter
  22794. */
  22795. static IDENTITY_QUATERNION: Quaternion;
  22796. /** @hidden */ private _pluginData: any;
  22797. private _physicsEngine;
  22798. private _physicsBody;
  22799. private _bodyUpdateRequired;
  22800. private _onBeforePhysicsStepCallbacks;
  22801. private _onAfterPhysicsStepCallbacks;
  22802. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22803. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22804. otherImpostors: Array<PhysicsImpostor>;
  22805. }>;
  22806. private _deltaPosition;
  22807. private _deltaRotation;
  22808. private _deltaRotationConjugated;
  22809. /** @hidden */ private _isFromLine: boolean;
  22810. private _parent;
  22811. private _isDisposed;
  22812. private static _tmpVecs;
  22813. private static _tmpQuat;
  22814. /**
  22815. * Specifies if the physics imposter is disposed
  22816. */
  22817. readonly isDisposed: boolean;
  22818. /**
  22819. * Gets the mass of the physics imposter
  22820. */
  22821. mass: number;
  22822. /**
  22823. * Gets the coefficient of friction
  22824. */
  22825. /**
  22826. * Sets the coefficient of friction
  22827. */
  22828. friction: number;
  22829. /**
  22830. * Gets the coefficient of restitution
  22831. */
  22832. /**
  22833. * Sets the coefficient of restitution
  22834. */
  22835. restitution: number;
  22836. /**
  22837. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22838. */
  22839. /**
  22840. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22841. */
  22842. pressure: number;
  22843. /**
  22844. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22845. */
  22846. /**
  22847. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22848. */
  22849. stiffness: number;
  22850. /**
  22851. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22852. */
  22853. /**
  22854. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22855. */
  22856. velocityIterations: number;
  22857. /**
  22858. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22859. */
  22860. /**
  22861. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22862. */
  22863. positionIterations: number;
  22864. /**
  22865. * The unique id of the physics imposter
  22866. * set by the physics engine when adding this impostor to the array
  22867. */
  22868. uniqueId: number;
  22869. /**
  22870. * @hidden
  22871. */
  22872. soft: boolean;
  22873. /**
  22874. * @hidden
  22875. */
  22876. segments: number;
  22877. private _joints;
  22878. /**
  22879. * Initializes the physics imposter
  22880. * @param object The physics-enabled object used as the physics imposter
  22881. * @param type The type of the physics imposter
  22882. * @param _options The options for the physics imposter
  22883. * @param _scene The Babylon scene
  22884. */
  22885. constructor(
  22886. /**
  22887. * The physics-enabled object used as the physics imposter
  22888. */
  22889. object: IPhysicsEnabledObject,
  22890. /**
  22891. * The type of the physics imposter
  22892. */
  22893. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22894. /**
  22895. * This function will completly initialize this impostor.
  22896. * It will create a new body - but only if this mesh has no parent.
  22897. * If it has, this impostor will not be used other than to define the impostor
  22898. * of the child mesh.
  22899. * @hidden
  22900. */ private _init(): void;
  22901. private _getPhysicsParent;
  22902. /**
  22903. * Should a new body be generated.
  22904. * @returns boolean specifying if body initialization is required
  22905. */
  22906. isBodyInitRequired(): boolean;
  22907. /**
  22908. * Sets the updated scaling
  22909. * @param updated Specifies if the scaling is updated
  22910. */
  22911. setScalingUpdated(): void;
  22912. /**
  22913. * Force a regeneration of this or the parent's impostor's body.
  22914. * Use under cautious - This will remove all joints already implemented.
  22915. */
  22916. forceUpdate(): void;
  22917. /**
  22918. * Gets the body that holds this impostor. Either its own, or its parent.
  22919. */
  22920. /**
  22921. * Set the physics body. Used mainly by the physics engine/plugin
  22922. */
  22923. physicsBody: any;
  22924. /**
  22925. * Get the parent of the physics imposter
  22926. * @returns Physics imposter or null
  22927. */
  22928. /**
  22929. * Sets the parent of the physics imposter
  22930. */
  22931. parent: Nullable<PhysicsImpostor>;
  22932. /**
  22933. * Resets the update flags
  22934. */
  22935. resetUpdateFlags(): void;
  22936. /**
  22937. * Gets the object extend size
  22938. * @returns the object extend size
  22939. */
  22940. getObjectExtendSize(): Vector3;
  22941. /**
  22942. * Gets the object center
  22943. * @returns The object center
  22944. */
  22945. getObjectCenter(): Vector3;
  22946. /**
  22947. * Get a specific parametes from the options parameter
  22948. * @param paramName The object parameter name
  22949. * @returns The object parameter
  22950. */
  22951. getParam(paramName: string): any;
  22952. /**
  22953. * Sets a specific parameter in the options given to the physics plugin
  22954. * @param paramName The parameter name
  22955. * @param value The value of the parameter
  22956. */
  22957. setParam(paramName: string, value: number): void;
  22958. /**
  22959. * Specifically change the body's mass option. Won't recreate the physics body object
  22960. * @param mass The mass of the physics imposter
  22961. */
  22962. setMass(mass: number): void;
  22963. /**
  22964. * Gets the linear velocity
  22965. * @returns linear velocity or null
  22966. */
  22967. getLinearVelocity(): Nullable<Vector3>;
  22968. /**
  22969. * Sets the linear velocity
  22970. * @param velocity linear velocity or null
  22971. */
  22972. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22973. /**
  22974. * Gets the angular velocity
  22975. * @returns angular velocity or null
  22976. */
  22977. getAngularVelocity(): Nullable<Vector3>;
  22978. /**
  22979. * Sets the angular velocity
  22980. * @param velocity The velocity or null
  22981. */
  22982. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22983. /**
  22984. * Execute a function with the physics plugin native code
  22985. * Provide a function the will have two variables - the world object and the physics body object
  22986. * @param func The function to execute with the physics plugin native code
  22987. */
  22988. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22989. /**
  22990. * Register a function that will be executed before the physics world is stepping forward
  22991. * @param func The function to execute before the physics world is stepped forward
  22992. */
  22993. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22994. /**
  22995. * Unregister a function that will be executed before the physics world is stepping forward
  22996. * @param func The function to execute before the physics world is stepped forward
  22997. */
  22998. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22999. /**
  23000. * Register a function that will be executed after the physics step
  23001. * @param func The function to execute after physics step
  23002. */
  23003. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23004. /**
  23005. * Unregisters a function that will be executed after the physics step
  23006. * @param func The function to execute after physics step
  23007. */
  23008. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23009. /**
  23010. * register a function that will be executed when this impostor collides against a different body
  23011. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23012. * @param func Callback that is executed on collision
  23013. */
  23014. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23015. /**
  23016. * Unregisters the physics imposter on contact
  23017. * @param collideAgainst The physics object to collide against
  23018. * @param func Callback to execute on collision
  23019. */
  23020. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23021. private _tmpQuat;
  23022. private _tmpQuat2;
  23023. /**
  23024. * Get the parent rotation
  23025. * @returns The parent rotation
  23026. */
  23027. getParentsRotation(): Quaternion;
  23028. /**
  23029. * this function is executed by the physics engine.
  23030. */
  23031. beforeStep: () => void;
  23032. /**
  23033. * this function is executed by the physics engine
  23034. */
  23035. afterStep: () => void;
  23036. /**
  23037. * Legacy collision detection event support
  23038. */
  23039. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23040. /**
  23041. * event and body object due to cannon's event-based architecture.
  23042. */
  23043. onCollide: (e: {
  23044. body: any;
  23045. }) => void;
  23046. /**
  23047. * Apply a force
  23048. * @param force The force to apply
  23049. * @param contactPoint The contact point for the force
  23050. * @returns The physics imposter
  23051. */
  23052. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23053. /**
  23054. * Apply an impulse
  23055. * @param force The impulse force
  23056. * @param contactPoint The contact point for the impulse force
  23057. * @returns The physics imposter
  23058. */
  23059. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23060. /**
  23061. * A help function to create a joint
  23062. * @param otherImpostor A physics imposter used to create a joint
  23063. * @param jointType The type of joint
  23064. * @param jointData The data for the joint
  23065. * @returns The physics imposter
  23066. */
  23067. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23068. /**
  23069. * Add a joint to this impostor with a different impostor
  23070. * @param otherImpostor A physics imposter used to add a joint
  23071. * @param joint The joint to add
  23072. * @returns The physics imposter
  23073. */
  23074. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23075. /**
  23076. * Add an anchor to a cloth impostor
  23077. * @param otherImpostor rigid impostor to anchor to
  23078. * @param width ratio across width from 0 to 1
  23079. * @param height ratio up height from 0 to 1
  23080. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23081. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23082. * @returns impostor the soft imposter
  23083. */
  23084. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23085. /**
  23086. * Add a hook to a rope impostor
  23087. * @param otherImpostor rigid impostor to anchor to
  23088. * @param length ratio across rope from 0 to 1
  23089. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23090. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23091. * @returns impostor the rope imposter
  23092. */
  23093. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23094. /**
  23095. * Will keep this body still, in a sleep mode.
  23096. * @returns the physics imposter
  23097. */
  23098. sleep(): PhysicsImpostor;
  23099. /**
  23100. * Wake the body up.
  23101. * @returns The physics imposter
  23102. */
  23103. wakeUp(): PhysicsImpostor;
  23104. /**
  23105. * Clones the physics imposter
  23106. * @param newObject The physics imposter clones to this physics-enabled object
  23107. * @returns A nullable physics imposter
  23108. */
  23109. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23110. /**
  23111. * Disposes the physics imposter
  23112. */
  23113. dispose(): void;
  23114. /**
  23115. * Sets the delta position
  23116. * @param position The delta position amount
  23117. */
  23118. setDeltaPosition(position: Vector3): void;
  23119. /**
  23120. * Sets the delta rotation
  23121. * @param rotation The delta rotation amount
  23122. */
  23123. setDeltaRotation(rotation: Quaternion): void;
  23124. /**
  23125. * Gets the box size of the physics imposter and stores the result in the input parameter
  23126. * @param result Stores the box size
  23127. * @returns The physics imposter
  23128. */
  23129. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23130. /**
  23131. * Gets the radius of the physics imposter
  23132. * @returns Radius of the physics imposter
  23133. */
  23134. getRadius(): number;
  23135. /**
  23136. * Sync a bone with this impostor
  23137. * @param bone The bone to sync to the impostor.
  23138. * @param boneMesh The mesh that the bone is influencing.
  23139. * @param jointPivot The pivot of the joint / bone in local space.
  23140. * @param distToJoint Optional distance from the impostor to the joint.
  23141. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23142. */
  23143. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23144. /**
  23145. * Sync impostor to a bone
  23146. * @param bone The bone that the impostor will be synced to.
  23147. * @param boneMesh The mesh that the bone is influencing.
  23148. * @param jointPivot The pivot of the joint / bone in local space.
  23149. * @param distToJoint Optional distance from the impostor to the joint.
  23150. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23151. * @param boneAxis Optional vector3 axis the bone is aligned with
  23152. */
  23153. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23154. /**
  23155. * No-Imposter type
  23156. */
  23157. static NoImpostor: number;
  23158. /**
  23159. * Sphere-Imposter type
  23160. */
  23161. static SphereImpostor: number;
  23162. /**
  23163. * Box-Imposter type
  23164. */
  23165. static BoxImpostor: number;
  23166. /**
  23167. * Plane-Imposter type
  23168. */
  23169. static PlaneImpostor: number;
  23170. /**
  23171. * Mesh-imposter type
  23172. */
  23173. static MeshImpostor: number;
  23174. /**
  23175. * Capsule-Impostor type (Ammo.js plugin only)
  23176. */
  23177. static CapsuleImpostor: number;
  23178. /**
  23179. * Cylinder-Imposter type
  23180. */
  23181. static CylinderImpostor: number;
  23182. /**
  23183. * Particle-Imposter type
  23184. */
  23185. static ParticleImpostor: number;
  23186. /**
  23187. * Heightmap-Imposter type
  23188. */
  23189. static HeightmapImpostor: number;
  23190. /**
  23191. * ConvexHull-Impostor type (Ammo.js plugin only)
  23192. */
  23193. static ConvexHullImpostor: number;
  23194. /**
  23195. * Rope-Imposter type
  23196. */
  23197. static RopeImpostor: number;
  23198. /**
  23199. * Cloth-Imposter type
  23200. */
  23201. static ClothImpostor: number;
  23202. /**
  23203. * Softbody-Imposter type
  23204. */
  23205. static SoftbodyImpostor: number;
  23206. }
  23207. }
  23208. declare module BABYLON {
  23209. /**
  23210. * @hidden
  23211. **/
  23212. export class _CreationDataStorage {
  23213. closePath?: boolean;
  23214. closeArray?: boolean;
  23215. idx: number[];
  23216. dashSize: number;
  23217. gapSize: number;
  23218. path3D: Path3D;
  23219. pathArray: Vector3[][];
  23220. arc: number;
  23221. radius: number;
  23222. cap: number;
  23223. tessellation: number;
  23224. }
  23225. /**
  23226. * @hidden
  23227. **/ private class _InstanceDataStorage {
  23228. visibleInstances: any;
  23229. batchCache: _InstancesBatch;
  23230. instancesBufferSize: number;
  23231. instancesBuffer: Nullable<Buffer>;
  23232. instancesData: Float32Array;
  23233. overridenInstanceCount: number;
  23234. isFrozen: boolean;
  23235. previousBatch: Nullable<_InstancesBatch>;
  23236. hardwareInstancedRendering: boolean;
  23237. sideOrientation: number;
  23238. }
  23239. /**
  23240. * @hidden
  23241. **/
  23242. export class _InstancesBatch {
  23243. mustReturn: boolean;
  23244. visibleInstances: Nullable<InstancedMesh[]>[];
  23245. renderSelf: boolean[];
  23246. hardwareInstancedRendering: boolean[];
  23247. }
  23248. /**
  23249. * Class used to represent renderable models
  23250. */
  23251. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23252. /**
  23253. * Mesh side orientation : usually the external or front surface
  23254. */
  23255. static readonly FRONTSIDE: number;
  23256. /**
  23257. * Mesh side orientation : usually the internal or back surface
  23258. */
  23259. static readonly BACKSIDE: number;
  23260. /**
  23261. * Mesh side orientation : both internal and external or front and back surfaces
  23262. */
  23263. static readonly DOUBLESIDE: number;
  23264. /**
  23265. * Mesh side orientation : by default, `FRONTSIDE`
  23266. */
  23267. static readonly DEFAULTSIDE: number;
  23268. /**
  23269. * Mesh cap setting : no cap
  23270. */
  23271. static readonly NO_CAP: number;
  23272. /**
  23273. * Mesh cap setting : one cap at the beginning of the mesh
  23274. */
  23275. static readonly CAP_START: number;
  23276. /**
  23277. * Mesh cap setting : one cap at the end of the mesh
  23278. */
  23279. static readonly CAP_END: number;
  23280. /**
  23281. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23282. */
  23283. static readonly CAP_ALL: number;
  23284. /**
  23285. * Mesh pattern setting : no flip or rotate
  23286. */
  23287. static readonly NO_FLIP: number;
  23288. /**
  23289. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23290. */
  23291. static readonly FLIP_TILE: number;
  23292. /**
  23293. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23294. */
  23295. static readonly ROTATE_TILE: number;
  23296. /**
  23297. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23298. */
  23299. static readonly FLIP_ROW: number;
  23300. /**
  23301. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23302. */
  23303. static readonly ROTATE_ROW: number;
  23304. /**
  23305. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23306. */
  23307. static readonly FLIP_N_ROTATE_TILE: number;
  23308. /**
  23309. * Mesh pattern setting : rotate pattern and rotate
  23310. */
  23311. static readonly FLIP_N_ROTATE_ROW: number;
  23312. /**
  23313. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23314. */
  23315. static readonly CENTER: number;
  23316. /**
  23317. * Mesh tile positioning : part tiles on left
  23318. */
  23319. static readonly LEFT: number;
  23320. /**
  23321. * Mesh tile positioning : part tiles on right
  23322. */
  23323. static readonly RIGHT: number;
  23324. /**
  23325. * Mesh tile positioning : part tiles on top
  23326. */
  23327. static readonly TOP: number;
  23328. /**
  23329. * Mesh tile positioning : part tiles on bottom
  23330. */
  23331. static readonly BOTTOM: number;
  23332. /**
  23333. * Gets the default side orientation.
  23334. * @param orientation the orientation to value to attempt to get
  23335. * @returns the default orientation
  23336. * @hidden
  23337. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23338. private _internalMeshDataInfo;
  23339. /**
  23340. * An event triggered before rendering the mesh
  23341. */
  23342. readonly onBeforeRenderObservable: Observable<Mesh>;
  23343. /**
  23344. * An event triggered before binding the mesh
  23345. */
  23346. readonly onBeforeBindObservable: Observable<Mesh>;
  23347. /**
  23348. * An event triggered after rendering the mesh
  23349. */
  23350. readonly onAfterRenderObservable: Observable<Mesh>;
  23351. /**
  23352. * An event triggered before drawing the mesh
  23353. */
  23354. readonly onBeforeDrawObservable: Observable<Mesh>;
  23355. private _onBeforeDrawObserver;
  23356. /**
  23357. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23358. */
  23359. onBeforeDraw: () => void;
  23360. readonly hasInstances: boolean;
  23361. /**
  23362. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23363. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23364. */
  23365. delayLoadState: number;
  23366. /**
  23367. * Gets the list of instances created from this mesh
  23368. * it is not supposed to be modified manually.
  23369. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23370. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23371. */
  23372. instances: InstancedMesh[];
  23373. /**
  23374. * Gets the file containing delay loading data for this mesh
  23375. */
  23376. delayLoadingFile: string;
  23377. /** @hidden */ private _binaryInfo: any;
  23378. /**
  23379. * User defined function used to change how LOD level selection is done
  23380. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23381. */
  23382. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23383. /**
  23384. * Gets or sets the morph target manager
  23385. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23386. */
  23387. morphTargetManager: Nullable<MorphTargetManager>;
  23388. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23389. /** @hidden */ private _geometry: Nullable<Geometry>;
  23390. /** @hidden */ private _delayInfo: Array<string>;
  23391. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23392. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23393. private _effectiveMaterial;
  23394. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23395. /** @hidden */ private _originalBuilderSideOrientation: number;
  23396. /**
  23397. * Use this property to change the original side orientation defined at construction time
  23398. */
  23399. overrideMaterialSideOrientation: Nullable<number>;
  23400. /**
  23401. * Gets the source mesh (the one used to clone this one from)
  23402. */
  23403. readonly source: Nullable<Mesh>;
  23404. /**
  23405. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23406. */
  23407. isUnIndexed: boolean;
  23408. /**
  23409. * @constructor
  23410. * @param name The value used by scene.getMeshByName() to do a lookup.
  23411. * @param scene The scene to add this mesh to.
  23412. * @param parent The parent of this mesh, if it has one
  23413. * @param source An optional Mesh from which geometry is shared, cloned.
  23414. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23415. * When false, achieved by calling a clone(), also passing False.
  23416. * This will make creation of children, recursive.
  23417. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23418. */
  23419. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23420. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23421. /**
  23422. * Gets the class name
  23423. * @returns the string "Mesh".
  23424. */
  23425. getClassName(): string;
  23426. /** @hidden */ protected readonly _isMesh: boolean;
  23427. /**
  23428. * Returns a description of this mesh
  23429. * @param fullDetails define if full details about this mesh must be used
  23430. * @returns a descriptive string representing this mesh
  23431. */
  23432. toString(fullDetails?: boolean): string;
  23433. /** @hidden */ private _unBindEffect(): void;
  23434. /**
  23435. * Gets a boolean indicating if this mesh has LOD
  23436. */
  23437. readonly hasLODLevels: boolean;
  23438. /**
  23439. * Gets the list of MeshLODLevel associated with the current mesh
  23440. * @returns an array of MeshLODLevel
  23441. */
  23442. getLODLevels(): MeshLODLevel[];
  23443. private _sortLODLevels;
  23444. /**
  23445. * Add a mesh as LOD level triggered at the given distance.
  23446. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23447. * @param distance The distance from the center of the object to show this level
  23448. * @param mesh The mesh to be added as LOD level (can be null)
  23449. * @return This mesh (for chaining)
  23450. */
  23451. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23452. /**
  23453. * Returns the LOD level mesh at the passed distance or null if not found.
  23454. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23455. * @param distance The distance from the center of the object to show this level
  23456. * @returns a Mesh or `null`
  23457. */
  23458. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23459. /**
  23460. * Remove a mesh from the LOD array
  23461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23462. * @param mesh defines the mesh to be removed
  23463. * @return This mesh (for chaining)
  23464. */
  23465. removeLODLevel(mesh: Mesh): Mesh;
  23466. /**
  23467. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23468. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23469. * @param camera defines the camera to use to compute distance
  23470. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23471. * @return This mesh (for chaining)
  23472. */
  23473. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23474. /**
  23475. * Gets the mesh internal Geometry object
  23476. */
  23477. readonly geometry: Nullable<Geometry>;
  23478. /**
  23479. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23480. * @returns the total number of vertices
  23481. */
  23482. getTotalVertices(): number;
  23483. /**
  23484. * Returns the content of an associated vertex buffer
  23485. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23486. * - VertexBuffer.PositionKind
  23487. * - VertexBuffer.UVKind
  23488. * - VertexBuffer.UV2Kind
  23489. * - VertexBuffer.UV3Kind
  23490. * - VertexBuffer.UV4Kind
  23491. * - VertexBuffer.UV5Kind
  23492. * - VertexBuffer.UV6Kind
  23493. * - VertexBuffer.ColorKind
  23494. * - VertexBuffer.MatricesIndicesKind
  23495. * - VertexBuffer.MatricesIndicesExtraKind
  23496. * - VertexBuffer.MatricesWeightsKind
  23497. * - VertexBuffer.MatricesWeightsExtraKind
  23498. * @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
  23499. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23500. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23501. */
  23502. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23503. /**
  23504. * Returns the mesh VertexBuffer object from the requested `kind`
  23505. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23506. * - VertexBuffer.PositionKind
  23507. * - VertexBuffer.NormalKind
  23508. * - VertexBuffer.UVKind
  23509. * - VertexBuffer.UV2Kind
  23510. * - VertexBuffer.UV3Kind
  23511. * - VertexBuffer.UV4Kind
  23512. * - VertexBuffer.UV5Kind
  23513. * - VertexBuffer.UV6Kind
  23514. * - VertexBuffer.ColorKind
  23515. * - VertexBuffer.MatricesIndicesKind
  23516. * - VertexBuffer.MatricesIndicesExtraKind
  23517. * - VertexBuffer.MatricesWeightsKind
  23518. * - VertexBuffer.MatricesWeightsExtraKind
  23519. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23520. */
  23521. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23522. /**
  23523. * Tests if a specific vertex buffer is associated with this mesh
  23524. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23525. * - VertexBuffer.PositionKind
  23526. * - VertexBuffer.NormalKind
  23527. * - VertexBuffer.UVKind
  23528. * - VertexBuffer.UV2Kind
  23529. * - VertexBuffer.UV3Kind
  23530. * - VertexBuffer.UV4Kind
  23531. * - VertexBuffer.UV5Kind
  23532. * - VertexBuffer.UV6Kind
  23533. * - VertexBuffer.ColorKind
  23534. * - VertexBuffer.MatricesIndicesKind
  23535. * - VertexBuffer.MatricesIndicesExtraKind
  23536. * - VertexBuffer.MatricesWeightsKind
  23537. * - VertexBuffer.MatricesWeightsExtraKind
  23538. * @returns a boolean
  23539. */
  23540. isVerticesDataPresent(kind: string): boolean;
  23541. /**
  23542. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23543. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23544. * - VertexBuffer.PositionKind
  23545. * - VertexBuffer.UVKind
  23546. * - VertexBuffer.UV2Kind
  23547. * - VertexBuffer.UV3Kind
  23548. * - VertexBuffer.UV4Kind
  23549. * - VertexBuffer.UV5Kind
  23550. * - VertexBuffer.UV6Kind
  23551. * - VertexBuffer.ColorKind
  23552. * - VertexBuffer.MatricesIndicesKind
  23553. * - VertexBuffer.MatricesIndicesExtraKind
  23554. * - VertexBuffer.MatricesWeightsKind
  23555. * - VertexBuffer.MatricesWeightsExtraKind
  23556. * @returns a boolean
  23557. */
  23558. isVertexBufferUpdatable(kind: string): boolean;
  23559. /**
  23560. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23561. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23562. * - VertexBuffer.PositionKind
  23563. * - VertexBuffer.NormalKind
  23564. * - VertexBuffer.UVKind
  23565. * - VertexBuffer.UV2Kind
  23566. * - VertexBuffer.UV3Kind
  23567. * - VertexBuffer.UV4Kind
  23568. * - VertexBuffer.UV5Kind
  23569. * - VertexBuffer.UV6Kind
  23570. * - VertexBuffer.ColorKind
  23571. * - VertexBuffer.MatricesIndicesKind
  23572. * - VertexBuffer.MatricesIndicesExtraKind
  23573. * - VertexBuffer.MatricesWeightsKind
  23574. * - VertexBuffer.MatricesWeightsExtraKind
  23575. * @returns an array of strings
  23576. */
  23577. getVerticesDataKinds(): string[];
  23578. /**
  23579. * Returns a positive integer : the total number of indices in this mesh geometry.
  23580. * @returns the numner of indices or zero if the mesh has no geometry.
  23581. */
  23582. getTotalIndices(): number;
  23583. /**
  23584. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23585. * @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.
  23586. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23587. * @returns the indices array or an empty array if the mesh has no geometry
  23588. */
  23589. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23590. readonly isBlocked: boolean;
  23591. /**
  23592. * Determine if the current mesh is ready to be rendered
  23593. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23594. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23595. * @returns true if all associated assets are ready (material, textures, shaders)
  23596. */
  23597. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23598. /**
  23599. * 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.
  23600. */
  23601. readonly areNormalsFrozen: boolean;
  23602. /**
  23603. * 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.
  23604. * @returns the current mesh
  23605. */
  23606. freezeNormals(): Mesh;
  23607. /**
  23608. * 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
  23609. * @returns the current mesh
  23610. */
  23611. unfreezeNormals(): Mesh;
  23612. /**
  23613. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23614. */
  23615. overridenInstanceCount: number;
  23616. /** @hidden */ private _preActivate(): Mesh;
  23617. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23618. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23619. /**
  23620. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23621. * This means the mesh underlying bounding box and sphere are recomputed.
  23622. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23623. * @returns the current mesh
  23624. */
  23625. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23626. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23627. /**
  23628. * This function will subdivide the mesh into multiple submeshes
  23629. * @param count defines the expected number of submeshes
  23630. */
  23631. subdivide(count: number): void;
  23632. /**
  23633. * Copy a FloatArray into a specific associated vertex buffer
  23634. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23635. * - VertexBuffer.PositionKind
  23636. * - VertexBuffer.UVKind
  23637. * - VertexBuffer.UV2Kind
  23638. * - VertexBuffer.UV3Kind
  23639. * - VertexBuffer.UV4Kind
  23640. * - VertexBuffer.UV5Kind
  23641. * - VertexBuffer.UV6Kind
  23642. * - VertexBuffer.ColorKind
  23643. * - VertexBuffer.MatricesIndicesKind
  23644. * - VertexBuffer.MatricesIndicesExtraKind
  23645. * - VertexBuffer.MatricesWeightsKind
  23646. * - VertexBuffer.MatricesWeightsExtraKind
  23647. * @param data defines the data source
  23648. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23649. * @param stride defines the data stride size (can be null)
  23650. * @returns the current mesh
  23651. */
  23652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23653. /**
  23654. * Flags an associated vertex buffer as updatable
  23655. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23656. * - VertexBuffer.PositionKind
  23657. * - VertexBuffer.UVKind
  23658. * - VertexBuffer.UV2Kind
  23659. * - VertexBuffer.UV3Kind
  23660. * - VertexBuffer.UV4Kind
  23661. * - VertexBuffer.UV5Kind
  23662. * - VertexBuffer.UV6Kind
  23663. * - VertexBuffer.ColorKind
  23664. * - VertexBuffer.MatricesIndicesKind
  23665. * - VertexBuffer.MatricesIndicesExtraKind
  23666. * - VertexBuffer.MatricesWeightsKind
  23667. * - VertexBuffer.MatricesWeightsExtraKind
  23668. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23669. */
  23670. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23671. /**
  23672. * Sets the mesh global Vertex Buffer
  23673. * @param buffer defines the buffer to use
  23674. * @returns the current mesh
  23675. */
  23676. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23677. /**
  23678. * Update a specific associated vertex buffer
  23679. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23680. * - VertexBuffer.PositionKind
  23681. * - VertexBuffer.UVKind
  23682. * - VertexBuffer.UV2Kind
  23683. * - VertexBuffer.UV3Kind
  23684. * - VertexBuffer.UV4Kind
  23685. * - VertexBuffer.UV5Kind
  23686. * - VertexBuffer.UV6Kind
  23687. * - VertexBuffer.ColorKind
  23688. * - VertexBuffer.MatricesIndicesKind
  23689. * - VertexBuffer.MatricesIndicesExtraKind
  23690. * - VertexBuffer.MatricesWeightsKind
  23691. * - VertexBuffer.MatricesWeightsExtraKind
  23692. * @param data defines the data source
  23693. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23694. * @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)
  23695. * @returns the current mesh
  23696. */
  23697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23698. /**
  23699. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23700. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23701. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23702. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23703. * @returns the current mesh
  23704. */
  23705. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23706. /**
  23707. * Creates a un-shared specific occurence of the geometry for the mesh.
  23708. * @returns the current mesh
  23709. */
  23710. makeGeometryUnique(): Mesh;
  23711. /**
  23712. * Set the index buffer of this mesh
  23713. * @param indices defines the source data
  23714. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23715. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23716. * @returns the current mesh
  23717. */
  23718. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23719. /**
  23720. * Update the current index buffer
  23721. * @param indices defines the source data
  23722. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23723. * @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)
  23724. * @returns the current mesh
  23725. */
  23726. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23727. /**
  23728. * Invert the geometry to move from a right handed system to a left handed one.
  23729. * @returns the current mesh
  23730. */
  23731. toLeftHanded(): Mesh;
  23732. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23733. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23734. /**
  23735. * Registers for this mesh a javascript function called just before the rendering process
  23736. * @param func defines the function to call before rendering this mesh
  23737. * @returns the current mesh
  23738. */
  23739. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23740. /**
  23741. * Disposes a previously registered javascript function called before the rendering
  23742. * @param func defines the function to remove
  23743. * @returns the current mesh
  23744. */
  23745. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23746. /**
  23747. * Registers for this mesh a javascript function called just after the rendering is complete
  23748. * @param func defines the function to call after rendering this mesh
  23749. * @returns the current mesh
  23750. */
  23751. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23752. /**
  23753. * Disposes a previously registered javascript function called after the rendering.
  23754. * @param func defines the function to remove
  23755. * @returns the current mesh
  23756. */
  23757. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23758. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23759. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23760. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23761. /** @hidden */ private _rebuild(): void;
  23762. /** @hidden */ private _freeze(): void;
  23763. /** @hidden */ private _unFreeze(): void;
  23764. /**
  23765. * 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
  23766. * @param subMesh defines the subMesh to render
  23767. * @param enableAlphaMode defines if alpha mode can be changed
  23768. * @returns the current mesh
  23769. */
  23770. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23771. private _onBeforeDraw;
  23772. /**
  23773. * Renormalize the mesh and patch it up if there are no weights
  23774. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23775. * However in the case of zero weights then we set just a single influence to 1.
  23776. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23777. */
  23778. cleanMatrixWeights(): void;
  23779. private normalizeSkinFourWeights;
  23780. private normalizeSkinWeightsAndExtra;
  23781. /**
  23782. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23783. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23784. * the user know there was an issue with importing the mesh
  23785. * @returns a validation object with skinned, valid and report string
  23786. */
  23787. validateSkinning(): {
  23788. skinned: boolean;
  23789. valid: boolean;
  23790. report: string;
  23791. };
  23792. /** @hidden */ private _checkDelayState(): Mesh;
  23793. private _queueLoad;
  23794. /**
  23795. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23796. * A mesh is in the frustum if its bounding box intersects the frustum
  23797. * @param frustumPlanes defines the frustum to test
  23798. * @returns true if the mesh is in the frustum planes
  23799. */
  23800. isInFrustum(frustumPlanes: Plane[]): boolean;
  23801. /**
  23802. * Sets the mesh material by the material or multiMaterial `id` property
  23803. * @param id is a string identifying the material or the multiMaterial
  23804. * @returns the current mesh
  23805. */
  23806. setMaterialByID(id: string): Mesh;
  23807. /**
  23808. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23809. * @returns an array of IAnimatable
  23810. */
  23811. getAnimatables(): IAnimatable[];
  23812. /**
  23813. * Modifies the mesh geometry according to the passed transformation matrix.
  23814. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23815. * The mesh normals are modified using the same transformation.
  23816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23817. * @param transform defines the transform matrix to use
  23818. * @see http://doc.babylonjs.com/resources/baking_transformations
  23819. * @returns the current mesh
  23820. */
  23821. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23822. /**
  23823. * Modifies the mesh geometry according to its own current World Matrix.
  23824. * The mesh World Matrix is then reset.
  23825. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23826. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23827. * @see http://doc.babylonjs.com/resources/baking_transformations
  23828. * @returns the current mesh
  23829. */
  23830. bakeCurrentTransformIntoVertices(): Mesh;
  23831. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23832. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23833. /** @hidden */ private _generatePointsArray(): boolean;
  23834. /**
  23835. * Returns a new Mesh object generated from the current mesh properties.
  23836. * This method must not get confused with createInstance()
  23837. * @param name is a string, the name given to the new mesh
  23838. * @param newParent can be any Node object (default `null`)
  23839. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23840. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23841. * @returns a new mesh
  23842. */
  23843. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23844. /**
  23845. * Releases resources associated with this mesh.
  23846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23848. */
  23849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23850. /**
  23851. * Modifies the mesh geometry according to a displacement map.
  23852. * 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.
  23853. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23854. * @param url is a string, the URL from the image file is to be downloaded.
  23855. * @param minHeight is the lower limit of the displacement.
  23856. * @param maxHeight is the upper limit of the displacement.
  23857. * @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.
  23858. * @param uvOffset is an optional vector2 used to offset UV.
  23859. * @param uvScale is an optional vector2 used to scale UV.
  23860. * @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.
  23861. * @returns the Mesh.
  23862. */
  23863. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23864. /**
  23865. * Modifies the mesh geometry according to a displacementMap buffer.
  23866. * 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.
  23867. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23868. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23869. * @param heightMapWidth is the width of the buffer image.
  23870. * @param heightMapHeight is the height of the buffer image.
  23871. * @param minHeight is the lower limit of the displacement.
  23872. * @param maxHeight is the upper limit of the displacement.
  23873. * @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.
  23874. * @param uvOffset is an optional vector2 used to offset UV.
  23875. * @param uvScale is an optional vector2 used to scale UV.
  23876. * @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.
  23877. * @returns the Mesh.
  23878. */
  23879. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23880. /**
  23881. * Modify the mesh to get a flat shading rendering.
  23882. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23883. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23884. * @returns current mesh
  23885. */
  23886. convertToFlatShadedMesh(): Mesh;
  23887. /**
  23888. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23889. * In other words, more vertices, no more indices and a single bigger VBO.
  23890. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23891. * @returns current mesh
  23892. */
  23893. convertToUnIndexedMesh(): Mesh;
  23894. /**
  23895. * Inverses facet orientations.
  23896. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23897. * @param flipNormals will also inverts the normals
  23898. * @returns current mesh
  23899. */
  23900. flipFaces(flipNormals?: boolean): Mesh;
  23901. /**
  23902. * Increase the number of facets and hence vertices in a mesh
  23903. * Vertex normals are interpolated from existing vertex normals
  23904. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23905. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23906. */
  23907. increaseVertices(numberPerEdge: number): void;
  23908. /**
  23909. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23910. * This will undo any application of covertToFlatShadedMesh
  23911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23912. */
  23913. forceSharedVertices(): void;
  23914. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23915. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23916. /**
  23917. * Creates a new InstancedMesh object from the mesh model.
  23918. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23919. * @param name defines the name of the new instance
  23920. * @returns a new InstancedMesh
  23921. */
  23922. createInstance(name: string): InstancedMesh;
  23923. /**
  23924. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23925. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23926. * @returns the current mesh
  23927. */
  23928. synchronizeInstances(): Mesh;
  23929. /**
  23930. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23931. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23932. * This should be used together with the simplification to avoid disappearing triangles.
  23933. * @param successCallback an optional success callback to be called after the optimization finished.
  23934. * @returns the current mesh
  23935. */
  23936. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23937. /**
  23938. * Serialize current mesh
  23939. * @param serializationObject defines the object which will receive the serialization data
  23940. */
  23941. serialize(serializationObject: any): void;
  23942. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23943. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23944. /**
  23945. * Returns a new Mesh object parsed from the source provided.
  23946. * @param parsedMesh is the source
  23947. * @param scene defines the hosting scene
  23948. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23949. * @returns a new Mesh
  23950. */
  23951. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23952. /**
  23953. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23954. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23955. * @param name defines the name of the mesh to create
  23956. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23957. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23958. * @param closePath creates a seam between the first and the last points of each path of the path array
  23959. * @param offset is taken in account only if the `pathArray` is containing a single path
  23960. * @param scene defines the hosting scene
  23961. * @param updatable defines if the mesh must be flagged as updatable
  23962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23963. * @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)
  23964. * @returns a new Mesh
  23965. */
  23966. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23967. /**
  23968. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23969. * @param name defines the name of the mesh to create
  23970. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23971. * @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
  23972. * @param scene defines the hosting scene
  23973. * @param updatable defines if the mesh must be flagged as updatable
  23974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23975. * @returns a new Mesh
  23976. */
  23977. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23978. /**
  23979. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23980. * @param name defines the name of the mesh to create
  23981. * @param size sets the size (float) of each box side (default 1)
  23982. * @param scene defines the hosting scene
  23983. * @param updatable defines if the mesh must be flagged as updatable
  23984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23985. * @returns a new Mesh
  23986. */
  23987. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23988. /**
  23989. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23990. * @param name defines the name of the mesh to create
  23991. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23992. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23993. * @param scene defines the hosting scene
  23994. * @param updatable defines if the mesh must be flagged as updatable
  23995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23996. * @returns a new Mesh
  23997. */
  23998. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23999. /**
  24000. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24001. * @param name defines the name of the mesh to create
  24002. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24003. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24004. * @param scene defines the hosting scene
  24005. * @returns a new Mesh
  24006. */
  24007. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24008. /**
  24009. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24010. * @param name defines the name of the mesh to create
  24011. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24012. * @param diameterTop set the top cap diameter (floats, default 1)
  24013. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24014. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24015. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24016. * @param scene defines the hosting scene
  24017. * @param updatable defines if the mesh must be flagged as updatable
  24018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24019. * @returns a new Mesh
  24020. */
  24021. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24022. /**
  24023. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24024. * @param name defines the name of the mesh to create
  24025. * @param diameter sets the diameter size (float) of the torus (default 1)
  24026. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24027. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24028. * @param scene defines the hosting scene
  24029. * @param updatable defines if the mesh must be flagged as updatable
  24030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24031. * @returns a new Mesh
  24032. */
  24033. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24034. /**
  24035. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24036. * @param name defines the name of the mesh to create
  24037. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24038. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24039. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24040. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24041. * @param p the number of windings on X axis (positive integers, default 2)
  24042. * @param q the number of windings on Y axis (positive integers, default 3)
  24043. * @param scene defines the hosting scene
  24044. * @param updatable defines if the mesh must be flagged as updatable
  24045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24046. * @returns a new Mesh
  24047. */
  24048. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24049. /**
  24050. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24051. * @param name defines the name of the mesh to create
  24052. * @param points is an array successive Vector3
  24053. * @param scene defines the hosting scene
  24054. * @param updatable defines if the mesh must be flagged as updatable
  24055. * @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).
  24056. * @returns a new Mesh
  24057. */
  24058. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24059. /**
  24060. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24061. * @param name defines the name of the mesh to create
  24062. * @param points is an array successive Vector3
  24063. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24064. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24065. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24066. * @param scene defines the hosting scene
  24067. * @param updatable defines if the mesh must be flagged as updatable
  24068. * @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)
  24069. * @returns a new Mesh
  24070. */
  24071. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24072. /**
  24073. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24074. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24075. * 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.
  24076. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24077. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24078. * Remember you can only change the shape positions, not their number when updating a polygon.
  24079. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24080. * @param name defines the name of the mesh to create
  24081. * @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
  24082. * @param scene defines the hosting scene
  24083. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24084. * @param updatable defines if the mesh must be flagged as updatable
  24085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24086. * @param earcutInjection can be used to inject your own earcut reference
  24087. * @returns a new Mesh
  24088. */
  24089. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24090. /**
  24091. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24092. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24093. * @param name defines the name of the mesh to create
  24094. * @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
  24095. * @param depth defines the height of extrusion
  24096. * @param scene defines the hosting scene
  24097. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24098. * @param updatable defines if the mesh must be flagged as updatable
  24099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24100. * @param earcutInjection can be used to inject your own earcut reference
  24101. * @returns a new Mesh
  24102. */
  24103. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24104. /**
  24105. * Creates an extruded shape mesh.
  24106. * 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
  24107. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24108. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24109. * @param name defines the name of the mesh to create
  24110. * @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
  24111. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24112. * @param scale is the value to scale the shape
  24113. * @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
  24114. * @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
  24115. * @param scene defines the hosting scene
  24116. * @param updatable defines if the mesh must be flagged as updatable
  24117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24118. * @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)
  24119. * @returns a new Mesh
  24120. */
  24121. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24122. /**
  24123. * Creates an custom extruded shape mesh.
  24124. * The custom extrusion is a parametric shape.
  24125. * It has no predefined shape. Its final shape will depend on the input parameters.
  24126. * Please consider using the same method from the MeshBuilder class instead
  24127. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24128. * @param name defines the name of the mesh to create
  24129. * @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
  24130. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24131. * @param scaleFunction is a custom Javascript function called on each path point
  24132. * @param rotationFunction is a custom Javascript function called on each path point
  24133. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24134. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24135. * @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
  24136. * @param scene defines the hosting scene
  24137. * @param updatable defines if the mesh must be flagged as updatable
  24138. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24139. * @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)
  24140. * @returns a new Mesh
  24141. */
  24142. 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;
  24143. /**
  24144. * Creates lathe mesh.
  24145. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24146. * Please consider using the same method from the MeshBuilder class instead
  24147. * @param name defines the name of the mesh to create
  24148. * @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
  24149. * @param radius is the radius value of the lathe
  24150. * @param tessellation is the side number of the lathe.
  24151. * @param scene defines the hosting scene
  24152. * @param updatable defines if the mesh must be flagged as updatable
  24153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24154. * @returns a new Mesh
  24155. */
  24156. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24157. /**
  24158. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24159. * @param name defines the name of the mesh to create
  24160. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24161. * @param scene defines the hosting scene
  24162. * @param updatable defines if the mesh must be flagged as updatable
  24163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24164. * @returns a new Mesh
  24165. */
  24166. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24167. /**
  24168. * Creates a ground mesh.
  24169. * Please consider using the same method from the MeshBuilder class instead
  24170. * @param name defines the name of the mesh to create
  24171. * @param width set the width of the ground
  24172. * @param height set the height of the ground
  24173. * @param subdivisions sets the number of subdivisions per side
  24174. * @param scene defines the hosting scene
  24175. * @param updatable defines if the mesh must be flagged as updatable
  24176. * @returns a new Mesh
  24177. */
  24178. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24179. /**
  24180. * Creates a tiled ground mesh.
  24181. * Please consider using the same method from the MeshBuilder class instead
  24182. * @param name defines the name of the mesh to create
  24183. * @param xmin set the ground minimum X coordinate
  24184. * @param zmin set the ground minimum Y coordinate
  24185. * @param xmax set the ground maximum X coordinate
  24186. * @param zmax set the ground maximum Z coordinate
  24187. * @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
  24188. * @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
  24189. * @param scene defines the hosting scene
  24190. * @param updatable defines if the mesh must be flagged as updatable
  24191. * @returns a new Mesh
  24192. */
  24193. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24194. w: number;
  24195. h: number;
  24196. }, precision: {
  24197. w: number;
  24198. h: number;
  24199. }, scene: Scene, updatable?: boolean): Mesh;
  24200. /**
  24201. * Creates a ground mesh from a height map.
  24202. * Please consider using the same method from the MeshBuilder class instead
  24203. * @see http://doc.babylonjs.com/babylon101/height_map
  24204. * @param name defines the name of the mesh to create
  24205. * @param url sets the URL of the height map image resource
  24206. * @param width set the ground width size
  24207. * @param height set the ground height size
  24208. * @param subdivisions sets the number of subdivision per side
  24209. * @param minHeight is the minimum altitude on the ground
  24210. * @param maxHeight is the maximum altitude on the ground
  24211. * @param scene defines the hosting scene
  24212. * @param updatable defines if the mesh must be flagged as updatable
  24213. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24214. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24215. * @returns a new Mesh
  24216. */
  24217. 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;
  24218. /**
  24219. * Creates a tube mesh.
  24220. * The tube is a parametric shape.
  24221. * It has no predefined shape. Its final shape will depend on the input parameters.
  24222. * Please consider using the same method from the MeshBuilder class instead
  24223. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24224. * @param name defines the name of the mesh to create
  24225. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24226. * @param radius sets the tube radius size
  24227. * @param tessellation is the number of sides on the tubular surface
  24228. * @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
  24229. * @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
  24230. * @param scene defines the hosting scene
  24231. * @param updatable defines if the mesh must be flagged as updatable
  24232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24233. * @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)
  24234. * @returns a new Mesh
  24235. */
  24236. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24237. (i: number, distance: number): number;
  24238. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24239. /**
  24240. * Creates a polyhedron mesh.
  24241. * Please consider using the same method from the MeshBuilder class instead.
  24242. * * 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
  24243. * * The parameter `size` (positive float, default 1) sets the polygon size
  24244. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24245. * * 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`
  24246. * * 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
  24247. * * 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)`)
  24248. * * 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
  24249. * * 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
  24250. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24251. * * 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
  24252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24253. * @param name defines the name of the mesh to create
  24254. * @param options defines the options used to create the mesh
  24255. * @param scene defines the hosting scene
  24256. * @returns a new Mesh
  24257. */
  24258. static CreatePolyhedron(name: string, options: {
  24259. type?: number;
  24260. size?: number;
  24261. sizeX?: number;
  24262. sizeY?: number;
  24263. sizeZ?: number;
  24264. custom?: any;
  24265. faceUV?: Vector4[];
  24266. faceColors?: Color4[];
  24267. updatable?: boolean;
  24268. sideOrientation?: number;
  24269. }, scene: Scene): Mesh;
  24270. /**
  24271. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24272. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24273. * * 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`)
  24274. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24275. * * 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
  24276. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24277. * * 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
  24278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24279. * @param name defines the name of the mesh
  24280. * @param options defines the options used to create the mesh
  24281. * @param scene defines the hosting scene
  24282. * @returns a new Mesh
  24283. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24284. */
  24285. static CreateIcoSphere(name: string, options: {
  24286. radius?: number;
  24287. flat?: boolean;
  24288. subdivisions?: number;
  24289. sideOrientation?: number;
  24290. updatable?: boolean;
  24291. }, scene: Scene): Mesh;
  24292. /**
  24293. * Creates a decal mesh.
  24294. * Please consider using the same method from the MeshBuilder class instead.
  24295. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24296. * @param name defines the name of the mesh
  24297. * @param sourceMesh defines the mesh receiving the decal
  24298. * @param position sets the position of the decal in world coordinates
  24299. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24300. * @param size sets the decal scaling
  24301. * @param angle sets the angle to rotate the decal
  24302. * @returns a new Mesh
  24303. */
  24304. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24305. /**
  24306. * Prepare internal position array for software CPU skinning
  24307. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24308. */
  24309. setPositionsForCPUSkinning(): Float32Array;
  24310. /**
  24311. * Prepare internal normal array for software CPU skinning
  24312. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24313. */
  24314. setNormalsForCPUSkinning(): Float32Array;
  24315. /**
  24316. * Updates the vertex buffer by applying transformation from the bones
  24317. * @param skeleton defines the skeleton to apply to current mesh
  24318. * @returns the current mesh
  24319. */
  24320. applySkeleton(skeleton: Skeleton): Mesh;
  24321. /**
  24322. * 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
  24323. * @param meshes defines the list of meshes to scan
  24324. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24325. */
  24326. static MinMax(meshes: AbstractMesh[]): {
  24327. min: Vector3;
  24328. max: Vector3;
  24329. };
  24330. /**
  24331. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24332. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24333. * @returns a vector3
  24334. */
  24335. static Center(meshesOrMinMaxVector: {
  24336. min: Vector3;
  24337. max: Vector3;
  24338. } | AbstractMesh[]): Vector3;
  24339. /**
  24340. * Merge the array of meshes into a single mesh for performance reasons.
  24341. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24342. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24343. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24344. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24345. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24346. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24347. * @returns a new mesh
  24348. */
  24349. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24350. /** @hidden */
  24351. addInstance(instance: InstancedMesh): void;
  24352. /** @hidden */
  24353. removeInstance(instance: InstancedMesh): void;
  24354. }
  24355. }
  24356. declare module BABYLON {
  24357. /**
  24358. * This is the base class of all the camera used in the application.
  24359. * @see http://doc.babylonjs.com/features/cameras
  24360. */
  24361. export class Camera extends Node {
  24362. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24363. /**
  24364. * This is the default projection mode used by the cameras.
  24365. * It helps recreating a feeling of perspective and better appreciate depth.
  24366. * This is the best way to simulate real life cameras.
  24367. */
  24368. static readonly PERSPECTIVE_CAMERA: number;
  24369. /**
  24370. * This helps creating camera with an orthographic mode.
  24371. * 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.
  24372. */
  24373. static readonly ORTHOGRAPHIC_CAMERA: number;
  24374. /**
  24375. * This is the default FOV mode for perspective cameras.
  24376. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24377. */
  24378. static readonly FOVMODE_VERTICAL_FIXED: number;
  24379. /**
  24380. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24381. */
  24382. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24383. /**
  24384. * This specifies ther is no need for a camera rig.
  24385. * Basically only one eye is rendered corresponding to the camera.
  24386. */
  24387. static readonly RIG_MODE_NONE: number;
  24388. /**
  24389. * Simulates a camera Rig with one blue eye and one red eye.
  24390. * This can be use with 3d blue and red glasses.
  24391. */
  24392. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24393. /**
  24394. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24395. */
  24396. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24397. /**
  24398. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24399. */
  24400. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24401. /**
  24402. * Defines that both eyes of the camera will be rendered over under each other.
  24403. */
  24404. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24405. /**
  24406. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24407. */
  24408. static readonly RIG_MODE_VR: number;
  24409. /**
  24410. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24411. */
  24412. static readonly RIG_MODE_WEBVR: number;
  24413. /**
  24414. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24415. */
  24416. static readonly RIG_MODE_CUSTOM: number;
  24417. /**
  24418. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24419. */
  24420. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24421. /**
  24422. * Define the input manager associated with the camera.
  24423. */
  24424. inputs: CameraInputsManager<Camera>;
  24425. /** @hidden */ private _position: Vector3;
  24426. /**
  24427. * Define the current local position of the camera in the scene
  24428. */
  24429. position: Vector3;
  24430. /**
  24431. * The vector the camera should consider as up.
  24432. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24433. */
  24434. upVector: Vector3;
  24435. /**
  24436. * Define the current limit on the left side for an orthographic camera
  24437. * In scene unit
  24438. */
  24439. orthoLeft: Nullable<number>;
  24440. /**
  24441. * Define the current limit on the right side for an orthographic camera
  24442. * In scene unit
  24443. */
  24444. orthoRight: Nullable<number>;
  24445. /**
  24446. * Define the current limit on the bottom side for an orthographic camera
  24447. * In scene unit
  24448. */
  24449. orthoBottom: Nullable<number>;
  24450. /**
  24451. * Define the current limit on the top side for an orthographic camera
  24452. * In scene unit
  24453. */
  24454. orthoTop: Nullable<number>;
  24455. /**
  24456. * Field Of View is set in Radians. (default is 0.8)
  24457. */
  24458. fov: number;
  24459. /**
  24460. * Define the minimum distance the camera can see from.
  24461. * This is important to note that the depth buffer are not infinite and the closer it starts
  24462. * the more your scene might encounter depth fighting issue.
  24463. */
  24464. minZ: number;
  24465. /**
  24466. * Define the maximum distance the camera can see to.
  24467. * This is important to note that the depth buffer are not infinite and the further it end
  24468. * the more your scene might encounter depth fighting issue.
  24469. */
  24470. maxZ: number;
  24471. /**
  24472. * Define the default inertia of the camera.
  24473. * This helps giving a smooth feeling to the camera movement.
  24474. */
  24475. inertia: number;
  24476. /**
  24477. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24478. */
  24479. mode: number;
  24480. /**
  24481. * Define wether the camera is intermediate.
  24482. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24483. */
  24484. isIntermediate: boolean;
  24485. /**
  24486. * Define the viewport of the camera.
  24487. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24488. */
  24489. viewport: Viewport;
  24490. /**
  24491. * Restricts the camera to viewing objects with the same layerMask.
  24492. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24493. */
  24494. layerMask: number;
  24495. /**
  24496. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24497. */
  24498. fovMode: number;
  24499. /**
  24500. * Rig mode of the camera.
  24501. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24502. * This is normally controlled byt the camera themselves as internal use.
  24503. */
  24504. cameraRigMode: number;
  24505. /**
  24506. * Defines the distance between both "eyes" in case of a RIG
  24507. */
  24508. interaxialDistance: number;
  24509. /**
  24510. * Defines if stereoscopic rendering is done side by side or over under.
  24511. */
  24512. isStereoscopicSideBySide: boolean;
  24513. /**
  24514. * 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
  24515. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24516. * else in the scene. (Eg. security camera)
  24517. *
  24518. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24519. */
  24520. customRenderTargets: RenderTargetTexture[];
  24521. /**
  24522. * When set, the camera will render to this render target instead of the default canvas
  24523. *
  24524. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24525. */
  24526. outputRenderTarget: Nullable<RenderTargetTexture>;
  24527. /**
  24528. * Observable triggered when the camera view matrix has changed.
  24529. */
  24530. onViewMatrixChangedObservable: Observable<Camera>;
  24531. /**
  24532. * Observable triggered when the camera Projection matrix has changed.
  24533. */
  24534. onProjectionMatrixChangedObservable: Observable<Camera>;
  24535. /**
  24536. * Observable triggered when the inputs have been processed.
  24537. */
  24538. onAfterCheckInputsObservable: Observable<Camera>;
  24539. /**
  24540. * Observable triggered when reset has been called and applied to the camera.
  24541. */
  24542. onRestoreStateObservable: Observable<Camera>;
  24543. /** @hidden */ private _cameraRigParams: any;
  24544. /** @hidden */ private _rigCameras: Camera[];
  24545. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24546. protected _webvrViewMatrix: Matrix;
  24547. /** @hidden */ private _skipRendering: boolean;
  24548. /** @hidden */ private _projectionMatrix: Matrix;
  24549. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24550. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24551. protected _globalPosition: Vector3;
  24552. /** @hidden */ private _computedViewMatrix: Matrix;
  24553. private _doNotComputeProjectionMatrix;
  24554. private _transformMatrix;
  24555. private _frustumPlanes;
  24556. private _refreshFrustumPlanes;
  24557. private _storedFov;
  24558. private _stateStored;
  24559. /**
  24560. * Instantiates a new camera object.
  24561. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24562. * @see http://doc.babylonjs.com/features/cameras
  24563. * @param name Defines the name of the camera in the scene
  24564. * @param position Defines the position of the camera
  24565. * @param scene Defines the scene the camera belongs too
  24566. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24567. */
  24568. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24569. /**
  24570. * Store current camera state (fov, position, etc..)
  24571. * @returns the camera
  24572. */
  24573. storeState(): Camera;
  24574. /**
  24575. * Restores the camera state values if it has been stored. You must call storeState() first
  24576. */
  24577. protected _restoreStateValues(): boolean;
  24578. /**
  24579. * Restored camera state. You must call storeState() first.
  24580. * @returns true if restored and false otherwise
  24581. */
  24582. restoreState(): boolean;
  24583. /**
  24584. * Gets the class name of the camera.
  24585. * @returns the class name
  24586. */
  24587. getClassName(): string;
  24588. /** @hidden */ protected readonly _isCamera: boolean;
  24589. /**
  24590. * Gets a string representation of the camera useful for debug purpose.
  24591. * @param fullDetails Defines that a more verboe level of logging is required
  24592. * @returns the string representation
  24593. */
  24594. toString(fullDetails?: boolean): string;
  24595. /**
  24596. * Gets the current world space position of the camera.
  24597. */
  24598. readonly globalPosition: Vector3;
  24599. /**
  24600. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24601. * @returns the active meshe list
  24602. */
  24603. getActiveMeshes(): SmartArray<AbstractMesh>;
  24604. /**
  24605. * Check wether a mesh is part of the current active mesh list of the camera
  24606. * @param mesh Defines the mesh to check
  24607. * @returns true if active, false otherwise
  24608. */
  24609. isActiveMesh(mesh: Mesh): boolean;
  24610. /**
  24611. * Is this camera ready to be used/rendered
  24612. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24613. * @return true if the camera is ready
  24614. */
  24615. isReady(completeCheck?: boolean): boolean;
  24616. /** @hidden */ private _initCache(): void;
  24617. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24618. /** @hidden */ private _isSynchronized(): boolean;
  24619. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24620. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24621. /**
  24622. * Attach the input controls to a specific dom element to get the input from.
  24623. * @param element Defines the element the controls should be listened from
  24624. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24625. */
  24626. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24627. /**
  24628. * Detach the current controls from the specified dom element.
  24629. * @param element Defines the element to stop listening the inputs from
  24630. */
  24631. detachControl(element: HTMLElement): void;
  24632. /**
  24633. * Update the camera state according to the different inputs gathered during the frame.
  24634. */
  24635. update(): void;
  24636. /** @hidden */ private _checkInputs(): void;
  24637. /** @hidden */
  24638. readonly rigCameras: Camera[];
  24639. /**
  24640. * Gets the post process used by the rig cameras
  24641. */
  24642. readonly rigPostProcess: Nullable<PostProcess>;
  24643. /**
  24644. * Internal, gets the first post proces.
  24645. * @returns the first post process to be run on this camera.
  24646. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24647. private _cascadePostProcessesToRigCams;
  24648. /**
  24649. * Attach a post process to the camera.
  24650. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24651. * @param postProcess The post process to attach to the camera
  24652. * @param insertAt The position of the post process in case several of them are in use in the scene
  24653. * @returns the position the post process has been inserted at
  24654. */
  24655. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24656. /**
  24657. * Detach a post process to the camera.
  24658. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24659. * @param postProcess The post process to detach from the camera
  24660. */
  24661. detachPostProcess(postProcess: PostProcess): void;
  24662. /**
  24663. * Gets the current world matrix of the camera
  24664. */
  24665. getWorldMatrix(): Matrix;
  24666. /** @hidden */ private _getViewMatrix(): Matrix;
  24667. /**
  24668. * Gets the current view matrix of the camera.
  24669. * @param force forces the camera to recompute the matrix without looking at the cached state
  24670. * @returns the view matrix
  24671. */
  24672. getViewMatrix(force?: boolean): Matrix;
  24673. /**
  24674. * Freeze the projection matrix.
  24675. * It will prevent the cache check of the camera projection compute and can speed up perf
  24676. * if no parameter of the camera are meant to change
  24677. * @param projection Defines manually a projection if necessary
  24678. */
  24679. freezeProjectionMatrix(projection?: Matrix): void;
  24680. /**
  24681. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24682. */
  24683. unfreezeProjectionMatrix(): void;
  24684. /**
  24685. * Gets the current projection matrix of the camera.
  24686. * @param force forces the camera to recompute the matrix without looking at the cached state
  24687. * @returns the projection matrix
  24688. */
  24689. getProjectionMatrix(force?: boolean): Matrix;
  24690. /**
  24691. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24692. * @returns a Matrix
  24693. */
  24694. getTransformationMatrix(): Matrix;
  24695. private _updateFrustumPlanes;
  24696. /**
  24697. * Checks if a cullable object (mesh...) is in the camera frustum
  24698. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24699. * @param target The object to check
  24700. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24701. * @returns true if the object is in frustum otherwise false
  24702. */
  24703. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24704. /**
  24705. * Checks if a cullable object (mesh...) is in the camera frustum
  24706. * Unlike isInFrustum this cheks the full bounding box
  24707. * @param target The object to check
  24708. * @returns true if the object is in frustum otherwise false
  24709. */
  24710. isCompletelyInFrustum(target: ICullable): boolean;
  24711. /**
  24712. * Gets a ray in the forward direction from the camera.
  24713. * @param length Defines the length of the ray to create
  24714. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24715. * @param origin Defines the start point of the ray which defaults to the camera position
  24716. * @returns the forward ray
  24717. */
  24718. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24719. /**
  24720. * Releases resources associated with this node.
  24721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24723. */
  24724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24725. /** @hidden */ private _isLeftCamera: boolean;
  24726. /**
  24727. * Gets the left camera of a rig setup in case of Rigged Camera
  24728. */
  24729. readonly isLeftCamera: boolean;
  24730. /** @hidden */ private _isRightCamera: boolean;
  24731. /**
  24732. * Gets the right camera of a rig setup in case of Rigged Camera
  24733. */
  24734. readonly isRightCamera: boolean;
  24735. /**
  24736. * Gets the left camera of a rig setup in case of Rigged Camera
  24737. */
  24738. readonly leftCamera: Nullable<FreeCamera>;
  24739. /**
  24740. * Gets the right camera of a rig setup in case of Rigged Camera
  24741. */
  24742. readonly rightCamera: Nullable<FreeCamera>;
  24743. /**
  24744. * Gets the left camera target of a rig setup in case of Rigged Camera
  24745. * @returns the target position
  24746. */
  24747. getLeftTarget(): Nullable<Vector3>;
  24748. /**
  24749. * Gets the right camera target of a rig setup in case of Rigged Camera
  24750. * @returns the target position
  24751. */
  24752. getRightTarget(): Nullable<Vector3>;
  24753. /**
  24754. * @hidden
  24755. */
  24756. setCameraRigMode(mode: number, rigParams: any): void;
  24757. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24758. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24759. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24760. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24761. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24762. protected _updateCameraRotationMatrix(): void;
  24763. protected _updateWebVRCameraRotationMatrix(): void;
  24764. /**
  24765. * This function MUST be overwritten by the different WebVR cameras available.
  24766. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24767. * @hidden
  24768. */ private _getWebVRProjectionMatrix(): Matrix;
  24769. /**
  24770. * This function MUST be overwritten by the different WebVR cameras available.
  24771. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24772. * @hidden
  24773. */ private _getWebVRViewMatrix(): Matrix;
  24774. /** @hidden */
  24775. setCameraRigParameter(name: string, value: any): void;
  24776. /**
  24777. * needs to be overridden by children so sub has required properties to be copied
  24778. * @hidden
  24779. */
  24780. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24781. /**
  24782. * May need to be overridden by children
  24783. * @hidden
  24784. */ private _updateRigCameras(): void;
  24785. /** @hidden */ private _setupInputs(): void;
  24786. /**
  24787. * Serialiaze the camera setup to a json represention
  24788. * @returns the JSON representation
  24789. */
  24790. serialize(): any;
  24791. /**
  24792. * Clones the current camera.
  24793. * @param name The cloned camera name
  24794. * @returns the cloned camera
  24795. */
  24796. clone(name: string): Camera;
  24797. /**
  24798. * Gets the direction of the camera relative to a given local axis.
  24799. * @param localAxis Defines the reference axis to provide a relative direction.
  24800. * @return the direction
  24801. */
  24802. getDirection(localAxis: Vector3): Vector3;
  24803. /**
  24804. * Returns the current camera absolute rotation
  24805. */
  24806. readonly absoluteRotation: Quaternion;
  24807. /**
  24808. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24809. * @param localAxis Defines the reference axis to provide a relative direction.
  24810. * @param result Defines the vector to store the result in
  24811. */
  24812. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24813. /**
  24814. * Gets a camera constructor for a given camera type
  24815. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24816. * @param name The name of the camera the result will be able to instantiate
  24817. * @param scene The scene the result will construct the camera in
  24818. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24819. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24820. * @returns a factory method to construc the camera
  24821. */
  24822. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24823. /**
  24824. * Compute the world matrix of the camera.
  24825. * @returns the camera workd matrix
  24826. */
  24827. computeWorldMatrix(): Matrix;
  24828. /**
  24829. * Parse a JSON and creates the camera from the parsed information
  24830. * @param parsedCamera The JSON to parse
  24831. * @param scene The scene to instantiate the camera in
  24832. * @returns the newly constructed camera
  24833. */
  24834. static Parse(parsedCamera: any, scene: Scene): Camera;
  24835. }
  24836. }
  24837. declare module BABYLON {
  24838. /**
  24839. * Class containing static functions to help procedurally build meshes
  24840. */
  24841. export class DiscBuilder {
  24842. /**
  24843. * Creates a plane polygonal mesh. By default, this is a disc
  24844. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24845. * * 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
  24846. * * 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
  24847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24848. * * 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
  24849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24850. * @param name defines the name of the mesh
  24851. * @param options defines the options used to create the mesh
  24852. * @param scene defines the hosting scene
  24853. * @returns the plane polygonal mesh
  24854. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24855. */
  24856. static CreateDisc(name: string, options: {
  24857. radius?: number;
  24858. tessellation?: number;
  24859. arc?: number;
  24860. updatable?: boolean;
  24861. sideOrientation?: number;
  24862. frontUVs?: Vector4;
  24863. backUVs?: Vector4;
  24864. }, scene?: Nullable<Scene>): Mesh;
  24865. }
  24866. }
  24867. declare module BABYLON {
  24868. /**
  24869. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24870. *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.
  24871. * The SPS is also a particle system. It provides some methods to manage the particles.
  24872. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24873. *
  24874. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24875. */
  24876. export class SolidParticleSystem implements IDisposable {
  24877. /**
  24878. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24879. * Example : var p = SPS.particles[i];
  24880. */
  24881. particles: SolidParticle[];
  24882. /**
  24883. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24884. */
  24885. nbParticles: number;
  24886. /**
  24887. * If the particles must ever face the camera (default false). Useful for planar particles.
  24888. */
  24889. billboard: boolean;
  24890. /**
  24891. * Recompute normals when adding a shape
  24892. */
  24893. recomputeNormals: boolean;
  24894. /**
  24895. * This a counter ofr your own usage. It's not set by any SPS functions.
  24896. */
  24897. counter: number;
  24898. /**
  24899. * The SPS name. This name is also given to the underlying mesh.
  24900. */
  24901. name: string;
  24902. /**
  24903. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24904. */
  24905. mesh: Mesh;
  24906. /**
  24907. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24908. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24909. */
  24910. vars: any;
  24911. /**
  24912. * This array is populated when the SPS is set as 'pickable'.
  24913. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24914. * Each element of this array is an object `{idx: int, faceId: int}`.
  24915. * `idx` is the picked particle index in the `SPS.particles` array
  24916. * `faceId` is the picked face index counted within this particle.
  24917. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24918. */
  24919. pickedParticles: {
  24920. idx: number;
  24921. faceId: number;
  24922. }[];
  24923. /**
  24924. * This array is populated when `enableDepthSort` is set to true.
  24925. * Each element of this array is an instance of the class DepthSortedParticle.
  24926. */
  24927. depthSortedParticles: DepthSortedParticle[];
  24928. /**
  24929. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24930. * @hidden
  24931. */ private _bSphereOnly: boolean;
  24932. /**
  24933. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24934. * @hidden
  24935. */ private _bSphereRadiusFactor: number;
  24936. private _scene;
  24937. private _positions;
  24938. private _indices;
  24939. private _normals;
  24940. private _colors;
  24941. private _uvs;
  24942. private _indices32;
  24943. private _positions32;
  24944. private _normals32;
  24945. private _fixedNormal32;
  24946. private _colors32;
  24947. private _uvs32;
  24948. private _index;
  24949. private _updatable;
  24950. private _pickable;
  24951. private _isVisibilityBoxLocked;
  24952. private _alwaysVisible;
  24953. private _depthSort;
  24954. private _shapeCounter;
  24955. private _copy;
  24956. private _color;
  24957. private _computeParticleColor;
  24958. private _computeParticleTexture;
  24959. private _computeParticleRotation;
  24960. private _computeParticleVertex;
  24961. private _computeBoundingBox;
  24962. private _depthSortParticles;
  24963. private _camera;
  24964. private _mustUnrotateFixedNormals;
  24965. private _particlesIntersect;
  24966. private _needs32Bits;
  24967. /**
  24968. * Creates a SPS (Solid Particle System) object.
  24969. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24970. * @param scene (Scene) is the scene in which the SPS is added.
  24971. * @param options defines the options of the sps e.g.
  24972. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24973. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24974. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24975. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24976. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24977. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24978. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24979. */
  24980. constructor(name: string, scene: Scene, options?: {
  24981. updatable?: boolean;
  24982. isPickable?: boolean;
  24983. enableDepthSort?: boolean;
  24984. particleIntersection?: boolean;
  24985. boundingSphereOnly?: boolean;
  24986. bSphereRadiusFactor?: number;
  24987. });
  24988. /**
  24989. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24990. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24991. * @returns the created mesh
  24992. */
  24993. buildMesh(): Mesh;
  24994. /**
  24995. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24996. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24997. * Thus the particles generated from `digest()` have their property `position` set yet.
  24998. * @param mesh ( Mesh ) is the mesh to be digested
  24999. * @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
  25000. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25001. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25002. * @returns the current SPS
  25003. */
  25004. digest(mesh: Mesh, options?: {
  25005. facetNb?: number;
  25006. number?: number;
  25007. delta?: number;
  25008. }): SolidParticleSystem;
  25009. private _unrotateFixedNormals;
  25010. private _resetCopy;
  25011. private _meshBuilder;
  25012. private _posToShape;
  25013. private _uvsToShapeUV;
  25014. private _addParticle;
  25015. /**
  25016. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25017. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25018. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25019. * @param nb (positive integer) the number of particles to be created from this model
  25020. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25021. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25022. * @returns the number of shapes in the system
  25023. */
  25024. addShape(mesh: Mesh, nb: number, options?: {
  25025. positionFunction?: any;
  25026. vertexFunction?: any;
  25027. }): number;
  25028. private _rebuildParticle;
  25029. /**
  25030. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25031. * @returns the SPS.
  25032. */
  25033. rebuildMesh(): SolidParticleSystem;
  25034. /**
  25035. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25036. * This method calls `updateParticle()` for each particle of the SPS.
  25037. * For an animated SPS, it is usually called within the render loop.
  25038. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25039. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25040. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25041. * @returns the SPS.
  25042. */
  25043. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25044. /**
  25045. * Disposes the SPS.
  25046. */
  25047. dispose(): void;
  25048. /**
  25049. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25050. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25051. * @returns the SPS.
  25052. */
  25053. refreshVisibleSize(): SolidParticleSystem;
  25054. /**
  25055. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25056. * @param size the size (float) of the visibility box
  25057. * note : this doesn't lock the SPS mesh bounding box.
  25058. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25059. */
  25060. setVisibilityBox(size: number): void;
  25061. /**
  25062. * Gets whether the SPS as always visible or not
  25063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25064. */
  25065. /**
  25066. * Sets the SPS as always visible or not
  25067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25068. */
  25069. isAlwaysVisible: boolean;
  25070. /**
  25071. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25073. */
  25074. /**
  25075. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25077. */
  25078. isVisibilityBoxLocked: boolean;
  25079. /**
  25080. * Tells to `setParticles()` to compute the particle rotations or not.
  25081. * Default value : true. The SPS is faster when it's set to false.
  25082. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25083. */
  25084. /**
  25085. * Gets if `setParticles()` computes the particle rotations or not.
  25086. * Default value : true. The SPS is faster when it's set to false.
  25087. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25088. */
  25089. computeParticleRotation: boolean;
  25090. /**
  25091. * Tells to `setParticles()` to compute the particle colors or not.
  25092. * Default value : true. The SPS is faster when it's set to false.
  25093. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25094. */
  25095. /**
  25096. * Gets if `setParticles()` computes the particle colors or not.
  25097. * Default value : true. The SPS is faster when it's set to false.
  25098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25099. */
  25100. computeParticleColor: boolean;
  25101. /**
  25102. * Gets if `setParticles()` computes the particle textures or not.
  25103. * Default value : true. The SPS is faster when it's set to false.
  25104. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25105. */
  25106. computeParticleTexture: boolean;
  25107. /**
  25108. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25109. * Default value : false. The SPS is faster when it's set to false.
  25110. * Note : the particle custom vertex positions aren't stored values.
  25111. */
  25112. /**
  25113. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25114. * Default value : false. The SPS is faster when it's set to false.
  25115. * Note : the particle custom vertex positions aren't stored values.
  25116. */
  25117. computeParticleVertex: boolean;
  25118. /**
  25119. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25120. */
  25121. /**
  25122. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25123. */
  25124. computeBoundingBox: boolean;
  25125. /**
  25126. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25127. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25128. * Default : `true`
  25129. */
  25130. /**
  25131. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25132. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25133. * Default : `true`
  25134. */
  25135. depthSortParticles: boolean;
  25136. /**
  25137. * This function does nothing. It may be overwritten to set all the particle first values.
  25138. * The SPS doesn't call this function, you may have to call it by your own.
  25139. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25140. */
  25141. initParticles(): void;
  25142. /**
  25143. * This function does nothing. It may be overwritten to recycle a particle.
  25144. * The SPS doesn't call this function, you may have to call it by your own.
  25145. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25146. * @param particle The particle to recycle
  25147. * @returns the recycled particle
  25148. */
  25149. recycleParticle(particle: SolidParticle): SolidParticle;
  25150. /**
  25151. * Updates a particle : this function should be overwritten by the user.
  25152. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25153. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25154. * @example : just set a particle position or velocity and recycle conditions
  25155. * @param particle The particle to update
  25156. * @returns the updated particle
  25157. */
  25158. updateParticle(particle: SolidParticle): SolidParticle;
  25159. /**
  25160. * Updates a vertex of a particle : it can be overwritten by the user.
  25161. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25162. * @param particle the current particle
  25163. * @param vertex the current index of the current particle
  25164. * @param pt the index of the current vertex in the particle shape
  25165. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25166. * @example : just set a vertex particle position
  25167. * @returns the updated vertex
  25168. */
  25169. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25170. /**
  25171. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25172. * This does nothing and may be overwritten by the user.
  25173. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25174. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25175. * @param update the boolean update value actually passed to setParticles()
  25176. */
  25177. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25178. /**
  25179. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25180. * This will be passed three parameters.
  25181. * This does nothing and may be overwritten by the user.
  25182. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25183. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25184. * @param update the boolean update value actually passed to setParticles()
  25185. */
  25186. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25187. }
  25188. }
  25189. declare module BABYLON {
  25190. /**
  25191. * Represents one particle of a solid particle system.
  25192. */
  25193. export class SolidParticle {
  25194. /**
  25195. * particle global index
  25196. */
  25197. idx: number;
  25198. /**
  25199. * The color of the particle
  25200. */
  25201. color: Nullable<Color4>;
  25202. /**
  25203. * The world space position of the particle.
  25204. */
  25205. position: Vector3;
  25206. /**
  25207. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25208. */
  25209. rotation: Vector3;
  25210. /**
  25211. * The world space rotation quaternion of the particle.
  25212. */
  25213. rotationQuaternion: Nullable<Quaternion>;
  25214. /**
  25215. * The scaling of the particle.
  25216. */
  25217. scaling: Vector3;
  25218. /**
  25219. * The uvs of the particle.
  25220. */
  25221. uvs: Vector4;
  25222. /**
  25223. * The current speed of the particle.
  25224. */
  25225. velocity: Vector3;
  25226. /**
  25227. * The pivot point in the particle local space.
  25228. */
  25229. pivot: Vector3;
  25230. /**
  25231. * Must the particle be translated from its pivot point in its local space ?
  25232. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25233. * Default : false
  25234. */
  25235. translateFromPivot: boolean;
  25236. /**
  25237. * Is the particle active or not ?
  25238. */
  25239. alive: boolean;
  25240. /**
  25241. * Is the particle visible or not ?
  25242. */
  25243. isVisible: boolean;
  25244. /**
  25245. * Index of this particle in the global "positions" array (Internal use)
  25246. * @hidden
  25247. */ private _pos: number;
  25248. /**
  25249. * @hidden Index of this particle in the global "indices" array (Internal use)
  25250. */ private _ind: number;
  25251. /**
  25252. * @hidden ModelShape of this particle (Internal use)
  25253. */ private _model: ModelShape;
  25254. /**
  25255. * ModelShape id of this particle
  25256. */
  25257. shapeId: number;
  25258. /**
  25259. * Index of the particle in its shape id
  25260. */
  25261. idxInShape: number;
  25262. /**
  25263. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25264. */ private _modelBoundingInfo: BoundingInfo;
  25265. /**
  25266. * @hidden Particle BoundingInfo object (Internal use)
  25267. */ private _boundingInfo: BoundingInfo;
  25268. /**
  25269. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25270. */ private _sps: SolidParticleSystem;
  25271. /**
  25272. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25273. */ private _stillInvisible: boolean;
  25274. /**
  25275. * @hidden Last computed particle rotation matrix
  25276. */ private _rotationMatrix: number[];
  25277. /**
  25278. * Parent particle Id, if any.
  25279. * Default null.
  25280. */
  25281. parentId: Nullable<number>;
  25282. /**
  25283. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25284. * The possible values are :
  25285. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25286. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25287. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25288. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25289. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25290. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25291. * */
  25292. cullingStrategy: number;
  25293. /**
  25294. * @hidden Internal global position in the SPS.
  25295. */ private _globalPosition: Vector3;
  25296. /**
  25297. * Creates a Solid Particle object.
  25298. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25299. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25300. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25301. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25302. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25303. * @param shapeId (integer) is the model shape identifier in the SPS.
  25304. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25305. * @param sps defines the sps it is associated to
  25306. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25307. */
  25308. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25309. /**
  25310. * Legacy support, changed scale to scaling
  25311. */
  25312. /**
  25313. * Legacy support, changed scale to scaling
  25314. */
  25315. scale: Vector3;
  25316. /**
  25317. * Legacy support, changed quaternion to rotationQuaternion
  25318. */
  25319. /**
  25320. * Legacy support, changed quaternion to rotationQuaternion
  25321. */
  25322. quaternion: Nullable<Quaternion>;
  25323. /**
  25324. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25325. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25326. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25327. * @returns true if it intersects
  25328. */
  25329. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25330. /**
  25331. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25332. * A particle is in the frustum if its bounding box intersects the frustum
  25333. * @param frustumPlanes defines the frustum to test
  25334. * @returns true if the particle is in the frustum planes
  25335. */
  25336. isInFrustum(frustumPlanes: Plane[]): boolean;
  25337. /**
  25338. * get the rotation matrix of the particle
  25339. * @hidden
  25340. */
  25341. getRotationMatrix(m: Matrix): void;
  25342. }
  25343. /**
  25344. * Represents the shape of the model used by one particle of a solid particle system.
  25345. * SPS internal tool, don't use it manually.
  25346. */
  25347. export class ModelShape {
  25348. /**
  25349. * The shape id
  25350. * @hidden
  25351. */
  25352. shapeID: number;
  25353. /**
  25354. * flat array of model positions (internal use)
  25355. * @hidden
  25356. */ private _shape: Vector3[];
  25357. /**
  25358. * flat array of model UVs (internal use)
  25359. * @hidden
  25360. */ private _shapeUV: number[];
  25361. /**
  25362. * length of the shape in the model indices array (internal use)
  25363. * @hidden
  25364. */ private _indicesLength: number;
  25365. /**
  25366. * Custom position function (internal use)
  25367. * @hidden
  25368. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25369. /**
  25370. * Custom vertex function (internal use)
  25371. * @hidden
  25372. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25373. /**
  25374. * 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.
  25375. * SPS internal tool, don't use it manually.
  25376. * @hidden
  25377. */
  25378. 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>);
  25379. }
  25380. /**
  25381. * Represents a Depth Sorted Particle in the solid particle system.
  25382. */
  25383. export class DepthSortedParticle {
  25384. /**
  25385. * Index of the particle in the "indices" array
  25386. */
  25387. ind: number;
  25388. /**
  25389. * Length of the particle shape in the "indices" array
  25390. */
  25391. indicesLength: number;
  25392. /**
  25393. * Squared distance from the particle to the camera
  25394. */
  25395. sqDistance: number;
  25396. }
  25397. }
  25398. declare module BABYLON {
  25399. /**
  25400. * @hidden
  25401. */
  25402. 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>>;
  25403. }
  25404. }
  25405. declare module BABYLON {
  25406. /** @hidden */ private class _FacetDataStorage {
  25407. facetPositions: Vector3[];
  25408. facetNormals: Vector3[];
  25409. facetPartitioning: number[][];
  25410. facetNb: number;
  25411. partitioningSubdivisions: number;
  25412. partitioningBBoxRatio: number;
  25413. facetDataEnabled: boolean;
  25414. facetParameters: any;
  25415. bbSize: Vector3;
  25416. subDiv: {
  25417. max: number;
  25418. X: number;
  25419. Y: number;
  25420. Z: number;
  25421. };
  25422. facetDepthSort: boolean;
  25423. facetDepthSortEnabled: boolean;
  25424. depthSortedIndices: IndicesArray;
  25425. depthSortedFacets: {
  25426. ind: number;
  25427. sqDistance: number;
  25428. }[];
  25429. facetDepthSortFunction: (f1: {
  25430. ind: number;
  25431. sqDistance: number;
  25432. }, f2: {
  25433. ind: number;
  25434. sqDistance: number;
  25435. }) => number;
  25436. facetDepthSortFrom: Vector3;
  25437. facetDepthSortOrigin: Vector3;
  25438. invertedMatrix: Matrix;
  25439. }
  25440. /**
  25441. * @hidden
  25442. **/ 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;
  25443. }
  25444. /**
  25445. * Class used to store all common mesh properties
  25446. */
  25447. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25448. /** No occlusion */
  25449. static OCCLUSION_TYPE_NONE: number;
  25450. /** Occlusion set to optimisitic */
  25451. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25452. /** Occlusion set to strict */
  25453. static OCCLUSION_TYPE_STRICT: number;
  25454. /** Use an accurante occlusion algorithm */
  25455. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25456. /** Use a conservative occlusion algorithm */
  25457. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25458. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25459. * Test order :
  25460. * Is the bounding sphere outside the frustum ?
  25461. * If not, are the bounding box vertices outside the frustum ?
  25462. * It not, then the cullable object is in the frustum.
  25463. */
  25464. static readonly CULLINGSTRATEGY_STANDARD: number;
  25465. /** Culling strategy : Bounding Sphere Only.
  25466. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25467. * It's also less accurate than the standard because some not visible objects can still be selected.
  25468. * Test : is the bounding sphere outside the frustum ?
  25469. * If not, then the cullable object is in the frustum.
  25470. */
  25471. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25472. /** Culling strategy : Optimistic Inclusion.
  25473. * This in an inclusion test first, then the standard exclusion test.
  25474. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25475. * 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.
  25476. * Anyway, it's as accurate as the standard strategy.
  25477. * Test :
  25478. * Is the cullable object bounding sphere center in the frustum ?
  25479. * If not, apply the default culling strategy.
  25480. */
  25481. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25482. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25483. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25484. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25485. * 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.
  25486. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25487. * Test :
  25488. * Is the cullable object bounding sphere center in the frustum ?
  25489. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25490. */
  25491. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25492. /**
  25493. * No billboard
  25494. */
  25495. static readonly BILLBOARDMODE_NONE: number;
  25496. /** Billboard on X axis */
  25497. static readonly BILLBOARDMODE_X: number;
  25498. /** Billboard on Y axis */
  25499. static readonly BILLBOARDMODE_Y: number;
  25500. /** Billboard on Z axis */
  25501. static readonly BILLBOARDMODE_Z: number;
  25502. /** Billboard on all axes */
  25503. static readonly BILLBOARDMODE_ALL: number;
  25504. /** Billboard on using position instead of orientation */
  25505. static readonly BILLBOARDMODE_USE_POSITION: number;
  25506. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25507. /**
  25508. * The culling strategy to use to check whether the mesh must be rendered or not.
  25509. * This value can be changed at any time and will be used on the next render mesh selection.
  25510. * The possible values are :
  25511. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25512. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25513. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25515. * Please read each static variable documentation to get details about the culling process.
  25516. * */
  25517. cullingStrategy: number;
  25518. /**
  25519. * Gets the number of facets in the mesh
  25520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25521. */
  25522. readonly facetNb: number;
  25523. /**
  25524. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25526. */
  25527. partitioningSubdivisions: number;
  25528. /**
  25529. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25530. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25532. */
  25533. partitioningBBoxRatio: number;
  25534. /**
  25535. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25536. * Works only for updatable meshes.
  25537. * Doesn't work with multi-materials
  25538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25539. */
  25540. mustDepthSortFacets: boolean;
  25541. /**
  25542. * The location (Vector3) where the facet depth sort must be computed from.
  25543. * By default, the active camera position.
  25544. * Used only when facet depth sort is enabled
  25545. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25546. */
  25547. facetDepthSortFrom: Vector3;
  25548. /**
  25549. * gets a boolean indicating if facetData is enabled
  25550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25551. */
  25552. readonly isFacetDataEnabled: boolean;
  25553. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25554. /**
  25555. * An event triggered when this mesh collides with another one
  25556. */
  25557. onCollideObservable: Observable<AbstractMesh>;
  25558. /** Set a function to call when this mesh collides with another one */
  25559. onCollide: () => void;
  25560. /**
  25561. * An event triggered when the collision's position changes
  25562. */
  25563. onCollisionPositionChangeObservable: Observable<Vector3>;
  25564. /** Set a function to call when the collision's position changes */
  25565. onCollisionPositionChange: () => void;
  25566. /**
  25567. * An event triggered when material is changed
  25568. */
  25569. onMaterialChangedObservable: Observable<AbstractMesh>;
  25570. /**
  25571. * Gets or sets the orientation for POV movement & rotation
  25572. */
  25573. definedFacingForward: boolean;
  25574. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25575. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25576. /**
  25577. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25578. */
  25579. /**
  25580. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25581. */
  25582. visibility: number;
  25583. /** Gets or sets the alpha index used to sort transparent meshes
  25584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25585. */
  25586. alphaIndex: number;
  25587. /**
  25588. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25589. */
  25590. isVisible: boolean;
  25591. /**
  25592. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25593. */
  25594. isPickable: boolean;
  25595. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25596. showSubMeshesBoundingBox: boolean;
  25597. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25599. */
  25600. isBlocker: boolean;
  25601. /**
  25602. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25603. */
  25604. enablePointerMoveEvents: boolean;
  25605. /**
  25606. * Specifies the rendering group id for this mesh (0 by default)
  25607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25608. */
  25609. renderingGroupId: number;
  25610. private _material;
  25611. /** Gets or sets current material */
  25612. material: Nullable<Material>;
  25613. /**
  25614. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25615. * @see http://doc.babylonjs.com/babylon101/shadows
  25616. */
  25617. receiveShadows: boolean;
  25618. /** Defines color to use when rendering outline */
  25619. outlineColor: Color3;
  25620. /** Define width to use when rendering outline */
  25621. outlineWidth: number;
  25622. /** Defines color to use when rendering overlay */
  25623. overlayColor: Color3;
  25624. /** Defines alpha to use when rendering overlay */
  25625. overlayAlpha: number;
  25626. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25627. hasVertexAlpha: boolean;
  25628. /** 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) */
  25629. useVertexColors: boolean;
  25630. /**
  25631. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25632. */
  25633. computeBonesUsingShaders: boolean;
  25634. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25635. numBoneInfluencers: number;
  25636. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25637. applyFog: boolean;
  25638. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25639. useOctreeForRenderingSelection: boolean;
  25640. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25641. useOctreeForPicking: boolean;
  25642. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25643. useOctreeForCollisions: boolean;
  25644. /**
  25645. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25646. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25647. */
  25648. layerMask: number;
  25649. /**
  25650. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25651. */
  25652. alwaysSelectAsActiveMesh: boolean;
  25653. /**
  25654. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25655. */
  25656. doNotSyncBoundingInfo: boolean;
  25657. /**
  25658. * Gets or sets the current action manager
  25659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25660. */
  25661. actionManager: Nullable<AbstractActionManager>;
  25662. private _meshCollisionData;
  25663. /**
  25664. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25666. */
  25667. ellipsoid: Vector3;
  25668. /**
  25669. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25671. */
  25672. ellipsoidOffset: Vector3;
  25673. /**
  25674. * Gets or sets a collision mask used to mask collisions (default is -1).
  25675. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25676. */
  25677. collisionMask: number;
  25678. /**
  25679. * Gets or sets the current collision group mask (-1 by default).
  25680. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25681. */
  25682. collisionGroup: number;
  25683. /**
  25684. * Defines edge width used when edgesRenderer is enabled
  25685. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25686. */
  25687. edgesWidth: number;
  25688. /**
  25689. * Defines edge color used when edgesRenderer is enabled
  25690. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25691. */
  25692. edgesColor: Color4;
  25693. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25694. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25695. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25696. /** @hidden */ private _renderId: number;
  25697. /**
  25698. * Gets or sets the list of subMeshes
  25699. * @see http://doc.babylonjs.com/how_to/multi_materials
  25700. */
  25701. subMeshes: SubMesh[];
  25702. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25703. /** @hidden */ private _unIndexed: boolean;
  25704. /** @hidden */ private _lightSources: Light[];
  25705. /** Gets the list of lights affecting that mesh */
  25706. readonly lightSources: Light[];
  25707. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25708. /** @hidden */ private _waitingData: {
  25709. lods: Nullable<any>;
  25710. actions: Nullable<any>;
  25711. freezeWorldMatrix: Nullable<boolean>;
  25712. };
  25713. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25714. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25715. /**
  25716. * Gets or sets a skeleton to apply skining transformations
  25717. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25718. */
  25719. skeleton: Nullable<Skeleton>;
  25720. /**
  25721. * An event triggered when the mesh is rebuilt.
  25722. */
  25723. onRebuildObservable: Observable<AbstractMesh>;
  25724. /**
  25725. * Creates a new AbstractMesh
  25726. * @param name defines the name of the mesh
  25727. * @param scene defines the hosting scene
  25728. */
  25729. constructor(name: string, scene?: Nullable<Scene>);
  25730. /**
  25731. * Returns the string "AbstractMesh"
  25732. * @returns "AbstractMesh"
  25733. */
  25734. getClassName(): string;
  25735. /**
  25736. * Gets a string representation of the current mesh
  25737. * @param fullDetails defines a boolean indicating if full details must be included
  25738. * @returns a string representation of the current mesh
  25739. */
  25740. toString(fullDetails?: boolean): string;
  25741. /**
  25742. * @hidden
  25743. */
  25744. protected _getEffectiveParent(): Nullable<Node>;
  25745. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25746. /** @hidden */ private _rebuild(): void;
  25747. /** @hidden */ private _resyncLightSources(): void;
  25748. /** @hidden */ private _resyncLighSource(light: Light): void;
  25749. /** @hidden */ private _unBindEffect(): void;
  25750. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25751. private _markSubMeshesAsDirty;
  25752. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25753. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25754. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25755. /**
  25756. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25757. */
  25758. scaling: Vector3;
  25759. /**
  25760. * Returns true if the mesh is blocked. Implemented by child classes
  25761. */
  25762. readonly isBlocked: boolean;
  25763. /**
  25764. * Returns the mesh itself by default. Implemented by child classes
  25765. * @param camera defines the camera to use to pick the right LOD level
  25766. * @returns the currentAbstractMesh
  25767. */
  25768. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25769. /**
  25770. * Returns 0 by default. Implemented by child classes
  25771. * @returns an integer
  25772. */
  25773. getTotalVertices(): number;
  25774. /**
  25775. * Returns a positive integer : the total number of indices in this mesh geometry.
  25776. * @returns the numner of indices or zero if the mesh has no geometry.
  25777. */
  25778. getTotalIndices(): number;
  25779. /**
  25780. * Returns null by default. Implemented by child classes
  25781. * @returns null
  25782. */
  25783. getIndices(): Nullable<IndicesArray>;
  25784. /**
  25785. * Returns the array of the requested vertex data kind. Implemented by child classes
  25786. * @param kind defines the vertex data kind to use
  25787. * @returns null
  25788. */
  25789. getVerticesData(kind: string): Nullable<FloatArray>;
  25790. /**
  25791. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25792. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25793. * Note that a new underlying VertexBuffer object is created each call.
  25794. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25795. * @param kind defines vertex data kind:
  25796. * * VertexBuffer.PositionKind
  25797. * * VertexBuffer.UVKind
  25798. * * VertexBuffer.UV2Kind
  25799. * * VertexBuffer.UV3Kind
  25800. * * VertexBuffer.UV4Kind
  25801. * * VertexBuffer.UV5Kind
  25802. * * VertexBuffer.UV6Kind
  25803. * * VertexBuffer.ColorKind
  25804. * * VertexBuffer.MatricesIndicesKind
  25805. * * VertexBuffer.MatricesIndicesExtraKind
  25806. * * VertexBuffer.MatricesWeightsKind
  25807. * * VertexBuffer.MatricesWeightsExtraKind
  25808. * @param data defines the data source
  25809. * @param updatable defines if the data must be flagged as updatable (or static)
  25810. * @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
  25811. * @returns the current mesh
  25812. */
  25813. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25814. /**
  25815. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25816. * If the mesh has no geometry, it is simply returned as it is.
  25817. * @param kind defines vertex data kind:
  25818. * * VertexBuffer.PositionKind
  25819. * * VertexBuffer.UVKind
  25820. * * VertexBuffer.UV2Kind
  25821. * * VertexBuffer.UV3Kind
  25822. * * VertexBuffer.UV4Kind
  25823. * * VertexBuffer.UV5Kind
  25824. * * VertexBuffer.UV6Kind
  25825. * * VertexBuffer.ColorKind
  25826. * * VertexBuffer.MatricesIndicesKind
  25827. * * VertexBuffer.MatricesIndicesExtraKind
  25828. * * VertexBuffer.MatricesWeightsKind
  25829. * * VertexBuffer.MatricesWeightsExtraKind
  25830. * @param data defines the data source
  25831. * @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
  25832. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25833. * @returns the current mesh
  25834. */
  25835. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25836. /**
  25837. * Sets the mesh indices,
  25838. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25839. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25840. * @param totalVertices Defines the total number of vertices
  25841. * @returns the current mesh
  25842. */
  25843. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25844. /**
  25845. * Gets a boolean indicating if specific vertex data is present
  25846. * @param kind defines the vertex data kind to use
  25847. * @returns true is data kind is present
  25848. */
  25849. isVerticesDataPresent(kind: string): boolean;
  25850. /**
  25851. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25852. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25853. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25854. * @returns a BoundingInfo
  25855. */
  25856. getBoundingInfo(): BoundingInfo;
  25857. /**
  25858. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25859. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25860. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25861. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25862. * @returns the current mesh
  25863. */
  25864. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25865. /**
  25866. * Overwrite the current bounding info
  25867. * @param boundingInfo defines the new bounding info
  25868. * @returns the current mesh
  25869. */
  25870. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25871. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25872. readonly useBones: boolean;
  25873. /** @hidden */ private _preActivate(): void;
  25874. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25875. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25876. /** @hidden */ private _postActivate(): void;
  25877. /** @hidden */ private _freeze(): void;
  25878. /** @hidden */ private _unFreeze(): void;
  25879. /**
  25880. * Gets the current world matrix
  25881. * @returns a Matrix
  25882. */
  25883. getWorldMatrix(): Matrix;
  25884. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25885. /**
  25886. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25887. */
  25888. readonly isAnInstance: boolean;
  25889. /**
  25890. * Gets a boolean indicating if this mesh has instances
  25891. */
  25892. readonly hasInstances: boolean;
  25893. /**
  25894. * Perform relative position change from the point of view of behind the front of the mesh.
  25895. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25896. * Supports definition of mesh facing forward or backward
  25897. * @param amountRight defines the distance on the right axis
  25898. * @param amountUp defines the distance on the up axis
  25899. * @param amountForward defines the distance on the forward axis
  25900. * @returns the current mesh
  25901. */
  25902. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25903. /**
  25904. * Calculate relative position change from the point of view of behind the front of the mesh.
  25905. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25906. * Supports definition of mesh facing forward or backward
  25907. * @param amountRight defines the distance on the right axis
  25908. * @param amountUp defines the distance on the up axis
  25909. * @param amountForward defines the distance on the forward axis
  25910. * @returns the new displacement vector
  25911. */
  25912. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25913. /**
  25914. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25915. * Supports definition of mesh facing forward or backward
  25916. * @param flipBack defines the flip
  25917. * @param twirlClockwise defines the twirl
  25918. * @param tiltRight defines the tilt
  25919. * @returns the current mesh
  25920. */
  25921. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25922. /**
  25923. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25924. * Supports definition of mesh facing forward or backward.
  25925. * @param flipBack defines the flip
  25926. * @param twirlClockwise defines the twirl
  25927. * @param tiltRight defines the tilt
  25928. * @returns the new rotation vector
  25929. */
  25930. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25931. /**
  25932. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25933. * This means the mesh underlying bounding box and sphere are recomputed.
  25934. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25935. * @returns the current mesh
  25936. */
  25937. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25938. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25939. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25940. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25941. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25942. /** @hidden */
  25943. protected _afterComputeWorldMatrix(): void;
  25944. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25945. /**
  25946. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25947. * A mesh is in the frustum if its bounding box intersects the frustum
  25948. * @param frustumPlanes defines the frustum to test
  25949. * @returns true if the mesh is in the frustum planes
  25950. */
  25951. isInFrustum(frustumPlanes: Plane[]): boolean;
  25952. /**
  25953. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25954. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25955. * @param frustumPlanes defines the frustum to test
  25956. * @returns true if the mesh is completely in the frustum planes
  25957. */
  25958. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25959. /**
  25960. * True if the mesh intersects another mesh or a SolidParticle object
  25961. * @param mesh defines a target mesh or SolidParticle to test
  25962. * @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)
  25963. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25964. * @returns true if there is an intersection
  25965. */
  25966. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25967. /**
  25968. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25969. * @param point defines the point to test
  25970. * @returns true if there is an intersection
  25971. */
  25972. intersectsPoint(point: Vector3): boolean;
  25973. /**
  25974. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25976. */
  25977. checkCollisions: boolean;
  25978. /**
  25979. * Gets Collider object used to compute collisions (not physics)
  25980. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25981. */
  25982. readonly collider: Nullable<Collider>;
  25983. /**
  25984. * Move the mesh using collision engine
  25985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25986. * @param displacement defines the requested displacement vector
  25987. * @returns the current mesh
  25988. */
  25989. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25990. private _onCollisionPositionChange;
  25991. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25992. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25993. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25994. /** @hidden */ private _generatePointsArray(): boolean;
  25995. /**
  25996. * Checks if the passed Ray intersects with the mesh
  25997. * @param ray defines the ray to use
  25998. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25999. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26000. * @returns the picking info
  26001. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26002. */
  26003. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26004. /**
  26005. * Clones the current mesh
  26006. * @param name defines the mesh name
  26007. * @param newParent defines the new mesh parent
  26008. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26009. * @returns the new mesh
  26010. */
  26011. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26012. /**
  26013. * Disposes all the submeshes of the current meshnp
  26014. * @returns the current mesh
  26015. */
  26016. releaseSubMeshes(): AbstractMesh;
  26017. /**
  26018. * Releases resources associated with this abstract mesh.
  26019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26021. */
  26022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26023. /**
  26024. * Adds the passed mesh as a child to the current mesh
  26025. * @param mesh defines the child mesh
  26026. * @returns the current mesh
  26027. */
  26028. addChild(mesh: AbstractMesh): AbstractMesh;
  26029. /**
  26030. * Removes the passed mesh from the current mesh children list
  26031. * @param mesh defines the child mesh
  26032. * @returns the current mesh
  26033. */
  26034. removeChild(mesh: AbstractMesh): AbstractMesh;
  26035. /** @hidden */
  26036. private _initFacetData;
  26037. /**
  26038. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26039. * This method can be called within the render loop.
  26040. * 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
  26041. * @returns the current mesh
  26042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26043. */
  26044. updateFacetData(): AbstractMesh;
  26045. /**
  26046. * Returns the facetLocalNormals array.
  26047. * The normals are expressed in the mesh local spac
  26048. * @returns an array of Vector3
  26049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26050. */
  26051. getFacetLocalNormals(): Vector3[];
  26052. /**
  26053. * Returns the facetLocalPositions array.
  26054. * The facet positions are expressed in the mesh local space
  26055. * @returns an array of Vector3
  26056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26057. */
  26058. getFacetLocalPositions(): Vector3[];
  26059. /**
  26060. * Returns the facetLocalPartioning array
  26061. * @returns an array of array of numbers
  26062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26063. */
  26064. getFacetLocalPartitioning(): number[][];
  26065. /**
  26066. * Returns the i-th facet position in the world system.
  26067. * This method allocates a new Vector3 per call
  26068. * @param i defines the facet index
  26069. * @returns a new Vector3
  26070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26071. */
  26072. getFacetPosition(i: number): Vector3;
  26073. /**
  26074. * Sets the reference Vector3 with the i-th facet position in the world system
  26075. * @param i defines the facet index
  26076. * @param ref defines the target vector
  26077. * @returns the current mesh
  26078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26079. */
  26080. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26081. /**
  26082. * Returns the i-th facet normal in the world system.
  26083. * This method allocates a new Vector3 per call
  26084. * @param i defines the facet index
  26085. * @returns a new Vector3
  26086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26087. */
  26088. getFacetNormal(i: number): Vector3;
  26089. /**
  26090. * Sets the reference Vector3 with the i-th facet normal in the world system
  26091. * @param i defines the facet index
  26092. * @param ref defines the target vector
  26093. * @returns the current mesh
  26094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26095. */
  26096. getFacetNormalToRef(i: number, ref: Vector3): this;
  26097. /**
  26098. * 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)
  26099. * @param x defines x coordinate
  26100. * @param y defines y coordinate
  26101. * @param z defines z coordinate
  26102. * @returns the array of facet indexes
  26103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26104. */
  26105. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26106. /**
  26107. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26108. * @param projected sets as the (x,y,z) world projection on the facet
  26109. * @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
  26110. * @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
  26111. * @param x defines x coordinate
  26112. * @param y defines y coordinate
  26113. * @param z defines z coordinate
  26114. * @returns the face index if found (or null instead)
  26115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26116. */
  26117. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26118. /**
  26119. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26120. * @param projected sets as the (x,y,z) local projection on the facet
  26121. * @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
  26122. * @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
  26123. * @param x defines x coordinate
  26124. * @param y defines y coordinate
  26125. * @param z defines z coordinate
  26126. * @returns the face index if found (or null instead)
  26127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26128. */
  26129. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26130. /**
  26131. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26132. * @returns the parameters
  26133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26134. */
  26135. getFacetDataParameters(): any;
  26136. /**
  26137. * Disables the feature FacetData and frees the related memory
  26138. * @returns the current mesh
  26139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26140. */
  26141. disableFacetData(): AbstractMesh;
  26142. /**
  26143. * Updates the AbstractMesh indices array
  26144. * @param indices defines the data source
  26145. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26146. * @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)
  26147. * @returns the current mesh
  26148. */
  26149. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26150. /**
  26151. * Creates new normals data for the mesh
  26152. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26153. * @returns the current mesh
  26154. */
  26155. createNormals(updatable: boolean): AbstractMesh;
  26156. /**
  26157. * Align the mesh with a normal
  26158. * @param normal defines the normal to use
  26159. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26160. * @returns the current mesh
  26161. */
  26162. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26163. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26164. /**
  26165. * Disables the mesh edge rendering mode
  26166. * @returns the currentAbstractMesh
  26167. */
  26168. disableEdgesRendering(): AbstractMesh;
  26169. /**
  26170. * Enables the edge rendering mode on the mesh.
  26171. * This mode makes the mesh edges visible
  26172. * @param epsilon defines the maximal distance between two angles to detect a face
  26173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26174. * @returns the currentAbstractMesh
  26175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26176. */
  26177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26178. }
  26179. }
  26180. declare module BABYLON {
  26181. /**
  26182. * Interface used to define ActionEvent
  26183. */
  26184. export interface IActionEvent {
  26185. /** The mesh or sprite that triggered the action */
  26186. source: any;
  26187. /** The X mouse cursor position at the time of the event */
  26188. pointerX: number;
  26189. /** The Y mouse cursor position at the time of the event */
  26190. pointerY: number;
  26191. /** The mesh that is currently pointed at (can be null) */
  26192. meshUnderPointer: Nullable<AbstractMesh>;
  26193. /** the original (browser) event that triggered the ActionEvent */
  26194. sourceEvent?: any;
  26195. /** additional data for the event */
  26196. additionalData?: any;
  26197. }
  26198. /**
  26199. * ActionEvent is the event being sent when an action is triggered.
  26200. */
  26201. export class ActionEvent implements IActionEvent {
  26202. /** The mesh or sprite that triggered the action */
  26203. source: any;
  26204. /** The X mouse cursor position at the time of the event */
  26205. pointerX: number;
  26206. /** The Y mouse cursor position at the time of the event */
  26207. pointerY: number;
  26208. /** The mesh that is currently pointed at (can be null) */
  26209. meshUnderPointer: Nullable<AbstractMesh>;
  26210. /** the original (browser) event that triggered the ActionEvent */
  26211. sourceEvent?: any;
  26212. /** additional data for the event */
  26213. additionalData?: any;
  26214. /**
  26215. * Creates a new ActionEvent
  26216. * @param source The mesh or sprite that triggered the action
  26217. * @param pointerX The X mouse cursor position at the time of the event
  26218. * @param pointerY The Y mouse cursor position at the time of the event
  26219. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26220. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26221. * @param additionalData additional data for the event
  26222. */
  26223. constructor(
  26224. /** The mesh or sprite that triggered the action */
  26225. source: any,
  26226. /** The X mouse cursor position at the time of the event */
  26227. pointerX: number,
  26228. /** The Y mouse cursor position at the time of the event */
  26229. pointerY: number,
  26230. /** The mesh that is currently pointed at (can be null) */
  26231. meshUnderPointer: Nullable<AbstractMesh>,
  26232. /** the original (browser) event that triggered the ActionEvent */
  26233. sourceEvent?: any,
  26234. /** additional data for the event */
  26235. additionalData?: any);
  26236. /**
  26237. * Helper function to auto-create an ActionEvent from a source mesh.
  26238. * @param source The source mesh that triggered the event
  26239. * @param evt The original (browser) event
  26240. * @param additionalData additional data for the event
  26241. * @returns the new ActionEvent
  26242. */
  26243. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26244. /**
  26245. * Helper function to auto-create an ActionEvent from a source sprite
  26246. * @param source The source sprite that triggered the event
  26247. * @param scene Scene associated with the sprite
  26248. * @param evt The original (browser) event
  26249. * @param additionalData additional data for the event
  26250. * @returns the new ActionEvent
  26251. */
  26252. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26253. /**
  26254. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26255. * @param scene the scene where the event occurred
  26256. * @param evt The original (browser) event
  26257. * @returns the new ActionEvent
  26258. */
  26259. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26260. /**
  26261. * Helper function to auto-create an ActionEvent from a primitive
  26262. * @param prim defines the target primitive
  26263. * @param pointerPos defines the pointer position
  26264. * @param evt The original (browser) event
  26265. * @param additionalData additional data for the event
  26266. * @returns the new ActionEvent
  26267. */
  26268. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26269. }
  26270. }
  26271. declare module BABYLON {
  26272. /**
  26273. * Abstract class used to decouple action Manager from scene and meshes.
  26274. * Do not instantiate.
  26275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26276. */
  26277. export abstract class AbstractActionManager implements IDisposable {
  26278. /** Gets the list of active triggers */
  26279. static Triggers: {
  26280. [key: string]: number;
  26281. };
  26282. /** Gets the cursor to use when hovering items */
  26283. hoverCursor: string;
  26284. /** Gets the list of actions */
  26285. actions: IAction[];
  26286. /**
  26287. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26288. */
  26289. isRecursive: boolean;
  26290. /**
  26291. * Releases all associated resources
  26292. */
  26293. abstract dispose(): void;
  26294. /**
  26295. * Does this action manager has pointer triggers
  26296. */
  26297. abstract readonly hasPointerTriggers: boolean;
  26298. /**
  26299. * Does this action manager has pick triggers
  26300. */
  26301. abstract readonly hasPickTriggers: boolean;
  26302. /**
  26303. * Process a specific trigger
  26304. * @param trigger defines the trigger to process
  26305. * @param evt defines the event details to be processed
  26306. */
  26307. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26308. /**
  26309. * Does this action manager handles actions of any of the given triggers
  26310. * @param triggers defines the triggers to be tested
  26311. * @return a boolean indicating whether one (or more) of the triggers is handled
  26312. */
  26313. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26314. /**
  26315. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26316. * speed.
  26317. * @param triggerA defines the trigger to be tested
  26318. * @param triggerB defines the trigger to be tested
  26319. * @return a boolean indicating whether one (or more) of the triggers is handled
  26320. */
  26321. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26322. /**
  26323. * Does this action manager handles actions of a given trigger
  26324. * @param trigger defines the trigger to be tested
  26325. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26326. * @return whether the trigger is handled
  26327. */
  26328. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26329. /**
  26330. * Serialize this manager to a JSON object
  26331. * @param name defines the property name to store this manager
  26332. * @returns a JSON representation of this manager
  26333. */
  26334. abstract serialize(name: string): any;
  26335. /**
  26336. * Registers an action to this action manager
  26337. * @param action defines the action to be registered
  26338. * @return the action amended (prepared) after registration
  26339. */
  26340. abstract registerAction(action: IAction): Nullable<IAction>;
  26341. /**
  26342. * Unregisters an action to this action manager
  26343. * @param action defines the action to be unregistered
  26344. * @return a boolean indicating whether the action has been unregistered
  26345. */
  26346. abstract unregisterAction(action: IAction): Boolean;
  26347. /**
  26348. * Does exist one action manager with at least one trigger
  26349. **/
  26350. static readonly HasTriggers: boolean;
  26351. /**
  26352. * Does exist one action manager with at least one pick trigger
  26353. **/
  26354. static readonly HasPickTriggers: boolean;
  26355. /**
  26356. * Does exist one action manager that handles actions of a given trigger
  26357. * @param trigger defines the trigger to be tested
  26358. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26359. **/
  26360. static HasSpecificTrigger(trigger: number): boolean;
  26361. }
  26362. }
  26363. declare module BABYLON {
  26364. /**
  26365. * Defines how a node can be built from a string name.
  26366. */
  26367. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26368. /**
  26369. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26370. */
  26371. export class Node implements IBehaviorAware<Node> {
  26372. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26373. private static _NodeConstructors;
  26374. /**
  26375. * Add a new node constructor
  26376. * @param type defines the type name of the node to construct
  26377. * @param constructorFunc defines the constructor function
  26378. */
  26379. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26380. /**
  26381. * Returns a node constructor based on type name
  26382. * @param type defines the type name
  26383. * @param name defines the new node name
  26384. * @param scene defines the hosting scene
  26385. * @param options defines optional options to transmit to constructors
  26386. * @returns the new constructor or null
  26387. */
  26388. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26389. /**
  26390. * Gets or sets the name of the node
  26391. */
  26392. name: string;
  26393. /**
  26394. * Gets or sets the id of the node
  26395. */
  26396. id: string;
  26397. /**
  26398. * Gets or sets the unique id of the node
  26399. */
  26400. uniqueId: number;
  26401. /**
  26402. * Gets or sets a string used to store user defined state for the node
  26403. */
  26404. state: string;
  26405. /**
  26406. * Gets or sets an object used to store user defined information for the node
  26407. */
  26408. metadata: any;
  26409. /**
  26410. * For internal use only. Please do not use.
  26411. */
  26412. reservedDataStore: any;
  26413. /**
  26414. * List of inspectable custom properties (used by the Inspector)
  26415. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26416. */
  26417. inspectableCustomProperties: IInspectable[];
  26418. /**
  26419. * Gets or sets a boolean used to define if the node must be serialized
  26420. */
  26421. doNotSerialize: boolean;
  26422. /** @hidden */ private _isDisposed: boolean;
  26423. /**
  26424. * Gets a list of Animations associated with the node
  26425. */
  26426. animations: Animation[];
  26427. protected _ranges: {
  26428. [name: string]: Nullable<AnimationRange>;
  26429. };
  26430. /**
  26431. * Callback raised when the node is ready to be used
  26432. */
  26433. onReady: Nullable<(node: Node) => void>;
  26434. private _isEnabled;
  26435. private _isParentEnabled;
  26436. private _isReady;
  26437. /** @hidden */ private _currentRenderId: number;
  26438. private _parentUpdateId;
  26439. /** @hidden */ private _childUpdateId: number;
  26440. /** @hidden */ private _waitingParentId: Nullable<string>;
  26441. /** @hidden */ private _scene: Scene;
  26442. /** @hidden */ private _cache: any;
  26443. private _parentNode;
  26444. private _children;
  26445. /** @hidden */ private _worldMatrix: Matrix;
  26446. /** @hidden */ private _worldMatrixDeterminant: number;
  26447. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26448. /** @hidden */
  26449. private _sceneRootNodesIndex;
  26450. /**
  26451. * Gets a boolean indicating if the node has been disposed
  26452. * @returns true if the node was disposed
  26453. */
  26454. isDisposed(): boolean;
  26455. /**
  26456. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26457. * @see https://doc.babylonjs.com/how_to/parenting
  26458. */
  26459. parent: Nullable<Node>;
  26460. private addToSceneRootNodes;
  26461. private removeFromSceneRootNodes;
  26462. private _animationPropertiesOverride;
  26463. /**
  26464. * Gets or sets the animation properties override
  26465. */
  26466. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26467. /**
  26468. * Gets a string idenfifying the name of the class
  26469. * @returns "Node" string
  26470. */
  26471. getClassName(): string;
  26472. /** @hidden */ protected readonly _isNode: boolean;
  26473. /**
  26474. * An event triggered when the mesh is disposed
  26475. */
  26476. onDisposeObservable: Observable<Node>;
  26477. private _onDisposeObserver;
  26478. /**
  26479. * Sets a callback that will be raised when the node will be disposed
  26480. */
  26481. onDispose: () => void;
  26482. /**
  26483. * Creates a new Node
  26484. * @param name the name and id to be given to this node
  26485. * @param scene the scene this node will be added to
  26486. * @param addToRootNodes the node will be added to scene.rootNodes
  26487. */
  26488. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26489. /**
  26490. * Gets the scene of the node
  26491. * @returns a scene
  26492. */
  26493. getScene(): Scene;
  26494. /**
  26495. * Gets the engine of the node
  26496. * @returns a Engine
  26497. */
  26498. getEngine(): Engine;
  26499. private _behaviors;
  26500. /**
  26501. * Attach a behavior to the node
  26502. * @see http://doc.babylonjs.com/features/behaviour
  26503. * @param behavior defines the behavior to attach
  26504. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26505. * @returns the current Node
  26506. */
  26507. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26508. /**
  26509. * Remove an attached behavior
  26510. * @see http://doc.babylonjs.com/features/behaviour
  26511. * @param behavior defines the behavior to attach
  26512. * @returns the current Node
  26513. */
  26514. removeBehavior(behavior: Behavior<Node>): Node;
  26515. /**
  26516. * Gets the list of attached behaviors
  26517. * @see http://doc.babylonjs.com/features/behaviour
  26518. */
  26519. readonly behaviors: Behavior<Node>[];
  26520. /**
  26521. * Gets an attached behavior by name
  26522. * @param name defines the name of the behavior to look for
  26523. * @see http://doc.babylonjs.com/features/behaviour
  26524. * @returns null if behavior was not found else the requested behavior
  26525. */
  26526. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26527. /**
  26528. * Returns the latest update of the World matrix
  26529. * @returns a Matrix
  26530. */
  26531. getWorldMatrix(): Matrix;
  26532. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26533. /**
  26534. * Returns directly the latest state of the mesh World matrix.
  26535. * A Matrix is returned.
  26536. */
  26537. readonly worldMatrixFromCache: Matrix;
  26538. /** @hidden */ private _initCache(): void;
  26539. /** @hidden */
  26540. updateCache(force?: boolean): void;
  26541. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26542. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26543. /** @hidden */ private _isSynchronized(): boolean;
  26544. /** @hidden */ private _markSyncedWithParent(): void;
  26545. /** @hidden */
  26546. isSynchronizedWithParent(): boolean;
  26547. /** @hidden */
  26548. isSynchronized(): boolean;
  26549. /**
  26550. * Is this node ready to be used/rendered
  26551. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26552. * @return true if the node is ready
  26553. */
  26554. isReady(completeCheck?: boolean): boolean;
  26555. /**
  26556. * Is this node enabled?
  26557. * 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
  26558. * @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
  26559. * @return whether this node (and its parent) is enabled
  26560. */
  26561. isEnabled(checkAncestors?: boolean): boolean;
  26562. /** @hidden */
  26563. protected _syncParentEnabledState(): void;
  26564. /**
  26565. * Set the enabled state of this node
  26566. * @param value defines the new enabled state
  26567. */
  26568. setEnabled(value: boolean): void;
  26569. /**
  26570. * Is this node a descendant of the given node?
  26571. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26572. * @param ancestor defines the parent node to inspect
  26573. * @returns a boolean indicating if this node is a descendant of the given node
  26574. */
  26575. isDescendantOf(ancestor: Node): boolean;
  26576. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26577. /**
  26578. * Will return all nodes that have this node as ascendant
  26579. * @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
  26580. * @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
  26581. * @return all children nodes of all types
  26582. */
  26583. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26584. /**
  26585. * Get all child-meshes of this node
  26586. * @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)
  26587. * @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
  26588. * @returns an array of AbstractMesh
  26589. */
  26590. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26591. /**
  26592. * Get all direct children of this node
  26593. * @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
  26594. * @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)
  26595. * @returns an array of Node
  26596. */
  26597. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26598. /** @hidden */ private _setReady(state: boolean): void;
  26599. /**
  26600. * Get an animation by name
  26601. * @param name defines the name of the animation to look for
  26602. * @returns null if not found else the requested animation
  26603. */
  26604. getAnimationByName(name: string): Nullable<Animation>;
  26605. /**
  26606. * Creates an animation range for this node
  26607. * @param name defines the name of the range
  26608. * @param from defines the starting key
  26609. * @param to defines the end key
  26610. */
  26611. createAnimationRange(name: string, from: number, to: number): void;
  26612. /**
  26613. * Delete a specific animation range
  26614. * @param name defines the name of the range to delete
  26615. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26616. */
  26617. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26618. /**
  26619. * Get an animation range by name
  26620. * @param name defines the name of the animation range to look for
  26621. * @returns null if not found else the requested animation range
  26622. */
  26623. getAnimationRange(name: string): Nullable<AnimationRange>;
  26624. /**
  26625. * Gets the list of all animation ranges defined on this node
  26626. * @returns an array
  26627. */
  26628. getAnimationRanges(): Nullable<AnimationRange>[];
  26629. /**
  26630. * Will start the animation sequence
  26631. * @param name defines the range frames for animation sequence
  26632. * @param loop defines if the animation should loop (false by default)
  26633. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26634. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26635. * @returns the object created for this animation. If range does not exist, it will return null
  26636. */
  26637. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26638. /**
  26639. * Serialize animation ranges into a JSON compatible object
  26640. * @returns serialization object
  26641. */
  26642. serializeAnimationRanges(): any;
  26643. /**
  26644. * Computes the world matrix of the node
  26645. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26646. * @returns the world matrix
  26647. */
  26648. computeWorldMatrix(force?: boolean): Matrix;
  26649. /**
  26650. * Releases resources associated with this node.
  26651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26653. */
  26654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26655. /**
  26656. * Parse animation range data from a serialization object and store them into a given node
  26657. * @param node defines where to store the animation ranges
  26658. * @param parsedNode defines the serialization object to read data from
  26659. * @param scene defines the hosting scene
  26660. */
  26661. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26662. /**
  26663. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26664. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26665. * @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
  26666. * @returns the new bounding vectors
  26667. */
  26668. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26669. min: Vector3;
  26670. max: Vector3;
  26671. };
  26672. }
  26673. }
  26674. declare module BABYLON {
  26675. /**
  26676. * @hidden
  26677. */
  26678. export class _IAnimationState {
  26679. key: number;
  26680. repeatCount: number;
  26681. workValue?: any;
  26682. loopMode?: number;
  26683. offsetValue?: any;
  26684. highLimitValue?: any;
  26685. }
  26686. /**
  26687. * Class used to store any kind of animation
  26688. */
  26689. export class Animation {
  26690. /**Name of the animation */
  26691. name: string;
  26692. /**Property to animate */
  26693. targetProperty: string;
  26694. /**The frames per second of the animation */
  26695. framePerSecond: number;
  26696. /**The data type of the animation */
  26697. dataType: number;
  26698. /**The loop mode of the animation */
  26699. loopMode?: number | undefined;
  26700. /**Specifies if blending should be enabled */
  26701. enableBlending?: boolean | undefined;
  26702. /**
  26703. * Use matrix interpolation instead of using direct key value when animating matrices
  26704. */
  26705. static AllowMatricesInterpolation: boolean;
  26706. /**
  26707. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26708. */
  26709. static AllowMatrixDecomposeForInterpolation: boolean;
  26710. /**
  26711. * Stores the key frames of the animation
  26712. */
  26713. private _keys;
  26714. /**
  26715. * Stores the easing function of the animation
  26716. */
  26717. private _easingFunction;
  26718. /**
  26719. * @hidden Internal use only
  26720. */ private _runtimeAnimations: RuntimeAnimation[];
  26721. /**
  26722. * The set of event that will be linked to this animation
  26723. */
  26724. private _events;
  26725. /**
  26726. * Stores an array of target property paths
  26727. */
  26728. targetPropertyPath: string[];
  26729. /**
  26730. * Stores the blending speed of the animation
  26731. */
  26732. blendingSpeed: number;
  26733. /**
  26734. * Stores the animation ranges for the animation
  26735. */
  26736. private _ranges;
  26737. /**
  26738. * @hidden Internal use
  26739. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26740. /**
  26741. * Sets up an animation
  26742. * @param property The property to animate
  26743. * @param animationType The animation type to apply
  26744. * @param framePerSecond The frames per second of the animation
  26745. * @param easingFunction The easing function used in the animation
  26746. * @returns The created animation
  26747. */
  26748. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26749. /**
  26750. * Create and start an animation on a node
  26751. * @param name defines the name of the global animation that will be run on all nodes
  26752. * @param node defines the root node where the animation will take place
  26753. * @param targetProperty defines property to animate
  26754. * @param framePerSecond defines the number of frame per second yo use
  26755. * @param totalFrame defines the number of frames in total
  26756. * @param from defines the initial value
  26757. * @param to defines the final value
  26758. * @param loopMode defines which loop mode you want to use (off by default)
  26759. * @param easingFunction defines the easing function to use (linear by default)
  26760. * @param onAnimationEnd defines the callback to call when animation end
  26761. * @returns the animatable created for this animation
  26762. */
  26763. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26764. /**
  26765. * Create and start an animation on a node and its descendants
  26766. * @param name defines the name of the global animation that will be run on all nodes
  26767. * @param node defines the root node where the animation will take place
  26768. * @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
  26769. * @param targetProperty defines property to animate
  26770. * @param framePerSecond defines the number of frame per second to use
  26771. * @param totalFrame defines the number of frames in total
  26772. * @param from defines the initial value
  26773. * @param to defines the final value
  26774. * @param loopMode defines which loop mode you want to use (off by default)
  26775. * @param easingFunction defines the easing function to use (linear by default)
  26776. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26777. * @returns the list of animatables created for all nodes
  26778. * @example https://www.babylonjs-playground.com/#MH0VLI
  26779. */
  26780. 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[]>;
  26781. /**
  26782. * Creates a new animation, merges it with the existing animations and starts it
  26783. * @param name Name of the animation
  26784. * @param node Node which contains the scene that begins the animations
  26785. * @param targetProperty Specifies which property to animate
  26786. * @param framePerSecond The frames per second of the animation
  26787. * @param totalFrame The total number of frames
  26788. * @param from The frame at the beginning of the animation
  26789. * @param to The frame at the end of the animation
  26790. * @param loopMode Specifies the loop mode of the animation
  26791. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26792. * @param onAnimationEnd Callback to run once the animation is complete
  26793. * @returns Nullable animation
  26794. */
  26795. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26796. /**
  26797. * Transition property of an host to the target Value
  26798. * @param property The property to transition
  26799. * @param targetValue The target Value of the property
  26800. * @param host The object where the property to animate belongs
  26801. * @param scene Scene used to run the animation
  26802. * @param frameRate Framerate (in frame/s) to use
  26803. * @param transition The transition type we want to use
  26804. * @param duration The duration of the animation, in milliseconds
  26805. * @param onAnimationEnd Callback trigger at the end of the animation
  26806. * @returns Nullable animation
  26807. */
  26808. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26809. /**
  26810. * Return the array of runtime animations currently using this animation
  26811. */
  26812. readonly runtimeAnimations: RuntimeAnimation[];
  26813. /**
  26814. * Specifies if any of the runtime animations are currently running
  26815. */
  26816. readonly hasRunningRuntimeAnimations: boolean;
  26817. /**
  26818. * Initializes the animation
  26819. * @param name Name of the animation
  26820. * @param targetProperty Property to animate
  26821. * @param framePerSecond The frames per second of the animation
  26822. * @param dataType The data type of the animation
  26823. * @param loopMode The loop mode of the animation
  26824. * @param enableBlending Specifies if blending should be enabled
  26825. */
  26826. constructor(
  26827. /**Name of the animation */
  26828. name: string,
  26829. /**Property to animate */
  26830. targetProperty: string,
  26831. /**The frames per second of the animation */
  26832. framePerSecond: number,
  26833. /**The data type of the animation */
  26834. dataType: number,
  26835. /**The loop mode of the animation */
  26836. loopMode?: number | undefined,
  26837. /**Specifies if blending should be enabled */
  26838. enableBlending?: boolean | undefined);
  26839. /**
  26840. * Converts the animation to a string
  26841. * @param fullDetails support for multiple levels of logging within scene loading
  26842. * @returns String form of the animation
  26843. */
  26844. toString(fullDetails?: boolean): string;
  26845. /**
  26846. * Add an event to this animation
  26847. * @param event Event to add
  26848. */
  26849. addEvent(event: AnimationEvent): void;
  26850. /**
  26851. * Remove all events found at the given frame
  26852. * @param frame The frame to remove events from
  26853. */
  26854. removeEvents(frame: number): void;
  26855. /**
  26856. * Retrieves all the events from the animation
  26857. * @returns Events from the animation
  26858. */
  26859. getEvents(): AnimationEvent[];
  26860. /**
  26861. * Creates an animation range
  26862. * @param name Name of the animation range
  26863. * @param from Starting frame of the animation range
  26864. * @param to Ending frame of the animation
  26865. */
  26866. createRange(name: string, from: number, to: number): void;
  26867. /**
  26868. * Deletes an animation range by name
  26869. * @param name Name of the animation range to delete
  26870. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26871. */
  26872. deleteRange(name: string, deleteFrames?: boolean): void;
  26873. /**
  26874. * Gets the animation range by name, or null if not defined
  26875. * @param name Name of the animation range
  26876. * @returns Nullable animation range
  26877. */
  26878. getRange(name: string): Nullable<AnimationRange>;
  26879. /**
  26880. * Gets the key frames from the animation
  26881. * @returns The key frames of the animation
  26882. */
  26883. getKeys(): Array<IAnimationKey>;
  26884. /**
  26885. * Gets the highest frame rate of the animation
  26886. * @returns Highest frame rate of the animation
  26887. */
  26888. getHighestFrame(): number;
  26889. /**
  26890. * Gets the easing function of the animation
  26891. * @returns Easing function of the animation
  26892. */
  26893. getEasingFunction(): IEasingFunction;
  26894. /**
  26895. * Sets the easing function of the animation
  26896. * @param easingFunction A custom mathematical formula for animation
  26897. */
  26898. setEasingFunction(easingFunction: EasingFunction): void;
  26899. /**
  26900. * Interpolates a scalar linearly
  26901. * @param startValue Start value of the animation curve
  26902. * @param endValue End value of the animation curve
  26903. * @param gradient Scalar amount to interpolate
  26904. * @returns Interpolated scalar value
  26905. */
  26906. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26907. /**
  26908. * Interpolates a scalar cubically
  26909. * @param startValue Start value of the animation curve
  26910. * @param outTangent End tangent of the animation
  26911. * @param endValue End value of the animation curve
  26912. * @param inTangent Start tangent of the animation curve
  26913. * @param gradient Scalar amount to interpolate
  26914. * @returns Interpolated scalar value
  26915. */
  26916. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26917. /**
  26918. * Interpolates a quaternion using a spherical linear interpolation
  26919. * @param startValue Start value of the animation curve
  26920. * @param endValue End value of the animation curve
  26921. * @param gradient Scalar amount to interpolate
  26922. * @returns Interpolated quaternion value
  26923. */
  26924. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26925. /**
  26926. * Interpolates a quaternion cubically
  26927. * @param startValue Start value of the animation curve
  26928. * @param outTangent End tangent of the animation curve
  26929. * @param endValue End value of the animation curve
  26930. * @param inTangent Start tangent of the animation curve
  26931. * @param gradient Scalar amount to interpolate
  26932. * @returns Interpolated quaternion value
  26933. */
  26934. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26935. /**
  26936. * Interpolates a Vector3 linearl
  26937. * @param startValue Start value of the animation curve
  26938. * @param endValue End value of the animation curve
  26939. * @param gradient Scalar amount to interpolate
  26940. * @returns Interpolated scalar value
  26941. */
  26942. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26943. /**
  26944. * Interpolates a Vector3 cubically
  26945. * @param startValue Start value of the animation curve
  26946. * @param outTangent End tangent of the animation
  26947. * @param endValue End value of the animation curve
  26948. * @param inTangent Start tangent of the animation curve
  26949. * @param gradient Scalar amount to interpolate
  26950. * @returns InterpolatedVector3 value
  26951. */
  26952. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26953. /**
  26954. * Interpolates a Vector2 linearly
  26955. * @param startValue Start value of the animation curve
  26956. * @param endValue End value of the animation curve
  26957. * @param gradient Scalar amount to interpolate
  26958. * @returns Interpolated Vector2 value
  26959. */
  26960. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26961. /**
  26962. * Interpolates a Vector2 cubically
  26963. * @param startValue Start value of the animation curve
  26964. * @param outTangent End tangent of the animation
  26965. * @param endValue End value of the animation curve
  26966. * @param inTangent Start tangent of the animation curve
  26967. * @param gradient Scalar amount to interpolate
  26968. * @returns Interpolated Vector2 value
  26969. */
  26970. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26971. /**
  26972. * Interpolates a size linearly
  26973. * @param startValue Start value of the animation curve
  26974. * @param endValue End value of the animation curve
  26975. * @param gradient Scalar amount to interpolate
  26976. * @returns Interpolated Size value
  26977. */
  26978. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26979. /**
  26980. * Interpolates a Color3 linearly
  26981. * @param startValue Start value of the animation curve
  26982. * @param endValue End value of the animation curve
  26983. * @param gradient Scalar amount to interpolate
  26984. * @returns Interpolated Color3 value
  26985. */
  26986. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26987. /**
  26988. * @hidden Internal use only
  26989. */ private _getKeyValue(value: any): any;
  26990. /**
  26991. * @hidden Internal use only
  26992. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26993. /**
  26994. * Defines the function to use to interpolate matrices
  26995. * @param startValue defines the start matrix
  26996. * @param endValue defines the end matrix
  26997. * @param gradient defines the gradient between both matrices
  26998. * @param result defines an optional target matrix where to store the interpolation
  26999. * @returns the interpolated matrix
  27000. */
  27001. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27002. /**
  27003. * Makes a copy of the animation
  27004. * @returns Cloned animation
  27005. */
  27006. clone(): Animation;
  27007. /**
  27008. * Sets the key frames of the animation
  27009. * @param values The animation key frames to set
  27010. */
  27011. setKeys(values: Array<IAnimationKey>): void;
  27012. /**
  27013. * Serializes the animation to an object
  27014. * @returns Serialized object
  27015. */
  27016. serialize(): any;
  27017. /**
  27018. * Float animation type
  27019. */
  27020. private static _ANIMATIONTYPE_FLOAT;
  27021. /**
  27022. * Vector3 animation type
  27023. */
  27024. private static _ANIMATIONTYPE_VECTOR3;
  27025. /**
  27026. * Quaternion animation type
  27027. */
  27028. private static _ANIMATIONTYPE_QUATERNION;
  27029. /**
  27030. * Matrix animation type
  27031. */
  27032. private static _ANIMATIONTYPE_MATRIX;
  27033. /**
  27034. * Color3 animation type
  27035. */
  27036. private static _ANIMATIONTYPE_COLOR3;
  27037. /**
  27038. * Vector2 animation type
  27039. */
  27040. private static _ANIMATIONTYPE_VECTOR2;
  27041. /**
  27042. * Size animation type
  27043. */
  27044. private static _ANIMATIONTYPE_SIZE;
  27045. /**
  27046. * Relative Loop Mode
  27047. */
  27048. private static _ANIMATIONLOOPMODE_RELATIVE;
  27049. /**
  27050. * Cycle Loop Mode
  27051. */
  27052. private static _ANIMATIONLOOPMODE_CYCLE;
  27053. /**
  27054. * Constant Loop Mode
  27055. */
  27056. private static _ANIMATIONLOOPMODE_CONSTANT;
  27057. /**
  27058. * Get the float animation type
  27059. */
  27060. static readonly ANIMATIONTYPE_FLOAT: number;
  27061. /**
  27062. * Get the Vector3 animation type
  27063. */
  27064. static readonly ANIMATIONTYPE_VECTOR3: number;
  27065. /**
  27066. * Get the Vector2 animation type
  27067. */
  27068. static readonly ANIMATIONTYPE_VECTOR2: number;
  27069. /**
  27070. * Get the Size animation type
  27071. */
  27072. static readonly ANIMATIONTYPE_SIZE: number;
  27073. /**
  27074. * Get the Quaternion animation type
  27075. */
  27076. static readonly ANIMATIONTYPE_QUATERNION: number;
  27077. /**
  27078. * Get the Matrix animation type
  27079. */
  27080. static readonly ANIMATIONTYPE_MATRIX: number;
  27081. /**
  27082. * Get the Color3 animation type
  27083. */
  27084. static readonly ANIMATIONTYPE_COLOR3: number;
  27085. /**
  27086. * Get the Relative Loop Mode
  27087. */
  27088. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27089. /**
  27090. * Get the Cycle Loop Mode
  27091. */
  27092. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27093. /**
  27094. * Get the Constant Loop Mode
  27095. */
  27096. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27097. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27098. /**
  27099. * Parses an animation object and creates an animation
  27100. * @param parsedAnimation Parsed animation object
  27101. * @returns Animation object
  27102. */
  27103. static Parse(parsedAnimation: any): Animation;
  27104. /**
  27105. * Appends the serialized animations from the source animations
  27106. * @param source Source containing the animations
  27107. * @param destination Target to store the animations
  27108. */
  27109. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27110. }
  27111. }
  27112. declare module BABYLON {
  27113. /**
  27114. * Interface containing an array of animations
  27115. */
  27116. export interface IAnimatable {
  27117. /**
  27118. * Array of animations
  27119. */
  27120. animations: Nullable<Array<Animation>>;
  27121. }
  27122. }
  27123. declare module BABYLON {
  27124. /**
  27125. * This represents all the required information to add a fresnel effect on a material:
  27126. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27127. */
  27128. export class FresnelParameters {
  27129. private _isEnabled;
  27130. /**
  27131. * Define if the fresnel effect is enable or not.
  27132. */
  27133. isEnabled: boolean;
  27134. /**
  27135. * Define the color used on edges (grazing angle)
  27136. */
  27137. leftColor: Color3;
  27138. /**
  27139. * Define the color used on center
  27140. */
  27141. rightColor: Color3;
  27142. /**
  27143. * Define bias applied to computed fresnel term
  27144. */
  27145. bias: number;
  27146. /**
  27147. * Defined the power exponent applied to fresnel term
  27148. */
  27149. power: number;
  27150. /**
  27151. * Clones the current fresnel and its valuues
  27152. * @returns a clone fresnel configuration
  27153. */
  27154. clone(): FresnelParameters;
  27155. /**
  27156. * Serializes the current fresnel parameters to a JSON representation.
  27157. * @return the JSON serialization
  27158. */
  27159. serialize(): any;
  27160. /**
  27161. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27162. * @param parsedFresnelParameters Define the JSON representation
  27163. * @returns the parsed parameters
  27164. */
  27165. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27166. }
  27167. }
  27168. declare module BABYLON {
  27169. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27170. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27171. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27172. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27173. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27174. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27175. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27176. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27177. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27178. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27179. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27180. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27181. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27182. /**
  27183. * Decorator used to define property that can be serialized as reference to a camera
  27184. * @param sourceName defines the name of the property to decorate
  27185. */
  27186. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27187. /**
  27188. * Class used to help serialization objects
  27189. */
  27190. export class SerializationHelper {
  27191. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27192. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27193. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27194. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27195. /**
  27196. * Appends the serialized animations from the source animations
  27197. * @param source Source containing the animations
  27198. * @param destination Target to store the animations
  27199. */
  27200. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27201. /**
  27202. * Static function used to serialized a specific entity
  27203. * @param entity defines the entity to serialize
  27204. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27205. * @returns a JSON compatible object representing the serialization of the entity
  27206. */
  27207. static Serialize<T>(entity: T, serializationObject?: any): any;
  27208. /**
  27209. * Creates a new entity from a serialization data object
  27210. * @param creationFunction defines a function used to instanciated the new entity
  27211. * @param source defines the source serialization data
  27212. * @param scene defines the hosting scene
  27213. * @param rootUrl defines the root url for resources
  27214. * @returns a new entity
  27215. */
  27216. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27217. /**
  27218. * Clones an object
  27219. * @param creationFunction defines the function used to instanciate the new object
  27220. * @param source defines the source object
  27221. * @returns the cloned object
  27222. */
  27223. static Clone<T>(creationFunction: () => T, source: T): T;
  27224. /**
  27225. * Instanciates a new object based on a source one (some data will be shared between both object)
  27226. * @param creationFunction defines the function used to instanciate the new object
  27227. * @param source defines the source object
  27228. * @returns the new object
  27229. */
  27230. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27231. }
  27232. }
  27233. declare module BABYLON {
  27234. /**
  27235. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27236. */
  27237. export interface CubeMapInfo {
  27238. /**
  27239. * The pixel array for the front face.
  27240. * This is stored in format, left to right, up to down format.
  27241. */
  27242. front: Nullable<ArrayBufferView>;
  27243. /**
  27244. * The pixel array for the back face.
  27245. * This is stored in format, left to right, up to down format.
  27246. */
  27247. back: Nullable<ArrayBufferView>;
  27248. /**
  27249. * The pixel array for the left face.
  27250. * This is stored in format, left to right, up to down format.
  27251. */
  27252. left: Nullable<ArrayBufferView>;
  27253. /**
  27254. * The pixel array for the right face.
  27255. * This is stored in format, left to right, up to down format.
  27256. */
  27257. right: Nullable<ArrayBufferView>;
  27258. /**
  27259. * The pixel array for the up face.
  27260. * This is stored in format, left to right, up to down format.
  27261. */
  27262. up: Nullable<ArrayBufferView>;
  27263. /**
  27264. * The pixel array for the down face.
  27265. * This is stored in format, left to right, up to down format.
  27266. */
  27267. down: Nullable<ArrayBufferView>;
  27268. /**
  27269. * The size of the cubemap stored.
  27270. *
  27271. * Each faces will be size * size pixels.
  27272. */
  27273. size: number;
  27274. /**
  27275. * The format of the texture.
  27276. *
  27277. * RGBA, RGB.
  27278. */
  27279. format: number;
  27280. /**
  27281. * The type of the texture data.
  27282. *
  27283. * UNSIGNED_INT, FLOAT.
  27284. */
  27285. type: number;
  27286. /**
  27287. * Specifies whether the texture is in gamma space.
  27288. */
  27289. gammaSpace: boolean;
  27290. }
  27291. /**
  27292. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27293. */
  27294. export class PanoramaToCubeMapTools {
  27295. private static FACE_FRONT;
  27296. private static FACE_BACK;
  27297. private static FACE_RIGHT;
  27298. private static FACE_LEFT;
  27299. private static FACE_DOWN;
  27300. private static FACE_UP;
  27301. /**
  27302. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27303. *
  27304. * @param float32Array The source data.
  27305. * @param inputWidth The width of the input panorama.
  27306. * @param inputHeight The height of the input panorama.
  27307. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27308. * @return The cubemap data
  27309. */
  27310. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27311. private static CreateCubemapTexture;
  27312. private static CalcProjectionSpherical;
  27313. }
  27314. }
  27315. declare module BABYLON {
  27316. /**
  27317. * Helper class dealing with the extraction of spherical polynomial dataArray
  27318. * from a cube map.
  27319. */
  27320. export class CubeMapToSphericalPolynomialTools {
  27321. private static FileFaces;
  27322. /**
  27323. * Converts a texture to the according Spherical Polynomial data.
  27324. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27325. *
  27326. * @param texture The texture to extract the information from.
  27327. * @return The Spherical Polynomial data.
  27328. */
  27329. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27330. /**
  27331. * Converts a cubemap to the according Spherical Polynomial data.
  27332. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27333. *
  27334. * @param cubeInfo The Cube map to extract the information from.
  27335. * @return The Spherical Polynomial data.
  27336. */
  27337. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27338. }
  27339. }
  27340. declare module BABYLON {
  27341. /**
  27342. * Class used to manipulate GUIDs
  27343. */
  27344. export class GUID {
  27345. /**
  27346. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27347. * Be aware Math.random() could cause collisions, but:
  27348. * "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"
  27349. * @returns a pseudo random id
  27350. */
  27351. static RandomId(): string;
  27352. }
  27353. }
  27354. declare module BABYLON {
  27355. /**
  27356. * Base class of all the textures in babylon.
  27357. * It groups all the common properties the materials, post process, lights... might need
  27358. * in order to make a correct use of the texture.
  27359. */
  27360. export class BaseTexture implements IAnimatable {
  27361. /**
  27362. * Default anisotropic filtering level for the application.
  27363. * It is set to 4 as a good tradeoff between perf and quality.
  27364. */
  27365. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27366. /**
  27367. * Gets or sets the unique id of the texture
  27368. */
  27369. uniqueId: number;
  27370. /**
  27371. * Define the name of the texture.
  27372. */
  27373. name: string;
  27374. /**
  27375. * Gets or sets an object used to store user defined information.
  27376. */
  27377. metadata: any;
  27378. /**
  27379. * For internal use only. Please do not use.
  27380. */
  27381. reservedDataStore: any;
  27382. private _hasAlpha;
  27383. /**
  27384. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27385. */
  27386. hasAlpha: boolean;
  27387. /**
  27388. * Defines if the alpha value should be determined via the rgb values.
  27389. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27390. */
  27391. getAlphaFromRGB: boolean;
  27392. /**
  27393. * Intensity or strength of the texture.
  27394. * It is commonly used by materials to fine tune the intensity of the texture
  27395. */
  27396. level: number;
  27397. /**
  27398. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27399. * This is part of the texture as textures usually maps to one uv set.
  27400. */
  27401. coordinatesIndex: number;
  27402. private _coordinatesMode;
  27403. /**
  27404. * How a texture is mapped.
  27405. *
  27406. * | Value | Type | Description |
  27407. * | ----- | ----------------------------------- | ----------- |
  27408. * | 0 | EXPLICIT_MODE | |
  27409. * | 1 | SPHERICAL_MODE | |
  27410. * | 2 | PLANAR_MODE | |
  27411. * | 3 | CUBIC_MODE | |
  27412. * | 4 | PROJECTION_MODE | |
  27413. * | 5 | SKYBOX_MODE | |
  27414. * | 6 | INVCUBIC_MODE | |
  27415. * | 7 | EQUIRECTANGULAR_MODE | |
  27416. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27417. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27418. */
  27419. coordinatesMode: number;
  27420. /**
  27421. * | Value | Type | Description |
  27422. * | ----- | ------------------ | ----------- |
  27423. * | 0 | CLAMP_ADDRESSMODE | |
  27424. * | 1 | WRAP_ADDRESSMODE | |
  27425. * | 2 | MIRROR_ADDRESSMODE | |
  27426. */
  27427. wrapU: number;
  27428. /**
  27429. * | Value | Type | Description |
  27430. * | ----- | ------------------ | ----------- |
  27431. * | 0 | CLAMP_ADDRESSMODE | |
  27432. * | 1 | WRAP_ADDRESSMODE | |
  27433. * | 2 | MIRROR_ADDRESSMODE | |
  27434. */
  27435. wrapV: number;
  27436. /**
  27437. * | Value | Type | Description |
  27438. * | ----- | ------------------ | ----------- |
  27439. * | 0 | CLAMP_ADDRESSMODE | |
  27440. * | 1 | WRAP_ADDRESSMODE | |
  27441. * | 2 | MIRROR_ADDRESSMODE | |
  27442. */
  27443. wrapR: number;
  27444. /**
  27445. * With compliant hardware and browser (supporting anisotropic filtering)
  27446. * this defines the level of anisotropic filtering in the texture.
  27447. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27448. */
  27449. anisotropicFilteringLevel: number;
  27450. /**
  27451. * Define if the texture is a cube texture or if false a 2d texture.
  27452. */
  27453. isCube: boolean;
  27454. /**
  27455. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27456. */
  27457. is3D: boolean;
  27458. /**
  27459. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27460. * HDR texture are usually stored in linear space.
  27461. * This only impacts the PBR and Background materials
  27462. */
  27463. gammaSpace: boolean;
  27464. /**
  27465. * Gets or sets whether or not the texture contains RGBD data.
  27466. */
  27467. isRGBD: boolean;
  27468. /**
  27469. * Is Z inverted in the texture (useful in a cube texture).
  27470. */
  27471. invertZ: boolean;
  27472. /**
  27473. * Are mip maps generated for this texture or not.
  27474. */
  27475. readonly noMipmap: boolean;
  27476. /**
  27477. * @hidden
  27478. */
  27479. lodLevelInAlpha: boolean;
  27480. /**
  27481. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27482. */
  27483. lodGenerationOffset: number;
  27484. /**
  27485. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27486. */
  27487. lodGenerationScale: number;
  27488. /**
  27489. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27490. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27491. * average roughness values.
  27492. */
  27493. linearSpecularLOD: boolean;
  27494. /**
  27495. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27496. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27497. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27498. */
  27499. irradianceTexture: Nullable<BaseTexture>;
  27500. /**
  27501. * Define if the texture is a render target.
  27502. */
  27503. isRenderTarget: boolean;
  27504. /**
  27505. * Define the unique id of the texture in the scene.
  27506. */
  27507. readonly uid: string;
  27508. /**
  27509. * Return a string representation of the texture.
  27510. * @returns the texture as a string
  27511. */
  27512. toString(): string;
  27513. /**
  27514. * Get the class name of the texture.
  27515. * @returns "BaseTexture"
  27516. */
  27517. getClassName(): string;
  27518. /**
  27519. * Define the list of animation attached to the texture.
  27520. */
  27521. animations: Animation[];
  27522. /**
  27523. * An event triggered when the texture is disposed.
  27524. */
  27525. onDisposeObservable: Observable<BaseTexture>;
  27526. private _onDisposeObserver;
  27527. /**
  27528. * Callback triggered when the texture has been disposed.
  27529. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27530. */
  27531. onDispose: () => void;
  27532. /**
  27533. * Define the current state of the loading sequence when in delayed load mode.
  27534. */
  27535. delayLoadState: number;
  27536. private _scene;
  27537. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27538. private _uid;
  27539. /**
  27540. * Define if the texture is preventinga material to render or not.
  27541. * If not and the texture is not ready, the engine will use a default black texture instead.
  27542. */
  27543. readonly isBlocking: boolean;
  27544. /**
  27545. * Instantiates a new BaseTexture.
  27546. * Base class of all the textures in babylon.
  27547. * It groups all the common properties the materials, post process, lights... might need
  27548. * in order to make a correct use of the texture.
  27549. * @param scene Define the scene the texture blongs to
  27550. */
  27551. constructor(scene: Nullable<Scene>);
  27552. /**
  27553. * Get the scene the texture belongs to.
  27554. * @returns the scene or null if undefined
  27555. */
  27556. getScene(): Nullable<Scene>;
  27557. /**
  27558. * Get the texture transform matrix used to offset tile the texture for istance.
  27559. * @returns the transformation matrix
  27560. */
  27561. getTextureMatrix(): Matrix;
  27562. /**
  27563. * Get the texture reflection matrix used to rotate/transform the reflection.
  27564. * @returns the reflection matrix
  27565. */
  27566. getReflectionTextureMatrix(): Matrix;
  27567. /**
  27568. * Get the underlying lower level texture from Babylon.
  27569. * @returns the insternal texture
  27570. */
  27571. getInternalTexture(): Nullable<InternalTexture>;
  27572. /**
  27573. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27574. * @returns true if ready or not blocking
  27575. */
  27576. isReadyOrNotBlocking(): boolean;
  27577. /**
  27578. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27579. * @returns true if fully ready
  27580. */
  27581. isReady(): boolean;
  27582. private _cachedSize;
  27583. /**
  27584. * Get the size of the texture.
  27585. * @returns the texture size.
  27586. */
  27587. getSize(): ISize;
  27588. /**
  27589. * Get the base size of the texture.
  27590. * It can be different from the size if the texture has been resized for POT for instance
  27591. * @returns the base size
  27592. */
  27593. getBaseSize(): ISize;
  27594. /**
  27595. * Update the sampling mode of the texture.
  27596. * Default is Trilinear mode.
  27597. *
  27598. * | Value | Type | Description |
  27599. * | ----- | ------------------ | ----------- |
  27600. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27601. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27602. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27603. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27604. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27605. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27606. * | 7 | NEAREST_LINEAR | |
  27607. * | 8 | NEAREST_NEAREST | |
  27608. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27609. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27610. * | 11 | LINEAR_LINEAR | |
  27611. * | 12 | LINEAR_NEAREST | |
  27612. *
  27613. * > _mag_: magnification filter (close to the viewer)
  27614. * > _min_: minification filter (far from the viewer)
  27615. * > _mip_: filter used between mip map levels
  27616. *@param samplingMode Define the new sampling mode of the texture
  27617. */
  27618. updateSamplingMode(samplingMode: number): void;
  27619. /**
  27620. * Scales the texture if is `canRescale()`
  27621. * @param ratio the resize factor we want to use to rescale
  27622. */
  27623. scale(ratio: number): void;
  27624. /**
  27625. * Get if the texture can rescale.
  27626. */
  27627. readonly canRescale: boolean;
  27628. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27629. /** @hidden */ private _rebuild(): void;
  27630. /**
  27631. * Triggers the load sequence in delayed load mode.
  27632. */
  27633. delayLoad(): void;
  27634. /**
  27635. * Clones the texture.
  27636. * @returns the cloned texture
  27637. */
  27638. clone(): Nullable<BaseTexture>;
  27639. /**
  27640. * Get the texture underlying type (INT, FLOAT...)
  27641. */
  27642. readonly textureType: number;
  27643. /**
  27644. * Get the texture underlying format (RGB, RGBA...)
  27645. */
  27646. readonly textureFormat: number;
  27647. /**
  27648. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27649. * This will returns an RGBA array buffer containing either in values (0-255) or
  27650. * float values (0-1) depending of the underlying buffer type.
  27651. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27652. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27653. * @param buffer defines a user defined buffer to fill with data (can be null)
  27654. * @returns The Array buffer containing the pixels data.
  27655. */
  27656. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27657. /**
  27658. * Release and destroy the underlying lower level texture aka internalTexture.
  27659. */
  27660. releaseInternalTexture(): void;
  27661. /**
  27662. * Get the polynomial representation of the texture data.
  27663. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27664. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27665. */
  27666. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27667. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27668. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27669. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27670. /**
  27671. * Dispose the texture and release its associated resources.
  27672. */
  27673. dispose(): void;
  27674. /**
  27675. * Serialize the texture into a JSON representation that can be parsed later on.
  27676. * @returns the JSON representation of the texture
  27677. */
  27678. serialize(): any;
  27679. /**
  27680. * Helper function to be called back once a list of texture contains only ready textures.
  27681. * @param textures Define the list of textures to wait for
  27682. * @param callback Define the callback triggered once the entire list will be ready
  27683. */
  27684. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27685. }
  27686. }
  27687. declare module BABYLON {
  27688. /**
  27689. * Options to be used when creating an effect.
  27690. */
  27691. export class EffectCreationOptions {
  27692. /**
  27693. * Atrributes that will be used in the shader.
  27694. */
  27695. attributes: string[];
  27696. /**
  27697. * Uniform varible names that will be set in the shader.
  27698. */
  27699. uniformsNames: string[];
  27700. /**
  27701. * Uniform buffer varible names that will be set in the shader.
  27702. */
  27703. uniformBuffersNames: string[];
  27704. /**
  27705. * Sampler texture variable names that will be set in the shader.
  27706. */
  27707. samplers: string[];
  27708. /**
  27709. * Define statements that will be set in the shader.
  27710. */
  27711. defines: any;
  27712. /**
  27713. * Possible fallbacks for this effect to improve performance when needed.
  27714. */
  27715. fallbacks: Nullable<IEffectFallbacks>;
  27716. /**
  27717. * Callback that will be called when the shader is compiled.
  27718. */
  27719. onCompiled: Nullable<(effect: Effect) => void>;
  27720. /**
  27721. * Callback that will be called if an error occurs during shader compilation.
  27722. */
  27723. onError: Nullable<(effect: Effect, errors: string) => void>;
  27724. /**
  27725. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27726. */
  27727. indexParameters?: any;
  27728. /**
  27729. * Max number of lights that can be used in the shader.
  27730. */
  27731. maxSimultaneousLights?: number;
  27732. /**
  27733. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27734. */
  27735. transformFeedbackVaryings?: Nullable<string[]>;
  27736. }
  27737. /**
  27738. * Effect containing vertex and fragment shader that can be executed on an object.
  27739. */
  27740. export class Effect implements IDisposable {
  27741. /**
  27742. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27743. */
  27744. static ShadersRepository: string;
  27745. /**
  27746. * Name of the effect.
  27747. */
  27748. name: any;
  27749. /**
  27750. * String container all the define statements that should be set on the shader.
  27751. */
  27752. defines: string;
  27753. /**
  27754. * Callback that will be called when the shader is compiled.
  27755. */
  27756. onCompiled: Nullable<(effect: Effect) => void>;
  27757. /**
  27758. * Callback that will be called if an error occurs during shader compilation.
  27759. */
  27760. onError: Nullable<(effect: Effect, errors: string) => void>;
  27761. /**
  27762. * Callback that will be called when effect is bound.
  27763. */
  27764. onBind: Nullable<(effect: Effect) => void>;
  27765. /**
  27766. * Unique ID of the effect.
  27767. */
  27768. uniqueId: number;
  27769. /**
  27770. * Observable that will be called when the shader is compiled.
  27771. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27772. */
  27773. onCompileObservable: Observable<Effect>;
  27774. /**
  27775. * Observable that will be called if an error occurs during shader compilation.
  27776. */
  27777. onErrorObservable: Observable<Effect>;
  27778. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27779. /**
  27780. * Observable that will be called when effect is bound.
  27781. */
  27782. readonly onBindObservable: Observable<Effect>;
  27783. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27784. private static _uniqueIdSeed;
  27785. private _engine;
  27786. private _uniformBuffersNames;
  27787. private _uniformsNames;
  27788. private _samplerList;
  27789. private _samplers;
  27790. private _isReady;
  27791. private _compilationError;
  27792. private _attributesNames;
  27793. private _attributes;
  27794. private _uniforms;
  27795. /**
  27796. * Key for the effect.
  27797. * @hidden
  27798. */ private _key: string;
  27799. private _indexParameters;
  27800. private _fallbacks;
  27801. private _vertexSourceCode;
  27802. private _fragmentSourceCode;
  27803. private _vertexSourceCodeOverride;
  27804. private _fragmentSourceCodeOverride;
  27805. private _transformFeedbackVaryings;
  27806. /**
  27807. * Compiled shader to webGL program.
  27808. * @hidden
  27809. */ private _pipelineContext: Nullable<IPipelineContext>;
  27810. private _valueCache;
  27811. private static _baseCache;
  27812. /**
  27813. * Instantiates an effect.
  27814. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27815. * @param baseName Name of the effect.
  27816. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27817. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27818. * @param samplers List of sampler variables that will be passed to the shader.
  27819. * @param engine Engine to be used to render the effect
  27820. * @param defines Define statements to be added to the shader.
  27821. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27822. * @param onCompiled Callback that will be called when the shader is compiled.
  27823. * @param onError Callback that will be called if an error occurs during shader compilation.
  27824. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27825. */
  27826. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27827. private _useFinalCode;
  27828. /**
  27829. * Unique key for this effect
  27830. */
  27831. readonly key: string;
  27832. /**
  27833. * If the effect has been compiled and prepared.
  27834. * @returns if the effect is compiled and prepared.
  27835. */
  27836. isReady(): boolean;
  27837. private _isReadyInternal;
  27838. /**
  27839. * The engine the effect was initialized with.
  27840. * @returns the engine.
  27841. */
  27842. getEngine(): Engine;
  27843. /**
  27844. * The pipeline context for this effect
  27845. * @returns the associated pipeline context
  27846. */
  27847. getPipelineContext(): Nullable<IPipelineContext>;
  27848. /**
  27849. * The set of names of attribute variables for the shader.
  27850. * @returns An array of attribute names.
  27851. */
  27852. getAttributesNames(): string[];
  27853. /**
  27854. * Returns the attribute at the given index.
  27855. * @param index The index of the attribute.
  27856. * @returns The location of the attribute.
  27857. */
  27858. getAttributeLocation(index: number): number;
  27859. /**
  27860. * Returns the attribute based on the name of the variable.
  27861. * @param name of the attribute to look up.
  27862. * @returns the attribute location.
  27863. */
  27864. getAttributeLocationByName(name: string): number;
  27865. /**
  27866. * The number of attributes.
  27867. * @returns the numnber of attributes.
  27868. */
  27869. getAttributesCount(): number;
  27870. /**
  27871. * Gets the index of a uniform variable.
  27872. * @param uniformName of the uniform to look up.
  27873. * @returns the index.
  27874. */
  27875. getUniformIndex(uniformName: string): number;
  27876. /**
  27877. * Returns the attribute based on the name of the variable.
  27878. * @param uniformName of the uniform to look up.
  27879. * @returns the location of the uniform.
  27880. */
  27881. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27882. /**
  27883. * Returns an array of sampler variable names
  27884. * @returns The array of sampler variable neames.
  27885. */
  27886. getSamplers(): string[];
  27887. /**
  27888. * The error from the last compilation.
  27889. * @returns the error string.
  27890. */
  27891. getCompilationError(): string;
  27892. /**
  27893. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27894. * @param func The callback to be used.
  27895. */
  27896. executeWhenCompiled(func: (effect: Effect) => void): void;
  27897. private _checkIsReady;
  27898. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27899. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27900. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27901. /**
  27902. * Recompiles the webGL program
  27903. * @param vertexSourceCode The source code for the vertex shader.
  27904. * @param fragmentSourceCode The source code for the fragment shader.
  27905. * @param onCompiled Callback called when completed.
  27906. * @param onError Callback called on error.
  27907. * @hidden
  27908. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27909. /**
  27910. * Prepares the effect
  27911. * @hidden
  27912. */ private _prepareEffect(): void;
  27913. private _processCompilationErrors;
  27914. /**
  27915. * Checks if the effect is supported. (Must be called after compilation)
  27916. */
  27917. readonly isSupported: boolean;
  27918. /**
  27919. * Binds a texture to the engine to be used as output of the shader.
  27920. * @param channel Name of the output variable.
  27921. * @param texture Texture to bind.
  27922. * @hidden
  27923. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27924. /**
  27925. * Sets a texture on the engine to be used in the shader.
  27926. * @param channel Name of the sampler variable.
  27927. * @param texture Texture to set.
  27928. */
  27929. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27930. /**
  27931. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27932. * @param channel Name of the sampler variable.
  27933. * @param texture Texture to set.
  27934. */
  27935. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27936. /**
  27937. * Sets an array of textures on the engine to be used in the shader.
  27938. * @param channel Name of the variable.
  27939. * @param textures Textures to set.
  27940. */
  27941. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27942. /**
  27943. * 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)
  27944. * @param channel Name of the sampler variable.
  27945. * @param postProcess Post process to get the input texture from.
  27946. */
  27947. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27948. /**
  27949. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27950. * 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)
  27951. * @param channel Name of the sampler variable.
  27952. * @param postProcess Post process to get the output texture from.
  27953. */
  27954. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27955. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27956. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27957. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27958. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27959. /**
  27960. * Binds a buffer to a uniform.
  27961. * @param buffer Buffer to bind.
  27962. * @param name Name of the uniform variable to bind to.
  27963. */
  27964. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27965. /**
  27966. * Binds block to a uniform.
  27967. * @param blockName Name of the block to bind.
  27968. * @param index Index to bind.
  27969. */
  27970. bindUniformBlock(blockName: string, index: number): void;
  27971. /**
  27972. * Sets an interger value on a uniform variable.
  27973. * @param uniformName Name of the variable.
  27974. * @param value Value to be set.
  27975. * @returns this effect.
  27976. */
  27977. setInt(uniformName: string, value: number): Effect;
  27978. /**
  27979. * Sets an int array on a uniform variable.
  27980. * @param uniformName Name of the variable.
  27981. * @param array array to be set.
  27982. * @returns this effect.
  27983. */
  27984. setIntArray(uniformName: string, array: Int32Array): Effect;
  27985. /**
  27986. * 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)
  27987. * @param uniformName Name of the variable.
  27988. * @param array array to be set.
  27989. * @returns this effect.
  27990. */
  27991. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27992. /**
  27993. * 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)
  27994. * @param uniformName Name of the variable.
  27995. * @param array array to be set.
  27996. * @returns this effect.
  27997. */
  27998. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27999. /**
  28000. * 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)
  28001. * @param uniformName Name of the variable.
  28002. * @param array array to be set.
  28003. * @returns this effect.
  28004. */
  28005. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28006. /**
  28007. * Sets an float array on a uniform variable.
  28008. * @param uniformName Name of the variable.
  28009. * @param array array to be set.
  28010. * @returns this effect.
  28011. */
  28012. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28013. /**
  28014. * 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)
  28015. * @param uniformName Name of the variable.
  28016. * @param array array to be set.
  28017. * @returns this effect.
  28018. */
  28019. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28020. /**
  28021. * 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)
  28022. * @param uniformName Name of the variable.
  28023. * @param array array to be set.
  28024. * @returns this effect.
  28025. */
  28026. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28027. /**
  28028. * 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)
  28029. * @param uniformName Name of the variable.
  28030. * @param array array to be set.
  28031. * @returns this effect.
  28032. */
  28033. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28034. /**
  28035. * Sets an array on a uniform variable.
  28036. * @param uniformName Name of the variable.
  28037. * @param array array to be set.
  28038. * @returns this effect.
  28039. */
  28040. setArray(uniformName: string, array: number[]): Effect;
  28041. /**
  28042. * 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)
  28043. * @param uniformName Name of the variable.
  28044. * @param array array to be set.
  28045. * @returns this effect.
  28046. */
  28047. setArray2(uniformName: string, array: number[]): Effect;
  28048. /**
  28049. * 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)
  28050. * @param uniformName Name of the variable.
  28051. * @param array array to be set.
  28052. * @returns this effect.
  28053. */
  28054. setArray3(uniformName: string, array: number[]): Effect;
  28055. /**
  28056. * 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)
  28057. * @param uniformName Name of the variable.
  28058. * @param array array to be set.
  28059. * @returns this effect.
  28060. */
  28061. setArray4(uniformName: string, array: number[]): Effect;
  28062. /**
  28063. * Sets matrices on a uniform variable.
  28064. * @param uniformName Name of the variable.
  28065. * @param matrices matrices to be set.
  28066. * @returns this effect.
  28067. */
  28068. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28069. /**
  28070. * Sets matrix on a uniform variable.
  28071. * @param uniformName Name of the variable.
  28072. * @param matrix matrix to be set.
  28073. * @returns this effect.
  28074. */
  28075. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28076. /**
  28077. * 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)
  28078. * @param uniformName Name of the variable.
  28079. * @param matrix matrix to be set.
  28080. * @returns this effect.
  28081. */
  28082. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28083. /**
  28084. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28085. * @param uniformName Name of the variable.
  28086. * @param matrix matrix to be set.
  28087. * @returns this effect.
  28088. */
  28089. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28090. /**
  28091. * Sets a float on a uniform variable.
  28092. * @param uniformName Name of the variable.
  28093. * @param value value to be set.
  28094. * @returns this effect.
  28095. */
  28096. setFloat(uniformName: string, value: number): Effect;
  28097. /**
  28098. * Sets a boolean on a uniform variable.
  28099. * @param uniformName Name of the variable.
  28100. * @param bool value to be set.
  28101. * @returns this effect.
  28102. */
  28103. setBool(uniformName: string, bool: boolean): Effect;
  28104. /**
  28105. * Sets a Vector2 on a uniform variable.
  28106. * @param uniformName Name of the variable.
  28107. * @param vector2 vector2 to be set.
  28108. * @returns this effect.
  28109. */
  28110. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28111. /**
  28112. * Sets a float2 on a uniform variable.
  28113. * @param uniformName Name of the variable.
  28114. * @param x First float in float2.
  28115. * @param y Second float in float2.
  28116. * @returns this effect.
  28117. */
  28118. setFloat2(uniformName: string, x: number, y: number): Effect;
  28119. /**
  28120. * Sets a Vector3 on a uniform variable.
  28121. * @param uniformName Name of the variable.
  28122. * @param vector3 Value to be set.
  28123. * @returns this effect.
  28124. */
  28125. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28126. /**
  28127. * Sets a float3 on a uniform variable.
  28128. * @param uniformName Name of the variable.
  28129. * @param x First float in float3.
  28130. * @param y Second float in float3.
  28131. * @param z Third float in float3.
  28132. * @returns this effect.
  28133. */
  28134. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28135. /**
  28136. * Sets a Vector4 on a uniform variable.
  28137. * @param uniformName Name of the variable.
  28138. * @param vector4 Value to be set.
  28139. * @returns this effect.
  28140. */
  28141. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28142. /**
  28143. * Sets a float4 on a uniform variable.
  28144. * @param uniformName Name of the variable.
  28145. * @param x First float in float4.
  28146. * @param y Second float in float4.
  28147. * @param z Third float in float4.
  28148. * @param w Fourth float in float4.
  28149. * @returns this effect.
  28150. */
  28151. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28152. /**
  28153. * Sets a Color3 on a uniform variable.
  28154. * @param uniformName Name of the variable.
  28155. * @param color3 Value to be set.
  28156. * @returns this effect.
  28157. */
  28158. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28159. /**
  28160. * Sets a Color4 on a uniform variable.
  28161. * @param uniformName Name of the variable.
  28162. * @param color3 Value to be set.
  28163. * @param alpha Alpha value to be set.
  28164. * @returns this effect.
  28165. */
  28166. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28167. /**
  28168. * Sets a Color4 on a uniform variable
  28169. * @param uniformName defines the name of the variable
  28170. * @param color4 defines the value to be set
  28171. * @returns this effect.
  28172. */
  28173. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28174. /** Release all associated resources */
  28175. dispose(): void;
  28176. /**
  28177. * This function will add a new shader to the shader store
  28178. * @param name the name of the shader
  28179. * @param pixelShader optional pixel shader content
  28180. * @param vertexShader optional vertex shader content
  28181. */
  28182. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28183. /**
  28184. * Store of each shader (The can be looked up using effect.key)
  28185. */
  28186. static ShadersStore: {
  28187. [key: string]: string;
  28188. };
  28189. /**
  28190. * Store of each included file for a shader (The can be looked up using effect.key)
  28191. */
  28192. static IncludesShadersStore: {
  28193. [key: string]: string;
  28194. };
  28195. /**
  28196. * Resets the cache of effects.
  28197. */
  28198. static ResetCache(): void;
  28199. }
  28200. }
  28201. declare module BABYLON {
  28202. /**
  28203. * Class used to describe the capabilities of the engine relatively to the current browser
  28204. */
  28205. export class EngineCapabilities {
  28206. /** Maximum textures units per fragment shader */
  28207. maxTexturesImageUnits: number;
  28208. /** Maximum texture units per vertex shader */
  28209. maxVertexTextureImageUnits: number;
  28210. /** Maximum textures units in the entire pipeline */
  28211. maxCombinedTexturesImageUnits: number;
  28212. /** Maximum texture size */
  28213. maxTextureSize: number;
  28214. /** Maximum cube texture size */
  28215. maxCubemapTextureSize: number;
  28216. /** Maximum render texture size */
  28217. maxRenderTextureSize: number;
  28218. /** Maximum number of vertex attributes */
  28219. maxVertexAttribs: number;
  28220. /** Maximum number of varyings */
  28221. maxVaryingVectors: number;
  28222. /** Maximum number of uniforms per vertex shader */
  28223. maxVertexUniformVectors: number;
  28224. /** Maximum number of uniforms per fragment shader */
  28225. maxFragmentUniformVectors: number;
  28226. /** Defines if standard derivates (dx/dy) are supported */
  28227. standardDerivatives: boolean;
  28228. /** Defines if s3tc texture compression is supported */
  28229. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28230. /** Defines if pvrtc texture compression is supported */
  28231. pvrtc: any;
  28232. /** Defines if etc1 texture compression is supported */
  28233. etc1: any;
  28234. /** Defines if etc2 texture compression is supported */
  28235. etc2: any;
  28236. /** Defines if astc texture compression is supported */
  28237. astc: any;
  28238. /** Defines if float textures are supported */
  28239. textureFloat: boolean;
  28240. /** Defines if vertex array objects are supported */
  28241. vertexArrayObject: boolean;
  28242. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28243. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28244. /** Gets the maximum level of anisotropy supported */
  28245. maxAnisotropy: number;
  28246. /** Defines if instancing is supported */
  28247. instancedArrays: boolean;
  28248. /** Defines if 32 bits indices are supported */
  28249. uintIndices: boolean;
  28250. /** Defines if high precision shaders are supported */
  28251. highPrecisionShaderSupported: boolean;
  28252. /** Defines if depth reading in the fragment shader is supported */
  28253. fragmentDepthSupported: boolean;
  28254. /** Defines if float texture linear filtering is supported*/
  28255. textureFloatLinearFiltering: boolean;
  28256. /** Defines if rendering to float textures is supported */
  28257. textureFloatRender: boolean;
  28258. /** Defines if half float textures are supported*/
  28259. textureHalfFloat: boolean;
  28260. /** Defines if half float texture linear filtering is supported*/
  28261. textureHalfFloatLinearFiltering: boolean;
  28262. /** Defines if rendering to half float textures is supported */
  28263. textureHalfFloatRender: boolean;
  28264. /** Defines if textureLOD shader command is supported */
  28265. textureLOD: boolean;
  28266. /** Defines if draw buffers extension is supported */
  28267. drawBuffersExtension: boolean;
  28268. /** Defines if depth textures are supported */
  28269. depthTextureExtension: boolean;
  28270. /** Defines if float color buffer are supported */
  28271. colorBufferFloat: boolean;
  28272. /** Gets disjoint timer query extension (null if not supported) */
  28273. timerQuery: EXT_disjoint_timer_query;
  28274. /** Defines if timestamp can be used with timer query */
  28275. canUseTimestampForTimerQuery: boolean;
  28276. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28277. multiview: any;
  28278. /** Function used to let the system compiles shaders in background */
  28279. parallelShaderCompile: {
  28280. COMPLETION_STATUS_KHR: number;
  28281. };
  28282. /** Max number of texture samples for MSAA */
  28283. maxMSAASamples: number;
  28284. /** Defines if the blend min max extension is supported */
  28285. blendMinMax: boolean;
  28286. }
  28287. }
  28288. declare module BABYLON {
  28289. /**
  28290. * This class is used to track a performance counter which is number based.
  28291. * The user has access to many properties which give statistics of different nature.
  28292. *
  28293. * The implementer can track two kinds of Performance Counter: time and count.
  28294. * 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.
  28295. * 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.
  28296. */
  28297. export class PerfCounter {
  28298. /**
  28299. * Gets or sets a global boolean to turn on and off all the counters
  28300. */
  28301. static Enabled: boolean;
  28302. /**
  28303. * Returns the smallest value ever
  28304. */
  28305. readonly min: number;
  28306. /**
  28307. * Returns the biggest value ever
  28308. */
  28309. readonly max: number;
  28310. /**
  28311. * Returns the average value since the performance counter is running
  28312. */
  28313. readonly average: number;
  28314. /**
  28315. * Returns the average value of the last second the counter was monitored
  28316. */
  28317. readonly lastSecAverage: number;
  28318. /**
  28319. * Returns the current value
  28320. */
  28321. readonly current: number;
  28322. /**
  28323. * Gets the accumulated total
  28324. */
  28325. readonly total: number;
  28326. /**
  28327. * Gets the total value count
  28328. */
  28329. readonly count: number;
  28330. /**
  28331. * Creates a new counter
  28332. */
  28333. constructor();
  28334. /**
  28335. * Call this method to start monitoring a new frame.
  28336. * 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.
  28337. */
  28338. fetchNewFrame(): void;
  28339. /**
  28340. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28341. * @param newCount the count value to add to the monitored count
  28342. * @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.
  28343. */
  28344. addCount(newCount: number, fetchResult: boolean): void;
  28345. /**
  28346. * Start monitoring this performance counter
  28347. */
  28348. beginMonitoring(): void;
  28349. /**
  28350. * Compute the time lapsed since the previous beginMonitoring() call.
  28351. * @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
  28352. */
  28353. endMonitoring(newFrame?: boolean): void;
  28354. private _fetchResult;
  28355. private _startMonitoringTime;
  28356. private _min;
  28357. private _max;
  28358. private _average;
  28359. private _current;
  28360. private _totalValueCount;
  28361. private _totalAccumulated;
  28362. private _lastSecAverage;
  28363. private _lastSecAccumulated;
  28364. private _lastSecTime;
  28365. private _lastSecValueCount;
  28366. }
  28367. }
  28368. declare module BABYLON {
  28369. /**
  28370. * @hidden
  28371. **/
  28372. export class DepthCullingState {
  28373. private _isDepthTestDirty;
  28374. private _isDepthMaskDirty;
  28375. private _isDepthFuncDirty;
  28376. private _isCullFaceDirty;
  28377. private _isCullDirty;
  28378. private _isZOffsetDirty;
  28379. private _isFrontFaceDirty;
  28380. private _depthTest;
  28381. private _depthMask;
  28382. private _depthFunc;
  28383. private _cull;
  28384. private _cullFace;
  28385. private _zOffset;
  28386. private _frontFace;
  28387. /**
  28388. * Initializes the state.
  28389. */
  28390. constructor();
  28391. readonly isDirty: boolean;
  28392. zOffset: number;
  28393. cullFace: Nullable<number>;
  28394. cull: Nullable<boolean>;
  28395. depthFunc: Nullable<number>;
  28396. depthMask: boolean;
  28397. depthTest: boolean;
  28398. frontFace: Nullable<number>;
  28399. reset(): void;
  28400. apply(gl: WebGLRenderingContext): void;
  28401. }
  28402. }
  28403. declare module BABYLON {
  28404. /**
  28405. * @hidden
  28406. **/
  28407. export class StencilState {
  28408. /** 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 */
  28409. static readonly ALWAYS: number;
  28410. /** Passed to stencilOperation to specify that stencil value must be kept */
  28411. static readonly KEEP: number;
  28412. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28413. static readonly REPLACE: number;
  28414. private _isStencilTestDirty;
  28415. private _isStencilMaskDirty;
  28416. private _isStencilFuncDirty;
  28417. private _isStencilOpDirty;
  28418. private _stencilTest;
  28419. private _stencilMask;
  28420. private _stencilFunc;
  28421. private _stencilFuncRef;
  28422. private _stencilFuncMask;
  28423. private _stencilOpStencilFail;
  28424. private _stencilOpDepthFail;
  28425. private _stencilOpStencilDepthPass;
  28426. readonly isDirty: boolean;
  28427. stencilFunc: number;
  28428. stencilFuncRef: number;
  28429. stencilFuncMask: number;
  28430. stencilOpStencilFail: number;
  28431. stencilOpDepthFail: number;
  28432. stencilOpStencilDepthPass: number;
  28433. stencilMask: number;
  28434. stencilTest: boolean;
  28435. constructor();
  28436. reset(): void;
  28437. apply(gl: WebGLRenderingContext): void;
  28438. }
  28439. }
  28440. declare module BABYLON {
  28441. /**
  28442. * @hidden
  28443. **/
  28444. export class AlphaState {
  28445. private _isAlphaBlendDirty;
  28446. private _isBlendFunctionParametersDirty;
  28447. private _isBlendEquationParametersDirty;
  28448. private _isBlendConstantsDirty;
  28449. private _alphaBlend;
  28450. private _blendFunctionParameters;
  28451. private _blendEquationParameters;
  28452. private _blendConstants;
  28453. /**
  28454. * Initializes the state.
  28455. */
  28456. constructor();
  28457. readonly isDirty: boolean;
  28458. alphaBlend: boolean;
  28459. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28460. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28461. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28462. reset(): void;
  28463. apply(gl: WebGLRenderingContext): void;
  28464. }
  28465. }
  28466. declare module BABYLON {
  28467. /** @hidden */
  28468. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28469. attributeProcessor(attribute: string): string;
  28470. varyingProcessor(varying: string, isFragment: boolean): string;
  28471. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28472. }
  28473. }
  28474. declare module BABYLON {
  28475. /**
  28476. * Interface for attribute information associated with buffer instanciation
  28477. */
  28478. export class InstancingAttributeInfo {
  28479. /**
  28480. * Index/offset of the attribute in the vertex shader
  28481. */
  28482. index: number;
  28483. /**
  28484. * size of the attribute, 1, 2, 3 or 4
  28485. */
  28486. attributeSize: number;
  28487. /**
  28488. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28489. * default is FLOAT
  28490. */
  28491. attribyteType: number;
  28492. /**
  28493. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28494. */
  28495. normalized: boolean;
  28496. /**
  28497. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28498. */
  28499. offset: number;
  28500. /**
  28501. * Name of the GLSL attribute, for debugging purpose only
  28502. */
  28503. attributeName: string;
  28504. }
  28505. }
  28506. declare module BABYLON {
  28507. interface ThinEngine {
  28508. /**
  28509. * Update a video texture
  28510. * @param texture defines the texture to update
  28511. * @param video defines the video element to use
  28512. * @param invertY defines if data must be stored with Y axis inverted
  28513. */
  28514. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28515. }
  28516. }
  28517. declare module BABYLON {
  28518. /**
  28519. * Settings for finer control over video usage
  28520. */
  28521. export interface VideoTextureSettings {
  28522. /**
  28523. * Applies `autoplay` to video, if specified
  28524. */
  28525. autoPlay?: boolean;
  28526. /**
  28527. * Applies `loop` to video, if specified
  28528. */
  28529. loop?: boolean;
  28530. /**
  28531. * Automatically updates internal texture from video at every frame in the render loop
  28532. */
  28533. autoUpdateTexture: boolean;
  28534. /**
  28535. * Image src displayed during the video loading or until the user interacts with the video.
  28536. */
  28537. poster?: string;
  28538. }
  28539. /**
  28540. * If you want to display a video in your scene, this is the special texture for that.
  28541. * This special texture works similar to other textures, with the exception of a few parameters.
  28542. * @see https://doc.babylonjs.com/how_to/video_texture
  28543. */
  28544. export class VideoTexture extends Texture {
  28545. /**
  28546. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28547. */
  28548. readonly autoUpdateTexture: boolean;
  28549. /**
  28550. * The video instance used by the texture internally
  28551. */
  28552. readonly video: HTMLVideoElement;
  28553. private _onUserActionRequestedObservable;
  28554. /**
  28555. * Event triggerd when a dom action is required by the user to play the video.
  28556. * This happens due to recent changes in browser policies preventing video to auto start.
  28557. */
  28558. readonly onUserActionRequestedObservable: Observable<Texture>;
  28559. private _generateMipMaps;
  28560. private _engine;
  28561. private _stillImageCaptured;
  28562. private _displayingPosterTexture;
  28563. private _settings;
  28564. private _createInternalTextureOnEvent;
  28565. private _frameId;
  28566. /**
  28567. * Creates a video texture.
  28568. * If you want to display a video in your scene, this is the special texture for that.
  28569. * This special texture works similar to other textures, with the exception of a few parameters.
  28570. * @see https://doc.babylonjs.com/how_to/video_texture
  28571. * @param name optional name, will detect from video source, if not defined
  28572. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28573. * @param scene is obviously the current scene.
  28574. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28575. * @param invertY is false by default but can be used to invert video on Y axis
  28576. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28577. * @param settings allows finer control over video usage
  28578. */
  28579. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28580. private _getName;
  28581. private _getVideo;
  28582. private _createInternalTexture;
  28583. private reset;
  28584. /**
  28585. * @hidden Internal method to initiate `update`.
  28586. */ private _rebuild(): void;
  28587. /**
  28588. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28589. */
  28590. update(): void;
  28591. /**
  28592. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28593. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28594. */
  28595. updateTexture(isVisible: boolean): void;
  28596. protected _updateInternalTexture: () => void;
  28597. /**
  28598. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28599. * @param url New url.
  28600. */
  28601. updateURL(url: string): void;
  28602. /**
  28603. * Dispose the texture and release its associated resources.
  28604. */
  28605. dispose(): void;
  28606. /**
  28607. * Creates a video texture straight from a stream.
  28608. * @param scene Define the scene the texture should be created in
  28609. * @param stream Define the stream the texture should be created from
  28610. * @returns The created video texture as a promise
  28611. */
  28612. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28613. /**
  28614. * Creates a video texture straight from your WebCam video feed.
  28615. * @param scene Define the scene the texture should be created in
  28616. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28617. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28618. * @returns The created video texture as a promise
  28619. */
  28620. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28621. minWidth: number;
  28622. maxWidth: number;
  28623. minHeight: number;
  28624. maxHeight: number;
  28625. deviceId: string;
  28626. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28627. /**
  28628. * Creates a video texture straight from your WebCam video feed.
  28629. * @param scene Define the scene the texture should be created in
  28630. * @param onReady Define a callback to triggered once the texture will be ready
  28631. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28632. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28633. */
  28634. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28635. minWidth: number;
  28636. maxWidth: number;
  28637. minHeight: number;
  28638. maxHeight: number;
  28639. deviceId: string;
  28640. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28641. }
  28642. }
  28643. declare module BABYLON {
  28644. /**
  28645. * Defines the interface used by objects working like Scene
  28646. * @hidden
  28647. */
  28648. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28649. offlineProvider: IOfflineProvider;
  28650. }
  28651. /** Interface defining initialization parameters for Engine class */
  28652. export interface EngineOptions extends WebGLContextAttributes {
  28653. /**
  28654. * Defines if the engine should no exceed a specified device ratio
  28655. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28656. */
  28657. limitDeviceRatio?: number;
  28658. /**
  28659. * Defines if webvr should be enabled automatically
  28660. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28661. */
  28662. autoEnableWebVR?: boolean;
  28663. /**
  28664. * Defines if webgl2 should be turned off even if supported
  28665. * @see http://doc.babylonjs.com/features/webgl2
  28666. */
  28667. disableWebGL2Support?: boolean;
  28668. /**
  28669. * Defines if webaudio should be initialized as well
  28670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28671. */
  28672. audioEngine?: boolean;
  28673. /**
  28674. * Defines if animations should run using a deterministic lock step
  28675. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28676. */
  28677. deterministicLockstep?: boolean;
  28678. /** Defines the maximum steps to use with deterministic lock step mode */
  28679. lockstepMaxSteps?: number;
  28680. /**
  28681. * Defines that engine should ignore context lost events
  28682. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28683. */
  28684. doNotHandleContextLost?: boolean;
  28685. /**
  28686. * Defines that engine should ignore modifying touch action attribute and style
  28687. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28688. */
  28689. doNotHandleTouchAction?: boolean;
  28690. /**
  28691. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28692. */
  28693. useHighPrecisionFloats?: boolean;
  28694. }
  28695. /**
  28696. * The base engine class (root of all engines)
  28697. */
  28698. export class ThinEngine {
  28699. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28700. static ExceptionList: ({
  28701. key: string;
  28702. capture: string;
  28703. captureConstraint: number;
  28704. targets: string[];
  28705. } | {
  28706. key: string;
  28707. capture: null;
  28708. captureConstraint: null;
  28709. targets: string[];
  28710. })[];
  28711. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28712. /**
  28713. * Returns the current npm package of the sdk
  28714. */
  28715. static readonly NpmPackage: string;
  28716. /**
  28717. * Returns the current version of the framework
  28718. */
  28719. static readonly Version: string;
  28720. /**
  28721. * Returns a string describing the current engine
  28722. */
  28723. readonly description: string;
  28724. /**
  28725. * Gets or sets the epsilon value used by collision engine
  28726. */
  28727. static CollisionsEpsilon: number;
  28728. /**
  28729. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28730. */
  28731. static ShadersRepository: string;
  28732. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28733. /**
  28734. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28735. */
  28736. forcePOTTextures: boolean;
  28737. /**
  28738. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28739. */
  28740. isFullscreen: boolean;
  28741. /**
  28742. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28743. */
  28744. cullBackFaces: boolean;
  28745. /**
  28746. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28747. */
  28748. renderEvenInBackground: boolean;
  28749. /**
  28750. * Gets or sets a boolean indicating that cache can be kept between frames
  28751. */
  28752. preventCacheWipeBetweenFrames: boolean;
  28753. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28754. validateShaderPrograms: boolean;
  28755. /**
  28756. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28757. */
  28758. disableUniformBuffers: boolean;
  28759. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28760. /**
  28761. * Gets a boolean indicating that the engine supports uniform buffers
  28762. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28763. */
  28764. readonly supportsUniformBuffers: boolean;
  28765. /** @hidden */ private _gl: WebGLRenderingContext;
  28766. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28767. protected _windowIsBackground: boolean;
  28768. protected _webGLVersion: number;
  28769. protected _highPrecisionShadersAllowed: boolean;
  28770. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28771. /**
  28772. * Gets a boolean indicating that only power of 2 textures are supported
  28773. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28774. */
  28775. readonly needPOTTextures: boolean;
  28776. /** @hidden */ private _badOS: boolean;
  28777. /** @hidden */ private _badDesktopOS: boolean;
  28778. private _hardwareScalingLevel;
  28779. /** @hidden */ private _caps: EngineCapabilities;
  28780. private _isStencilEnable;
  28781. protected _colorWrite: boolean;
  28782. /** @hidden */ private _drawCalls: PerfCounter;
  28783. private _glVersion;
  28784. private _glRenderer;
  28785. private _glVendor;
  28786. /** @hidden */ private _videoTextureSupported: boolean;
  28787. protected _renderingQueueLaunched: boolean;
  28788. protected _activeRenderLoops: (() => void)[];
  28789. /**
  28790. * Observable signaled when a context lost event is raised
  28791. */
  28792. onContextLostObservable: Observable<ThinEngine>;
  28793. /**
  28794. * Observable signaled when a context restored event is raised
  28795. */
  28796. onContextRestoredObservable: Observable<ThinEngine>;
  28797. private _onContextLost;
  28798. private _onContextRestored;
  28799. protected _contextWasLost: boolean;
  28800. /** @hidden */ private _doNotHandleContextLost: boolean;
  28801. /**
  28802. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28804. */
  28805. doNotHandleContextLost: boolean;
  28806. /**
  28807. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28808. */
  28809. disableVertexArrayObjects: boolean;
  28810. /** @hidden */
  28811. protected _depthCullingState: DepthCullingState;
  28812. /** @hidden */
  28813. protected _stencilState: StencilState;
  28814. /** @hidden */
  28815. protected _alphaState: AlphaState;
  28816. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28817. /** @hidden */
  28818. protected _activeChannel: number;
  28819. private _currentTextureChannel;
  28820. /** @hidden */
  28821. protected _boundTexturesCache: {
  28822. [key: string]: Nullable<InternalTexture>;
  28823. };
  28824. /** @hidden */
  28825. protected _currentEffect: Nullable<Effect>;
  28826. /** @hidden */
  28827. protected _currentProgram: Nullable<WebGLProgram>;
  28828. private _compiledEffects;
  28829. private _vertexAttribArraysEnabled;
  28830. /** @hidden */
  28831. protected _cachedViewport: Nullable<IViewportLike>;
  28832. private _cachedVertexArrayObject;
  28833. /** @hidden */
  28834. protected _cachedVertexBuffers: any;
  28835. /** @hidden */
  28836. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28837. /** @hidden */
  28838. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28839. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28840. private _uintIndicesCurrentlySet;
  28841. private _currentBoundBuffer;
  28842. /** @hidden */
  28843. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28844. private _currentBufferPointers;
  28845. private _currentInstanceLocations;
  28846. private _currentInstanceBuffers;
  28847. private _textureUnits;
  28848. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  28849. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  28850. /** @hidden */ private _bindedRenderFunction: any;
  28851. private _vaoRecordInProgress;
  28852. private _mustWipeVertexAttributes;
  28853. private _emptyTexture;
  28854. private _emptyCubeTexture;
  28855. private _emptyTexture3D;
  28856. /** @hidden */ private _frameHandler: number;
  28857. private _nextFreeTextureSlots;
  28858. private _maxSimultaneousTextures;
  28859. private _activeRequests;
  28860. protected _texturesSupported: string[];
  28861. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28862. protected readonly _supportsHardwareTextureRescaling: boolean;
  28863. /**
  28864. * Gets the list of texture formats supported
  28865. */
  28866. readonly texturesSupported: Array<string>;
  28867. /**
  28868. * Gets the list of texture formats in use
  28869. */
  28870. readonly textureFormatInUse: Nullable<string>;
  28871. /**
  28872. * Gets the current viewport
  28873. */
  28874. readonly currentViewport: Nullable<IViewportLike>;
  28875. /**
  28876. * Gets the default empty texture
  28877. */
  28878. readonly emptyTexture: InternalTexture;
  28879. /**
  28880. * Gets the default empty 3D texture
  28881. */
  28882. readonly emptyTexture3D: InternalTexture;
  28883. /**
  28884. * Gets the default empty cube texture
  28885. */
  28886. readonly emptyCubeTexture: InternalTexture;
  28887. /**
  28888. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28889. */
  28890. readonly premultipliedAlpha: boolean;
  28891. /**
  28892. * Creates a new engine
  28893. * @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
  28894. * @param antialias defines enable antialiasing (default: false)
  28895. * @param options defines further options to be sent to the getContext() function
  28896. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28897. */
  28898. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28899. private _rebuildInternalTextures;
  28900. private _rebuildEffects;
  28901. /**
  28902. * Gets a boolean indicating if all created effects are ready
  28903. * @returns true if all effects are ready
  28904. */
  28905. areAllEffectsReady(): boolean;
  28906. protected _rebuildBuffers(): void;
  28907. private _initGLContext;
  28908. /**
  28909. * Gets version of the current webGL context
  28910. */
  28911. readonly webGLVersion: number;
  28912. /**
  28913. * Gets a string idenfifying the name of the class
  28914. * @returns "Engine" string
  28915. */
  28916. getClassName(): string;
  28917. /**
  28918. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28919. */
  28920. readonly isStencilEnable: boolean;
  28921. /** @hidden */ private _prepareWorkingCanvas(): void;
  28922. /**
  28923. * Reset the texture cache to empty state
  28924. */
  28925. resetTextureCache(): void;
  28926. /**
  28927. * Gets an object containing information about the current webGL context
  28928. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28929. */
  28930. getGlInfo(): {
  28931. vendor: string;
  28932. renderer: string;
  28933. version: string;
  28934. };
  28935. /**
  28936. * Defines the hardware scaling level.
  28937. * By default the hardware scaling level is computed from the window device ratio.
  28938. * 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.
  28939. * @param level defines the level to use
  28940. */
  28941. setHardwareScalingLevel(level: number): void;
  28942. /**
  28943. * Gets the current hardware scaling level.
  28944. * By default the hardware scaling level is computed from the window device ratio.
  28945. * 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.
  28946. * @returns a number indicating the current hardware scaling level
  28947. */
  28948. getHardwareScalingLevel(): number;
  28949. /**
  28950. * Gets the list of loaded textures
  28951. * @returns an array containing all loaded textures
  28952. */
  28953. getLoadedTexturesCache(): InternalTexture[];
  28954. /**
  28955. * Gets the object containing all engine capabilities
  28956. * @returns the EngineCapabilities object
  28957. */
  28958. getCaps(): EngineCapabilities;
  28959. /**
  28960. * stop executing a render loop function and remove it from the execution array
  28961. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28962. */
  28963. stopRenderLoop(renderFunction?: () => void): void;
  28964. /** @hidden */ private _renderLoop(): void;
  28965. /**
  28966. * Gets the HTML canvas attached with the current webGL context
  28967. * @returns a HTML canvas
  28968. */
  28969. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28970. /**
  28971. * Gets host window
  28972. * @returns the host window object
  28973. */
  28974. getHostWindow(): Window;
  28975. /**
  28976. * Gets the current render width
  28977. * @param useScreen defines if screen size must be used (or the current render target if any)
  28978. * @returns a number defining the current render width
  28979. */
  28980. getRenderWidth(useScreen?: boolean): number;
  28981. /**
  28982. * Gets the current render height
  28983. * @param useScreen defines if screen size must be used (or the current render target if any)
  28984. * @returns a number defining the current render height
  28985. */
  28986. getRenderHeight(useScreen?: boolean): number;
  28987. /**
  28988. * Can be used to override the current requestAnimationFrame requester.
  28989. * @hidden
  28990. */
  28991. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  28992. /**
  28993. * Register and execute a render loop. The engine can have more than one render function
  28994. * @param renderFunction defines the function to continuously execute
  28995. */
  28996. runRenderLoop(renderFunction: () => void): void;
  28997. /**
  28998. * Clear the current render buffer or the current render target (if any is set up)
  28999. * @param color defines the color to use
  29000. * @param backBuffer defines if the back buffer must be cleared
  29001. * @param depth defines if the depth buffer must be cleared
  29002. * @param stencil defines if the stencil buffer must be cleared
  29003. */
  29004. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29005. private _viewportCached;
  29006. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  29007. /**
  29008. * Set the WebGL's viewport
  29009. * @param viewport defines the viewport element to be used
  29010. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29011. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29012. */
  29013. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29014. /**
  29015. * Begin a new frame
  29016. */
  29017. beginFrame(): void;
  29018. /**
  29019. * Enf the current frame
  29020. */
  29021. endFrame(): void;
  29022. /**
  29023. * Resize the view according to the canvas' size
  29024. */
  29025. resize(): void;
  29026. /**
  29027. * Force a specific size of the canvas
  29028. * @param width defines the new canvas' width
  29029. * @param height defines the new canvas' height
  29030. */
  29031. setSize(width: number, height: number): void;
  29032. /**
  29033. * Binds the frame buffer to the specified texture.
  29034. * @param texture The texture to render to or null for the default canvas
  29035. * @param faceIndex The face of the texture to render to in case of cube texture
  29036. * @param requiredWidth The width of the target to render to
  29037. * @param requiredHeight The height of the target to render to
  29038. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29039. * @param depthStencilTexture The depth stencil texture to use to render
  29040. * @param lodLevel defines le lod level to bind to the frame buffer
  29041. */
  29042. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29043. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29044. /**
  29045. * Unbind the current render target texture from the webGL context
  29046. * @param texture defines the render target texture to unbind
  29047. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29048. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29049. */
  29050. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29051. /**
  29052. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29053. */
  29054. flushFramebuffer(): void;
  29055. /**
  29056. * Unbind the current render target and bind the default framebuffer
  29057. */
  29058. restoreDefaultFramebuffer(): void;
  29059. private _resetVertexBufferBinding;
  29060. /**
  29061. * Creates a vertex buffer
  29062. * @param data the data for the vertex buffer
  29063. * @returns the new WebGL static buffer
  29064. */
  29065. createVertexBuffer(data: DataArray): DataBuffer;
  29066. private _createVertexBuffer;
  29067. /**
  29068. * Creates a dynamic vertex buffer
  29069. * @param data the data for the dynamic vertex buffer
  29070. * @returns the new WebGL dynamic buffer
  29071. */
  29072. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29073. /**
  29074. * Update a dynamic index buffer
  29075. * @param indexBuffer defines the target index buffer
  29076. * @param indices defines the data to update
  29077. * @param offset defines the offset in the target index buffer where update should start
  29078. */
  29079. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29080. /**
  29081. * Updates a dynamic vertex buffer.
  29082. * @param vertexBuffer the vertex buffer to update
  29083. * @param data the data used to update the vertex buffer
  29084. * @param byteOffset the byte offset of the data
  29085. * @param byteLength the byte length of the data
  29086. */
  29087. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29088. private _resetIndexBufferBinding;
  29089. /**
  29090. * Creates a new index buffer
  29091. * @param indices defines the content of the index buffer
  29092. * @param updatable defines if the index buffer must be updatable
  29093. * @returns a new webGL buffer
  29094. */
  29095. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29096. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29097. /**
  29098. * Bind a webGL buffer to the webGL context
  29099. * @param buffer defines the buffer to bind
  29100. */
  29101. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29102. private bindIndexBuffer;
  29103. private bindBuffer;
  29104. /**
  29105. * update the bound buffer with the given data
  29106. * @param data defines the data to update
  29107. */
  29108. updateArrayBuffer(data: Float32Array): void;
  29109. private _vertexAttribPointer;
  29110. private _bindIndexBufferWithCache;
  29111. private _bindVertexBuffersAttributes;
  29112. /**
  29113. * Records a vertex array object
  29114. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29115. * @param vertexBuffers defines the list of vertex buffers to store
  29116. * @param indexBuffer defines the index buffer to store
  29117. * @param effect defines the effect to store
  29118. * @returns the new vertex array object
  29119. */
  29120. recordVertexArrayObject(vertexBuffers: {
  29121. [key: string]: VertexBuffer;
  29122. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29123. /**
  29124. * Bind a specific vertex array object
  29125. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29126. * @param vertexArrayObject defines the vertex array object to bind
  29127. * @param indexBuffer defines the index buffer to bind
  29128. */
  29129. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29130. /**
  29131. * Bind webGl buffers directly to the webGL context
  29132. * @param vertexBuffer defines the vertex buffer to bind
  29133. * @param indexBuffer defines the index buffer to bind
  29134. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29135. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29136. * @param effect defines the effect associated with the vertex buffer
  29137. */
  29138. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29139. private _unbindVertexArrayObject;
  29140. /**
  29141. * Bind a list of vertex buffers to the webGL context
  29142. * @param vertexBuffers defines the list of vertex buffers to bind
  29143. * @param indexBuffer defines the index buffer to bind
  29144. * @param effect defines the effect associated with the vertex buffers
  29145. */
  29146. bindBuffers(vertexBuffers: {
  29147. [key: string]: Nullable<VertexBuffer>;
  29148. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29149. /**
  29150. * Unbind all instance attributes
  29151. */
  29152. unbindInstanceAttributes(): void;
  29153. /**
  29154. * Release and free the memory of a vertex array object
  29155. * @param vao defines the vertex array object to delete
  29156. */
  29157. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29158. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  29159. protected _deleteBuffer(buffer: DataBuffer): void;
  29160. /**
  29161. * Creates a webGL buffer to use with instanciation
  29162. * @param capacity defines the size of the buffer
  29163. * @returns the webGL buffer
  29164. */
  29165. createInstancesBuffer(capacity: number): DataBuffer;
  29166. /**
  29167. * Delete a webGL buffer used with instanciation
  29168. * @param buffer defines the webGL buffer to delete
  29169. */
  29170. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29171. /**
  29172. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29173. * @param instancesBuffer defines the webGL buffer to update and bind
  29174. * @param data defines the data to store in the buffer
  29175. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29176. */
  29177. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29178. /**
  29179. * Apply all cached states (depth, culling, stencil and alpha)
  29180. */
  29181. applyStates(): void;
  29182. /**
  29183. * Send a draw order
  29184. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29185. * @param indexStart defines the starting index
  29186. * @param indexCount defines the number of index to draw
  29187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29188. */
  29189. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29190. /**
  29191. * Draw a list of points
  29192. * @param verticesStart defines the index of first vertex to draw
  29193. * @param verticesCount defines the count of vertices to draw
  29194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29195. */
  29196. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29197. /**
  29198. * Draw a list of unindexed primitives
  29199. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29200. * @param verticesStart defines the index of first vertex to draw
  29201. * @param verticesCount defines the count of vertices to draw
  29202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29203. */
  29204. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29205. /**
  29206. * Draw a list of indexed primitives
  29207. * @param fillMode defines the primitive to use
  29208. * @param indexStart defines the starting index
  29209. * @param indexCount defines the number of index to draw
  29210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29211. */
  29212. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29213. /**
  29214. * Draw a list of unindexed primitives
  29215. * @param fillMode defines the primitive to use
  29216. * @param verticesStart defines the index of first vertex to draw
  29217. * @param verticesCount defines the count of vertices to draw
  29218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29219. */
  29220. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29221. private _drawMode;
  29222. /** @hidden */ private _releaseEffect(effect: Effect): void;
  29223. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29224. /**
  29225. * Create a new effect (used to store vertex/fragment shaders)
  29226. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29227. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29228. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29229. * @param samplers defines an array of string used to represent textures
  29230. * @param defines defines the string containing the defines to use to compile the shaders
  29231. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29232. * @param onCompiled defines a function to call when the effect creation is successful
  29233. * @param onError defines a function to call when the effect creation has failed
  29234. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29235. * @returns the new Effect
  29236. */
  29237. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29238. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29239. private _compileShader;
  29240. private _compileRawShader;
  29241. /**
  29242. * Directly creates a webGL program
  29243. * @param pipelineContext defines the pipeline context to attach to
  29244. * @param vertexCode defines the vertex shader code to use
  29245. * @param fragmentCode defines the fragment shader code to use
  29246. * @param context defines the webGL context to use (if not set, the current one will be used)
  29247. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29248. * @returns the new webGL program
  29249. */
  29250. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29251. /**
  29252. * Creates a webGL program
  29253. * @param pipelineContext defines the pipeline context to attach to
  29254. * @param vertexCode defines the vertex shader code to use
  29255. * @param fragmentCode defines the fragment shader code to use
  29256. * @param defines defines the string containing the defines to use to compile the shaders
  29257. * @param context defines the webGL context to use (if not set, the current one will be used)
  29258. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29259. * @returns the new webGL program
  29260. */
  29261. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29262. /**
  29263. * Creates a new pipeline context
  29264. * @returns the new pipeline
  29265. */
  29266. createPipelineContext(): IPipelineContext;
  29267. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29268. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29269. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29270. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29271. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29272. /**
  29273. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29274. * @param pipelineContext defines the pipeline context to use
  29275. * @param uniformsNames defines the list of uniform names
  29276. * @returns an array of webGL uniform locations
  29277. */
  29278. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29279. /**
  29280. * Gets the lsit of active attributes for a given webGL program
  29281. * @param pipelineContext defines the pipeline context to use
  29282. * @param attributesNames defines the list of attribute names to get
  29283. * @returns an array of indices indicating the offset of each attribute
  29284. */
  29285. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29286. /**
  29287. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29288. * @param effect defines the effect to activate
  29289. */
  29290. enableEffect(effect: Nullable<Effect>): void;
  29291. /**
  29292. * Set the value of an uniform to an array of int32
  29293. * @param uniform defines the webGL uniform location where to store the value
  29294. * @param array defines the array of int32 to store
  29295. */
  29296. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29297. /**
  29298. * Set the value of an uniform to an array of int32 (stored as vec2)
  29299. * @param uniform defines the webGL uniform location where to store the value
  29300. * @param array defines the array of int32 to store
  29301. */
  29302. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29303. /**
  29304. * Set the value of an uniform to an array of int32 (stored as vec3)
  29305. * @param uniform defines the webGL uniform location where to store the value
  29306. * @param array defines the array of int32 to store
  29307. */
  29308. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29309. /**
  29310. * Set the value of an uniform to an array of int32 (stored as vec4)
  29311. * @param uniform defines the webGL uniform location where to store the value
  29312. * @param array defines the array of int32 to store
  29313. */
  29314. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29315. /**
  29316. * Set the value of an uniform to an array of float32
  29317. * @param uniform defines the webGL uniform location where to store the value
  29318. * @param array defines the array of float32 to store
  29319. */
  29320. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29321. /**
  29322. * Set the value of an uniform to an array of float32 (stored as vec2)
  29323. * @param uniform defines the webGL uniform location where to store the value
  29324. * @param array defines the array of float32 to store
  29325. */
  29326. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29327. /**
  29328. * Set the value of an uniform to an array of float32 (stored as vec3)
  29329. * @param uniform defines the webGL uniform location where to store the value
  29330. * @param array defines the array of float32 to store
  29331. */
  29332. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29333. /**
  29334. * Set the value of an uniform to an array of float32 (stored as vec4)
  29335. * @param uniform defines the webGL uniform location where to store the value
  29336. * @param array defines the array of float32 to store
  29337. */
  29338. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29339. /**
  29340. * Set the value of an uniform to an array of number
  29341. * @param uniform defines the webGL uniform location where to store the value
  29342. * @param array defines the array of number to store
  29343. */
  29344. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29345. /**
  29346. * Set the value of an uniform to an array of number (stored as vec2)
  29347. * @param uniform defines the webGL uniform location where to store the value
  29348. * @param array defines the array of number to store
  29349. */
  29350. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29351. /**
  29352. * Set the value of an uniform to an array of number (stored as vec3)
  29353. * @param uniform defines the webGL uniform location where to store the value
  29354. * @param array defines the array of number to store
  29355. */
  29356. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29357. /**
  29358. * Set the value of an uniform to an array of number (stored as vec4)
  29359. * @param uniform defines the webGL uniform location where to store the value
  29360. * @param array defines the array of number to store
  29361. */
  29362. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29363. /**
  29364. * Set the value of an uniform to an array of float32 (stored as matrices)
  29365. * @param uniform defines the webGL uniform location where to store the value
  29366. * @param matrices defines the array of float32 to store
  29367. */
  29368. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29369. /**
  29370. * Set the value of an uniform to a matrix (3x3)
  29371. * @param uniform defines the webGL uniform location where to store the value
  29372. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29373. */
  29374. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29375. /**
  29376. * Set the value of an uniform to a matrix (2x2)
  29377. * @param uniform defines the webGL uniform location where to store the value
  29378. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29379. */
  29380. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29381. /**
  29382. * Set the value of an uniform to a number (int)
  29383. * @param uniform defines the webGL uniform location where to store the value
  29384. * @param value defines the int number to store
  29385. */
  29386. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29387. /**
  29388. * Set the value of an uniform to a number (float)
  29389. * @param uniform defines the webGL uniform location where to store the value
  29390. * @param value defines the float number to store
  29391. */
  29392. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29393. /**
  29394. * Set the value of an uniform to a vec2
  29395. * @param uniform defines the webGL uniform location where to store the value
  29396. * @param x defines the 1st component of the value
  29397. * @param y defines the 2nd component of the value
  29398. */
  29399. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29400. /**
  29401. * Set the value of an uniform to a vec3
  29402. * @param uniform defines the webGL uniform location where to store the value
  29403. * @param x defines the 1st component of the value
  29404. * @param y defines the 2nd component of the value
  29405. * @param z defines the 3rd component of the value
  29406. */
  29407. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29408. /**
  29409. * Set the value of an uniform to a boolean
  29410. * @param uniform defines the webGL uniform location where to store the value
  29411. * @param bool defines the boolean to store
  29412. */
  29413. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29414. /**
  29415. * Set the value of an uniform to a vec4
  29416. * @param uniform defines the webGL uniform location where to store the value
  29417. * @param x defines the 1st component of the value
  29418. * @param y defines the 2nd component of the value
  29419. * @param z defines the 3rd component of the value
  29420. * @param w defines the 4th component of the value
  29421. */
  29422. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29423. /**
  29424. * Sets a Color4 on a uniform variable
  29425. * @param uniform defines the uniform location
  29426. * @param color4 defines the value to be set
  29427. */
  29428. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29429. /**
  29430. * Gets the depth culling state manager
  29431. */
  29432. readonly depthCullingState: DepthCullingState;
  29433. /**
  29434. * Gets the alpha state manager
  29435. */
  29436. readonly alphaState: AlphaState;
  29437. /**
  29438. * Gets the stencil state manager
  29439. */
  29440. readonly stencilState: StencilState;
  29441. /**
  29442. * Clears the list of texture accessible through engine.
  29443. * This can help preventing texture load conflict due to name collision.
  29444. */
  29445. clearInternalTexturesCache(): void;
  29446. /**
  29447. * Force the entire cache to be cleared
  29448. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29449. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29450. */
  29451. wipeCaches(bruteForce?: boolean): void;
  29452. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29453. min: number;
  29454. mag: number;
  29455. };
  29456. /** @hidden */ private _createTexture(): WebGLTexture;
  29457. /**
  29458. * Usually called from Texture.ts.
  29459. * Passed information to create a WebGLTexture
  29460. * @param urlArg defines a value which contains one of the following:
  29461. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29462. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29463. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29465. * @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)
  29466. * @param scene needed for loading to the correct scene
  29467. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29468. * @param onLoad optional callback to be called upon successful completion
  29469. * @param onError optional callback to be called upon failure
  29470. * @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
  29471. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29472. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29473. * @param forcedExtension defines the extension to use to pick the right loader
  29474. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29475. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29476. */
  29477. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29478. /**
  29479. * @hidden
  29480. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29481. /**
  29482. * Creates a raw texture
  29483. * @param data defines the data to store in the texture
  29484. * @param width defines the width of the texture
  29485. * @param height defines the height of the texture
  29486. * @param format defines the format of the data
  29487. * @param generateMipMaps defines if the engine should generate the mip levels
  29488. * @param invertY defines if data must be stored with Y axis inverted
  29489. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29490. * @param compression defines the compression used (null by default)
  29491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29492. * @returns the raw texture inside an InternalTexture
  29493. */
  29494. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29495. /**
  29496. * Creates a new raw cube texture
  29497. * @param data defines the array of data to use to create each face
  29498. * @param size defines the size of the textures
  29499. * @param format defines the format of the data
  29500. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29501. * @param generateMipMaps defines if the engine should generate the mip levels
  29502. * @param invertY defines if data must be stored with Y axis inverted
  29503. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29504. * @param compression defines the compression used (null by default)
  29505. * @returns the cube texture as an InternalTexture
  29506. */
  29507. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29508. /**
  29509. * Creates a new raw 3D texture
  29510. * @param data defines the data used to create the texture
  29511. * @param width defines the width of the texture
  29512. * @param height defines the height of the texture
  29513. * @param depth defines the depth of the texture
  29514. * @param format defines the format of the texture
  29515. * @param generateMipMaps defines if the engine must generate mip levels
  29516. * @param invertY defines if data must be stored with Y axis inverted
  29517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29518. * @param compression defines the compressed used (can be null)
  29519. * @param textureType defines the compressed used (can be null)
  29520. * @returns a new raw 3D texture (stored in an InternalTexture)
  29521. */
  29522. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29523. private _unpackFlipYCached;
  29524. /**
  29525. * In case you are sharing the context with other applications, it might
  29526. * be interested to not cache the unpack flip y state to ensure a consistent
  29527. * value would be set.
  29528. */
  29529. enableUnpackFlipYCached: boolean;
  29530. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29531. /** @hidden */ private _getUnpackAlignement(): number;
  29532. /**
  29533. * Update the sampling mode of a given texture
  29534. * @param samplingMode defines the required sampling mode
  29535. * @param texture defines the texture to update
  29536. */
  29537. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29538. /**
  29539. * Updates a depth texture Comparison Mode and Function.
  29540. * If the comparison Function is equal to 0, the mode will be set to none.
  29541. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29542. * @param texture The texture to set the comparison function for
  29543. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29544. */
  29545. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29546. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29547. width: number;
  29548. height: number;
  29549. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29550. /**
  29551. * Creates a depth stencil texture.
  29552. * This is only available in WebGL 2 or with the depth texture extension available.
  29553. * @param size The size of face edge in the texture.
  29554. * @param options The options defining the texture.
  29555. * @returns The texture
  29556. */
  29557. createDepthStencilTexture(size: number | {
  29558. width: number;
  29559. height: number;
  29560. }, options: DepthTextureCreationOptions): InternalTexture;
  29561. /**
  29562. * Creates a depth stencil texture.
  29563. * This is only available in WebGL 2 or with the depth texture extension available.
  29564. * @param size The size of face edge in the texture.
  29565. * @param options The options defining the texture.
  29566. * @returns The texture
  29567. */
  29568. private _createDepthStencilTexture;
  29569. /**
  29570. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29571. * @param renderTarget The render target to set the frame buffer for
  29572. */
  29573. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29574. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29575. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29576. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29577. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29578. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29579. /**
  29580. * @hidden
  29581. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  29582. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29583. private _prepareWebGLTexture;
  29584. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29585. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29586. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29587. protected _setProgram(program: WebGLProgram): void;
  29588. protected _boundUniforms: {
  29589. [key: number]: WebGLUniformLocation;
  29590. };
  29591. /**
  29592. * Binds an effect to the webGL context
  29593. * @param effect defines the effect to bind
  29594. */
  29595. bindSamplers(effect: Effect): void;
  29596. private _activateCurrentTexture;
  29597. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29598. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29599. /**
  29600. * Unbind all textures from the webGL context
  29601. */
  29602. unbindAllTextures(): void;
  29603. /**
  29604. * Sets a texture to the according uniform.
  29605. * @param channel The texture channel
  29606. * @param uniform The uniform to set
  29607. * @param texture The texture to apply
  29608. */
  29609. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29610. private _bindSamplerUniformToChannel;
  29611. private _getTextureWrapMode;
  29612. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29613. /**
  29614. * Sets an array of texture to the webGL context
  29615. * @param channel defines the channel where the texture array must be set
  29616. * @param uniform defines the associated uniform location
  29617. * @param textures defines the array of textures to bind
  29618. */
  29619. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29620. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29621. private _setTextureParameterFloat;
  29622. private _setTextureParameterInteger;
  29623. /**
  29624. * Unbind all vertex attributes from the webGL context
  29625. */
  29626. unbindAllAttributes(): void;
  29627. /**
  29628. * 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
  29629. */
  29630. releaseEffects(): void;
  29631. /**
  29632. * Dispose and release all associated resources
  29633. */
  29634. dispose(): void;
  29635. /**
  29636. * Attach a new callback raised when context lost event is fired
  29637. * @param callback defines the callback to call
  29638. */
  29639. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29640. /**
  29641. * Attach a new callback raised when context restored event is fired
  29642. * @param callback defines the callback to call
  29643. */
  29644. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29645. /**
  29646. * Get the current error code of the webGL context
  29647. * @returns the error code
  29648. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29649. */
  29650. getError(): number;
  29651. private _canRenderToFloatFramebuffer;
  29652. private _canRenderToHalfFloatFramebuffer;
  29653. private _canRenderToFramebuffer;
  29654. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29655. /** @hidden */ private _getInternalFormat(format: number): number;
  29656. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29657. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29658. /** @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;
  29659. /**
  29660. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29661. * @returns true if the engine can be created
  29662. * @ignorenaming
  29663. */
  29664. static isSupported(): boolean;
  29665. /**
  29666. * Find the next highest power of two.
  29667. * @param x Number to start search from.
  29668. * @return Next highest power of two.
  29669. */
  29670. static CeilingPOT(x: number): number;
  29671. /**
  29672. * Find the next lowest power of two.
  29673. * @param x Number to start search from.
  29674. * @return Next lowest power of two.
  29675. */
  29676. static FloorPOT(x: number): number;
  29677. /**
  29678. * Find the nearest power of two.
  29679. * @param x Number to start search from.
  29680. * @return Next nearest power of two.
  29681. */
  29682. static NearestPOT(x: number): number;
  29683. /**
  29684. * Get the closest exponent of two
  29685. * @param value defines the value to approximate
  29686. * @param max defines the maximum value to return
  29687. * @param mode defines how to define the closest value
  29688. * @returns closest exponent of two of the given value
  29689. */
  29690. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29691. /**
  29692. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29693. * @param func - the function to be called
  29694. * @param requester - the object that will request the next frame. Falls back to window.
  29695. * @returns frame number
  29696. */
  29697. static QueueNewFrame(func: () => void, requester?: any): number;
  29698. }
  29699. }
  29700. declare module BABYLON {
  29701. /**
  29702. * Class used to store data associated with WebGL texture data for the engine
  29703. * This class should not be used directly
  29704. */
  29705. export class InternalTexture {
  29706. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  29707. /**
  29708. * The source of the texture data is unknown
  29709. */
  29710. static DATASOURCE_UNKNOWN: number;
  29711. /**
  29712. * Texture data comes from an URL
  29713. */
  29714. static DATASOURCE_URL: number;
  29715. /**
  29716. * Texture data is only used for temporary storage
  29717. */
  29718. static DATASOURCE_TEMP: number;
  29719. /**
  29720. * Texture data comes from raw data (ArrayBuffer)
  29721. */
  29722. static DATASOURCE_RAW: number;
  29723. /**
  29724. * Texture content is dynamic (video or dynamic texture)
  29725. */
  29726. static DATASOURCE_DYNAMIC: number;
  29727. /**
  29728. * Texture content is generated by rendering to it
  29729. */
  29730. static DATASOURCE_RENDERTARGET: number;
  29731. /**
  29732. * Texture content is part of a multi render target process
  29733. */
  29734. static DATASOURCE_MULTIRENDERTARGET: number;
  29735. /**
  29736. * Texture data comes from a cube data file
  29737. */
  29738. static DATASOURCE_CUBE: number;
  29739. /**
  29740. * Texture data comes from a raw cube data
  29741. */
  29742. static DATASOURCE_CUBERAW: number;
  29743. /**
  29744. * Texture data come from a prefiltered cube data file
  29745. */
  29746. static DATASOURCE_CUBEPREFILTERED: number;
  29747. /**
  29748. * Texture content is raw 3D data
  29749. */
  29750. static DATASOURCE_RAW3D: number;
  29751. /**
  29752. * Texture content is a depth texture
  29753. */
  29754. static DATASOURCE_DEPTHTEXTURE: number;
  29755. /**
  29756. * Texture data comes from a raw cube data encoded with RGBD
  29757. */
  29758. static DATASOURCE_CUBERAW_RGBD: number;
  29759. /**
  29760. * Defines if the texture is ready
  29761. */
  29762. isReady: boolean;
  29763. /**
  29764. * Defines if the texture is a cube texture
  29765. */
  29766. isCube: boolean;
  29767. /**
  29768. * Defines if the texture contains 3D data
  29769. */
  29770. is3D: boolean;
  29771. /**
  29772. * Defines if the texture contains multiview data
  29773. */
  29774. isMultiview: boolean;
  29775. /**
  29776. * Gets the URL used to load this texture
  29777. */
  29778. url: string;
  29779. /**
  29780. * Gets the sampling mode of the texture
  29781. */
  29782. samplingMode: number;
  29783. /**
  29784. * Gets a boolean indicating if the texture needs mipmaps generation
  29785. */
  29786. generateMipMaps: boolean;
  29787. /**
  29788. * Gets the number of samples used by the texture (WebGL2+ only)
  29789. */
  29790. samples: number;
  29791. /**
  29792. * Gets the type of the texture (int, float...)
  29793. */
  29794. type: number;
  29795. /**
  29796. * Gets the format of the texture (RGB, RGBA...)
  29797. */
  29798. format: number;
  29799. /**
  29800. * Observable called when the texture is loaded
  29801. */
  29802. onLoadedObservable: Observable<InternalTexture>;
  29803. /**
  29804. * Gets the width of the texture
  29805. */
  29806. width: number;
  29807. /**
  29808. * Gets the height of the texture
  29809. */
  29810. height: number;
  29811. /**
  29812. * Gets the depth of the texture
  29813. */
  29814. depth: number;
  29815. /**
  29816. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29817. */
  29818. baseWidth: number;
  29819. /**
  29820. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29821. */
  29822. baseHeight: number;
  29823. /**
  29824. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29825. */
  29826. baseDepth: number;
  29827. /**
  29828. * Gets a boolean indicating if the texture is inverted on Y axis
  29829. */
  29830. invertY: boolean;
  29831. /** @hidden */ private _invertVScale: boolean;
  29832. /** @hidden */ private _associatedChannel: number;
  29833. /** @hidden */ private _dataSource: number;
  29834. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  29835. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  29836. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  29837. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29838. /** @hidden */ private _size: number;
  29839. /** @hidden */ private _extension: string;
  29840. /** @hidden */ private _files: Nullable<string[]>;
  29841. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29842. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29843. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  29844. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29845. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29846. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29847. /** @hidden */ private _attachments: Nullable<number[]>;
  29848. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  29849. /** @hidden */ private _cachedWrapU: Nullable<number>;
  29850. /** @hidden */ private _cachedWrapV: Nullable<number>;
  29851. /** @hidden */ private _cachedWrapR: Nullable<number>;
  29852. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  29853. /** @hidden */ private _isDisabled: boolean;
  29854. /** @hidden */ private _compression: Nullable<string>;
  29855. /** @hidden */ private _generateStencilBuffer: boolean;
  29856. /** @hidden */ private _generateDepthBuffer: boolean;
  29857. /** @hidden */ private _comparisonFunction: number;
  29858. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29859. /** @hidden */ private _lodGenerationScale: number;
  29860. /** @hidden */ private _lodGenerationOffset: number;
  29861. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  29862. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  29863. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  29864. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  29865. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  29866. /** @hidden */ private _isRGBD: boolean;
  29867. /** @hidden */ private _linearSpecularLOD: boolean;
  29868. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  29869. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  29870. /** @hidden */ private _references: number;
  29871. private _engine;
  29872. /**
  29873. * Gets the Engine the texture belongs to.
  29874. * @returns The babylon engine
  29875. */
  29876. getEngine(): ThinEngine;
  29877. /**
  29878. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29879. */
  29880. readonly dataSource: number;
  29881. /**
  29882. * Creates a new InternalTexture
  29883. * @param engine defines the engine to use
  29884. * @param dataSource defines the type of data that will be used
  29885. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29886. */
  29887. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  29888. /**
  29889. * Increments the number of references (ie. the number of Texture that point to it)
  29890. */
  29891. incrementReferences(): void;
  29892. /**
  29893. * Change the size of the texture (not the size of the content)
  29894. * @param width defines the new width
  29895. * @param height defines the new height
  29896. * @param depth defines the new depth (1 by default)
  29897. */
  29898. updateSize(width: int, height: int, depth?: int): void;
  29899. /** @hidden */ private _rebuild(): void;
  29900. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  29901. /**
  29902. * Dispose the current allocated resources
  29903. */
  29904. dispose(): void;
  29905. }
  29906. }
  29907. declare module BABYLON {
  29908. /**
  29909. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29911. */
  29912. export class Analyser {
  29913. /**
  29914. * Gets or sets the smoothing
  29915. * @ignorenaming
  29916. */
  29917. SMOOTHING: number;
  29918. /**
  29919. * Gets or sets the FFT table size
  29920. * @ignorenaming
  29921. */
  29922. FFT_SIZE: number;
  29923. /**
  29924. * Gets or sets the bar graph amplitude
  29925. * @ignorenaming
  29926. */
  29927. BARGRAPHAMPLITUDE: number;
  29928. /**
  29929. * Gets or sets the position of the debug canvas
  29930. * @ignorenaming
  29931. */
  29932. DEBUGCANVASPOS: {
  29933. x: number;
  29934. y: number;
  29935. };
  29936. /**
  29937. * Gets or sets the debug canvas size
  29938. * @ignorenaming
  29939. */
  29940. DEBUGCANVASSIZE: {
  29941. width: number;
  29942. height: number;
  29943. };
  29944. private _byteFreqs;
  29945. private _byteTime;
  29946. private _floatFreqs;
  29947. private _webAudioAnalyser;
  29948. private _debugCanvas;
  29949. private _debugCanvasContext;
  29950. private _scene;
  29951. private _registerFunc;
  29952. private _audioEngine;
  29953. /**
  29954. * Creates a new analyser
  29955. * @param scene defines hosting scene
  29956. */
  29957. constructor(scene: Scene);
  29958. /**
  29959. * Get the number of data values you will have to play with for the visualization
  29960. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29961. * @returns a number
  29962. */
  29963. getFrequencyBinCount(): number;
  29964. /**
  29965. * Gets the current frequency data as a byte array
  29966. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29967. * @returns a Uint8Array
  29968. */
  29969. getByteFrequencyData(): Uint8Array;
  29970. /**
  29971. * Gets the current waveform as a byte array
  29972. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29973. * @returns a Uint8Array
  29974. */
  29975. getByteTimeDomainData(): Uint8Array;
  29976. /**
  29977. * Gets the current frequency data as a float array
  29978. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29979. * @returns a Float32Array
  29980. */
  29981. getFloatFrequencyData(): Float32Array;
  29982. /**
  29983. * Renders the debug canvas
  29984. */
  29985. drawDebugCanvas(): void;
  29986. /**
  29987. * Stops rendering the debug canvas and removes it
  29988. */
  29989. stopDebugCanvas(): void;
  29990. /**
  29991. * Connects two audio nodes
  29992. * @param inputAudioNode defines first node to connect
  29993. * @param outputAudioNode defines second node to connect
  29994. */
  29995. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29996. /**
  29997. * Releases all associated resources
  29998. */
  29999. dispose(): void;
  30000. }
  30001. }
  30002. declare module BABYLON {
  30003. /**
  30004. * This represents an audio engine and it is responsible
  30005. * to play, synchronize and analyse sounds throughout the application.
  30006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30007. */
  30008. export interface IAudioEngine extends IDisposable {
  30009. /**
  30010. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30011. */
  30012. readonly canUseWebAudio: boolean;
  30013. /**
  30014. * Gets the current AudioContext if available.
  30015. */
  30016. readonly audioContext: Nullable<AudioContext>;
  30017. /**
  30018. * The master gain node defines the global audio volume of your audio engine.
  30019. */
  30020. readonly masterGain: GainNode;
  30021. /**
  30022. * Gets whether or not mp3 are supported by your browser.
  30023. */
  30024. readonly isMP3supported: boolean;
  30025. /**
  30026. * Gets whether or not ogg are supported by your browser.
  30027. */
  30028. readonly isOGGsupported: boolean;
  30029. /**
  30030. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30031. * @ignoreNaming
  30032. */
  30033. WarnedWebAudioUnsupported: boolean;
  30034. /**
  30035. * Defines if the audio engine relies on a custom unlocked button.
  30036. * In this case, the embedded button will not be displayed.
  30037. */
  30038. useCustomUnlockedButton: boolean;
  30039. /**
  30040. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30041. */
  30042. readonly unlocked: boolean;
  30043. /**
  30044. * Event raised when audio has been unlocked on the browser.
  30045. */
  30046. onAudioUnlockedObservable: Observable<AudioEngine>;
  30047. /**
  30048. * Event raised when audio has been locked on the browser.
  30049. */
  30050. onAudioLockedObservable: Observable<AudioEngine>;
  30051. /**
  30052. * Flags the audio engine in Locked state.
  30053. * This happens due to new browser policies preventing audio to autoplay.
  30054. */
  30055. lock(): void;
  30056. /**
  30057. * Unlocks the audio engine once a user action has been done on the dom.
  30058. * This is helpful to resume play once browser policies have been satisfied.
  30059. */
  30060. unlock(): void;
  30061. }
  30062. /**
  30063. * This represents the default audio engine used in babylon.
  30064. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30066. */
  30067. export class AudioEngine implements IAudioEngine {
  30068. private _audioContext;
  30069. private _audioContextInitialized;
  30070. private _muteButton;
  30071. private _hostElement;
  30072. /**
  30073. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30074. */
  30075. canUseWebAudio: boolean;
  30076. /**
  30077. * The master gain node defines the global audio volume of your audio engine.
  30078. */
  30079. masterGain: GainNode;
  30080. /**
  30081. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30082. * @ignoreNaming
  30083. */
  30084. WarnedWebAudioUnsupported: boolean;
  30085. /**
  30086. * Gets whether or not mp3 are supported by your browser.
  30087. */
  30088. isMP3supported: boolean;
  30089. /**
  30090. * Gets whether or not ogg are supported by your browser.
  30091. */
  30092. isOGGsupported: boolean;
  30093. /**
  30094. * Gets whether audio has been unlocked on the device.
  30095. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30096. * a user interaction has happened.
  30097. */
  30098. unlocked: boolean;
  30099. /**
  30100. * Defines if the audio engine relies on a custom unlocked button.
  30101. * In this case, the embedded button will not be displayed.
  30102. */
  30103. useCustomUnlockedButton: boolean;
  30104. /**
  30105. * Event raised when audio has been unlocked on the browser.
  30106. */
  30107. onAudioUnlockedObservable: Observable<AudioEngine>;
  30108. /**
  30109. * Event raised when audio has been locked on the browser.
  30110. */
  30111. onAudioLockedObservable: Observable<AudioEngine>;
  30112. /**
  30113. * Gets the current AudioContext if available.
  30114. */
  30115. readonly audioContext: Nullable<AudioContext>;
  30116. private _connectedAnalyser;
  30117. /**
  30118. * Instantiates a new audio engine.
  30119. *
  30120. * There should be only one per page as some browsers restrict the number
  30121. * of audio contexts you can create.
  30122. * @param hostElement defines the host element where to display the mute icon if necessary
  30123. */
  30124. constructor(hostElement?: Nullable<HTMLElement>);
  30125. /**
  30126. * Flags the audio engine in Locked state.
  30127. * This happens due to new browser policies preventing audio to autoplay.
  30128. */
  30129. lock(): void;
  30130. /**
  30131. * Unlocks the audio engine once a user action has been done on the dom.
  30132. * This is helpful to resume play once browser policies have been satisfied.
  30133. */
  30134. unlock(): void;
  30135. private _resumeAudioContext;
  30136. private _initializeAudioContext;
  30137. private _tryToRun;
  30138. private _triggerRunningState;
  30139. private _triggerSuspendedState;
  30140. private _displayMuteButton;
  30141. private _moveButtonToTopLeft;
  30142. private _onResize;
  30143. private _hideMuteButton;
  30144. /**
  30145. * Destroy and release the resources associated with the audio ccontext.
  30146. */
  30147. dispose(): void;
  30148. /**
  30149. * Gets the global volume sets on the master gain.
  30150. * @returns the global volume if set or -1 otherwise
  30151. */
  30152. getGlobalVolume(): number;
  30153. /**
  30154. * Sets the global volume of your experience (sets on the master gain).
  30155. * @param newVolume Defines the new global volume of the application
  30156. */
  30157. setGlobalVolume(newVolume: number): void;
  30158. /**
  30159. * Connect the audio engine to an audio analyser allowing some amazing
  30160. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30162. * @param analyser The analyser to connect to the engine
  30163. */
  30164. connectToAnalyser(analyser: Analyser): void;
  30165. }
  30166. }
  30167. declare module BABYLON {
  30168. /**
  30169. * Interface used to present a loading screen while loading a scene
  30170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30171. */
  30172. export interface ILoadingScreen {
  30173. /**
  30174. * Function called to display the loading screen
  30175. */
  30176. displayLoadingUI: () => void;
  30177. /**
  30178. * Function called to hide the loading screen
  30179. */
  30180. hideLoadingUI: () => void;
  30181. /**
  30182. * Gets or sets the color to use for the background
  30183. */
  30184. loadingUIBackgroundColor: string;
  30185. /**
  30186. * Gets or sets the text to display while loading
  30187. */
  30188. loadingUIText: string;
  30189. }
  30190. /**
  30191. * Class used for the default loading screen
  30192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30193. */
  30194. export class DefaultLoadingScreen implements ILoadingScreen {
  30195. private _renderingCanvas;
  30196. private _loadingText;
  30197. private _loadingDivBackgroundColor;
  30198. private _loadingDiv;
  30199. private _loadingTextDiv;
  30200. /** Gets or sets the logo url to use for the default loading screen */
  30201. static DefaultLogoUrl: string;
  30202. /** Gets or sets the spinner url to use for the default loading screen */
  30203. static DefaultSpinnerUrl: string;
  30204. /**
  30205. * Creates a new default loading screen
  30206. * @param _renderingCanvas defines the canvas used to render the scene
  30207. * @param _loadingText defines the default text to display
  30208. * @param _loadingDivBackgroundColor defines the default background color
  30209. */
  30210. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30211. /**
  30212. * Function called to display the loading screen
  30213. */
  30214. displayLoadingUI(): void;
  30215. /**
  30216. * Function called to hide the loading screen
  30217. */
  30218. hideLoadingUI(): void;
  30219. /**
  30220. * Gets or sets the text to display while loading
  30221. */
  30222. loadingUIText: string;
  30223. /**
  30224. * Gets or sets the color to use for the background
  30225. */
  30226. loadingUIBackgroundColor: string;
  30227. private _resizeLoadingUI;
  30228. }
  30229. }
  30230. declare module BABYLON {
  30231. /**
  30232. * Interface for any object that can request an animation frame
  30233. */
  30234. export interface ICustomAnimationFrameRequester {
  30235. /**
  30236. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30237. */
  30238. renderFunction?: Function;
  30239. /**
  30240. * Called to request the next frame to render to
  30241. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30242. */
  30243. requestAnimationFrame: Function;
  30244. /**
  30245. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30246. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30247. */
  30248. requestID?: number;
  30249. }
  30250. }
  30251. declare module BABYLON {
  30252. /**
  30253. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30254. */
  30255. export class PerformanceMonitor {
  30256. private _enabled;
  30257. private _rollingFrameTime;
  30258. private _lastFrameTimeMs;
  30259. /**
  30260. * constructor
  30261. * @param frameSampleSize The number of samples required to saturate the sliding window
  30262. */
  30263. constructor(frameSampleSize?: number);
  30264. /**
  30265. * Samples current frame
  30266. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30267. */
  30268. sampleFrame(timeMs?: number): void;
  30269. /**
  30270. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30271. */
  30272. readonly averageFrameTime: number;
  30273. /**
  30274. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30275. */
  30276. readonly averageFrameTimeVariance: number;
  30277. /**
  30278. * Returns the frame time of the most recent frame
  30279. */
  30280. readonly instantaneousFrameTime: number;
  30281. /**
  30282. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30283. */
  30284. readonly averageFPS: number;
  30285. /**
  30286. * Returns the average framerate in frames per second using the most recent frame time
  30287. */
  30288. readonly instantaneousFPS: number;
  30289. /**
  30290. * Returns true if enough samples have been taken to completely fill the sliding window
  30291. */
  30292. readonly isSaturated: boolean;
  30293. /**
  30294. * Enables contributions to the sliding window sample set
  30295. */
  30296. enable(): void;
  30297. /**
  30298. * Disables contributions to the sliding window sample set
  30299. * Samples will not be interpolated over the disabled period
  30300. */
  30301. disable(): void;
  30302. /**
  30303. * Returns true if sampling is enabled
  30304. */
  30305. readonly isEnabled: boolean;
  30306. /**
  30307. * Resets performance monitor
  30308. */
  30309. reset(): void;
  30310. }
  30311. /**
  30312. * RollingAverage
  30313. *
  30314. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30315. */
  30316. export class RollingAverage {
  30317. /**
  30318. * Current average
  30319. */
  30320. average: number;
  30321. /**
  30322. * Current variance
  30323. */
  30324. variance: number;
  30325. protected _samples: Array<number>;
  30326. protected _sampleCount: number;
  30327. protected _pos: number;
  30328. protected _m2: number;
  30329. /**
  30330. * constructor
  30331. * @param length The number of samples required to saturate the sliding window
  30332. */
  30333. constructor(length: number);
  30334. /**
  30335. * Adds a sample to the sample set
  30336. * @param v The sample value
  30337. */
  30338. add(v: number): void;
  30339. /**
  30340. * Returns previously added values or null if outside of history or outside the sliding window domain
  30341. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30342. * @return Value previously recorded with add() or null if outside of range
  30343. */
  30344. history(i: number): number;
  30345. /**
  30346. * Returns true if enough samples have been taken to completely fill the sliding window
  30347. * @return true if sample-set saturated
  30348. */
  30349. isSaturated(): boolean;
  30350. /**
  30351. * Resets the rolling average (equivalent to 0 samples taken so far)
  30352. */
  30353. reset(): void;
  30354. /**
  30355. * Wraps a value around the sample range boundaries
  30356. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30357. * @return Wrapped position in sample range
  30358. */
  30359. protected _wrapPosition(i: number): number;
  30360. }
  30361. }
  30362. declare module BABYLON {
  30363. /**
  30364. * Defines the interface used by display changed events
  30365. */
  30366. export interface IDisplayChangedEventArgs {
  30367. /** Gets the vrDisplay object (if any) */
  30368. vrDisplay: Nullable<any>;
  30369. /** Gets a boolean indicating if webVR is supported */
  30370. vrSupported: boolean;
  30371. }
  30372. /**
  30373. * Defines the interface used by objects containing a viewport (like a camera)
  30374. */
  30375. interface IViewportOwnerLike {
  30376. /**
  30377. * Gets or sets the viewport
  30378. */
  30379. viewport: IViewportLike;
  30380. }
  30381. /**
  30382. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30383. */
  30384. export class Engine extends ThinEngine {
  30385. /** Defines that alpha blending is disabled */
  30386. static readonly ALPHA_DISABLE: number;
  30387. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30388. static readonly ALPHA_ADD: number;
  30389. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30390. static readonly ALPHA_COMBINE: number;
  30391. /** Defines that alpha blending to DEST - SRC * DEST */
  30392. static readonly ALPHA_SUBTRACT: number;
  30393. /** Defines that alpha blending to SRC * DEST */
  30394. static readonly ALPHA_MULTIPLY: number;
  30395. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30396. static readonly ALPHA_MAXIMIZED: number;
  30397. /** Defines that alpha blending to SRC + DEST */
  30398. static readonly ALPHA_ONEONE: number;
  30399. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30400. static readonly ALPHA_PREMULTIPLIED: number;
  30401. /**
  30402. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30403. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30404. */
  30405. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30406. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30407. static readonly ALPHA_INTERPOLATE: number;
  30408. /**
  30409. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30410. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30411. */
  30412. static readonly ALPHA_SCREENMODE: number;
  30413. /** Defines that the ressource is not delayed*/
  30414. static readonly DELAYLOADSTATE_NONE: number;
  30415. /** Defines that the ressource was successfully delay loaded */
  30416. static readonly DELAYLOADSTATE_LOADED: number;
  30417. /** Defines that the ressource is currently delay loading */
  30418. static readonly DELAYLOADSTATE_LOADING: number;
  30419. /** Defines that the ressource is delayed and has not started loading */
  30420. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30421. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30422. static readonly NEVER: number;
  30423. /** 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 */
  30424. static readonly ALWAYS: number;
  30425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30426. static readonly LESS: number;
  30427. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30428. static readonly EQUAL: number;
  30429. /** 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 */
  30430. static readonly LEQUAL: number;
  30431. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30432. static readonly GREATER: number;
  30433. /** 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 */
  30434. static readonly GEQUAL: number;
  30435. /** 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 */
  30436. static readonly NOTEQUAL: number;
  30437. /** Passed to stencilOperation to specify that stencil value must be kept */
  30438. static readonly KEEP: number;
  30439. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30440. static readonly REPLACE: number;
  30441. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30442. static readonly INCR: number;
  30443. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30444. static readonly DECR: number;
  30445. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30446. static readonly INVERT: number;
  30447. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30448. static readonly INCR_WRAP: number;
  30449. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30450. static readonly DECR_WRAP: number;
  30451. /** Texture is not repeating outside of 0..1 UVs */
  30452. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30453. /** Texture is repeating outside of 0..1 UVs */
  30454. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30455. /** Texture is repeating and mirrored */
  30456. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30457. /** ALPHA */
  30458. static readonly TEXTUREFORMAT_ALPHA: number;
  30459. /** LUMINANCE */
  30460. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30461. /** LUMINANCE_ALPHA */
  30462. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30463. /** RGB */
  30464. static readonly TEXTUREFORMAT_RGB: number;
  30465. /** RGBA */
  30466. static readonly TEXTUREFORMAT_RGBA: number;
  30467. /** RED */
  30468. static readonly TEXTUREFORMAT_RED: number;
  30469. /** RED (2nd reference) */
  30470. static readonly TEXTUREFORMAT_R: number;
  30471. /** RG */
  30472. static readonly TEXTUREFORMAT_RG: number;
  30473. /** RED_INTEGER */
  30474. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30475. /** RED_INTEGER (2nd reference) */
  30476. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30477. /** RG_INTEGER */
  30478. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30479. /** RGB_INTEGER */
  30480. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30481. /** RGBA_INTEGER */
  30482. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30483. /** UNSIGNED_BYTE */
  30484. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30485. /** UNSIGNED_BYTE (2nd reference) */
  30486. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30487. /** FLOAT */
  30488. static readonly TEXTURETYPE_FLOAT: number;
  30489. /** HALF_FLOAT */
  30490. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30491. /** BYTE */
  30492. static readonly TEXTURETYPE_BYTE: number;
  30493. /** SHORT */
  30494. static readonly TEXTURETYPE_SHORT: number;
  30495. /** UNSIGNED_SHORT */
  30496. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30497. /** INT */
  30498. static readonly TEXTURETYPE_INT: number;
  30499. /** UNSIGNED_INT */
  30500. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30501. /** UNSIGNED_SHORT_4_4_4_4 */
  30502. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30503. /** UNSIGNED_SHORT_5_5_5_1 */
  30504. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30505. /** UNSIGNED_SHORT_5_6_5 */
  30506. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30507. /** UNSIGNED_INT_2_10_10_10_REV */
  30508. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30509. /** UNSIGNED_INT_24_8 */
  30510. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30511. /** UNSIGNED_INT_10F_11F_11F_REV */
  30512. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30513. /** UNSIGNED_INT_5_9_9_9_REV */
  30514. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30515. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30516. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30517. /** nearest is mag = nearest and min = nearest and mip = linear */
  30518. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30519. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30520. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30521. /** Trilinear is mag = linear and min = linear and mip = linear */
  30522. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30523. /** nearest is mag = nearest and min = nearest and mip = linear */
  30524. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30525. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30526. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30527. /** Trilinear is mag = linear and min = linear and mip = linear */
  30528. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30529. /** mag = nearest and min = nearest and mip = nearest */
  30530. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30531. /** mag = nearest and min = linear and mip = nearest */
  30532. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30533. /** mag = nearest and min = linear and mip = linear */
  30534. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30535. /** mag = nearest and min = linear and mip = none */
  30536. static readonly TEXTURE_NEAREST_LINEAR: number;
  30537. /** mag = nearest and min = nearest and mip = none */
  30538. static readonly TEXTURE_NEAREST_NEAREST: number;
  30539. /** mag = linear and min = nearest and mip = nearest */
  30540. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30541. /** mag = linear and min = nearest and mip = linear */
  30542. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30543. /** mag = linear and min = linear and mip = none */
  30544. static readonly TEXTURE_LINEAR_LINEAR: number;
  30545. /** mag = linear and min = nearest and mip = none */
  30546. static readonly TEXTURE_LINEAR_NEAREST: number;
  30547. /** Explicit coordinates mode */
  30548. static readonly TEXTURE_EXPLICIT_MODE: number;
  30549. /** Spherical coordinates mode */
  30550. static readonly TEXTURE_SPHERICAL_MODE: number;
  30551. /** Planar coordinates mode */
  30552. static readonly TEXTURE_PLANAR_MODE: number;
  30553. /** Cubic coordinates mode */
  30554. static readonly TEXTURE_CUBIC_MODE: number;
  30555. /** Projection coordinates mode */
  30556. static readonly TEXTURE_PROJECTION_MODE: number;
  30557. /** Skybox coordinates mode */
  30558. static readonly TEXTURE_SKYBOX_MODE: number;
  30559. /** Inverse Cubic coordinates mode */
  30560. static readonly TEXTURE_INVCUBIC_MODE: number;
  30561. /** Equirectangular coordinates mode */
  30562. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30563. /** Equirectangular Fixed coordinates mode */
  30564. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30565. /** Equirectangular Fixed Mirrored coordinates mode */
  30566. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30567. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30568. static readonly SCALEMODE_FLOOR: number;
  30569. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30570. static readonly SCALEMODE_NEAREST: number;
  30571. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30572. static readonly SCALEMODE_CEILING: number;
  30573. /**
  30574. * Returns the current npm package of the sdk
  30575. */
  30576. static readonly NpmPackage: string;
  30577. /**
  30578. * Returns the current version of the framework
  30579. */
  30580. static readonly Version: string;
  30581. /** Gets the list of created engines */
  30582. static readonly Instances: Engine[];
  30583. /**
  30584. * Gets the latest created engine
  30585. */
  30586. static readonly LastCreatedEngine: Nullable<Engine>;
  30587. /**
  30588. * Gets the latest created scene
  30589. */
  30590. static readonly LastCreatedScene: Nullable<Scene>;
  30591. /**
  30592. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30593. * @param flag defines which part of the materials must be marked as dirty
  30594. * @param predicate defines a predicate used to filter which materials should be affected
  30595. */
  30596. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30597. /**
  30598. * Method called to create the default loading screen.
  30599. * This can be overriden in your own app.
  30600. * @param canvas The rendering canvas element
  30601. * @returns The loading screen
  30602. */
  30603. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30604. /**
  30605. * Method called to create the default rescale post process on each engine.
  30606. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30607. /**
  30608. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30609. **/
  30610. enableOfflineSupport: boolean;
  30611. /**
  30612. * 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)
  30613. **/
  30614. disableManifestCheck: boolean;
  30615. /**
  30616. * Gets the list of created scenes
  30617. */
  30618. scenes: Scene[];
  30619. /**
  30620. * Event raised when a new scene is created
  30621. */
  30622. onNewSceneAddedObservable: Observable<Scene>;
  30623. /**
  30624. * Gets the list of created postprocesses
  30625. */
  30626. postProcesses: PostProcess[];
  30627. /**
  30628. * Gets a boolean indicating if the pointer is currently locked
  30629. */
  30630. isPointerLock: boolean;
  30631. /**
  30632. * Observable event triggered each time the rendering canvas is resized
  30633. */
  30634. onResizeObservable: Observable<Engine>;
  30635. /**
  30636. * Observable event triggered each time the canvas loses focus
  30637. */
  30638. onCanvasBlurObservable: Observable<Engine>;
  30639. /**
  30640. * Observable event triggered each time the canvas gains focus
  30641. */
  30642. onCanvasFocusObservable: Observable<Engine>;
  30643. /**
  30644. * Observable event triggered each time the canvas receives pointerout event
  30645. */
  30646. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30647. /**
  30648. * Observable event triggered before each texture is initialized
  30649. */
  30650. onBeforeTextureInitObservable: Observable<Texture>;
  30651. /**
  30652. * Observable raised when the engine begins a new frame
  30653. */
  30654. onBeginFrameObservable: Observable<Engine>;
  30655. /**
  30656. * If set, will be used to request the next animation frame for the render loop
  30657. */
  30658. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30659. /**
  30660. * Observable raised when the engine ends the current frame
  30661. */
  30662. onEndFrameObservable: Observable<Engine>;
  30663. /**
  30664. * Observable raised when the engine is about to compile a shader
  30665. */
  30666. onBeforeShaderCompilationObservable: Observable<Engine>;
  30667. /**
  30668. * Observable raised when the engine has jsut compiled a shader
  30669. */
  30670. onAfterShaderCompilationObservable: Observable<Engine>;
  30671. /**
  30672. * Gets the audio engine
  30673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30674. * @ignorenaming
  30675. */
  30676. static audioEngine: IAudioEngine;
  30677. /**
  30678. * Default AudioEngine factory responsible of creating the Audio Engine.
  30679. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30680. */
  30681. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30682. /**
  30683. * Default offline support factory responsible of creating a tool used to store data locally.
  30684. * By default, this will create a Database object if the workload has been embedded.
  30685. */
  30686. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30687. private _loadingScreen;
  30688. private _pointerLockRequested;
  30689. private _dummyFramebuffer;
  30690. private _rescalePostProcess;
  30691. /** @hidden */
  30692. protected _alphaMode: number;
  30693. /** @hidden */
  30694. protected _alphaEquation: number;
  30695. private _deterministicLockstep;
  30696. private _lockstepMaxSteps;
  30697. protected readonly _supportsHardwareTextureRescaling: boolean;
  30698. private _fps;
  30699. private _deltaTime;
  30700. /**
  30701. * Turn this value on if you want to pause FPS computation when in background
  30702. */
  30703. disablePerformanceMonitorInBackground: boolean;
  30704. private _performanceMonitor;
  30705. /**
  30706. * Gets the performance monitor attached to this engine
  30707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30708. */
  30709. readonly performanceMonitor: PerformanceMonitor;
  30710. private _onFocus;
  30711. private _onBlur;
  30712. private _onCanvasPointerOut;
  30713. private _onCanvasBlur;
  30714. private _onCanvasFocus;
  30715. private _onFullscreenChange;
  30716. private _onPointerLockChange;
  30717. /**
  30718. * Creates a new engine
  30719. * @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
  30720. * @param antialias defines enable antialiasing (default: false)
  30721. * @param options defines further options to be sent to the getContext() function
  30722. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30723. */
  30724. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30725. /**
  30726. * Gets current aspect ratio
  30727. * @param viewportOwner defines the camera to use to get the aspect ratio
  30728. * @param useScreen defines if screen size must be used (or the current render target if any)
  30729. * @returns a number defining the aspect ratio
  30730. */
  30731. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30732. /**
  30733. * Gets current screen aspect ratio
  30734. * @returns a number defining the aspect ratio
  30735. */
  30736. getScreenAspectRatio(): number;
  30737. /**
  30738. * Gets host document
  30739. * @returns the host document object
  30740. */
  30741. getHostDocument(): Document;
  30742. /**
  30743. * Gets the client rect of the HTML canvas attached with the current webGL context
  30744. * @returns a client rectanglee
  30745. */
  30746. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30747. /**
  30748. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30750. * @returns true if engine is in deterministic lock step mode
  30751. */
  30752. isDeterministicLockStep(): boolean;
  30753. /**
  30754. * Gets the max steps when engine is running in deterministic lock step
  30755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30756. * @returns the max steps
  30757. */
  30758. getLockstepMaxSteps(): number;
  30759. /**
  30760. * Force the mipmap generation for the given render target texture
  30761. * @param texture defines the render target texture to use
  30762. */
  30763. generateMipMapsForCubemap(texture: InternalTexture): void;
  30764. /** States */
  30765. /**
  30766. * Set various states to the webGL context
  30767. * @param culling defines backface culling state
  30768. * @param zOffset defines the value to apply to zOffset (0 by default)
  30769. * @param force defines if states must be applied even if cache is up to date
  30770. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30771. */
  30772. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30773. /**
  30774. * Set the z offset to apply to current rendering
  30775. * @param value defines the offset to apply
  30776. */
  30777. setZOffset(value: number): void;
  30778. /**
  30779. * Gets the current value of the zOffset
  30780. * @returns the current zOffset state
  30781. */
  30782. getZOffset(): number;
  30783. /**
  30784. * Enable or disable depth buffering
  30785. * @param enable defines the state to set
  30786. */
  30787. setDepthBuffer(enable: boolean): void;
  30788. /**
  30789. * Gets a boolean indicating if depth writing is enabled
  30790. * @returns the current depth writing state
  30791. */
  30792. getDepthWrite(): boolean;
  30793. /**
  30794. * Enable or disable depth writing
  30795. * @param enable defines the state to set
  30796. */
  30797. setDepthWrite(enable: boolean): void;
  30798. /**
  30799. * Enable or disable color writing
  30800. * @param enable defines the state to set
  30801. */
  30802. setColorWrite(enable: boolean): void;
  30803. /**
  30804. * Gets a boolean indicating if color writing is enabled
  30805. * @returns the current color writing state
  30806. */
  30807. getColorWrite(): boolean;
  30808. /**
  30809. * Sets alpha constants used by some alpha blending modes
  30810. * @param r defines the red component
  30811. * @param g defines the green component
  30812. * @param b defines the blue component
  30813. * @param a defines the alpha component
  30814. */
  30815. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30816. /**
  30817. * Sets the current alpha mode
  30818. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30819. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30821. */
  30822. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30823. /**
  30824. * Gets the current alpha mode
  30825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30826. * @returns the current alpha mode
  30827. */
  30828. getAlphaMode(): number;
  30829. /**
  30830. * Sets the current alpha equation
  30831. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  30832. */
  30833. setAlphaEquation(equation: number): void;
  30834. /**
  30835. * Gets the current alpha equation.
  30836. * @returns the current alpha equation
  30837. */
  30838. getAlphaEquation(): number;
  30839. /**
  30840. * Gets a boolean indicating if stencil buffer is enabled
  30841. * @returns the current stencil buffer state
  30842. */
  30843. getStencilBuffer(): boolean;
  30844. /**
  30845. * Enable or disable the stencil buffer
  30846. * @param enable defines if the stencil buffer must be enabled or disabled
  30847. */
  30848. setStencilBuffer(enable: boolean): void;
  30849. /**
  30850. * Gets the current stencil mask
  30851. * @returns a number defining the new stencil mask to use
  30852. */
  30853. getStencilMask(): number;
  30854. /**
  30855. * Sets the current stencil mask
  30856. * @param mask defines the new stencil mask to use
  30857. */
  30858. setStencilMask(mask: number): void;
  30859. /**
  30860. * Gets the current stencil function
  30861. * @returns a number defining the stencil function to use
  30862. */
  30863. getStencilFunction(): number;
  30864. /**
  30865. * Gets the current stencil reference value
  30866. * @returns a number defining the stencil reference value to use
  30867. */
  30868. getStencilFunctionReference(): number;
  30869. /**
  30870. * Gets the current stencil mask
  30871. * @returns a number defining the stencil mask to use
  30872. */
  30873. getStencilFunctionMask(): number;
  30874. /**
  30875. * Sets the current stencil function
  30876. * @param stencilFunc defines the new stencil function to use
  30877. */
  30878. setStencilFunction(stencilFunc: number): void;
  30879. /**
  30880. * Sets the current stencil reference
  30881. * @param reference defines the new stencil reference to use
  30882. */
  30883. setStencilFunctionReference(reference: number): void;
  30884. /**
  30885. * Sets the current stencil mask
  30886. * @param mask defines the new stencil mask to use
  30887. */
  30888. setStencilFunctionMask(mask: number): void;
  30889. /**
  30890. * Gets the current stencil operation when stencil fails
  30891. * @returns a number defining stencil operation to use when stencil fails
  30892. */
  30893. getStencilOperationFail(): number;
  30894. /**
  30895. * Gets the current stencil operation when depth fails
  30896. * @returns a number defining stencil operation to use when depth fails
  30897. */
  30898. getStencilOperationDepthFail(): number;
  30899. /**
  30900. * Gets the current stencil operation when stencil passes
  30901. * @returns a number defining stencil operation to use when stencil passes
  30902. */
  30903. getStencilOperationPass(): number;
  30904. /**
  30905. * Sets the stencil operation to use when stencil fails
  30906. * @param operation defines the stencil operation to use when stencil fails
  30907. */
  30908. setStencilOperationFail(operation: number): void;
  30909. /**
  30910. * Sets the stencil operation to use when depth fails
  30911. * @param operation defines the stencil operation to use when depth fails
  30912. */
  30913. setStencilOperationDepthFail(operation: number): void;
  30914. /**
  30915. * Sets the stencil operation to use when stencil passes
  30916. * @param operation defines the stencil operation to use when stencil passes
  30917. */
  30918. setStencilOperationPass(operation: number): void;
  30919. /**
  30920. * Sets a boolean indicating if the dithering state is enabled or disabled
  30921. * @param value defines the dithering state
  30922. */
  30923. setDitheringState(value: boolean): void;
  30924. /**
  30925. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30926. * @param value defines the rasterizer state
  30927. */
  30928. setRasterizerState(value: boolean): void;
  30929. /**
  30930. * Gets the current depth function
  30931. * @returns a number defining the depth function
  30932. */
  30933. getDepthFunction(): Nullable<number>;
  30934. /**
  30935. * Sets the current depth function
  30936. * @param depthFunc defines the function to use
  30937. */
  30938. setDepthFunction(depthFunc: number): void;
  30939. /**
  30940. * Sets the current depth function to GREATER
  30941. */
  30942. setDepthFunctionToGreater(): void;
  30943. /**
  30944. * Sets the current depth function to GEQUAL
  30945. */
  30946. setDepthFunctionToGreaterOrEqual(): void;
  30947. /**
  30948. * Sets the current depth function to LESS
  30949. */
  30950. setDepthFunctionToLess(): void;
  30951. /**
  30952. * Sets the current depth function to LEQUAL
  30953. */
  30954. setDepthFunctionToLessOrEqual(): void;
  30955. private _cachedStencilBuffer;
  30956. private _cachedStencilFunction;
  30957. private _cachedStencilMask;
  30958. private _cachedStencilOperationPass;
  30959. private _cachedStencilOperationFail;
  30960. private _cachedStencilOperationDepthFail;
  30961. private _cachedStencilReference;
  30962. /**
  30963. * Caches the the state of the stencil buffer
  30964. */
  30965. cacheStencilState(): void;
  30966. /**
  30967. * Restores the state of the stencil buffer
  30968. */
  30969. restoreStencilState(): void;
  30970. /**
  30971. * Directly set the WebGL Viewport
  30972. * @param x defines the x coordinate of the viewport (in screen space)
  30973. * @param y defines the y coordinate of the viewport (in screen space)
  30974. * @param width defines the width of the viewport (in screen space)
  30975. * @param height defines the height of the viewport (in screen space)
  30976. * @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
  30977. */
  30978. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30979. /**
  30980. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30981. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30982. * @param y defines the y-coordinate of the corner of the clear rectangle
  30983. * @param width defines the width of the clear rectangle
  30984. * @param height defines the height of the clear rectangle
  30985. * @param clearColor defines the clear color
  30986. */
  30987. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30988. /**
  30989. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30990. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30991. * @param y defines the y-coordinate of the corner of the clear rectangle
  30992. * @param width defines the width of the clear rectangle
  30993. * @param height defines the height of the clear rectangle
  30994. */
  30995. enableScissor(x: number, y: number, width: number, height: number): void;
  30996. /**
  30997. * Disable previously set scissor test rectangle
  30998. */
  30999. disableScissor(): void;
  31000. /**
  31001. * Initializes a webVR display and starts listening to display change events
  31002. * The onVRDisplayChangedObservable will be notified upon these changes
  31003. * @returns The onVRDisplayChangedObservable
  31004. */
  31005. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31006. /** @hidden */ private _prepareVRComponent(): void;
  31007. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31008. /** @hidden */ private _submitVRFrame(): void;
  31009. /**
  31010. * Call this function to leave webVR mode
  31011. * Will do nothing if webVR is not supported or if there is no webVR device
  31012. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31013. */
  31014. disableVR(): void;
  31015. /**
  31016. * Gets a boolean indicating that the system is in VR mode and is presenting
  31017. * @returns true if VR mode is engaged
  31018. */
  31019. isVRPresenting(): boolean;
  31020. /** @hidden */ private _requestVRFrame(): void;
  31021. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31022. /**
  31023. * Gets the source code of the vertex shader associated with a specific webGL program
  31024. * @param program defines the program to use
  31025. * @returns a string containing the source code of the vertex shader associated with the program
  31026. */
  31027. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31028. /**
  31029. * Gets the source code of the fragment shader associated with a specific webGL program
  31030. * @param program defines the program to use
  31031. * @returns a string containing the source code of the fragment shader associated with the program
  31032. */
  31033. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31034. /**
  31035. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31036. * @param x defines the x coordinate of the rectangle where pixels must be read
  31037. * @param y defines the y coordinate of the rectangle where pixels must be read
  31038. * @param width defines the width of the rectangle where pixels must be read
  31039. * @param height defines the height of the rectangle where pixels must be read
  31040. * @returns a Uint8Array containing RGBA colors
  31041. */
  31042. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31043. /**
  31044. * Sets a depth stencil texture from a render target to the according uniform.
  31045. * @param channel The texture channel
  31046. * @param uniform The uniform to set
  31047. * @param texture The render target texture containing the depth stencil texture to apply
  31048. */
  31049. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31050. /**
  31051. * Sets a texture to the webGL context from a postprocess
  31052. * @param channel defines the channel to use
  31053. * @param postProcess defines the source postprocess
  31054. */
  31055. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31056. /**
  31057. * Binds the output of the passed in post process to the texture channel specified
  31058. * @param channel The channel the texture should be bound to
  31059. * @param postProcess The post process which's output should be bound
  31060. */
  31061. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31062. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31063. protected _rebuildBuffers(): void; private _renderLoop(): void;
  31064. /**
  31065. * Toggle full screen mode
  31066. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31067. */
  31068. switchFullscreen(requestPointerLock: boolean): void;
  31069. /**
  31070. * Enters full screen mode
  31071. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31072. */
  31073. enterFullscreen(requestPointerLock: boolean): void;
  31074. /**
  31075. * Exits full screen mode
  31076. */
  31077. exitFullscreen(): void;
  31078. /**
  31079. * Enters Pointerlock mode
  31080. */
  31081. enterPointerlock(): void;
  31082. /**
  31083. * Exits Pointerlock mode
  31084. */
  31085. exitPointerlock(): void;
  31086. /**
  31087. * Begin a new frame
  31088. */
  31089. beginFrame(): void;
  31090. /**
  31091. * Enf the current frame
  31092. */
  31093. endFrame(): void;
  31094. resize(): void;
  31095. /**
  31096. * Set the compressed texture format to use, based on the formats you have, and the formats
  31097. * supported by the hardware / browser.
  31098. *
  31099. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31100. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31101. * to API arguments needed to compressed textures. This puts the burden on the container
  31102. * generator to house the arcane code for determining these for current & future formats.
  31103. *
  31104. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31105. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31106. *
  31107. * Note: The result of this call is not taken into account when a texture is base64.
  31108. *
  31109. * @param formatsAvailable defines the list of those format families you have created
  31110. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31111. *
  31112. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31113. * @returns The extension selected.
  31114. */
  31115. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31116. /**
  31117. * Force a specific size of the canvas
  31118. * @param width defines the new canvas' width
  31119. * @param height defines the new canvas' height
  31120. */
  31121. setSize(width: number, height: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31123. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  31124. /**
  31125. * @hidden
  31126. * Rescales a texture
  31127. * @param source input texutre
  31128. * @param destination destination texture
  31129. * @param scene scene to use to render the resize
  31130. * @param internalFormat format to use when resizing
  31131. * @param onComplete callback to be called when resize has completed
  31132. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31133. /**
  31134. * Gets the current framerate
  31135. * @returns a number representing the framerate
  31136. */
  31137. getFps(): number;
  31138. /**
  31139. * Gets the time spent between current and previous frame
  31140. * @returns a number representing the delta time in ms
  31141. */
  31142. getDeltaTime(): number;
  31143. private _measureFps;
  31144. /**
  31145. * Creates a new render target texture
  31146. * @param size defines the size of the texture
  31147. * @param options defines the options used to create the texture
  31148. * @returns a new render target texture stored in an InternalTexture
  31149. */
  31150. createRenderTargetTexture(size: number | {
  31151. width: number;
  31152. height: number;
  31153. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31154. /**
  31155. * Updates the sample count of a render target texture
  31156. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31157. * @param texture defines the texture to update
  31158. * @param samples defines the sample count to set
  31159. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31160. */
  31161. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31162. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31163. dispose(): void;
  31164. private _disableTouchAction;
  31165. /**
  31166. * Display the loading screen
  31167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31168. */
  31169. displayLoadingUI(): void;
  31170. /**
  31171. * Hide the loading screen
  31172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31173. */
  31174. hideLoadingUI(): void;
  31175. /**
  31176. * Gets the current loading screen object
  31177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31178. */
  31179. /**
  31180. * Sets the current loading screen object
  31181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31182. */
  31183. loadingScreen: ILoadingScreen;
  31184. /**
  31185. * Sets the current loading screen text
  31186. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31187. */
  31188. loadingUIText: string;
  31189. /**
  31190. * Sets the current loading screen background color
  31191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31192. */
  31193. loadingUIBackgroundColor: string;
  31194. /** Pointerlock and fullscreen */
  31195. /**
  31196. * Ask the browser to promote the current element to pointerlock mode
  31197. * @param element defines the DOM element to promote
  31198. */ private static _RequestPointerlock(element: HTMLElement): void;
  31199. /**
  31200. * Asks the browser to exit pointerlock mode
  31201. */ private static _ExitPointerlock(): void;
  31202. /**
  31203. * Ask the browser to promote the current element to fullscreen rendering mode
  31204. * @param element defines the DOM element to promote
  31205. */ private static _RequestFullscreen(element: HTMLElement): void;
  31206. /**
  31207. * Asks the browser to exit fullscreen mode
  31208. */ private static _ExitFullscreen(): void;
  31209. }
  31210. }
  31211. declare module BABYLON {
  31212. /**
  31213. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31214. * during the life time of the application.
  31215. */
  31216. export class EngineStore {
  31217. /** Gets the list of created engines */
  31218. static Instances: Engine[];
  31219. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31220. /**
  31221. * Gets the latest created engine
  31222. */
  31223. static readonly LastCreatedEngine: Nullable<Engine>;
  31224. /**
  31225. * Gets the latest created scene
  31226. */
  31227. static readonly LastCreatedScene: Nullable<Scene>;
  31228. /**
  31229. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31230. * @ignorenaming
  31231. */
  31232. static UseFallbackTexture: boolean;
  31233. /**
  31234. * Texture content used if a texture cannot loaded
  31235. * @ignorenaming
  31236. */
  31237. static FallbackTexture: string;
  31238. }
  31239. }
  31240. declare module BABYLON {
  31241. /**
  31242. * Helper class that provides a small promise polyfill
  31243. */
  31244. export class PromisePolyfill {
  31245. /**
  31246. * Static function used to check if the polyfill is required
  31247. * If this is the case then the function will inject the polyfill to window.Promise
  31248. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31249. */
  31250. static Apply(force?: boolean): void;
  31251. }
  31252. }
  31253. declare module BABYLON {
  31254. /**
  31255. * Interface for screenshot methods with describe argument called `size` as object with options
  31256. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31257. */
  31258. export interface IScreenshotSize {
  31259. /**
  31260. * number in pixels for canvas height
  31261. */
  31262. height?: number;
  31263. /**
  31264. * multiplier allowing render at a higher or lower resolution
  31265. * If value is defined then height and width will be ignored and taken from camera
  31266. */
  31267. precision?: number;
  31268. /**
  31269. * number in pixels for canvas width
  31270. */
  31271. width?: number;
  31272. }
  31273. }
  31274. declare module BABYLON {
  31275. interface IColor4Like {
  31276. r: float;
  31277. g: float;
  31278. b: float;
  31279. a: float;
  31280. }
  31281. /**
  31282. * Class containing a set of static utilities functions
  31283. */
  31284. export class Tools {
  31285. /**
  31286. * Gets or sets the base URL to use to load assets
  31287. */
  31288. static BaseUrl: string;
  31289. /**
  31290. * Enable/Disable Custom HTTP Request Headers globally.
  31291. * default = false
  31292. * @see CustomRequestHeaders
  31293. */
  31294. static UseCustomRequestHeaders: boolean;
  31295. /**
  31296. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31297. * i.e. when loading files, where the server/service expects an Authorization header
  31298. */
  31299. static CustomRequestHeaders: {
  31300. [key: string]: string;
  31301. };
  31302. /**
  31303. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31304. */
  31305. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31306. /**
  31307. * Default behaviour for cors in the application.
  31308. * It can be a string if the expected behavior is identical in the entire app.
  31309. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31310. */
  31311. static CorsBehavior: string | ((url: string | string[]) => string);
  31312. /**
  31313. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31314. * @ignorenaming
  31315. */
  31316. static UseFallbackTexture: boolean;
  31317. /**
  31318. * Use this object to register external classes like custom textures or material
  31319. * to allow the laoders to instantiate them
  31320. */
  31321. static RegisteredExternalClasses: {
  31322. [key: string]: Object;
  31323. };
  31324. /**
  31325. * Texture content used if a texture cannot loaded
  31326. * @ignorenaming
  31327. */
  31328. static fallbackTexture: string;
  31329. /**
  31330. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31331. * @param u defines the coordinate on X axis
  31332. * @param v defines the coordinate on Y axis
  31333. * @param width defines the width of the source data
  31334. * @param height defines the height of the source data
  31335. * @param pixels defines the source byte array
  31336. * @param color defines the output color
  31337. */
  31338. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31339. /**
  31340. * Interpolates between a and b via alpha
  31341. * @param a The lower value (returned when alpha = 0)
  31342. * @param b The upper value (returned when alpha = 1)
  31343. * @param alpha The interpolation-factor
  31344. * @return The mixed value
  31345. */
  31346. static Mix(a: number, b: number, alpha: number): number;
  31347. /**
  31348. * Tries to instantiate a new object from a given class name
  31349. * @param className defines the class name to instantiate
  31350. * @returns the new object or null if the system was not able to do the instantiation
  31351. */
  31352. static Instantiate(className: string): any;
  31353. /**
  31354. * Provides a slice function that will work even on IE
  31355. * @param data defines the array to slice
  31356. * @param start defines the start of the data (optional)
  31357. * @param end defines the end of the data (optional)
  31358. * @returns the new sliced array
  31359. */
  31360. static Slice<T>(data: T, start?: number, end?: number): T;
  31361. /**
  31362. * Polyfill for setImmediate
  31363. * @param action defines the action to execute after the current execution block
  31364. */
  31365. static SetImmediate(action: () => void): void;
  31366. /**
  31367. * Function indicating if a number is an exponent of 2
  31368. * @param value defines the value to test
  31369. * @returns true if the value is an exponent of 2
  31370. */
  31371. static IsExponentOfTwo(value: number): boolean;
  31372. private static _tmpFloatArray;
  31373. /**
  31374. * Returns the nearest 32-bit single precision float representation of a Number
  31375. * @param value A Number. If the parameter is of a different type, it will get converted
  31376. * to a number or to NaN if it cannot be converted
  31377. * @returns number
  31378. */
  31379. static FloatRound(value: number): number;
  31380. /**
  31381. * Extracts the filename from a path
  31382. * @param path defines the path to use
  31383. * @returns the filename
  31384. */
  31385. static GetFilename(path: string): string;
  31386. /**
  31387. * Extracts the "folder" part of a path (everything before the filename).
  31388. * @param uri The URI to extract the info from
  31389. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31390. * @returns The "folder" part of the path
  31391. */
  31392. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31393. /**
  31394. * Extracts text content from a DOM element hierarchy
  31395. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31396. */
  31397. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31398. /**
  31399. * Convert an angle in radians to degrees
  31400. * @param angle defines the angle to convert
  31401. * @returns the angle in degrees
  31402. */
  31403. static ToDegrees(angle: number): number;
  31404. /**
  31405. * Convert an angle in degrees to radians
  31406. * @param angle defines the angle to convert
  31407. * @returns the angle in radians
  31408. */
  31409. static ToRadians(angle: number): number;
  31410. /**
  31411. * Encode a buffer to a base64 string
  31412. * @param buffer defines the buffer to encode
  31413. * @returns the encoded string
  31414. */
  31415. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31416. /**
  31417. * Returns an array if obj is not an array
  31418. * @param obj defines the object to evaluate as an array
  31419. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31420. * @returns either obj directly if obj is an array or a new array containing obj
  31421. */
  31422. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31423. /**
  31424. * Gets the pointer prefix to use
  31425. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31426. */
  31427. static GetPointerPrefix(): string;
  31428. /**
  31429. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31430. * @param url define the url we are trying
  31431. * @param element define the dom element where to configure the cors policy
  31432. */
  31433. static SetCorsBehavior(url: string | string[], element: {
  31434. crossOrigin: string | null;
  31435. }): void;
  31436. /**
  31437. * Removes unwanted characters from an url
  31438. * @param url defines the url to clean
  31439. * @returns the cleaned url
  31440. */
  31441. static CleanUrl(url: string): string;
  31442. /**
  31443. * Gets or sets a function used to pre-process url before using them to load assets
  31444. */
  31445. static PreprocessUrl: (url: string) => string;
  31446. /**
  31447. * Loads an image as an HTMLImageElement.
  31448. * @param input url string, ArrayBuffer, or Blob to load
  31449. * @param onLoad callback called when the image successfully loads
  31450. * @param onError callback called when the image fails to load
  31451. * @param offlineProvider offline provider for caching
  31452. * @returns the HTMLImageElement of the loaded image
  31453. */
  31454. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31455. /**
  31456. * Loads a file
  31457. * @param url url string, ArrayBuffer, or Blob to load
  31458. * @param onSuccess callback called when the file successfully loads
  31459. * @param onProgress callback called while file is loading (if the server supports this mode)
  31460. * @param offlineProvider defines the offline provider for caching
  31461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31462. * @param onError callback called when the file fails to load
  31463. * @returns a file request object
  31464. */
  31465. 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;
  31466. /**
  31467. * Loads a file from a url
  31468. * @param url the file url to load
  31469. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31470. */
  31471. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31472. /**
  31473. * Load a script (identified by an url). When the url returns, the
  31474. * content of this file is added into a new script element, attached to the DOM (body element)
  31475. * @param scriptUrl defines the url of the script to laod
  31476. * @param onSuccess defines the callback called when the script is loaded
  31477. * @param onError defines the callback to call if an error occurs
  31478. * @param scriptId defines the id of the script element
  31479. */
  31480. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31481. /**
  31482. * Load an asynchronous script (identified by an url). When the url returns, the
  31483. * content of this file is added into a new script element, attached to the DOM (body element)
  31484. * @param scriptUrl defines the url of the script to laod
  31485. * @param scriptId defines the id of the script element
  31486. * @returns a promise request object
  31487. */
  31488. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31489. /**
  31490. * Loads a file from a blob
  31491. * @param fileToLoad defines the blob to use
  31492. * @param callback defines the callback to call when data is loaded
  31493. * @param progressCallback defines the callback to call during loading process
  31494. * @returns a file request object
  31495. */
  31496. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31497. /**
  31498. * Loads a file
  31499. * @param fileToLoad defines the file to load
  31500. * @param callback defines the callback to call when data is loaded
  31501. * @param progressCallBack defines the callback to call during loading process
  31502. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31503. * @returns a file request object
  31504. */
  31505. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31506. /**
  31507. * Creates a data url from a given string content
  31508. * @param content defines the content to convert
  31509. * @returns the new data url link
  31510. */
  31511. static FileAsURL(content: string): string;
  31512. /**
  31513. * Format the given number to a specific decimal format
  31514. * @param value defines the number to format
  31515. * @param decimals defines the number of decimals to use
  31516. * @returns the formatted string
  31517. */
  31518. static Format(value: number, decimals?: number): string;
  31519. /**
  31520. * Tries to copy an object by duplicating every property
  31521. * @param source defines the source object
  31522. * @param destination defines the target object
  31523. * @param doNotCopyList defines a list of properties to avoid
  31524. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31525. */
  31526. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31527. /**
  31528. * Gets a boolean indicating if the given object has no own property
  31529. * @param obj defines the object to test
  31530. * @returns true if object has no own property
  31531. */
  31532. static IsEmpty(obj: any): boolean;
  31533. /**
  31534. * Function used to register events at window level
  31535. * @param windowElement defines the Window object to use
  31536. * @param events defines the events to register
  31537. */
  31538. static RegisterTopRootEvents(windowElement: Window, events: {
  31539. name: string;
  31540. handler: Nullable<(e: FocusEvent) => any>;
  31541. }[]): void;
  31542. /**
  31543. * Function used to unregister events from window level
  31544. * @param windowElement defines the Window object to use
  31545. * @param events defines the events to unregister
  31546. */
  31547. static UnregisterTopRootEvents(windowElement: Window, events: {
  31548. name: string;
  31549. handler: Nullable<(e: FocusEvent) => any>;
  31550. }[]): void;
  31551. /**
  31552. * @ignore
  31553. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31554. /**
  31555. * Dumps the current bound framebuffer
  31556. * @param width defines the rendering width
  31557. * @param height defines the rendering height
  31558. * @param engine defines the hosting engine
  31559. * @param successCallback defines the callback triggered once the data are available
  31560. * @param mimeType defines the mime type of the result
  31561. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31562. */
  31563. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31564. /**
  31565. * Converts the canvas data to blob.
  31566. * This acts as a polyfill for browsers not supporting the to blob function.
  31567. * @param canvas Defines the canvas to extract the data from
  31568. * @param successCallback Defines the callback triggered once the data are available
  31569. * @param mimeType Defines the mime type of the result
  31570. */
  31571. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31572. /**
  31573. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31574. * @param successCallback defines the callback triggered once the data are available
  31575. * @param mimeType defines the mime type of the result
  31576. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31577. */
  31578. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31579. /**
  31580. * Downloads a blob in the browser
  31581. * @param blob defines the blob to download
  31582. * @param fileName defines the name of the downloaded file
  31583. */
  31584. static Download(blob: Blob, fileName: string): void;
  31585. /**
  31586. * Captures a screenshot of the current rendering
  31587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31588. * @param engine defines the rendering engine
  31589. * @param camera defines the source camera
  31590. * @param size This parameter can be set to a single number or to an object with the
  31591. * following (optional) properties: precision, width, height. If a single number is passed,
  31592. * it will be used for both width and height. If an object is passed, the screenshot size
  31593. * will be derived from the parameters. The precision property is a multiplier allowing
  31594. * rendering at a higher or lower resolution
  31595. * @param successCallback defines the callback receives a single parameter which contains the
  31596. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31597. * src parameter of an <img> to display it
  31598. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31599. * Check your browser for supported MIME types
  31600. */
  31601. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31602. /**
  31603. * Captures a screenshot of the current rendering
  31604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31605. * @param engine defines the rendering engine
  31606. * @param camera defines the source camera
  31607. * @param size This parameter can be set to a single number or to an object with the
  31608. * following (optional) properties: precision, width, height. If a single number is passed,
  31609. * it will be used for both width and height. If an object is passed, the screenshot size
  31610. * will be derived from the parameters. The precision property is a multiplier allowing
  31611. * rendering at a higher or lower resolution
  31612. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31613. * Check your browser for supported MIME types
  31614. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31615. * to the src parameter of an <img> to display it
  31616. */
  31617. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31618. /**
  31619. * Generates an image screenshot from the specified camera.
  31620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31621. * @param engine The engine to use for rendering
  31622. * @param camera The camera to use for rendering
  31623. * @param size This parameter can be set to a single number or to an object with the
  31624. * following (optional) properties: precision, width, height. If a single number is passed,
  31625. * it will be used for both width and height. If an object is passed, the screenshot size
  31626. * will be derived from the parameters. The precision property is a multiplier allowing
  31627. * rendering at a higher or lower resolution
  31628. * @param successCallback The callback receives a single parameter which contains the
  31629. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31630. * src parameter of an <img> to display it
  31631. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31632. * Check your browser for supported MIME types
  31633. * @param samples Texture samples (default: 1)
  31634. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31635. * @param fileName A name for for the downloaded file.
  31636. */
  31637. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31638. /**
  31639. * Generates an image screenshot from the specified camera.
  31640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31641. * @param engine The engine to use for rendering
  31642. * @param camera The camera to use for rendering
  31643. * @param size This parameter can be set to a single number or to an object with the
  31644. * following (optional) properties: precision, width, height. If a single number is passed,
  31645. * it will be used for both width and height. If an object is passed, the screenshot size
  31646. * will be derived from the parameters. The precision property is a multiplier allowing
  31647. * rendering at a higher or lower resolution
  31648. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31649. * Check your browser for supported MIME types
  31650. * @param samples Texture samples (default: 1)
  31651. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31652. * @param fileName A name for for the downloaded file.
  31653. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31654. * to the src parameter of an <img> to display it
  31655. */
  31656. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31657. /**
  31658. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31659. * Be aware Math.random() could cause collisions, but:
  31660. * "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"
  31661. * @returns a pseudo random id
  31662. */
  31663. static RandomId(): string;
  31664. /**
  31665. * Test if the given uri is a base64 string
  31666. * @param uri The uri to test
  31667. * @return True if the uri is a base64 string or false otherwise
  31668. */
  31669. static IsBase64(uri: string): boolean;
  31670. /**
  31671. * Decode the given base64 uri.
  31672. * @param uri The uri to decode
  31673. * @return The decoded base64 data.
  31674. */
  31675. static DecodeBase64(uri: string): ArrayBuffer;
  31676. /**
  31677. * Gets the absolute url.
  31678. * @param url the input url
  31679. * @return the absolute url
  31680. */
  31681. static GetAbsoluteUrl(url: string): string;
  31682. /**
  31683. * No log
  31684. */
  31685. static readonly NoneLogLevel: number;
  31686. /**
  31687. * Only message logs
  31688. */
  31689. static readonly MessageLogLevel: number;
  31690. /**
  31691. * Only warning logs
  31692. */
  31693. static readonly WarningLogLevel: number;
  31694. /**
  31695. * Only error logs
  31696. */
  31697. static readonly ErrorLogLevel: number;
  31698. /**
  31699. * All logs
  31700. */
  31701. static readonly AllLogLevel: number;
  31702. /**
  31703. * Gets a value indicating the number of loading errors
  31704. * @ignorenaming
  31705. */
  31706. static readonly errorsCount: number;
  31707. /**
  31708. * Callback called when a new log is added
  31709. */
  31710. static OnNewCacheEntry: (entry: string) => void;
  31711. /**
  31712. * Log a message to the console
  31713. * @param message defines the message to log
  31714. */
  31715. static Log(message: string): void;
  31716. /**
  31717. * Write a warning message to the console
  31718. * @param message defines the message to log
  31719. */
  31720. static Warn(message: string): void;
  31721. /**
  31722. * Write an error message to the console
  31723. * @param message defines the message to log
  31724. */
  31725. static Error(message: string): void;
  31726. /**
  31727. * Gets current log cache (list of logs)
  31728. */
  31729. static readonly LogCache: string;
  31730. /**
  31731. * Clears the log cache
  31732. */
  31733. static ClearLogCache(): void;
  31734. /**
  31735. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31736. */
  31737. static LogLevels: number;
  31738. /**
  31739. * Checks if the window object exists
  31740. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31741. */
  31742. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31743. /**
  31744. * No performance log
  31745. */
  31746. static readonly PerformanceNoneLogLevel: number;
  31747. /**
  31748. * Use user marks to log performance
  31749. */
  31750. static readonly PerformanceUserMarkLogLevel: number;
  31751. /**
  31752. * Log performance to the console
  31753. */
  31754. static readonly PerformanceConsoleLogLevel: number;
  31755. private static _performance;
  31756. /**
  31757. * Sets the current performance log level
  31758. */
  31759. static PerformanceLogLevel: number;
  31760. private static _StartPerformanceCounterDisabled;
  31761. private static _EndPerformanceCounterDisabled;
  31762. private static _StartUserMark;
  31763. private static _EndUserMark;
  31764. private static _StartPerformanceConsole;
  31765. private static _EndPerformanceConsole;
  31766. /**
  31767. * Starts a performance counter
  31768. */
  31769. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31770. /**
  31771. * Ends a specific performance coutner
  31772. */
  31773. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31774. /**
  31775. * Gets either window.performance.now() if supported or Date.now() else
  31776. */
  31777. static readonly Now: number;
  31778. /**
  31779. * This method will return the name of the class used to create the instance of the given object.
  31780. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31781. * @param object the object to get the class name from
  31782. * @param isType defines if the object is actually a type
  31783. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31784. */
  31785. static GetClassName(object: any, isType?: boolean): string;
  31786. /**
  31787. * Gets the first element of an array satisfying a given predicate
  31788. * @param array defines the array to browse
  31789. * @param predicate defines the predicate to use
  31790. * @returns null if not found or the element
  31791. */
  31792. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31793. /**
  31794. * This method will return the name of the full name of the class, including its owning module (if any).
  31795. * 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).
  31796. * @param object the object to get the class name from
  31797. * @param isType defines if the object is actually a type
  31798. * @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.
  31799. * @ignorenaming
  31800. */
  31801. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31802. /**
  31803. * Returns a promise that resolves after the given amount of time.
  31804. * @param delay Number of milliseconds to delay
  31805. * @returns Promise that resolves after the given amount of time
  31806. */
  31807. static DelayAsync(delay: number): Promise<void>;
  31808. }
  31809. /**
  31810. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31811. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31812. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31813. * @param name The name of the class, case should be preserved
  31814. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31815. */
  31816. export function className(name: string, module?: string): (target: Object) => void;
  31817. /**
  31818. * An implementation of a loop for asynchronous functions.
  31819. */
  31820. export class AsyncLoop {
  31821. /**
  31822. * Defines the number of iterations for the loop
  31823. */
  31824. iterations: number;
  31825. /**
  31826. * Defines the current index of the loop.
  31827. */
  31828. index: number;
  31829. private _done;
  31830. private _fn;
  31831. private _successCallback;
  31832. /**
  31833. * Constructor.
  31834. * @param iterations the number of iterations.
  31835. * @param func the function to run each iteration
  31836. * @param successCallback the callback that will be called upon succesful execution
  31837. * @param offset starting offset.
  31838. */
  31839. constructor(
  31840. /**
  31841. * Defines the number of iterations for the loop
  31842. */
  31843. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31844. /**
  31845. * Execute the next iteration. Must be called after the last iteration was finished.
  31846. */
  31847. executeNext(): void;
  31848. /**
  31849. * Break the loop and run the success callback.
  31850. */
  31851. breakLoop(): void;
  31852. /**
  31853. * Create and run an async loop.
  31854. * @param iterations the number of iterations.
  31855. * @param fn the function to run each iteration
  31856. * @param successCallback the callback that will be called upon succesful execution
  31857. * @param offset starting offset.
  31858. * @returns the created async loop object
  31859. */
  31860. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31861. /**
  31862. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31863. * @param iterations total number of iterations
  31864. * @param syncedIterations number of synchronous iterations in each async iteration.
  31865. * @param fn the function to call each iteration.
  31866. * @param callback a success call back that will be called when iterating stops.
  31867. * @param breakFunction a break condition (optional)
  31868. * @param timeout timeout settings for the setTimeout function. default - 0.
  31869. * @returns the created async loop object
  31870. */
  31871. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31872. }
  31873. }
  31874. declare module BABYLON {
  31875. /**
  31876. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31877. * The underlying implementation relies on an associative array to ensure the best performances.
  31878. * The value can be anything including 'null' but except 'undefined'
  31879. */
  31880. export class StringDictionary<T> {
  31881. /**
  31882. * This will clear this dictionary and copy the content from the 'source' one.
  31883. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31884. * @param source the dictionary to take the content from and copy to this dictionary
  31885. */
  31886. copyFrom(source: StringDictionary<T>): void;
  31887. /**
  31888. * Get a value based from its key
  31889. * @param key the given key to get the matching value from
  31890. * @return the value if found, otherwise undefined is returned
  31891. */
  31892. get(key: string): T | undefined;
  31893. /**
  31894. * Get a value from its key or add it if it doesn't exist.
  31895. * This method will ensure you that a given key/data will be present in the dictionary.
  31896. * @param key the given key to get the matching value from
  31897. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31898. * The factory will only be invoked if there's no data for the given key.
  31899. * @return the value corresponding to the key.
  31900. */
  31901. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31902. /**
  31903. * Get a value from its key if present in the dictionary otherwise add it
  31904. * @param key the key to get the value from
  31905. * @param val if there's no such key/value pair in the dictionary add it with this value
  31906. * @return the value corresponding to the key
  31907. */
  31908. getOrAdd(key: string, val: T): T;
  31909. /**
  31910. * Check if there's a given key in the dictionary
  31911. * @param key the key to check for
  31912. * @return true if the key is present, false otherwise
  31913. */
  31914. contains(key: string): boolean;
  31915. /**
  31916. * Add a new key and its corresponding value
  31917. * @param key the key to add
  31918. * @param value the value corresponding to the key
  31919. * @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
  31920. */
  31921. add(key: string, value: T): boolean;
  31922. /**
  31923. * Update a specific value associated to a key
  31924. * @param key defines the key to use
  31925. * @param value defines the value to store
  31926. * @returns true if the value was updated (or false if the key was not found)
  31927. */
  31928. set(key: string, value: T): boolean;
  31929. /**
  31930. * Get the element of the given key and remove it from the dictionary
  31931. * @param key defines the key to search
  31932. * @returns the value associated with the key or null if not found
  31933. */
  31934. getAndRemove(key: string): Nullable<T>;
  31935. /**
  31936. * Remove a key/value from the dictionary.
  31937. * @param key the key to remove
  31938. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31939. */
  31940. remove(key: string): boolean;
  31941. /**
  31942. * Clear the whole content of the dictionary
  31943. */
  31944. clear(): void;
  31945. /**
  31946. * Gets the current count
  31947. */
  31948. readonly count: number;
  31949. /**
  31950. * Execute a callback on each key/val of the dictionary.
  31951. * Note that you can remove any element in this dictionary in the callback implementation
  31952. * @param callback the callback to execute on a given key/value pair
  31953. */
  31954. forEach(callback: (key: string, val: T) => void): void;
  31955. /**
  31956. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31957. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31958. * Note that you can remove any element in this dictionary in the callback implementation
  31959. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31960. * @returns the first item
  31961. */
  31962. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31963. private _count;
  31964. private _data;
  31965. }
  31966. }
  31967. declare module BABYLON {
  31968. /** @hidden */
  31969. export interface ICollisionCoordinator {
  31970. createCollider(): Collider;
  31971. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31972. init(scene: Scene): void;
  31973. }
  31974. /** @hidden */
  31975. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31976. private _scene;
  31977. private _scaledPosition;
  31978. private _scaledVelocity;
  31979. private _finalPosition;
  31980. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31981. createCollider(): Collider;
  31982. init(scene: Scene): void;
  31983. private _collideWithWorld;
  31984. }
  31985. }
  31986. declare module BABYLON {
  31987. /**
  31988. * Class used to manage all inputs for the scene.
  31989. */
  31990. export class InputManager {
  31991. /** The distance in pixel that you have to move to prevent some events */
  31992. static DragMovementThreshold: number;
  31993. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31994. static LongPressDelay: number;
  31995. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31996. static DoubleClickDelay: number;
  31997. /** If you need to check double click without raising a single click at first click, enable this flag */
  31998. static ExclusiveDoubleClickMode: boolean;
  31999. private _wheelEventName;
  32000. private _onPointerMove;
  32001. private _onPointerDown;
  32002. private _onPointerUp;
  32003. private _initClickEvent;
  32004. private _initActionManager;
  32005. private _delayedSimpleClick;
  32006. private _delayedSimpleClickTimeout;
  32007. private _previousDelayedSimpleClickTimeout;
  32008. private _meshPickProceed;
  32009. private _previousButtonPressed;
  32010. private _currentPickResult;
  32011. private _previousPickResult;
  32012. private _totalPointersPressed;
  32013. private _doubleClickOccured;
  32014. private _pointerOverMesh;
  32015. private _pickedDownMesh;
  32016. private _pickedUpMesh;
  32017. private _pointerX;
  32018. private _pointerY;
  32019. private _unTranslatedPointerX;
  32020. private _unTranslatedPointerY;
  32021. private _startingPointerPosition;
  32022. private _previousStartingPointerPosition;
  32023. private _startingPointerTime;
  32024. private _previousStartingPointerTime;
  32025. private _pointerCaptures;
  32026. private _onKeyDown;
  32027. private _onKeyUp;
  32028. private _onCanvasFocusObserver;
  32029. private _onCanvasBlurObserver;
  32030. private _scene;
  32031. /**
  32032. * Creates a new InputManager
  32033. * @param scene defines the hosting scene
  32034. */
  32035. constructor(scene: Scene);
  32036. /**
  32037. * Gets the mesh that is currently under the pointer
  32038. */
  32039. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32040. /**
  32041. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32042. */
  32043. readonly unTranslatedPointer: Vector2;
  32044. /**
  32045. * Gets or sets the current on-screen X position of the pointer
  32046. */
  32047. pointerX: number;
  32048. /**
  32049. * Gets or sets the current on-screen Y position of the pointer
  32050. */
  32051. pointerY: number;
  32052. private _updatePointerPosition;
  32053. private _processPointerMove;
  32054. private _setRayOnPointerInfo;
  32055. private _checkPrePointerObservable;
  32056. /**
  32057. * Use this method to simulate a pointer move on a mesh
  32058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32061. */
  32062. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32063. /**
  32064. * Use this method to simulate a pointer down on a mesh
  32065. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32066. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32067. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32068. */
  32069. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32070. private _processPointerDown;
  32071. /** @hidden */ private _isPointerSwiping(): boolean;
  32072. /**
  32073. * Use this method to simulate a pointer up on a mesh
  32074. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32075. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32076. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32077. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32078. */
  32079. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32080. private _processPointerUp;
  32081. /**
  32082. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32083. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32084. * @returns true if the pointer was captured
  32085. */
  32086. isPointerCaptured(pointerId?: number): boolean;
  32087. /**
  32088. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32089. * @param attachUp defines if you want to attach events to pointerup
  32090. * @param attachDown defines if you want to attach events to pointerdown
  32091. * @param attachMove defines if you want to attach events to pointermove
  32092. */
  32093. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32094. /**
  32095. * Detaches all event handlers
  32096. */
  32097. detachControl(): void;
  32098. /**
  32099. * Force the value of meshUnderPointer
  32100. * @param mesh defines the mesh to use
  32101. */
  32102. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32103. /**
  32104. * Gets the mesh under the pointer
  32105. * @returns a Mesh or null if no mesh is under the pointer
  32106. */
  32107. getPointerOverMesh(): Nullable<AbstractMesh>;
  32108. }
  32109. }
  32110. declare module BABYLON {
  32111. /**
  32112. * Helper class used to generate session unique ID
  32113. */
  32114. export class UniqueIdGenerator {
  32115. private static _UniqueIdCounter;
  32116. /**
  32117. * Gets an unique (relatively to the current scene) Id
  32118. */
  32119. static readonly UniqueId: number;
  32120. }
  32121. }
  32122. declare module BABYLON {
  32123. /**
  32124. * This class defines the direct association between an animation and a target
  32125. */
  32126. export class TargetedAnimation {
  32127. /**
  32128. * Animation to perform
  32129. */
  32130. animation: Animation;
  32131. /**
  32132. * Target to animate
  32133. */
  32134. target: any;
  32135. /**
  32136. * Serialize the object
  32137. * @returns the JSON object representing the current entity
  32138. */
  32139. serialize(): any;
  32140. }
  32141. /**
  32142. * Use this class to create coordinated animations on multiple targets
  32143. */
  32144. export class AnimationGroup implements IDisposable {
  32145. /** The name of the animation group */
  32146. name: string;
  32147. private _scene;
  32148. private _targetedAnimations;
  32149. private _animatables;
  32150. private _from;
  32151. private _to;
  32152. private _isStarted;
  32153. private _isPaused;
  32154. private _speedRatio;
  32155. private _loopAnimation;
  32156. /**
  32157. * Gets or sets the unique id of the node
  32158. */
  32159. uniqueId: number;
  32160. /**
  32161. * This observable will notify when one animation have ended
  32162. */
  32163. onAnimationEndObservable: Observable<TargetedAnimation>;
  32164. /**
  32165. * Observer raised when one animation loops
  32166. */
  32167. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32168. /**
  32169. * This observable will notify when all animations have ended.
  32170. */
  32171. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32172. /**
  32173. * This observable will notify when all animations have paused.
  32174. */
  32175. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32176. /**
  32177. * This observable will notify when all animations are playing.
  32178. */
  32179. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32180. /**
  32181. * Gets the first frame
  32182. */
  32183. readonly from: number;
  32184. /**
  32185. * Gets the last frame
  32186. */
  32187. readonly to: number;
  32188. /**
  32189. * Define if the animations are started
  32190. */
  32191. readonly isStarted: boolean;
  32192. /**
  32193. * Gets a value indicating that the current group is playing
  32194. */
  32195. readonly isPlaying: boolean;
  32196. /**
  32197. * Gets or sets the speed ratio to use for all animations
  32198. */
  32199. /**
  32200. * Gets or sets the speed ratio to use for all animations
  32201. */
  32202. speedRatio: number;
  32203. /**
  32204. * Gets or sets if all animations should loop or not
  32205. */
  32206. loopAnimation: boolean;
  32207. /**
  32208. * Gets the targeted animations for this animation group
  32209. */
  32210. readonly targetedAnimations: Array<TargetedAnimation>;
  32211. /**
  32212. * returning the list of animatables controlled by this animation group.
  32213. */
  32214. readonly animatables: Array<Animatable>;
  32215. /**
  32216. * Instantiates a new Animation Group.
  32217. * This helps managing several animations at once.
  32218. * @see http://doc.babylonjs.com/how_to/group
  32219. * @param name Defines the name of the group
  32220. * @param scene Defines the scene the group belongs to
  32221. */
  32222. constructor(
  32223. /** The name of the animation group */
  32224. name: string, scene?: Nullable<Scene>);
  32225. /**
  32226. * Add an animation (with its target) in the group
  32227. * @param animation defines the animation we want to add
  32228. * @param target defines the target of the animation
  32229. * @returns the TargetedAnimation object
  32230. */
  32231. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32232. /**
  32233. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32234. * It can add constant keys at begin or end
  32235. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32236. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32237. * @returns the animation group
  32238. */
  32239. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32240. /**
  32241. * Start all animations on given targets
  32242. * @param loop defines if animations must loop
  32243. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32244. * @param from defines the from key (optional)
  32245. * @param to defines the to key (optional)
  32246. * @returns the current animation group
  32247. */
  32248. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32249. /**
  32250. * Pause all animations
  32251. * @returns the animation group
  32252. */
  32253. pause(): AnimationGroup;
  32254. /**
  32255. * Play all animations to initial state
  32256. * This function will start() the animations if they were not started or will restart() them if they were paused
  32257. * @param loop defines if animations must loop
  32258. * @returns the animation group
  32259. */
  32260. play(loop?: boolean): AnimationGroup;
  32261. /**
  32262. * Reset all animations to initial state
  32263. * @returns the animation group
  32264. */
  32265. reset(): AnimationGroup;
  32266. /**
  32267. * Restart animations from key 0
  32268. * @returns the animation group
  32269. */
  32270. restart(): AnimationGroup;
  32271. /**
  32272. * Stop all animations
  32273. * @returns the animation group
  32274. */
  32275. stop(): AnimationGroup;
  32276. /**
  32277. * Set animation weight for all animatables
  32278. * @param weight defines the weight to use
  32279. * @return the animationGroup
  32280. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32281. */
  32282. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32283. /**
  32284. * Synchronize and normalize all animatables with a source animatable
  32285. * @param root defines the root animatable to synchronize with
  32286. * @return the animationGroup
  32287. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32288. */
  32289. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32290. /**
  32291. * Goes to a specific frame in this animation group
  32292. * @param frame the frame number to go to
  32293. * @return the animationGroup
  32294. */
  32295. goToFrame(frame: number): AnimationGroup;
  32296. /**
  32297. * Dispose all associated resources
  32298. */
  32299. dispose(): void;
  32300. private _checkAnimationGroupEnded;
  32301. /**
  32302. * Clone the current animation group and returns a copy
  32303. * @param newName defines the name of the new group
  32304. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32305. * @returns the new aniamtion group
  32306. */
  32307. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32308. /**
  32309. * Serializes the animationGroup to an object
  32310. * @returns Serialized object
  32311. */
  32312. serialize(): any;
  32313. /**
  32314. * Returns a new AnimationGroup object parsed from the source provided.
  32315. * @param parsedAnimationGroup defines the source
  32316. * @param scene defines the scene that will receive the animationGroup
  32317. * @returns a new AnimationGroup
  32318. */
  32319. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32320. /**
  32321. * Returns the string "AnimationGroup"
  32322. * @returns "AnimationGroup"
  32323. */
  32324. getClassName(): string;
  32325. /**
  32326. * Creates a detailled string about the object
  32327. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32328. * @returns a string representing the object
  32329. */
  32330. toString(fullDetails?: boolean): string;
  32331. }
  32332. }
  32333. declare module BABYLON {
  32334. /**
  32335. * Define an interface for all classes that will hold resources
  32336. */
  32337. export interface IDisposable {
  32338. /**
  32339. * Releases all held resources
  32340. */
  32341. dispose(): void;
  32342. }
  32343. /** Interface defining initialization parameters for Scene class */
  32344. export interface SceneOptions {
  32345. /**
  32346. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32347. * It will improve performance when the number of geometries becomes important.
  32348. */
  32349. useGeometryUniqueIdsMap?: boolean;
  32350. /**
  32351. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32352. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32353. */
  32354. useMaterialMeshMap?: boolean;
  32355. /**
  32356. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32357. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32358. */
  32359. useClonedMeshhMap?: boolean;
  32360. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32361. virtual?: boolean;
  32362. }
  32363. /**
  32364. * Represents a scene to be rendered by the engine.
  32365. * @see http://doc.babylonjs.com/features/scene
  32366. */
  32367. export class Scene extends AbstractScene implements IAnimatable {
  32368. /** The fog is deactivated */
  32369. static readonly FOGMODE_NONE: number;
  32370. /** The fog density is following an exponential function */
  32371. static readonly FOGMODE_EXP: number;
  32372. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32373. static readonly FOGMODE_EXP2: number;
  32374. /** The fog density is following a linear function. */
  32375. static readonly FOGMODE_LINEAR: number;
  32376. /**
  32377. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32379. */
  32380. static MinDeltaTime: number;
  32381. /**
  32382. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32383. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32384. */
  32385. static MaxDeltaTime: number;
  32386. /**
  32387. * Factory used to create the default material.
  32388. * @param name The name of the material to create
  32389. * @param scene The scene to create the material for
  32390. * @returns The default material
  32391. */
  32392. static DefaultMaterialFactory(scene: Scene): Material;
  32393. /**
  32394. * Factory used to create the a collision coordinator.
  32395. * @returns The collision coordinator
  32396. */
  32397. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32398. /** @hidden */ private _inputManager: InputManager;
  32399. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32400. cameraToUseForPointers: Nullable<Camera>;
  32401. /** @hidden */ protected readonly _isScene: boolean;
  32402. /**
  32403. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32404. */
  32405. autoClear: boolean;
  32406. /**
  32407. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32408. */
  32409. autoClearDepthAndStencil: boolean;
  32410. /**
  32411. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32412. */
  32413. clearColor: Color4;
  32414. /**
  32415. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32416. */
  32417. ambientColor: Color3;
  32418. /**
  32419. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32420. * It should only be one of the following (if not the default embedded one):
  32421. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32422. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32423. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32424. * The material properties need to be setup according to the type of texture in use.
  32425. */
  32426. environmentBRDFTexture: BaseTexture;
  32427. /** @hidden */
  32428. protected _environmentTexture: Nullable<BaseTexture>;
  32429. /**
  32430. * Texture used in all pbr material as the reflection texture.
  32431. * As in the majority of the scene they are the same (exception for multi room and so on),
  32432. * this is easier to reference from here than from all the materials.
  32433. */
  32434. /**
  32435. * Texture used in all pbr material as the reflection texture.
  32436. * As in the majority of the scene they are the same (exception for multi room and so on),
  32437. * this is easier to set here than in all the materials.
  32438. */
  32439. environmentTexture: Nullable<BaseTexture>;
  32440. /** @hidden */
  32441. protected _environmentIntensity: number;
  32442. /**
  32443. * Intensity of the environment in all pbr material.
  32444. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32445. * As in the majority of the scene they are the same (exception for multi room and so on),
  32446. * this is easier to reference from here than from all the materials.
  32447. */
  32448. /**
  32449. * Intensity of the environment in all pbr material.
  32450. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32451. * As in the majority of the scene they are the same (exception for multi room and so on),
  32452. * this is easier to set here than in all the materials.
  32453. */
  32454. environmentIntensity: number;
  32455. /** @hidden */
  32456. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32457. /**
  32458. * Default image processing configuration used either in the rendering
  32459. * Forward main pass or through the imageProcessingPostProcess if present.
  32460. * As in the majority of the scene they are the same (exception for multi camera),
  32461. * this is easier to reference from here than from all the materials and post process.
  32462. *
  32463. * No setter as we it is a shared configuration, you can set the values instead.
  32464. */
  32465. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32466. private _forceWireframe;
  32467. /**
  32468. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32469. */
  32470. forceWireframe: boolean;
  32471. private _forcePointsCloud;
  32472. /**
  32473. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32474. */
  32475. forcePointsCloud: boolean;
  32476. /**
  32477. * Gets or sets the active clipplane 1
  32478. */
  32479. clipPlane: Nullable<Plane>;
  32480. /**
  32481. * Gets or sets the active clipplane 2
  32482. */
  32483. clipPlane2: Nullable<Plane>;
  32484. /**
  32485. * Gets or sets the active clipplane 3
  32486. */
  32487. clipPlane3: Nullable<Plane>;
  32488. /**
  32489. * Gets or sets the active clipplane 4
  32490. */
  32491. clipPlane4: Nullable<Plane>;
  32492. /**
  32493. * Gets or sets a boolean indicating if animations are enabled
  32494. */
  32495. animationsEnabled: boolean;
  32496. private _animationPropertiesOverride;
  32497. /**
  32498. * Gets or sets the animation properties override
  32499. */
  32500. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32501. /**
  32502. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32503. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32504. */
  32505. useConstantAnimationDeltaTime: boolean;
  32506. /**
  32507. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32508. * Please note that it requires to run a ray cast through the scene on every frame
  32509. */
  32510. constantlyUpdateMeshUnderPointer: boolean;
  32511. /**
  32512. * Defines the HTML cursor to use when hovering over interactive elements
  32513. */
  32514. hoverCursor: string;
  32515. /**
  32516. * Defines the HTML default cursor to use (empty by default)
  32517. */
  32518. defaultCursor: string;
  32519. /**
  32520. * This is used to call preventDefault() on pointer down
  32521. * in order to block unwanted artifacts like system double clicks
  32522. */
  32523. preventDefaultOnPointerDown: boolean;
  32524. /**
  32525. * This is used to call preventDefault() on pointer up
  32526. * in order to block unwanted artifacts like system double clicks
  32527. */
  32528. preventDefaultOnPointerUp: boolean;
  32529. /**
  32530. * Gets or sets user defined metadata
  32531. */
  32532. metadata: any;
  32533. /**
  32534. * For internal use only. Please do not use.
  32535. */
  32536. reservedDataStore: any;
  32537. /**
  32538. * Gets the name of the plugin used to load this scene (null by default)
  32539. */
  32540. loadingPluginName: string;
  32541. /**
  32542. * Use this array to add regular expressions used to disable offline support for specific urls
  32543. */
  32544. disableOfflineSupportExceptionRules: RegExp[];
  32545. /**
  32546. * An event triggered when the scene is disposed.
  32547. */
  32548. onDisposeObservable: Observable<Scene>;
  32549. private _onDisposeObserver;
  32550. /** Sets a function to be executed when this scene is disposed. */
  32551. onDispose: () => void;
  32552. /**
  32553. * An event triggered before rendering the scene (right after animations and physics)
  32554. */
  32555. onBeforeRenderObservable: Observable<Scene>;
  32556. private _onBeforeRenderObserver;
  32557. /** Sets a function to be executed before rendering this scene */
  32558. beforeRender: Nullable<() => void>;
  32559. /**
  32560. * An event triggered after rendering the scene
  32561. */
  32562. onAfterRenderObservable: Observable<Scene>;
  32563. /**
  32564. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32565. */
  32566. onAfterRenderCameraObservable: Observable<Camera>;
  32567. private _onAfterRenderObserver;
  32568. /** Sets a function to be executed after rendering this scene */
  32569. afterRender: Nullable<() => void>;
  32570. /**
  32571. * An event triggered before animating the scene
  32572. */
  32573. onBeforeAnimationsObservable: Observable<Scene>;
  32574. /**
  32575. * An event triggered after animations processing
  32576. */
  32577. onAfterAnimationsObservable: Observable<Scene>;
  32578. /**
  32579. * An event triggered before draw calls are ready to be sent
  32580. */
  32581. onBeforeDrawPhaseObservable: Observable<Scene>;
  32582. /**
  32583. * An event triggered after draw calls have been sent
  32584. */
  32585. onAfterDrawPhaseObservable: Observable<Scene>;
  32586. /**
  32587. * An event triggered when the scene is ready
  32588. */
  32589. onReadyObservable: Observable<Scene>;
  32590. /**
  32591. * An event triggered before rendering a camera
  32592. */
  32593. onBeforeCameraRenderObservable: Observable<Camera>;
  32594. private _onBeforeCameraRenderObserver;
  32595. /** Sets a function to be executed before rendering a camera*/
  32596. beforeCameraRender: () => void;
  32597. /**
  32598. * An event triggered after rendering a camera
  32599. */
  32600. onAfterCameraRenderObservable: Observable<Camera>;
  32601. private _onAfterCameraRenderObserver;
  32602. /** Sets a function to be executed after rendering a camera*/
  32603. afterCameraRender: () => void;
  32604. /**
  32605. * An event triggered when active meshes evaluation is about to start
  32606. */
  32607. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32608. /**
  32609. * An event triggered when active meshes evaluation is done
  32610. */
  32611. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32612. /**
  32613. * An event triggered when particles rendering is about to start
  32614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32615. */
  32616. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32617. /**
  32618. * An event triggered when particles rendering is done
  32619. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32620. */
  32621. onAfterParticlesRenderingObservable: Observable<Scene>;
  32622. /**
  32623. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32624. */
  32625. onDataLoadedObservable: Observable<Scene>;
  32626. /**
  32627. * An event triggered when a camera is created
  32628. */
  32629. onNewCameraAddedObservable: Observable<Camera>;
  32630. /**
  32631. * An event triggered when a camera is removed
  32632. */
  32633. onCameraRemovedObservable: Observable<Camera>;
  32634. /**
  32635. * An event triggered when a light is created
  32636. */
  32637. onNewLightAddedObservable: Observable<Light>;
  32638. /**
  32639. * An event triggered when a light is removed
  32640. */
  32641. onLightRemovedObservable: Observable<Light>;
  32642. /**
  32643. * An event triggered when a geometry is created
  32644. */
  32645. onNewGeometryAddedObservable: Observable<Geometry>;
  32646. /**
  32647. * An event triggered when a geometry is removed
  32648. */
  32649. onGeometryRemovedObservable: Observable<Geometry>;
  32650. /**
  32651. * An event triggered when a transform node is created
  32652. */
  32653. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32654. /**
  32655. * An event triggered when a transform node is removed
  32656. */
  32657. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32658. /**
  32659. * An event triggered when a mesh is created
  32660. */
  32661. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32662. /**
  32663. * An event triggered when a mesh is removed
  32664. */
  32665. onMeshRemovedObservable: Observable<AbstractMesh>;
  32666. /**
  32667. * An event triggered when a skeleton is created
  32668. */
  32669. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32670. /**
  32671. * An event triggered when a skeleton is removed
  32672. */
  32673. onSkeletonRemovedObservable: Observable<Skeleton>;
  32674. /**
  32675. * An event triggered when a material is created
  32676. */
  32677. onNewMaterialAddedObservable: Observable<Material>;
  32678. /**
  32679. * An event triggered when a material is removed
  32680. */
  32681. onMaterialRemovedObservable: Observable<Material>;
  32682. /**
  32683. * An event triggered when a texture is created
  32684. */
  32685. onNewTextureAddedObservable: Observable<BaseTexture>;
  32686. /**
  32687. * An event triggered when a texture is removed
  32688. */
  32689. onTextureRemovedObservable: Observable<BaseTexture>;
  32690. /**
  32691. * An event triggered when render targets are about to be rendered
  32692. * Can happen multiple times per frame.
  32693. */
  32694. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32695. /**
  32696. * An event triggered when render targets were rendered.
  32697. * Can happen multiple times per frame.
  32698. */
  32699. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32700. /**
  32701. * An event triggered before calculating deterministic simulation step
  32702. */
  32703. onBeforeStepObservable: Observable<Scene>;
  32704. /**
  32705. * An event triggered after calculating deterministic simulation step
  32706. */
  32707. onAfterStepObservable: Observable<Scene>;
  32708. /**
  32709. * An event triggered when the activeCamera property is updated
  32710. */
  32711. onActiveCameraChanged: Observable<Scene>;
  32712. /**
  32713. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32714. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32715. * 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)
  32716. */
  32717. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32718. /**
  32719. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32720. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32721. * 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)
  32722. */
  32723. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32724. /**
  32725. * This Observable will when a mesh has been imported into the scene.
  32726. */
  32727. onMeshImportedObservable: Observable<AbstractMesh>;
  32728. /**
  32729. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32730. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32731. */
  32732. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32733. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32734. /**
  32735. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32736. */
  32737. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32738. /**
  32739. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32740. */
  32741. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32742. /**
  32743. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32744. */
  32745. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32746. /** Callback called when a pointer move is detected */
  32747. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32748. /** Callback called when a pointer down is detected */
  32749. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32750. /** Callback called when a pointer up is detected */
  32751. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32752. /** Callback called when a pointer pick is detected */
  32753. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32754. /**
  32755. * 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).
  32756. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32757. */
  32758. onPrePointerObservable: Observable<PointerInfoPre>;
  32759. /**
  32760. * Observable event triggered each time an input event is received from the rendering canvas
  32761. */
  32762. onPointerObservable: Observable<PointerInfo>;
  32763. /**
  32764. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32765. */
  32766. readonly unTranslatedPointer: Vector2;
  32767. /**
  32768. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32769. */
  32770. static DragMovementThreshold: number;
  32771. /**
  32772. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32773. */
  32774. static LongPressDelay: number;
  32775. /**
  32776. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32777. */
  32778. static DoubleClickDelay: number;
  32779. /** If you need to check double click without raising a single click at first click, enable this flag */
  32780. static ExclusiveDoubleClickMode: boolean;
  32781. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32782. /**
  32783. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32784. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32785. */
  32786. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32787. /**
  32788. * Observable event triggered each time an keyboard event is received from the hosting window
  32789. */
  32790. onKeyboardObservable: Observable<KeyboardInfo>;
  32791. private _useRightHandedSystem;
  32792. /**
  32793. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32794. */
  32795. useRightHandedSystem: boolean;
  32796. private _timeAccumulator;
  32797. private _currentStepId;
  32798. private _currentInternalStep;
  32799. /**
  32800. * Sets the step Id used by deterministic lock step
  32801. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32802. * @param newStepId defines the step Id
  32803. */
  32804. setStepId(newStepId: number): void;
  32805. /**
  32806. * Gets the step Id used by deterministic lock step
  32807. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32808. * @returns the step Id
  32809. */
  32810. getStepId(): number;
  32811. /**
  32812. * Gets the internal step used by deterministic lock step
  32813. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32814. * @returns the internal step
  32815. */
  32816. getInternalStep(): number;
  32817. private _fogEnabled;
  32818. /**
  32819. * Gets or sets a boolean indicating if fog is enabled on this scene
  32820. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32821. * (Default is true)
  32822. */
  32823. fogEnabled: boolean;
  32824. private _fogMode;
  32825. /**
  32826. * Gets or sets the fog mode to use
  32827. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32828. * | mode | value |
  32829. * | --- | --- |
  32830. * | FOGMODE_NONE | 0 |
  32831. * | FOGMODE_EXP | 1 |
  32832. * | FOGMODE_EXP2 | 2 |
  32833. * | FOGMODE_LINEAR | 3 |
  32834. */
  32835. fogMode: number;
  32836. /**
  32837. * Gets or sets the fog color to use
  32838. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32839. * (Default is Color3(0.2, 0.2, 0.3))
  32840. */
  32841. fogColor: Color3;
  32842. /**
  32843. * Gets or sets the fog density to use
  32844. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32845. * (Default is 0.1)
  32846. */
  32847. fogDensity: number;
  32848. /**
  32849. * Gets or sets the fog start distance to use
  32850. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32851. * (Default is 0)
  32852. */
  32853. fogStart: number;
  32854. /**
  32855. * Gets or sets the fog end distance to use
  32856. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32857. * (Default is 1000)
  32858. */
  32859. fogEnd: number;
  32860. private _shadowsEnabled;
  32861. /**
  32862. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32863. */
  32864. shadowsEnabled: boolean;
  32865. private _lightsEnabled;
  32866. /**
  32867. * Gets or sets a boolean indicating if lights are enabled on this scene
  32868. */
  32869. lightsEnabled: boolean;
  32870. /** All of the active cameras added to this scene. */
  32871. activeCameras: Camera[];
  32872. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32873. /** Gets or sets the current active camera */
  32874. activeCamera: Nullable<Camera>;
  32875. private _defaultMaterial;
  32876. /** The default material used on meshes when no material is affected */
  32877. /** The default material used on meshes when no material is affected */
  32878. defaultMaterial: Material;
  32879. private _texturesEnabled;
  32880. /**
  32881. * Gets or sets a boolean indicating if textures are enabled on this scene
  32882. */
  32883. texturesEnabled: boolean;
  32884. /**
  32885. * Gets or sets a boolean indicating if particles are enabled on this scene
  32886. */
  32887. particlesEnabled: boolean;
  32888. /**
  32889. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32890. */
  32891. spritesEnabled: boolean;
  32892. private _skeletonsEnabled;
  32893. /**
  32894. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32895. */
  32896. skeletonsEnabled: boolean;
  32897. /**
  32898. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32899. */
  32900. lensFlaresEnabled: boolean;
  32901. /**
  32902. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32903. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32904. */
  32905. collisionsEnabled: boolean;
  32906. private _collisionCoordinator;
  32907. /** @hidden */
  32908. readonly collisionCoordinator: ICollisionCoordinator;
  32909. /**
  32910. * Defines the gravity applied to this scene (used only for collisions)
  32911. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32912. */
  32913. gravity: Vector3;
  32914. /**
  32915. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32916. */
  32917. postProcessesEnabled: boolean;
  32918. /**
  32919. * The list of postprocesses added to the scene
  32920. */
  32921. postProcesses: PostProcess[];
  32922. /**
  32923. * Gets the current postprocess manager
  32924. */
  32925. postProcessManager: PostProcessManager;
  32926. /**
  32927. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32928. */
  32929. renderTargetsEnabled: boolean;
  32930. /**
  32931. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32932. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32933. */
  32934. dumpNextRenderTargets: boolean;
  32935. /**
  32936. * The list of user defined render targets added to the scene
  32937. */
  32938. customRenderTargets: RenderTargetTexture[];
  32939. /**
  32940. * Defines if texture loading must be delayed
  32941. * If true, textures will only be loaded when they need to be rendered
  32942. */
  32943. useDelayedTextureLoading: boolean;
  32944. /**
  32945. * Gets the list of meshes imported to the scene through SceneLoader
  32946. */
  32947. importedMeshesFiles: String[];
  32948. /**
  32949. * Gets or sets a boolean indicating if probes are enabled on this scene
  32950. */
  32951. probesEnabled: boolean;
  32952. /**
  32953. * Gets or sets the current offline provider to use to store scene data
  32954. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32955. */
  32956. offlineProvider: IOfflineProvider;
  32957. /**
  32958. * Gets or sets the action manager associated with the scene
  32959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32960. */
  32961. actionManager: AbstractActionManager;
  32962. private _meshesForIntersections;
  32963. /**
  32964. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32965. */
  32966. proceduralTexturesEnabled: boolean;
  32967. private _engine;
  32968. private _totalVertices;
  32969. /** @hidden */ private _activeIndices: PerfCounter;
  32970. /** @hidden */ private _activeParticles: PerfCounter;
  32971. /** @hidden */ private _activeBones: PerfCounter;
  32972. private _animationRatio;
  32973. /** @hidden */ private _animationTimeLast: number;
  32974. /** @hidden */ private _animationTime: number;
  32975. /**
  32976. * Gets or sets a general scale for animation speed
  32977. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32978. */
  32979. animationTimeScale: number;
  32980. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32981. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32982. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32983. private _renderId;
  32984. private _frameId;
  32985. private _executeWhenReadyTimeoutId;
  32986. private _intermediateRendering;
  32987. private _viewUpdateFlag;
  32988. private _projectionUpdateFlag;
  32989. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32990. private _activeRequests;
  32991. /** @hidden */ private _pendingData: any[];
  32992. private _isDisposed;
  32993. /**
  32994. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32995. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32996. */
  32997. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32998. private _activeMeshes;
  32999. private _processedMaterials;
  33000. private _renderTargets;
  33001. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  33002. private _activeSkeletons;
  33003. private _softwareSkinnedMeshes;
  33004. private _renderingManager;
  33005. /** @hidden */ private _activeAnimatables: Animatable[];
  33006. private _transformMatrix;
  33007. private _sceneUbo;
  33008. /** @hidden */ private _viewMatrix: Matrix;
  33009. private _projectionMatrix;
  33010. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  33011. /** @hidden */ private _frustumPlanes: Plane[];
  33012. /**
  33013. * Gets the list of frustum planes (built from the active camera)
  33014. */
  33015. readonly frustumPlanes: Plane[];
  33016. /**
  33017. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33018. * This is useful if there are more lights that the maximum simulteanous authorized
  33019. */
  33020. requireLightSorting: boolean;
  33021. /** @hidden */
  33022. readonly useMaterialMeshMap: boolean;
  33023. /** @hidden */
  33024. readonly useClonedMeshhMap: boolean;
  33025. private _externalData;
  33026. private _uid;
  33027. /**
  33028. * @hidden
  33029. * Backing store of defined scene components.
  33030. */ private _components: ISceneComponent[];
  33031. /**
  33032. * @hidden
  33033. * Backing store of defined scene components.
  33034. */ private _serializableComponents: ISceneSerializableComponent[];
  33035. /**
  33036. * List of components to register on the next registration step.
  33037. */
  33038. private _transientComponents;
  33039. /**
  33040. * Registers the transient components if needed.
  33041. */
  33042. private _registerTransientComponents;
  33043. /**
  33044. * @hidden
  33045. * Add a component to the scene.
  33046. * Note that the ccomponent could be registered on th next frame if this is called after
  33047. * the register component stage.
  33048. * @param component Defines the component to add to the scene
  33049. */ private _addComponent(component: ISceneComponent): void;
  33050. /**
  33051. * @hidden
  33052. * Gets a component from the scene.
  33053. * @param name defines the name of the component to retrieve
  33054. * @returns the component or null if not present
  33055. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  33056. /**
  33057. * @hidden
  33058. * Defines the actions happening before camera updates.
  33059. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33060. /**
  33061. * @hidden
  33062. * Defines the actions happening before clear the canvas.
  33063. */ private _beforeClearStage: Stage<SimpleStageAction>;
  33064. /**
  33065. * @hidden
  33066. * Defines the actions when collecting render targets for the frame.
  33067. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33068. /**
  33069. * @hidden
  33070. * Defines the actions happening for one camera in the frame.
  33071. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33072. /**
  33073. * @hidden
  33074. * Defines the actions happening during the per mesh ready checks.
  33075. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33076. /**
  33077. * @hidden
  33078. * Defines the actions happening before evaluate active mesh checks.
  33079. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33080. /**
  33081. * @hidden
  33082. * Defines the actions happening during the evaluate sub mesh checks.
  33083. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33084. /**
  33085. * @hidden
  33086. * Defines the actions happening during the active mesh stage.
  33087. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33088. /**
  33089. * @hidden
  33090. * Defines the actions happening during the per camera render target step.
  33091. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33092. /**
  33093. * @hidden
  33094. * Defines the actions happening just before the active camera is drawing.
  33095. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33096. /**
  33097. * @hidden
  33098. * Defines the actions happening just before a render target is drawing.
  33099. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33100. /**
  33101. * @hidden
  33102. * Defines the actions happening just before a rendering group is drawing.
  33103. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33104. /**
  33105. * @hidden
  33106. * Defines the actions happening just before a mesh is drawing.
  33107. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33108. /**
  33109. * @hidden
  33110. * Defines the actions happening just after a mesh has been drawn.
  33111. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33112. /**
  33113. * @hidden
  33114. * Defines the actions happening just after a rendering group has been drawn.
  33115. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33116. /**
  33117. * @hidden
  33118. * Defines the actions happening just after the active camera has been drawn.
  33119. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33120. /**
  33121. * @hidden
  33122. * Defines the actions happening just after a render target has been drawn.
  33123. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33124. /**
  33125. * @hidden
  33126. * Defines the actions happening just after rendering all cameras and computing intersections.
  33127. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33128. /**
  33129. * @hidden
  33130. * Defines the actions happening when a pointer move event happens.
  33131. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33132. /**
  33133. * @hidden
  33134. * Defines the actions happening when a pointer down event happens.
  33135. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33136. /**
  33137. * @hidden
  33138. * Defines the actions happening when a pointer up event happens.
  33139. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33140. /**
  33141. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33142. */
  33143. private geometriesByUniqueId;
  33144. /**
  33145. * Creates a new Scene
  33146. * @param engine defines the engine to use to render this scene
  33147. * @param options defines the scene options
  33148. */
  33149. constructor(engine: Engine, options?: SceneOptions);
  33150. /**
  33151. * Gets a string idenfifying the name of the class
  33152. * @returns "Scene" string
  33153. */
  33154. getClassName(): string;
  33155. private _defaultMeshCandidates;
  33156. /**
  33157. * @hidden
  33158. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33159. private _defaultSubMeshCandidates;
  33160. /**
  33161. * @hidden
  33162. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33163. /**
  33164. * Sets the default candidate providers for the scene.
  33165. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33166. * and getCollidingSubMeshCandidates to their default function
  33167. */
  33168. setDefaultCandidateProviders(): void;
  33169. /**
  33170. * Gets the mesh that is currently under the pointer
  33171. */
  33172. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33173. /**
  33174. * Gets or sets the current on-screen X position of the pointer
  33175. */
  33176. pointerX: number;
  33177. /**
  33178. * Gets or sets the current on-screen Y position of the pointer
  33179. */
  33180. pointerY: number;
  33181. /**
  33182. * Gets the cached material (ie. the latest rendered one)
  33183. * @returns the cached material
  33184. */
  33185. getCachedMaterial(): Nullable<Material>;
  33186. /**
  33187. * Gets the cached effect (ie. the latest rendered one)
  33188. * @returns the cached effect
  33189. */
  33190. getCachedEffect(): Nullable<Effect>;
  33191. /**
  33192. * Gets the cached visibility state (ie. the latest rendered one)
  33193. * @returns the cached visibility state
  33194. */
  33195. getCachedVisibility(): Nullable<number>;
  33196. /**
  33197. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33198. * @param material defines the current material
  33199. * @param effect defines the current effect
  33200. * @param visibility defines the current visibility state
  33201. * @returns true if one parameter is not cached
  33202. */
  33203. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33204. /**
  33205. * Gets the engine associated with the scene
  33206. * @returns an Engine
  33207. */
  33208. getEngine(): Engine;
  33209. /**
  33210. * Gets the total number of vertices rendered per frame
  33211. * @returns the total number of vertices rendered per frame
  33212. */
  33213. getTotalVertices(): number;
  33214. /**
  33215. * Gets the performance counter for total vertices
  33216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33217. */
  33218. readonly totalVerticesPerfCounter: PerfCounter;
  33219. /**
  33220. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33221. * @returns the total number of active indices rendered per frame
  33222. */
  33223. getActiveIndices(): number;
  33224. /**
  33225. * Gets the performance counter for active indices
  33226. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33227. */
  33228. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33229. /**
  33230. * Gets the total number of active particles rendered per frame
  33231. * @returns the total number of active particles rendered per frame
  33232. */
  33233. getActiveParticles(): number;
  33234. /**
  33235. * Gets the performance counter for active particles
  33236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33237. */
  33238. readonly activeParticlesPerfCounter: PerfCounter;
  33239. /**
  33240. * Gets the total number of active bones rendered per frame
  33241. * @returns the total number of active bones rendered per frame
  33242. */
  33243. getActiveBones(): number;
  33244. /**
  33245. * Gets the performance counter for active bones
  33246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33247. */
  33248. readonly activeBonesPerfCounter: PerfCounter;
  33249. /**
  33250. * Gets the array of active meshes
  33251. * @returns an array of AbstractMesh
  33252. */
  33253. getActiveMeshes(): SmartArray<AbstractMesh>;
  33254. /**
  33255. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33256. * @returns a number
  33257. */
  33258. getAnimationRatio(): number;
  33259. /**
  33260. * Gets an unique Id for the current render phase
  33261. * @returns a number
  33262. */
  33263. getRenderId(): number;
  33264. /**
  33265. * Gets an unique Id for the current frame
  33266. * @returns a number
  33267. */
  33268. getFrameId(): number;
  33269. /** Call this function if you want to manually increment the render Id*/
  33270. incrementRenderId(): void;
  33271. private _createUbo;
  33272. /**
  33273. * Use this method to simulate a pointer move on a mesh
  33274. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33275. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33276. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33277. * @returns the current scene
  33278. */
  33279. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33280. /**
  33281. * Use this method to simulate a pointer down on a mesh
  33282. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33283. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33284. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33285. * @returns the current scene
  33286. */
  33287. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33288. /**
  33289. * Use this method to simulate a pointer up on a mesh
  33290. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33291. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33292. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33293. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33294. * @returns the current scene
  33295. */
  33296. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33297. /**
  33298. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33299. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33300. * @returns true if the pointer was captured
  33301. */
  33302. isPointerCaptured(pointerId?: number): boolean;
  33303. /**
  33304. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33305. * @param attachUp defines if you want to attach events to pointerup
  33306. * @param attachDown defines if you want to attach events to pointerdown
  33307. * @param attachMove defines if you want to attach events to pointermove
  33308. */
  33309. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33310. /** Detaches all event handlers*/
  33311. detachControl(): void;
  33312. /**
  33313. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33314. * Delay loaded resources are not taking in account
  33315. * @return true if all required resources are ready
  33316. */
  33317. isReady(): boolean;
  33318. /** Resets all cached information relative to material (including effect and visibility) */
  33319. resetCachedMaterial(): void;
  33320. /**
  33321. * Registers a function to be called before every frame render
  33322. * @param func defines the function to register
  33323. */
  33324. registerBeforeRender(func: () => void): void;
  33325. /**
  33326. * Unregisters a function called before every frame render
  33327. * @param func defines the function to unregister
  33328. */
  33329. unregisterBeforeRender(func: () => void): void;
  33330. /**
  33331. * Registers a function to be called after every frame render
  33332. * @param func defines the function to register
  33333. */
  33334. registerAfterRender(func: () => void): void;
  33335. /**
  33336. * Unregisters a function called after every frame render
  33337. * @param func defines the function to unregister
  33338. */
  33339. unregisterAfterRender(func: () => void): void;
  33340. private _executeOnceBeforeRender;
  33341. /**
  33342. * The provided function will run before render once and will be disposed afterwards.
  33343. * A timeout delay can be provided so that the function will be executed in N ms.
  33344. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33345. * @param func The function to be executed.
  33346. * @param timeout optional delay in ms
  33347. */
  33348. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33349. /** @hidden */ private _addPendingData(data: any): void;
  33350. /** @hidden */ private _removePendingData(data: any): void;
  33351. /**
  33352. * Returns the number of items waiting to be loaded
  33353. * @returns the number of items waiting to be loaded
  33354. */
  33355. getWaitingItemsCount(): number;
  33356. /**
  33357. * Returns a boolean indicating if the scene is still loading data
  33358. */
  33359. readonly isLoading: boolean;
  33360. /**
  33361. * Registers a function to be executed when the scene is ready
  33362. * @param {Function} func - the function to be executed
  33363. */
  33364. executeWhenReady(func: () => void): void;
  33365. /**
  33366. * Returns a promise that resolves when the scene is ready
  33367. * @returns A promise that resolves when the scene is ready
  33368. */
  33369. whenReadyAsync(): Promise<void>;
  33370. /** @hidden */ private _checkIsReady(): void;
  33371. /**
  33372. * Gets all animatable attached to the scene
  33373. */
  33374. readonly animatables: Animatable[];
  33375. /**
  33376. * Resets the last animation time frame.
  33377. * Useful to override when animations start running when loading a scene for the first time.
  33378. */
  33379. resetLastAnimationTimeFrame(): void;
  33380. /**
  33381. * Gets the current view matrix
  33382. * @returns a Matrix
  33383. */
  33384. getViewMatrix(): Matrix;
  33385. /**
  33386. * Gets the current projection matrix
  33387. * @returns a Matrix
  33388. */
  33389. getProjectionMatrix(): Matrix;
  33390. /**
  33391. * Gets the current transform matrix
  33392. * @returns a Matrix made of View * Projection
  33393. */
  33394. getTransformMatrix(): Matrix;
  33395. /**
  33396. * Sets the current transform matrix
  33397. * @param viewL defines the View matrix to use
  33398. * @param projectionL defines the Projection matrix to use
  33399. * @param viewR defines the right View matrix to use (if provided)
  33400. * @param projectionR defines the right Projection matrix to use (if provided)
  33401. */
  33402. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33403. /**
  33404. * Gets the uniform buffer used to store scene data
  33405. * @returns a UniformBuffer
  33406. */
  33407. getSceneUniformBuffer(): UniformBuffer;
  33408. /**
  33409. * Gets an unique (relatively to the current scene) Id
  33410. * @returns an unique number for the scene
  33411. */
  33412. getUniqueId(): number;
  33413. /**
  33414. * Add a mesh to the list of scene's meshes
  33415. * @param newMesh defines the mesh to add
  33416. * @param recursive if all child meshes should also be added to the scene
  33417. */
  33418. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33419. /**
  33420. * Remove a mesh for the list of scene's meshes
  33421. * @param toRemove defines the mesh to remove
  33422. * @param recursive if all child meshes should also be removed from the scene
  33423. * @returns the index where the mesh was in the mesh list
  33424. */
  33425. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33426. /**
  33427. * Add a transform node to the list of scene's transform nodes
  33428. * @param newTransformNode defines the transform node to add
  33429. */
  33430. addTransformNode(newTransformNode: TransformNode): void;
  33431. /**
  33432. * Remove a transform node for the list of scene's transform nodes
  33433. * @param toRemove defines the transform node to remove
  33434. * @returns the index where the transform node was in the transform node list
  33435. */
  33436. removeTransformNode(toRemove: TransformNode): number;
  33437. /**
  33438. * Remove a skeleton for the list of scene's skeletons
  33439. * @param toRemove defines the skeleton to remove
  33440. * @returns the index where the skeleton was in the skeleton list
  33441. */
  33442. removeSkeleton(toRemove: Skeleton): number;
  33443. /**
  33444. * Remove a morph target for the list of scene's morph targets
  33445. * @param toRemove defines the morph target to remove
  33446. * @returns the index where the morph target was in the morph target list
  33447. */
  33448. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33449. /**
  33450. * Remove a light for the list of scene's lights
  33451. * @param toRemove defines the light to remove
  33452. * @returns the index where the light was in the light list
  33453. */
  33454. removeLight(toRemove: Light): number;
  33455. /**
  33456. * Remove a camera for the list of scene's cameras
  33457. * @param toRemove defines the camera to remove
  33458. * @returns the index where the camera was in the camera list
  33459. */
  33460. removeCamera(toRemove: Camera): number;
  33461. /**
  33462. * Remove a particle system for the list of scene's particle systems
  33463. * @param toRemove defines the particle system to remove
  33464. * @returns the index where the particle system was in the particle system list
  33465. */
  33466. removeParticleSystem(toRemove: IParticleSystem): number;
  33467. /**
  33468. * Remove a animation for the list of scene's animations
  33469. * @param toRemove defines the animation to remove
  33470. * @returns the index where the animation was in the animation list
  33471. */
  33472. removeAnimation(toRemove: Animation): number;
  33473. /**
  33474. * Will stop the animation of the given target
  33475. * @param target - the target
  33476. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33477. * @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)
  33478. */
  33479. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33480. /**
  33481. * Removes the given animation group from this scene.
  33482. * @param toRemove The animation group to remove
  33483. * @returns The index of the removed animation group
  33484. */
  33485. removeAnimationGroup(toRemove: AnimationGroup): number;
  33486. /**
  33487. * Removes the given multi-material from this scene.
  33488. * @param toRemove The multi-material to remove
  33489. * @returns The index of the removed multi-material
  33490. */
  33491. removeMultiMaterial(toRemove: MultiMaterial): number;
  33492. /**
  33493. * Removes the given material from this scene.
  33494. * @param toRemove The material to remove
  33495. * @returns The index of the removed material
  33496. */
  33497. removeMaterial(toRemove: Material): number;
  33498. /**
  33499. * Removes the given action manager from this scene.
  33500. * @param toRemove The action manager to remove
  33501. * @returns The index of the removed action manager
  33502. */
  33503. removeActionManager(toRemove: AbstractActionManager): number;
  33504. /**
  33505. * Removes the given texture from this scene.
  33506. * @param toRemove The texture to remove
  33507. * @returns The index of the removed texture
  33508. */
  33509. removeTexture(toRemove: BaseTexture): number;
  33510. /**
  33511. * Adds the given light to this scene
  33512. * @param newLight The light to add
  33513. */
  33514. addLight(newLight: Light): void;
  33515. /**
  33516. * Sorts the list list based on light priorities
  33517. */
  33518. sortLightsByPriority(): void;
  33519. /**
  33520. * Adds the given camera to this scene
  33521. * @param newCamera The camera to add
  33522. */
  33523. addCamera(newCamera: Camera): void;
  33524. /**
  33525. * Adds the given skeleton to this scene
  33526. * @param newSkeleton The skeleton to add
  33527. */
  33528. addSkeleton(newSkeleton: Skeleton): void;
  33529. /**
  33530. * Adds the given particle system to this scene
  33531. * @param newParticleSystem The particle system to add
  33532. */
  33533. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33534. /**
  33535. * Adds the given animation to this scene
  33536. * @param newAnimation The animation to add
  33537. */
  33538. addAnimation(newAnimation: Animation): void;
  33539. /**
  33540. * Adds the given animation group to this scene.
  33541. * @param newAnimationGroup The animation group to add
  33542. */
  33543. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33544. /**
  33545. * Adds the given multi-material to this scene
  33546. * @param newMultiMaterial The multi-material to add
  33547. */
  33548. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33549. /**
  33550. * Adds the given material to this scene
  33551. * @param newMaterial The material to add
  33552. */
  33553. addMaterial(newMaterial: Material): void;
  33554. /**
  33555. * Adds the given morph target to this scene
  33556. * @param newMorphTargetManager The morph target to add
  33557. */
  33558. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33559. /**
  33560. * Adds the given geometry to this scene
  33561. * @param newGeometry The geometry to add
  33562. */
  33563. addGeometry(newGeometry: Geometry): void;
  33564. /**
  33565. * Adds the given action manager to this scene
  33566. * @param newActionManager The action manager to add
  33567. */
  33568. addActionManager(newActionManager: AbstractActionManager): void;
  33569. /**
  33570. * Adds the given texture to this scene.
  33571. * @param newTexture The texture to add
  33572. */
  33573. addTexture(newTexture: BaseTexture): void;
  33574. /**
  33575. * Switch active camera
  33576. * @param newCamera defines the new active camera
  33577. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33578. */
  33579. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33580. /**
  33581. * sets the active camera of the scene using its ID
  33582. * @param id defines the camera's ID
  33583. * @return the new active camera or null if none found.
  33584. */
  33585. setActiveCameraByID(id: string): Nullable<Camera>;
  33586. /**
  33587. * sets the active camera of the scene using its name
  33588. * @param name defines the camera's name
  33589. * @returns the new active camera or null if none found.
  33590. */
  33591. setActiveCameraByName(name: string): Nullable<Camera>;
  33592. /**
  33593. * get an animation group using its name
  33594. * @param name defines the material's name
  33595. * @return the animation group or null if none found.
  33596. */
  33597. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33598. /**
  33599. * Get a material using its unique id
  33600. * @param uniqueId defines the material's unique id
  33601. * @return the material or null if none found.
  33602. */
  33603. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33604. /**
  33605. * get a material using its id
  33606. * @param id defines the material's ID
  33607. * @return the material or null if none found.
  33608. */
  33609. getMaterialByID(id: string): Nullable<Material>;
  33610. /**
  33611. * Gets a the last added material using a given id
  33612. * @param id defines the material's ID
  33613. * @return the last material with the given id or null if none found.
  33614. */
  33615. getLastMaterialByID(id: string): Nullable<Material>;
  33616. /**
  33617. * Gets a material using its name
  33618. * @param name defines the material's name
  33619. * @return the material or null if none found.
  33620. */
  33621. getMaterialByName(name: string): Nullable<Material>;
  33622. /**
  33623. * Get a texture using its unique id
  33624. * @param uniqueId defines the texture's unique id
  33625. * @return the texture or null if none found.
  33626. */
  33627. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33628. /**
  33629. * Gets a camera using its id
  33630. * @param id defines the id to look for
  33631. * @returns the camera or null if not found
  33632. */
  33633. getCameraByID(id: string): Nullable<Camera>;
  33634. /**
  33635. * Gets a camera using its unique id
  33636. * @param uniqueId defines the unique id to look for
  33637. * @returns the camera or null if not found
  33638. */
  33639. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33640. /**
  33641. * Gets a camera using its name
  33642. * @param name defines the camera's name
  33643. * @return the camera or null if none found.
  33644. */
  33645. getCameraByName(name: string): Nullable<Camera>;
  33646. /**
  33647. * Gets a bone using its id
  33648. * @param id defines the bone's id
  33649. * @return the bone or null if not found
  33650. */
  33651. getBoneByID(id: string): Nullable<Bone>;
  33652. /**
  33653. * Gets a bone using its id
  33654. * @param name defines the bone's name
  33655. * @return the bone or null if not found
  33656. */
  33657. getBoneByName(name: string): Nullable<Bone>;
  33658. /**
  33659. * Gets a light node using its name
  33660. * @param name defines the the light's name
  33661. * @return the light or null if none found.
  33662. */
  33663. getLightByName(name: string): Nullable<Light>;
  33664. /**
  33665. * Gets a light node using its id
  33666. * @param id defines the light's id
  33667. * @return the light or null if none found.
  33668. */
  33669. getLightByID(id: string): Nullable<Light>;
  33670. /**
  33671. * Gets a light node using its scene-generated unique ID
  33672. * @param uniqueId defines the light's unique id
  33673. * @return the light or null if none found.
  33674. */
  33675. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33676. /**
  33677. * Gets a particle system by id
  33678. * @param id defines the particle system id
  33679. * @return the corresponding system or null if none found
  33680. */
  33681. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33682. /**
  33683. * Gets a geometry using its ID
  33684. * @param id defines the geometry's id
  33685. * @return the geometry or null if none found.
  33686. */
  33687. getGeometryByID(id: string): Nullable<Geometry>;
  33688. private _getGeometryByUniqueID;
  33689. /**
  33690. * Add a new geometry to this scene
  33691. * @param geometry defines the geometry to be added to the scene.
  33692. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33693. * @return a boolean defining if the geometry was added or not
  33694. */
  33695. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33696. /**
  33697. * Removes an existing geometry
  33698. * @param geometry defines the geometry to be removed from the scene
  33699. * @return a boolean defining if the geometry was removed or not
  33700. */
  33701. removeGeometry(geometry: Geometry): boolean;
  33702. /**
  33703. * Gets the list of geometries attached to the scene
  33704. * @returns an array of Geometry
  33705. */
  33706. getGeometries(): Geometry[];
  33707. /**
  33708. * Gets the first added mesh found of a given ID
  33709. * @param id defines the id to search for
  33710. * @return the mesh found or null if not found at all
  33711. */
  33712. getMeshByID(id: string): Nullable<AbstractMesh>;
  33713. /**
  33714. * Gets a list of meshes using their id
  33715. * @param id defines the id to search for
  33716. * @returns a list of meshes
  33717. */
  33718. getMeshesByID(id: string): Array<AbstractMesh>;
  33719. /**
  33720. * Gets the first added transform node found of a given ID
  33721. * @param id defines the id to search for
  33722. * @return the found transform node or null if not found at all.
  33723. */
  33724. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33725. /**
  33726. * Gets a transform node with its auto-generated unique id
  33727. * @param uniqueId efines the unique id to search for
  33728. * @return the found transform node or null if not found at all.
  33729. */
  33730. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33731. /**
  33732. * Gets a list of transform nodes using their id
  33733. * @param id defines the id to search for
  33734. * @returns a list of transform nodes
  33735. */
  33736. getTransformNodesByID(id: string): Array<TransformNode>;
  33737. /**
  33738. * Gets a mesh with its auto-generated unique id
  33739. * @param uniqueId defines the unique id to search for
  33740. * @return the found mesh or null if not found at all.
  33741. */
  33742. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33743. /**
  33744. * Gets a the last added mesh using a given id
  33745. * @param id defines the id to search for
  33746. * @return the found mesh or null if not found at all.
  33747. */
  33748. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33749. /**
  33750. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33751. * @param id defines the id to search for
  33752. * @return the found node or null if not found at all
  33753. */
  33754. getLastEntryByID(id: string): Nullable<Node>;
  33755. /**
  33756. * Gets a node (Mesh, Camera, Light) using a given id
  33757. * @param id defines the id to search for
  33758. * @return the found node or null if not found at all
  33759. */
  33760. getNodeByID(id: string): Nullable<Node>;
  33761. /**
  33762. * Gets a node (Mesh, Camera, Light) using a given name
  33763. * @param name defines the name to search for
  33764. * @return the found node or null if not found at all.
  33765. */
  33766. getNodeByName(name: string): Nullable<Node>;
  33767. /**
  33768. * Gets a mesh using a given name
  33769. * @param name defines the name to search for
  33770. * @return the found mesh or null if not found at all.
  33771. */
  33772. getMeshByName(name: string): Nullable<AbstractMesh>;
  33773. /**
  33774. * Gets a transform node using a given name
  33775. * @param name defines the name to search for
  33776. * @return the found transform node or null if not found at all.
  33777. */
  33778. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33779. /**
  33780. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33781. * @param id defines the id to search for
  33782. * @return the found skeleton or null if not found at all.
  33783. */
  33784. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33785. /**
  33786. * Gets a skeleton using a given auto generated unique id
  33787. * @param uniqueId defines the unique id to search for
  33788. * @return the found skeleton or null if not found at all.
  33789. */
  33790. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33791. /**
  33792. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33793. * @param id defines the id to search for
  33794. * @return the found skeleton or null if not found at all.
  33795. */
  33796. getSkeletonById(id: string): Nullable<Skeleton>;
  33797. /**
  33798. * Gets a skeleton using a given name
  33799. * @param name defines the name to search for
  33800. * @return the found skeleton or null if not found at all.
  33801. */
  33802. getSkeletonByName(name: string): Nullable<Skeleton>;
  33803. /**
  33804. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33805. * @param id defines the id to search for
  33806. * @return the found morph target manager or null if not found at all.
  33807. */
  33808. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33809. /**
  33810. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33811. * @param id defines the id to search for
  33812. * @return the found morph target or null if not found at all.
  33813. */
  33814. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33815. /**
  33816. * Gets a boolean indicating if the given mesh is active
  33817. * @param mesh defines the mesh to look for
  33818. * @returns true if the mesh is in the active list
  33819. */
  33820. isActiveMesh(mesh: AbstractMesh): boolean;
  33821. /**
  33822. * Return a unique id as a string which can serve as an identifier for the scene
  33823. */
  33824. readonly uid: string;
  33825. /**
  33826. * Add an externaly attached data from its key.
  33827. * This method call will fail and return false, if such key already exists.
  33828. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33829. * @param key the unique key that identifies the data
  33830. * @param data the data object to associate to the key for this Engine instance
  33831. * @return true if no such key were already present and the data was added successfully, false otherwise
  33832. */
  33833. addExternalData<T>(key: string, data: T): boolean;
  33834. /**
  33835. * Get an externaly attached data from its key
  33836. * @param key the unique key that identifies the data
  33837. * @return the associated data, if present (can be null), or undefined if not present
  33838. */
  33839. getExternalData<T>(key: string): Nullable<T>;
  33840. /**
  33841. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33842. * @param key the unique key that identifies the data
  33843. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33844. * @return the associated data, can be null if the factory returned null.
  33845. */
  33846. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33847. /**
  33848. * Remove an externaly attached data from the Engine instance
  33849. * @param key the unique key that identifies the data
  33850. * @return true if the data was successfully removed, false if it doesn't exist
  33851. */
  33852. removeExternalData(key: string): boolean;
  33853. private _evaluateSubMesh;
  33854. /**
  33855. * Clear the processed materials smart array preventing retention point in material dispose.
  33856. */
  33857. freeProcessedMaterials(): void;
  33858. private _preventFreeActiveMeshesAndRenderingGroups;
  33859. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33860. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33861. * when disposing several meshes in a row or a hierarchy of meshes.
  33862. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33863. */
  33864. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33865. /**
  33866. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33867. */
  33868. freeActiveMeshes(): void;
  33869. /**
  33870. * Clear the info related to rendering groups preventing retention points during dispose.
  33871. */
  33872. freeRenderingGroups(): void;
  33873. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33874. /**
  33875. * Lambda returning the list of potentially active meshes.
  33876. */
  33877. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33878. /**
  33879. * Lambda returning the list of potentially active sub meshes.
  33880. */
  33881. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33882. /**
  33883. * Lambda returning the list of potentially intersecting sub meshes.
  33884. */
  33885. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33886. /**
  33887. * Lambda returning the list of potentially colliding sub meshes.
  33888. */
  33889. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33890. private _activeMeshesFrozen;
  33891. /**
  33892. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33893. * @returns the current scene
  33894. */
  33895. freezeActiveMeshes(): Scene;
  33896. /**
  33897. * Use this function to restart evaluating active meshes on every frame
  33898. * @returns the current scene
  33899. */
  33900. unfreezeActiveMeshes(): Scene;
  33901. private _evaluateActiveMeshes;
  33902. private _activeMesh;
  33903. /**
  33904. * Update the transform matrix to update from the current active camera
  33905. * @param force defines a boolean used to force the update even if cache is up to date
  33906. */
  33907. updateTransformMatrix(force?: boolean): void;
  33908. private _bindFrameBuffer;
  33909. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33910. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33911. private _processSubCameras;
  33912. private _checkIntersections;
  33913. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33914. /**
  33915. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33916. */
  33917. getDeterministicFrameTime: () => number;
  33918. /** @hidden */ private _animate(): void;
  33919. /** Execute all animations (for a frame) */
  33920. animate(): void;
  33921. /**
  33922. * Render the scene
  33923. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33924. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33925. */
  33926. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33927. /**
  33928. * Freeze all materials
  33929. * A frozen material will not be updatable but should be faster to render
  33930. */
  33931. freezeMaterials(): void;
  33932. /**
  33933. * Unfreeze all materials
  33934. * A frozen material will not be updatable but should be faster to render
  33935. */
  33936. unfreezeMaterials(): void;
  33937. /**
  33938. * Releases all held ressources
  33939. */
  33940. dispose(): void;
  33941. /**
  33942. * Gets if the scene is already disposed
  33943. */
  33944. readonly isDisposed: boolean;
  33945. /**
  33946. * Call this function to reduce memory footprint of the scene.
  33947. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33948. */
  33949. clearCachedVertexData(): void;
  33950. /**
  33951. * This function will remove the local cached buffer data from texture.
  33952. * It will save memory but will prevent the texture from being rebuilt
  33953. */
  33954. cleanCachedTextureBuffer(): void;
  33955. /**
  33956. * Get the world extend vectors with an optional filter
  33957. *
  33958. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33959. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33960. */
  33961. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33962. min: Vector3;
  33963. max: Vector3;
  33964. };
  33965. /**
  33966. * Creates a ray that can be used to pick in the scene
  33967. * @param x defines the x coordinate of the origin (on-screen)
  33968. * @param y defines the y coordinate of the origin (on-screen)
  33969. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33970. * @param camera defines the camera to use for the picking
  33971. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33972. * @returns a Ray
  33973. */
  33974. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33975. /**
  33976. * Creates a ray that can be used to pick in the scene
  33977. * @param x defines the x coordinate of the origin (on-screen)
  33978. * @param y defines the y coordinate of the origin (on-screen)
  33979. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33980. * @param result defines the ray where to store the picking ray
  33981. * @param camera defines the camera to use for the picking
  33982. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33983. * @returns the current scene
  33984. */
  33985. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33986. /**
  33987. * Creates a ray that can be used to pick in the scene
  33988. * @param x defines the x coordinate of the origin (on-screen)
  33989. * @param y defines the y coordinate of the origin (on-screen)
  33990. * @param camera defines the camera to use for the picking
  33991. * @returns a Ray
  33992. */
  33993. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33994. /**
  33995. * Creates a ray that can be used to pick in the scene
  33996. * @param x defines the x coordinate of the origin (on-screen)
  33997. * @param y defines the y coordinate of the origin (on-screen)
  33998. * @param result defines the ray where to store the picking ray
  33999. * @param camera defines the camera to use for the picking
  34000. * @returns the current scene
  34001. */
  34002. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34003. /** Launch a ray to try to pick a mesh in the scene
  34004. * @param x position on screen
  34005. * @param y position on screen
  34006. * @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
  34007. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34008. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34009. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34010. * @returns a PickingInfo
  34011. */
  34012. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34013. /** Use the given ray to pick a mesh in the scene
  34014. * @param ray The ray to use to pick meshes
  34015. * @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
  34016. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34018. * @returns a PickingInfo
  34019. */
  34020. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34021. /**
  34022. * Launch a ray to try to pick a mesh in the scene
  34023. * @param x X position on screen
  34024. * @param y Y position on screen
  34025. * @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
  34026. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34027. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34028. * @returns an array of PickingInfo
  34029. */
  34030. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34031. /**
  34032. * Launch a ray to try to pick a mesh in the scene
  34033. * @param ray Ray to use
  34034. * @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
  34035. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34036. * @returns an array of PickingInfo
  34037. */
  34038. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34039. /**
  34040. * Force the value of meshUnderPointer
  34041. * @param mesh defines the mesh to use
  34042. */
  34043. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34044. /**
  34045. * Gets the mesh under the pointer
  34046. * @returns a Mesh or null if no mesh is under the pointer
  34047. */
  34048. getPointerOverMesh(): Nullable<AbstractMesh>;
  34049. /** @hidden */ private _rebuildGeometries(): void;
  34050. /** @hidden */ private _rebuildTextures(): void;
  34051. private _getByTags;
  34052. /**
  34053. * Get a list of meshes by tags
  34054. * @param tagsQuery defines the tags query to use
  34055. * @param forEach defines a predicate used to filter results
  34056. * @returns an array of Mesh
  34057. */
  34058. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34059. /**
  34060. * Get a list of cameras by tags
  34061. * @param tagsQuery defines the tags query to use
  34062. * @param forEach defines a predicate used to filter results
  34063. * @returns an array of Camera
  34064. */
  34065. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34066. /**
  34067. * Get a list of lights by tags
  34068. * @param tagsQuery defines the tags query to use
  34069. * @param forEach defines a predicate used to filter results
  34070. * @returns an array of Light
  34071. */
  34072. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34073. /**
  34074. * Get a list of materials by tags
  34075. * @param tagsQuery defines the tags query to use
  34076. * @param forEach defines a predicate used to filter results
  34077. * @returns an array of Material
  34078. */
  34079. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34080. /**
  34081. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34082. * This allowed control for front to back rendering or reversly depending of the special needs.
  34083. *
  34084. * @param renderingGroupId The rendering group id corresponding to its index
  34085. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34086. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34087. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34088. */
  34089. 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;
  34090. /**
  34091. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34092. *
  34093. * @param renderingGroupId The rendering group id corresponding to its index
  34094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34095. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34096. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34097. */
  34098. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34099. /**
  34100. * Gets the current auto clear configuration for one rendering group of the rendering
  34101. * manager.
  34102. * @param index the rendering group index to get the information for
  34103. * @returns The auto clear setup for the requested rendering group
  34104. */
  34105. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34106. private _blockMaterialDirtyMechanism;
  34107. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34108. blockMaterialDirtyMechanism: boolean;
  34109. /**
  34110. * Will flag all materials as dirty to trigger new shader compilation
  34111. * @param flag defines the flag used to specify which material part must be marked as dirty
  34112. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34113. */
  34114. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34115. /** @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;
  34116. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34117. }
  34118. }
  34119. declare module BABYLON {
  34120. /**
  34121. * Set of assets to keep when moving a scene into an asset container.
  34122. */
  34123. export class KeepAssets extends AbstractScene {
  34124. }
  34125. /**
  34126. * Container with a set of assets that can be added or removed from a scene.
  34127. */
  34128. export class AssetContainer extends AbstractScene {
  34129. /**
  34130. * The scene the AssetContainer belongs to.
  34131. */
  34132. scene: Scene;
  34133. /**
  34134. * Instantiates an AssetContainer.
  34135. * @param scene The scene the AssetContainer belongs to.
  34136. */
  34137. constructor(scene: Scene);
  34138. /**
  34139. * Adds all the assets from the container to the scene.
  34140. */
  34141. addAllToScene(): void;
  34142. /**
  34143. * Removes all the assets in the container from the scene
  34144. */
  34145. removeAllFromScene(): void;
  34146. /**
  34147. * Disposes all the assets in the container
  34148. */
  34149. dispose(): void;
  34150. private _moveAssets;
  34151. /**
  34152. * Removes all the assets contained in the scene and adds them to the container.
  34153. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34154. */
  34155. moveAllFromScene(keepAssets?: KeepAssets): void;
  34156. /**
  34157. * 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.
  34158. * @returns the root mesh
  34159. */
  34160. createRootMesh(): Mesh;
  34161. }
  34162. }
  34163. declare module BABYLON {
  34164. /**
  34165. * Defines how the parser contract is defined.
  34166. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34167. */
  34168. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34169. /**
  34170. * Defines how the individual parser contract is defined.
  34171. * These parser can parse an individual asset
  34172. */
  34173. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34174. /**
  34175. * Base class of the scene acting as a container for the different elements composing a scene.
  34176. * This class is dynamically extended by the different components of the scene increasing
  34177. * flexibility and reducing coupling
  34178. */
  34179. export abstract class AbstractScene {
  34180. /**
  34181. * Stores the list of available parsers in the application.
  34182. */
  34183. private static _BabylonFileParsers;
  34184. /**
  34185. * Stores the list of available individual parsers in the application.
  34186. */
  34187. private static _IndividualBabylonFileParsers;
  34188. /**
  34189. * Adds a parser in the list of available ones
  34190. * @param name Defines the name of the parser
  34191. * @param parser Defines the parser to add
  34192. */
  34193. static AddParser(name: string, parser: BabylonFileParser): void;
  34194. /**
  34195. * Gets a general parser from the list of avaialble ones
  34196. * @param name Defines the name of the parser
  34197. * @returns the requested parser or null
  34198. */
  34199. static GetParser(name: string): Nullable<BabylonFileParser>;
  34200. /**
  34201. * Adds n individual parser in the list of available ones
  34202. * @param name Defines the name of the parser
  34203. * @param parser Defines the parser to add
  34204. */
  34205. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34206. /**
  34207. * Gets an individual parser from the list of avaialble ones
  34208. * @param name Defines the name of the parser
  34209. * @returns the requested parser or null
  34210. */
  34211. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34212. /**
  34213. * Parser json data and populate both a scene and its associated container object
  34214. * @param jsonData Defines the data to parse
  34215. * @param scene Defines the scene to parse the data for
  34216. * @param container Defines the container attached to the parsing sequence
  34217. * @param rootUrl Defines the root url of the data
  34218. */
  34219. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34220. /**
  34221. * Gets the list of root nodes (ie. nodes with no parent)
  34222. */
  34223. rootNodes: Node[];
  34224. /** All of the cameras added to this scene
  34225. * @see http://doc.babylonjs.com/babylon101/cameras
  34226. */
  34227. cameras: Camera[];
  34228. /**
  34229. * All of the lights added to this scene
  34230. * @see http://doc.babylonjs.com/babylon101/lights
  34231. */
  34232. lights: Light[];
  34233. /**
  34234. * All of the (abstract) meshes added to this scene
  34235. */
  34236. meshes: AbstractMesh[];
  34237. /**
  34238. * The list of skeletons added to the scene
  34239. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34240. */
  34241. skeletons: Skeleton[];
  34242. /**
  34243. * All of the particle systems added to this scene
  34244. * @see http://doc.babylonjs.com/babylon101/particles
  34245. */
  34246. particleSystems: IParticleSystem[];
  34247. /**
  34248. * Gets a list of Animations associated with the scene
  34249. */
  34250. animations: Animation[];
  34251. /**
  34252. * All of the animation groups added to this scene
  34253. * @see http://doc.babylonjs.com/how_to/group
  34254. */
  34255. animationGroups: AnimationGroup[];
  34256. /**
  34257. * All of the multi-materials added to this scene
  34258. * @see http://doc.babylonjs.com/how_to/multi_materials
  34259. */
  34260. multiMaterials: MultiMaterial[];
  34261. /**
  34262. * All of the materials added to this scene
  34263. * In the context of a Scene, it is not supposed to be modified manually.
  34264. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34265. * Note also that the order of the Material wihin the array is not significant and might change.
  34266. * @see http://doc.babylonjs.com/babylon101/materials
  34267. */
  34268. materials: Material[];
  34269. /**
  34270. * The list of morph target managers added to the scene
  34271. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34272. */
  34273. morphTargetManagers: MorphTargetManager[];
  34274. /**
  34275. * The list of geometries used in the scene.
  34276. */
  34277. geometries: Geometry[];
  34278. /**
  34279. * All of the tranform nodes added to this scene
  34280. * In the context of a Scene, it is not supposed to be modified manually.
  34281. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34282. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34283. * @see http://doc.babylonjs.com/how_to/transformnode
  34284. */
  34285. transformNodes: TransformNode[];
  34286. /**
  34287. * ActionManagers available on the scene.
  34288. */
  34289. actionManagers: AbstractActionManager[];
  34290. /**
  34291. * Textures to keep.
  34292. */
  34293. textures: BaseTexture[];
  34294. /**
  34295. * Environment texture for the scene
  34296. */
  34297. environmentTexture: Nullable<BaseTexture>;
  34298. }
  34299. }
  34300. declare module BABYLON {
  34301. /**
  34302. * Interface used to define options for Sound class
  34303. */
  34304. export interface ISoundOptions {
  34305. /**
  34306. * Does the sound autoplay once loaded.
  34307. */
  34308. autoplay?: boolean;
  34309. /**
  34310. * Does the sound loop after it finishes playing once.
  34311. */
  34312. loop?: boolean;
  34313. /**
  34314. * Sound's volume
  34315. */
  34316. volume?: number;
  34317. /**
  34318. * Is it a spatial sound?
  34319. */
  34320. spatialSound?: boolean;
  34321. /**
  34322. * Maximum distance to hear that sound
  34323. */
  34324. maxDistance?: number;
  34325. /**
  34326. * Uses user defined attenuation function
  34327. */
  34328. useCustomAttenuation?: boolean;
  34329. /**
  34330. * Define the roll off factor of spatial sounds.
  34331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34332. */
  34333. rolloffFactor?: number;
  34334. /**
  34335. * Define the reference distance the sound should be heard perfectly.
  34336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34337. */
  34338. refDistance?: number;
  34339. /**
  34340. * Define the distance attenuation model the sound will follow.
  34341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34342. */
  34343. distanceModel?: string;
  34344. /**
  34345. * Defines the playback speed (1 by default)
  34346. */
  34347. playbackRate?: number;
  34348. /**
  34349. * Defines if the sound is from a streaming source
  34350. */
  34351. streaming?: boolean;
  34352. /**
  34353. * Defines an optional length (in seconds) inside the sound file
  34354. */
  34355. length?: number;
  34356. /**
  34357. * Defines an optional offset (in seconds) inside the sound file
  34358. */
  34359. offset?: number;
  34360. /**
  34361. * If true, URLs will not be required to state the audio file codec to use.
  34362. */
  34363. skipCodecCheck?: boolean;
  34364. }
  34365. /**
  34366. * Defines a sound that can be played in the application.
  34367. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34369. */
  34370. export class Sound {
  34371. /**
  34372. * The name of the sound in the scene.
  34373. */
  34374. name: string;
  34375. /**
  34376. * Does the sound autoplay once loaded.
  34377. */
  34378. autoplay: boolean;
  34379. /**
  34380. * Does the sound loop after it finishes playing once.
  34381. */
  34382. loop: boolean;
  34383. /**
  34384. * Does the sound use a custom attenuation curve to simulate the falloff
  34385. * happening when the source gets further away from the camera.
  34386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34387. */
  34388. useCustomAttenuation: boolean;
  34389. /**
  34390. * The sound track id this sound belongs to.
  34391. */
  34392. soundTrackId: number;
  34393. /**
  34394. * Is this sound currently played.
  34395. */
  34396. isPlaying: boolean;
  34397. /**
  34398. * Is this sound currently paused.
  34399. */
  34400. isPaused: boolean;
  34401. /**
  34402. * Does this sound enables spatial sound.
  34403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34404. */
  34405. spatialSound: boolean;
  34406. /**
  34407. * Define the reference distance the sound should be heard perfectly.
  34408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34409. */
  34410. refDistance: number;
  34411. /**
  34412. * Define the roll off factor of spatial sounds.
  34413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34414. */
  34415. rolloffFactor: number;
  34416. /**
  34417. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34419. */
  34420. maxDistance: number;
  34421. /**
  34422. * Define the distance attenuation model the sound will follow.
  34423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34424. */
  34425. distanceModel: string;
  34426. /**
  34427. * @hidden
  34428. * Back Compat
  34429. **/
  34430. onended: () => any;
  34431. /**
  34432. * Observable event when the current playing sound finishes.
  34433. */
  34434. onEndedObservable: Observable<Sound>;
  34435. private _panningModel;
  34436. private _playbackRate;
  34437. private _streaming;
  34438. private _startTime;
  34439. private _startOffset;
  34440. private _position;
  34441. /** @hidden */ private _positionInEmitterSpace: boolean;
  34442. private _localDirection;
  34443. private _volume;
  34444. private _isReadyToPlay;
  34445. private _isDirectional;
  34446. private _readyToPlayCallback;
  34447. private _audioBuffer;
  34448. private _soundSource;
  34449. private _streamingSource;
  34450. private _soundPanner;
  34451. private _soundGain;
  34452. private _inputAudioNode;
  34453. private _outputAudioNode;
  34454. private _coneInnerAngle;
  34455. private _coneOuterAngle;
  34456. private _coneOuterGain;
  34457. private _scene;
  34458. private _connectedTransformNode;
  34459. private _customAttenuationFunction;
  34460. private _registerFunc;
  34461. private _isOutputConnected;
  34462. private _htmlAudioElement;
  34463. private _urlType;
  34464. private _length?;
  34465. private _offset?;
  34466. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34467. /**
  34468. * Create a sound and attach it to a scene
  34469. * @param name Name of your sound
  34470. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34471. * @param scene defines the scene the sound belongs to
  34472. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34473. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34474. */
  34475. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34476. /**
  34477. * Release the sound and its associated resources
  34478. */
  34479. dispose(): void;
  34480. /**
  34481. * Gets if the sounds is ready to be played or not.
  34482. * @returns true if ready, otherwise false
  34483. */
  34484. isReady(): boolean;
  34485. private _soundLoaded;
  34486. /**
  34487. * Sets the data of the sound from an audiobuffer
  34488. * @param audioBuffer The audioBuffer containing the data
  34489. */
  34490. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34491. /**
  34492. * Updates the current sounds options such as maxdistance, loop...
  34493. * @param options A JSON object containing values named as the object properties
  34494. */
  34495. updateOptions(options: ISoundOptions): void;
  34496. private _createSpatialParameters;
  34497. private _updateSpatialParameters;
  34498. /**
  34499. * Switch the panning model to HRTF:
  34500. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34502. */
  34503. switchPanningModelToHRTF(): void;
  34504. /**
  34505. * Switch the panning model to Equal Power:
  34506. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34508. */
  34509. switchPanningModelToEqualPower(): void;
  34510. private _switchPanningModel;
  34511. /**
  34512. * Connect this sound to a sound track audio node like gain...
  34513. * @param soundTrackAudioNode the sound track audio node to connect to
  34514. */
  34515. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34516. /**
  34517. * Transform this sound into a directional source
  34518. * @param coneInnerAngle Size of the inner cone in degree
  34519. * @param coneOuterAngle Size of the outer cone in degree
  34520. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34521. */
  34522. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34523. /**
  34524. * Gets or sets the inner angle for the directional cone.
  34525. */
  34526. /**
  34527. * Gets or sets the inner angle for the directional cone.
  34528. */
  34529. directionalConeInnerAngle: number;
  34530. /**
  34531. * Gets or sets the outer angle for the directional cone.
  34532. */
  34533. /**
  34534. * Gets or sets the outer angle for the directional cone.
  34535. */
  34536. directionalConeOuterAngle: number;
  34537. /**
  34538. * Sets the position of the emitter if spatial sound is enabled
  34539. * @param newPosition Defines the new posisiton
  34540. */
  34541. setPosition(newPosition: Vector3): void;
  34542. /**
  34543. * Sets the local direction of the emitter if spatial sound is enabled
  34544. * @param newLocalDirection Defines the new local direction
  34545. */
  34546. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34547. private _updateDirection;
  34548. /** @hidden */
  34549. updateDistanceFromListener(): void;
  34550. /**
  34551. * Sets a new custom attenuation function for the sound.
  34552. * @param callback Defines the function used for the attenuation
  34553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34554. */
  34555. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34556. /**
  34557. * Play the sound
  34558. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34559. * @param offset (optional) Start the sound at a specific time in seconds
  34560. * @param length (optional) Sound duration (in seconds)
  34561. */
  34562. play(time?: number, offset?: number, length?: number): void;
  34563. private _onended;
  34564. /**
  34565. * Stop the sound
  34566. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34567. */
  34568. stop(time?: number): void;
  34569. /**
  34570. * Put the sound in pause
  34571. */
  34572. pause(): void;
  34573. /**
  34574. * Sets a dedicated volume for this sounds
  34575. * @param newVolume Define the new volume of the sound
  34576. * @param time Define time for gradual change to new volume
  34577. */
  34578. setVolume(newVolume: number, time?: number): void;
  34579. /**
  34580. * Set the sound play back rate
  34581. * @param newPlaybackRate Define the playback rate the sound should be played at
  34582. */
  34583. setPlaybackRate(newPlaybackRate: number): void;
  34584. /**
  34585. * Gets the volume of the sound.
  34586. * @returns the volume of the sound
  34587. */
  34588. getVolume(): number;
  34589. /**
  34590. * Attach the sound to a dedicated mesh
  34591. * @param transformNode The transform node to connect the sound with
  34592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34593. */
  34594. attachToMesh(transformNode: TransformNode): void;
  34595. /**
  34596. * Detach the sound from the previously attached mesh
  34597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34598. */
  34599. detachFromMesh(): void;
  34600. private _onRegisterAfterWorldMatrixUpdate;
  34601. /**
  34602. * Clone the current sound in the scene.
  34603. * @returns the new sound clone
  34604. */
  34605. clone(): Nullable<Sound>;
  34606. /**
  34607. * Gets the current underlying audio buffer containing the data
  34608. * @returns the audio buffer
  34609. */
  34610. getAudioBuffer(): Nullable<AudioBuffer>;
  34611. /**
  34612. * Serializes the Sound in a JSON representation
  34613. * @returns the JSON representation of the sound
  34614. */
  34615. serialize(): any;
  34616. /**
  34617. * Parse a JSON representation of a sound to innstantiate in a given scene
  34618. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34619. * @param scene Define the scene the new parsed sound should be created in
  34620. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34621. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34622. * @returns the newly parsed sound
  34623. */
  34624. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34625. }
  34626. }
  34627. declare module BABYLON {
  34628. /**
  34629. * This defines an action helpful to play a defined sound on a triggered action.
  34630. */
  34631. export class PlaySoundAction extends Action {
  34632. private _sound;
  34633. /**
  34634. * Instantiate the action
  34635. * @param triggerOptions defines the trigger options
  34636. * @param sound defines the sound to play
  34637. * @param condition defines the trigger related conditions
  34638. */
  34639. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34640. /** @hidden */ private _prepare(): void;
  34641. /**
  34642. * Execute the action and play the sound.
  34643. */
  34644. execute(): void;
  34645. /**
  34646. * Serializes the actions and its related information.
  34647. * @param parent defines the object to serialize in
  34648. * @returns the serialized object
  34649. */
  34650. serialize(parent: any): any;
  34651. }
  34652. /**
  34653. * This defines an action helpful to stop a defined sound on a triggered action.
  34654. */
  34655. export class StopSoundAction extends Action {
  34656. private _sound;
  34657. /**
  34658. * Instantiate the action
  34659. * @param triggerOptions defines the trigger options
  34660. * @param sound defines the sound to stop
  34661. * @param condition defines the trigger related conditions
  34662. */
  34663. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34664. /** @hidden */ private _prepare(): void;
  34665. /**
  34666. * Execute the action and stop the sound.
  34667. */
  34668. execute(): void;
  34669. /**
  34670. * Serializes the actions and its related information.
  34671. * @param parent defines the object to serialize in
  34672. * @returns the serialized object
  34673. */
  34674. serialize(parent: any): any;
  34675. }
  34676. }
  34677. declare module BABYLON {
  34678. /**
  34679. * This defines an action responsible to change the value of a property
  34680. * by interpolating between its current value and the newly set one once triggered.
  34681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34682. */
  34683. export class InterpolateValueAction extends Action {
  34684. /**
  34685. * Defines the path of the property where the value should be interpolated
  34686. */
  34687. propertyPath: string;
  34688. /**
  34689. * Defines the target value at the end of the interpolation.
  34690. */
  34691. value: any;
  34692. /**
  34693. * Defines the time it will take for the property to interpolate to the value.
  34694. */
  34695. duration: number;
  34696. /**
  34697. * Defines if the other scene animations should be stopped when the action has been triggered
  34698. */
  34699. stopOtherAnimations?: boolean;
  34700. /**
  34701. * Defines a callback raised once the interpolation animation has been done.
  34702. */
  34703. onInterpolationDone?: () => void;
  34704. /**
  34705. * Observable triggered once the interpolation animation has been done.
  34706. */
  34707. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34708. private _target;
  34709. private _effectiveTarget;
  34710. private _property;
  34711. /**
  34712. * Instantiate the action
  34713. * @param triggerOptions defines the trigger options
  34714. * @param target defines the object containing the value to interpolate
  34715. * @param propertyPath defines the path to the property in the target object
  34716. * @param value defines the target value at the end of the interpolation
  34717. * @param duration deines the time it will take for the property to interpolate to the value.
  34718. * @param condition defines the trigger related conditions
  34719. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34720. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34721. */
  34722. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34723. /** @hidden */ private _prepare(): void;
  34724. /**
  34725. * Execute the action starts the value interpolation.
  34726. */
  34727. execute(): void;
  34728. /**
  34729. * Serializes the actions and its related information.
  34730. * @param parent defines the object to serialize in
  34731. * @returns the serialized object
  34732. */
  34733. serialize(parent: any): any;
  34734. }
  34735. }
  34736. declare module BABYLON {
  34737. /**
  34738. * Options allowed during the creation of a sound track.
  34739. */
  34740. export interface ISoundTrackOptions {
  34741. /**
  34742. * The volume the sound track should take during creation
  34743. */
  34744. volume?: number;
  34745. /**
  34746. * Define if the sound track is the main sound track of the scene
  34747. */
  34748. mainTrack?: boolean;
  34749. }
  34750. /**
  34751. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34752. * It will be also used in a future release to apply effects on a specific track.
  34753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34754. */
  34755. export class SoundTrack {
  34756. /**
  34757. * The unique identifier of the sound track in the scene.
  34758. */
  34759. id: number;
  34760. /**
  34761. * The list of sounds included in the sound track.
  34762. */
  34763. soundCollection: Array<Sound>;
  34764. private _outputAudioNode;
  34765. private _scene;
  34766. private _isMainTrack;
  34767. private _connectedAnalyser;
  34768. private _options;
  34769. private _isInitialized;
  34770. /**
  34771. * Creates a new sound track.
  34772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34773. * @param scene Define the scene the sound track belongs to
  34774. * @param options
  34775. */
  34776. constructor(scene: Scene, options?: ISoundTrackOptions);
  34777. private _initializeSoundTrackAudioGraph;
  34778. /**
  34779. * Release the sound track and its associated resources
  34780. */
  34781. dispose(): void;
  34782. /**
  34783. * Adds a sound to this sound track
  34784. * @param sound define the cound to add
  34785. * @ignoreNaming
  34786. */
  34787. AddSound(sound: Sound): void;
  34788. /**
  34789. * Removes a sound to this sound track
  34790. * @param sound define the cound to remove
  34791. * @ignoreNaming
  34792. */
  34793. RemoveSound(sound: Sound): void;
  34794. /**
  34795. * Set a global volume for the full sound track.
  34796. * @param newVolume Define the new volume of the sound track
  34797. */
  34798. setVolume(newVolume: number): void;
  34799. /**
  34800. * Switch the panning model to HRTF:
  34801. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34803. */
  34804. switchPanningModelToHRTF(): void;
  34805. /**
  34806. * Switch the panning model to Equal Power:
  34807. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34809. */
  34810. switchPanningModelToEqualPower(): void;
  34811. /**
  34812. * Connect the sound track to an audio analyser allowing some amazing
  34813. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34815. * @param analyser The analyser to connect to the engine
  34816. */
  34817. connectToAnalyser(analyser: Analyser): void;
  34818. }
  34819. }
  34820. declare module BABYLON {
  34821. interface AbstractScene {
  34822. /**
  34823. * The list of sounds used in the scene.
  34824. */
  34825. sounds: Nullable<Array<Sound>>;
  34826. }
  34827. interface Scene {
  34828. /**
  34829. * @hidden
  34830. * Backing field
  34831. */ private _mainSoundTrack: SoundTrack;
  34832. /**
  34833. * The main sound track played by the scene.
  34834. * It cotains your primary collection of sounds.
  34835. */
  34836. mainSoundTrack: SoundTrack;
  34837. /**
  34838. * The list of sound tracks added to the scene
  34839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34840. */
  34841. soundTracks: Nullable<Array<SoundTrack>>;
  34842. /**
  34843. * Gets a sound using a given name
  34844. * @param name defines the name to search for
  34845. * @return the found sound or null if not found at all.
  34846. */
  34847. getSoundByName(name: string): Nullable<Sound>;
  34848. /**
  34849. * Gets or sets if audio support is enabled
  34850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34851. */
  34852. audioEnabled: boolean;
  34853. /**
  34854. * Gets or sets if audio will be output to headphones
  34855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34856. */
  34857. headphone: boolean;
  34858. /**
  34859. * Gets or sets custom audio listener position provider
  34860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34861. */
  34862. audioListenerPositionProvider: Nullable<() => Vector3>;
  34863. }
  34864. /**
  34865. * Defines the sound scene component responsible to manage any sounds
  34866. * in a given scene.
  34867. */
  34868. export class AudioSceneComponent implements ISceneSerializableComponent {
  34869. /**
  34870. * The component name helpfull to identify the component in the list of scene components.
  34871. */
  34872. readonly name: string;
  34873. /**
  34874. * The scene the component belongs to.
  34875. */
  34876. scene: Scene;
  34877. private _audioEnabled;
  34878. /**
  34879. * Gets whether audio is enabled or not.
  34880. * Please use related enable/disable method to switch state.
  34881. */
  34882. readonly audioEnabled: boolean;
  34883. private _headphone;
  34884. /**
  34885. * Gets whether audio is outputing to headphone or not.
  34886. * Please use the according Switch methods to change output.
  34887. */
  34888. readonly headphone: boolean;
  34889. private _audioListenerPositionProvider;
  34890. /**
  34891. * Gets the current audio listener position provider
  34892. */
  34893. /**
  34894. * Sets a custom listener position for all sounds in the scene
  34895. * By default, this is the position of the first active camera
  34896. */
  34897. audioListenerPositionProvider: Nullable<() => Vector3>;
  34898. /**
  34899. * Creates a new instance of the component for the given scene
  34900. * @param scene Defines the scene to register the component in
  34901. */
  34902. constructor(scene: Scene);
  34903. /**
  34904. * Registers the component in a given scene
  34905. */
  34906. register(): void;
  34907. /**
  34908. * Rebuilds the elements related to this component in case of
  34909. * context lost for instance.
  34910. */
  34911. rebuild(): void;
  34912. /**
  34913. * Serializes the component data to the specified json object
  34914. * @param serializationObject The object to serialize to
  34915. */
  34916. serialize(serializationObject: any): void;
  34917. /**
  34918. * Adds all the elements from the container to the scene
  34919. * @param container the container holding the elements
  34920. */
  34921. addFromContainer(container: AbstractScene): void;
  34922. /**
  34923. * Removes all the elements in the container from the scene
  34924. * @param container contains the elements to remove
  34925. * @param dispose if the removed element should be disposed (default: false)
  34926. */
  34927. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34928. /**
  34929. * Disposes the component and the associated ressources.
  34930. */
  34931. dispose(): void;
  34932. /**
  34933. * Disables audio in the associated scene.
  34934. */
  34935. disableAudio(): void;
  34936. /**
  34937. * Enables audio in the associated scene.
  34938. */
  34939. enableAudio(): void;
  34940. /**
  34941. * Switch audio to headphone output.
  34942. */
  34943. switchAudioModeForHeadphones(): void;
  34944. /**
  34945. * Switch audio to normal speakers.
  34946. */
  34947. switchAudioModeForNormalSpeakers(): void;
  34948. private _afterRender;
  34949. }
  34950. }
  34951. declare module BABYLON {
  34952. /**
  34953. * Wraps one or more Sound objects and selects one with random weight for playback.
  34954. */
  34955. export class WeightedSound {
  34956. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34957. loop: boolean;
  34958. private _coneInnerAngle;
  34959. private _coneOuterAngle;
  34960. private _volume;
  34961. /** A Sound is currently playing. */
  34962. isPlaying: boolean;
  34963. /** A Sound is currently paused. */
  34964. isPaused: boolean;
  34965. private _sounds;
  34966. private _weights;
  34967. private _currentIndex?;
  34968. /**
  34969. * Creates a new WeightedSound from the list of sounds given.
  34970. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34971. * @param sounds Array of Sounds that will be selected from.
  34972. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34973. */
  34974. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34975. /**
  34976. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34977. */
  34978. /**
  34979. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34980. */
  34981. directionalConeInnerAngle: number;
  34982. /**
  34983. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34984. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34985. */
  34986. /**
  34987. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34988. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34989. */
  34990. directionalConeOuterAngle: number;
  34991. /**
  34992. * Playback volume.
  34993. */
  34994. /**
  34995. * Playback volume.
  34996. */
  34997. volume: number;
  34998. private _onended;
  34999. /**
  35000. * Suspend playback
  35001. */
  35002. pause(): void;
  35003. /**
  35004. * Stop playback
  35005. */
  35006. stop(): void;
  35007. /**
  35008. * Start playback.
  35009. * @param startOffset Position the clip head at a specific time in seconds.
  35010. */
  35011. play(startOffset?: number): void;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. /**
  35016. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35017. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35018. */
  35019. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35020. /**
  35021. * Gets the name of the behavior.
  35022. */
  35023. readonly name: string;
  35024. /**
  35025. * The easing function used by animations
  35026. */
  35027. static EasingFunction: BackEase;
  35028. /**
  35029. * The easing mode used by animations
  35030. */
  35031. static EasingMode: number;
  35032. /**
  35033. * The duration of the animation, in milliseconds
  35034. */
  35035. transitionDuration: number;
  35036. /**
  35037. * Length of the distance animated by the transition when lower radius is reached
  35038. */
  35039. lowerRadiusTransitionRange: number;
  35040. /**
  35041. * Length of the distance animated by the transition when upper radius is reached
  35042. */
  35043. upperRadiusTransitionRange: number;
  35044. private _autoTransitionRange;
  35045. /**
  35046. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35047. */
  35048. /**
  35049. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35050. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35051. */
  35052. autoTransitionRange: boolean;
  35053. private _attachedCamera;
  35054. private _onAfterCheckInputsObserver;
  35055. private _onMeshTargetChangedObserver;
  35056. /**
  35057. * Initializes the behavior.
  35058. */
  35059. init(): void;
  35060. /**
  35061. * Attaches the behavior to its arc rotate camera.
  35062. * @param camera Defines the camera to attach the behavior to
  35063. */
  35064. attach(camera: ArcRotateCamera): void;
  35065. /**
  35066. * Detaches the behavior from its current arc rotate camera.
  35067. */
  35068. detach(): void;
  35069. private _radiusIsAnimating;
  35070. private _radiusBounceTransition;
  35071. private _animatables;
  35072. private _cachedWheelPrecision;
  35073. /**
  35074. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35075. * @param radiusLimit The limit to check against.
  35076. * @return Bool to indicate if at limit.
  35077. */
  35078. private _isRadiusAtLimit;
  35079. /**
  35080. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35081. * @param radiusDelta The delta by which to animate to. Can be negative.
  35082. */
  35083. private _applyBoundRadiusAnimation;
  35084. /**
  35085. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35086. */
  35087. protected _clearAnimationLocks(): void;
  35088. /**
  35089. * Stops and removes all animations that have been applied to the camera
  35090. */
  35091. stopAllAnimations(): void;
  35092. }
  35093. }
  35094. declare module BABYLON {
  35095. /**
  35096. * 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.
  35097. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35098. */
  35099. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35100. /**
  35101. * Gets the name of the behavior.
  35102. */
  35103. readonly name: string;
  35104. private _mode;
  35105. private _radiusScale;
  35106. private _positionScale;
  35107. private _defaultElevation;
  35108. private _elevationReturnTime;
  35109. private _elevationReturnWaitTime;
  35110. private _zoomStopsAnimation;
  35111. private _framingTime;
  35112. /**
  35113. * The easing function used by animations
  35114. */
  35115. static EasingFunction: ExponentialEase;
  35116. /**
  35117. * The easing mode used by animations
  35118. */
  35119. static EasingMode: number;
  35120. /**
  35121. * Sets the current mode used by the behavior
  35122. */
  35123. /**
  35124. * Gets current mode used by the behavior.
  35125. */
  35126. mode: number;
  35127. /**
  35128. * Sets the scale applied to the radius (1 by default)
  35129. */
  35130. /**
  35131. * Gets the scale applied to the radius
  35132. */
  35133. radiusScale: number;
  35134. /**
  35135. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35136. */
  35137. /**
  35138. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35139. */
  35140. positionScale: number;
  35141. /**
  35142. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35143. * behaviour is triggered, in radians.
  35144. */
  35145. /**
  35146. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35147. * behaviour is triggered, in radians.
  35148. */
  35149. defaultElevation: number;
  35150. /**
  35151. * Sets the time (in milliseconds) taken to return to the default beta position.
  35152. * Negative value indicates camera should not return to default.
  35153. */
  35154. /**
  35155. * Gets the time (in milliseconds) taken to return to the default beta position.
  35156. * Negative value indicates camera should not return to default.
  35157. */
  35158. elevationReturnTime: number;
  35159. /**
  35160. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35161. */
  35162. /**
  35163. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35164. */
  35165. elevationReturnWaitTime: number;
  35166. /**
  35167. * Sets the flag that indicates if user zooming should stop animation.
  35168. */
  35169. /**
  35170. * Gets the flag that indicates if user zooming should stop animation.
  35171. */
  35172. zoomStopsAnimation: boolean;
  35173. /**
  35174. * Sets the transition time when framing the mesh, in milliseconds
  35175. */
  35176. /**
  35177. * Gets the transition time when framing the mesh, in milliseconds
  35178. */
  35179. framingTime: number;
  35180. /**
  35181. * Define if the behavior should automatically change the configured
  35182. * camera limits and sensibilities.
  35183. */
  35184. autoCorrectCameraLimitsAndSensibility: boolean;
  35185. private _onPrePointerObservableObserver;
  35186. private _onAfterCheckInputsObserver;
  35187. private _onMeshTargetChangedObserver;
  35188. private _attachedCamera;
  35189. private _isPointerDown;
  35190. private _lastInteractionTime;
  35191. /**
  35192. * Initializes the behavior.
  35193. */
  35194. init(): void;
  35195. /**
  35196. * Attaches the behavior to its arc rotate camera.
  35197. * @param camera Defines the camera to attach the behavior to
  35198. */
  35199. attach(camera: ArcRotateCamera): void;
  35200. /**
  35201. * Detaches the behavior from its current arc rotate camera.
  35202. */
  35203. detach(): void;
  35204. private _animatables;
  35205. private _betaIsAnimating;
  35206. private _betaTransition;
  35207. private _radiusTransition;
  35208. private _vectorTransition;
  35209. /**
  35210. * Targets the given mesh and updates zoom level accordingly.
  35211. * @param mesh The mesh to target.
  35212. * @param radius Optional. If a cached radius position already exists, overrides default.
  35213. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35214. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35215. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35216. */
  35217. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35218. /**
  35219. * Targets the given mesh with its children and updates zoom level accordingly.
  35220. * @param mesh The mesh to target.
  35221. * @param radius Optional. If a cached radius position already exists, overrides default.
  35222. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35223. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35224. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35225. */
  35226. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35227. /**
  35228. * Targets the given meshes with their children and updates zoom level accordingly.
  35229. * @param meshes The mesh to target.
  35230. * @param radius Optional. If a cached radius position already exists, overrides default.
  35231. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35232. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35233. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35234. */
  35235. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35236. /**
  35237. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35238. * @param minimumWorld Determines the smaller position of the bounding box extend
  35239. * @param maximumWorld Determines the bigger position of the bounding box extend
  35240. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35241. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35242. */
  35243. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35244. /**
  35245. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35246. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35247. * frustum width.
  35248. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35249. * to fully enclose the mesh in the viewing frustum.
  35250. */
  35251. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35252. /**
  35253. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35254. * is automatically returned to its default position (expected to be above ground plane).
  35255. */
  35256. private _maintainCameraAboveGround;
  35257. /**
  35258. * Returns the frustum slope based on the canvas ratio and camera FOV
  35259. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35260. */
  35261. private _getFrustumSlope;
  35262. /**
  35263. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35264. */
  35265. private _clearAnimationLocks;
  35266. /**
  35267. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35268. */
  35269. private _applyUserInteraction;
  35270. /**
  35271. * Stops and removes all animations that have been applied to the camera
  35272. */
  35273. stopAllAnimations(): void;
  35274. /**
  35275. * Gets a value indicating if the user is moving the camera
  35276. */
  35277. readonly isUserIsMoving: boolean;
  35278. /**
  35279. * The camera can move all the way towards the mesh.
  35280. */
  35281. static IgnoreBoundsSizeMode: number;
  35282. /**
  35283. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35284. */
  35285. static FitFrustumSidesMode: number;
  35286. }
  35287. }
  35288. declare module BABYLON {
  35289. /**
  35290. * Base class for Camera Pointer Inputs.
  35291. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35292. * for example usage.
  35293. */
  35294. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35295. /**
  35296. * Defines the camera the input is attached to.
  35297. */
  35298. abstract camera: Camera;
  35299. /**
  35300. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35301. */
  35302. protected _altKey: boolean;
  35303. protected _ctrlKey: boolean;
  35304. protected _metaKey: boolean;
  35305. protected _shiftKey: boolean;
  35306. /**
  35307. * Which mouse buttons were pressed at time of last mouse event.
  35308. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35309. */
  35310. protected _buttonsPressed: number;
  35311. /**
  35312. * Defines the buttons associated with the input to handle camera move.
  35313. */
  35314. buttons: number[];
  35315. /**
  35316. * Attach the input controls to a specific dom element to get the input from.
  35317. * @param element Defines the element the controls should be listened from
  35318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35319. */
  35320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35321. /**
  35322. * Detach the current controls from the specified dom element.
  35323. * @param element Defines the element to stop listening the inputs from
  35324. */
  35325. detachControl(element: Nullable<HTMLElement>): void;
  35326. /**
  35327. * Gets the class name of the current input.
  35328. * @returns the class name
  35329. */
  35330. getClassName(): string;
  35331. /**
  35332. * Get the friendly name associated with the input class.
  35333. * @returns the input friendly name
  35334. */
  35335. getSimpleName(): string;
  35336. /**
  35337. * Called on pointer POINTERDOUBLETAP event.
  35338. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35339. */
  35340. protected onDoubleTap(type: string): void;
  35341. /**
  35342. * Called on pointer POINTERMOVE event if only a single touch is active.
  35343. * Override this method to provide functionality.
  35344. */
  35345. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35346. /**
  35347. * Called on pointer POINTERMOVE event if multiple touches are active.
  35348. * Override this method to provide functionality.
  35349. */
  35350. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35351. /**
  35352. * Called on JS contextmenu event.
  35353. * Override this method to provide functionality.
  35354. */
  35355. protected onContextMenu(evt: PointerEvent): void;
  35356. /**
  35357. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35358. * press.
  35359. * Override this method to provide functionality.
  35360. */
  35361. protected onButtonDown(evt: PointerEvent): void;
  35362. /**
  35363. * Called each time a new POINTERUP event occurs. Ie, for each button
  35364. * release.
  35365. * Override this method to provide functionality.
  35366. */
  35367. protected onButtonUp(evt: PointerEvent): void;
  35368. /**
  35369. * Called when window becomes inactive.
  35370. * Override this method to provide functionality.
  35371. */
  35372. protected onLostFocus(): void;
  35373. private _pointerInput;
  35374. private _observer;
  35375. private _onLostFocus;
  35376. private pointA;
  35377. private pointB;
  35378. }
  35379. }
  35380. declare module BABYLON {
  35381. /**
  35382. * Manage the pointers inputs to control an arc rotate camera.
  35383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35384. */
  35385. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35386. /**
  35387. * Defines the camera the input is attached to.
  35388. */
  35389. camera: ArcRotateCamera;
  35390. /**
  35391. * Gets the class name of the current input.
  35392. * @returns the class name
  35393. */
  35394. getClassName(): string;
  35395. /**
  35396. * Defines the buttons associated with the input to handle camera move.
  35397. */
  35398. buttons: number[];
  35399. /**
  35400. * Defines the pointer angular sensibility along the X axis or how fast is
  35401. * the camera rotating.
  35402. */
  35403. angularSensibilityX: number;
  35404. /**
  35405. * Defines the pointer angular sensibility along the Y axis or how fast is
  35406. * the camera rotating.
  35407. */
  35408. angularSensibilityY: number;
  35409. /**
  35410. * Defines the pointer pinch precision or how fast is the camera zooming.
  35411. */
  35412. pinchPrecision: number;
  35413. /**
  35414. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35415. * from 0.
  35416. * It defines the percentage of current camera.radius to use as delta when
  35417. * pinch zoom is used.
  35418. */
  35419. pinchDeltaPercentage: number;
  35420. /**
  35421. * Defines the pointer panning sensibility or how fast is the camera moving.
  35422. */
  35423. panningSensibility: number;
  35424. /**
  35425. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35426. */
  35427. multiTouchPanning: boolean;
  35428. /**
  35429. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35430. * zoom (pinch) through multitouch.
  35431. */
  35432. multiTouchPanAndZoom: boolean;
  35433. /**
  35434. * Revers pinch action direction.
  35435. */
  35436. pinchInwards: boolean;
  35437. private _isPanClick;
  35438. private _twoFingerActivityCount;
  35439. private _isPinching;
  35440. /**
  35441. * Called on pointer POINTERMOVE event if only a single touch is active.
  35442. */
  35443. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35444. /**
  35445. * Called on pointer POINTERDOUBLETAP event.
  35446. */
  35447. protected onDoubleTap(type: string): void;
  35448. /**
  35449. * Called on pointer POINTERMOVE event if multiple touches are active.
  35450. */
  35451. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35452. /**
  35453. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35454. * press.
  35455. */
  35456. protected onButtonDown(evt: PointerEvent): void;
  35457. /**
  35458. * Called each time a new POINTERUP event occurs. Ie, for each button
  35459. * release.
  35460. */
  35461. protected onButtonUp(evt: PointerEvent): void;
  35462. /**
  35463. * Called when window becomes inactive.
  35464. */
  35465. protected onLostFocus(): void;
  35466. }
  35467. }
  35468. declare module BABYLON {
  35469. /**
  35470. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35472. */
  35473. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35474. /**
  35475. * Defines the camera the input is attached to.
  35476. */
  35477. camera: ArcRotateCamera;
  35478. /**
  35479. * Defines the list of key codes associated with the up action (increase alpha)
  35480. */
  35481. keysUp: number[];
  35482. /**
  35483. * Defines the list of key codes associated with the down action (decrease alpha)
  35484. */
  35485. keysDown: number[];
  35486. /**
  35487. * Defines the list of key codes associated with the left action (increase beta)
  35488. */
  35489. keysLeft: number[];
  35490. /**
  35491. * Defines the list of key codes associated with the right action (decrease beta)
  35492. */
  35493. keysRight: number[];
  35494. /**
  35495. * Defines the list of key codes associated with the reset action.
  35496. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35497. */
  35498. keysReset: number[];
  35499. /**
  35500. * Defines the panning sensibility of the inputs.
  35501. * (How fast is the camera paning)
  35502. */
  35503. panningSensibility: number;
  35504. /**
  35505. * Defines the zooming sensibility of the inputs.
  35506. * (How fast is the camera zooming)
  35507. */
  35508. zoomingSensibility: number;
  35509. /**
  35510. * Defines wether maintaining the alt key down switch the movement mode from
  35511. * orientation to zoom.
  35512. */
  35513. useAltToZoom: boolean;
  35514. /**
  35515. * Rotation speed of the camera
  35516. */
  35517. angularSpeed: number;
  35518. private _keys;
  35519. private _ctrlPressed;
  35520. private _altPressed;
  35521. private _onCanvasBlurObserver;
  35522. private _onKeyboardObserver;
  35523. private _engine;
  35524. private _scene;
  35525. /**
  35526. * Attach the input controls to a specific dom element to get the input from.
  35527. * @param element Defines the element the controls should be listened from
  35528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35529. */
  35530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35531. /**
  35532. * Detach the current controls from the specified dom element.
  35533. * @param element Defines the element to stop listening the inputs from
  35534. */
  35535. detachControl(element: Nullable<HTMLElement>): void;
  35536. /**
  35537. * Update the current camera state depending on the inputs that have been used this frame.
  35538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35539. */
  35540. checkInputs(): void;
  35541. /**
  35542. * Gets the class name of the current intput.
  35543. * @returns the class name
  35544. */
  35545. getClassName(): string;
  35546. /**
  35547. * Get the friendly name associated with the input class.
  35548. * @returns the input friendly name
  35549. */
  35550. getSimpleName(): string;
  35551. }
  35552. }
  35553. declare module BABYLON {
  35554. /**
  35555. * Manage the mouse wheel inputs to control an arc rotate camera.
  35556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35557. */
  35558. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35559. /**
  35560. * Defines the camera the input is attached to.
  35561. */
  35562. camera: ArcRotateCamera;
  35563. /**
  35564. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35565. */
  35566. wheelPrecision: number;
  35567. /**
  35568. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35569. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35570. */
  35571. wheelDeltaPercentage: number;
  35572. private _wheel;
  35573. private _observer;
  35574. private computeDeltaFromMouseWheelLegacyEvent;
  35575. /**
  35576. * Attach the input controls to a specific dom element to get the input from.
  35577. * @param element Defines the element the controls should be listened from
  35578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35579. */
  35580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35581. /**
  35582. * Detach the current controls from the specified dom element.
  35583. * @param element Defines the element to stop listening the inputs from
  35584. */
  35585. detachControl(element: Nullable<HTMLElement>): void;
  35586. /**
  35587. * Gets the class name of the current intput.
  35588. * @returns the class name
  35589. */
  35590. getClassName(): string;
  35591. /**
  35592. * Get the friendly name associated with the input class.
  35593. * @returns the input friendly name
  35594. */
  35595. getSimpleName(): string;
  35596. }
  35597. }
  35598. declare module BABYLON {
  35599. /**
  35600. * Default Inputs manager for the ArcRotateCamera.
  35601. * It groups all the default supported inputs for ease of use.
  35602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35603. */
  35604. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35605. /**
  35606. * Instantiates a new ArcRotateCameraInputsManager.
  35607. * @param camera Defines the camera the inputs belong to
  35608. */
  35609. constructor(camera: ArcRotateCamera);
  35610. /**
  35611. * Add mouse wheel input support to the input manager.
  35612. * @returns the current input manager
  35613. */
  35614. addMouseWheel(): ArcRotateCameraInputsManager;
  35615. /**
  35616. * Add pointers input support to the input manager.
  35617. * @returns the current input manager
  35618. */
  35619. addPointers(): ArcRotateCameraInputsManager;
  35620. /**
  35621. * Add keyboard input support to the input manager.
  35622. * @returns the current input manager
  35623. */
  35624. addKeyboard(): ArcRotateCameraInputsManager;
  35625. }
  35626. }
  35627. declare module BABYLON {
  35628. /**
  35629. * This represents an orbital type of camera.
  35630. *
  35631. * 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.
  35632. * 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.
  35633. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35634. */
  35635. export class ArcRotateCamera extends TargetCamera {
  35636. /**
  35637. * Defines the rotation angle of the camera along the longitudinal axis.
  35638. */
  35639. alpha: number;
  35640. /**
  35641. * Defines the rotation angle of the camera along the latitudinal axis.
  35642. */
  35643. beta: number;
  35644. /**
  35645. * Defines the radius of the camera from it s target point.
  35646. */
  35647. radius: number;
  35648. protected _target: Vector3;
  35649. protected _targetHost: Nullable<AbstractMesh>;
  35650. /**
  35651. * Defines the target point of the camera.
  35652. * The camera looks towards it form the radius distance.
  35653. */
  35654. target: Vector3;
  35655. /**
  35656. * Define the current local position of the camera in the scene
  35657. */
  35658. position: Vector3;
  35659. protected _upVector: Vector3;
  35660. protected _upToYMatrix: Matrix;
  35661. protected _YToUpMatrix: Matrix;
  35662. /**
  35663. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35664. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35665. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35666. */
  35667. upVector: Vector3;
  35668. /**
  35669. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35670. */
  35671. setMatUp(): void;
  35672. /**
  35673. * Current inertia value on the longitudinal axis.
  35674. * The bigger this number the longer it will take for the camera to stop.
  35675. */
  35676. inertialAlphaOffset: number;
  35677. /**
  35678. * Current inertia value on the latitudinal axis.
  35679. * The bigger this number the longer it will take for the camera to stop.
  35680. */
  35681. inertialBetaOffset: number;
  35682. /**
  35683. * Current inertia value on the radius axis.
  35684. * The bigger this number the longer it will take for the camera to stop.
  35685. */
  35686. inertialRadiusOffset: number;
  35687. /**
  35688. * Minimum allowed angle on the longitudinal axis.
  35689. * This can help limiting how the Camera is able to move in the scene.
  35690. */
  35691. lowerAlphaLimit: Nullable<number>;
  35692. /**
  35693. * Maximum allowed angle on the longitudinal axis.
  35694. * This can help limiting how the Camera is able to move in the scene.
  35695. */
  35696. upperAlphaLimit: Nullable<number>;
  35697. /**
  35698. * Minimum allowed angle on the latitudinal axis.
  35699. * This can help limiting how the Camera is able to move in the scene.
  35700. */
  35701. lowerBetaLimit: number;
  35702. /**
  35703. * Maximum allowed angle on the latitudinal axis.
  35704. * This can help limiting how the Camera is able to move in the scene.
  35705. */
  35706. upperBetaLimit: number;
  35707. /**
  35708. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35709. * This can help limiting how the Camera is able to move in the scene.
  35710. */
  35711. lowerRadiusLimit: Nullable<number>;
  35712. /**
  35713. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35714. * This can help limiting how the Camera is able to move in the scene.
  35715. */
  35716. upperRadiusLimit: Nullable<number>;
  35717. /**
  35718. * Defines the current inertia value used during panning of the camera along the X axis.
  35719. */
  35720. inertialPanningX: number;
  35721. /**
  35722. * Defines the current inertia value used during panning of the camera along the Y axis.
  35723. */
  35724. inertialPanningY: number;
  35725. /**
  35726. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35727. * Basically if your fingers moves away from more than this distance you will be considered
  35728. * in pinch mode.
  35729. */
  35730. pinchToPanMaxDistance: number;
  35731. /**
  35732. * Defines the maximum distance the camera can pan.
  35733. * This could help keeping the cammera always in your scene.
  35734. */
  35735. panningDistanceLimit: Nullable<number>;
  35736. /**
  35737. * Defines the target of the camera before paning.
  35738. */
  35739. panningOriginTarget: Vector3;
  35740. /**
  35741. * Defines the value of the inertia used during panning.
  35742. * 0 would mean stop inertia and one would mean no decelleration at all.
  35743. */
  35744. panningInertia: number;
  35745. /**
  35746. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35747. */
  35748. angularSensibilityX: number;
  35749. /**
  35750. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35751. */
  35752. angularSensibilityY: number;
  35753. /**
  35754. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35755. */
  35756. pinchPrecision: number;
  35757. /**
  35758. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35759. * It will be used instead of pinchDeltaPrecision if different from 0.
  35760. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35761. */
  35762. pinchDeltaPercentage: number;
  35763. /**
  35764. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35765. */
  35766. panningSensibility: number;
  35767. /**
  35768. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35769. */
  35770. keysUp: number[];
  35771. /**
  35772. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35773. */
  35774. keysDown: number[];
  35775. /**
  35776. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35777. */
  35778. keysLeft: number[];
  35779. /**
  35780. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35781. */
  35782. keysRight: number[];
  35783. /**
  35784. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35785. */
  35786. wheelPrecision: number;
  35787. /**
  35788. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35789. * It will be used instead of pinchDeltaPrecision if different from 0.
  35790. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35791. */
  35792. wheelDeltaPercentage: number;
  35793. /**
  35794. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35795. */
  35796. zoomOnFactor: number;
  35797. /**
  35798. * Defines a screen offset for the camera position.
  35799. */
  35800. targetScreenOffset: Vector2;
  35801. /**
  35802. * Allows the camera to be completely reversed.
  35803. * If false the camera can not arrive upside down.
  35804. */
  35805. allowUpsideDown: boolean;
  35806. /**
  35807. * Define if double tap/click is used to restore the previously saved state of the camera.
  35808. */
  35809. useInputToRestoreState: boolean;
  35810. /** @hidden */ private _viewMatrix: Matrix;
  35811. /** @hidden */ private _useCtrlForPanning: boolean;
  35812. /** @hidden */ private _panningMouseButton: number;
  35813. /**
  35814. * Defines the input associated to the camera.
  35815. */
  35816. inputs: ArcRotateCameraInputsManager;
  35817. /** @hidden */ private _reset: () => void;
  35818. /**
  35819. * Defines the allowed panning axis.
  35820. */
  35821. panningAxis: Vector3;
  35822. protected _localDirection: Vector3;
  35823. protected _transformedDirection: Vector3;
  35824. private _bouncingBehavior;
  35825. /**
  35826. * Gets the bouncing behavior of the camera if it has been enabled.
  35827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35828. */
  35829. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35830. /**
  35831. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35832. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35833. */
  35834. useBouncingBehavior: boolean;
  35835. private _framingBehavior;
  35836. /**
  35837. * Gets the framing behavior of the camera if it has been enabled.
  35838. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35839. */
  35840. readonly framingBehavior: Nullable<FramingBehavior>;
  35841. /**
  35842. * Defines if the framing behavior of the camera is enabled on the camera.
  35843. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35844. */
  35845. useFramingBehavior: boolean;
  35846. private _autoRotationBehavior;
  35847. /**
  35848. * Gets the auto rotation behavior of the camera if it has been enabled.
  35849. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35850. */
  35851. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35852. /**
  35853. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35854. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35855. */
  35856. useAutoRotationBehavior: boolean;
  35857. /**
  35858. * Observable triggered when the mesh target has been changed on the camera.
  35859. */
  35860. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35861. /**
  35862. * Event raised when the camera is colliding with a mesh.
  35863. */
  35864. onCollide: (collidedMesh: AbstractMesh) => void;
  35865. /**
  35866. * Defines whether the camera should check collision with the objects oh the scene.
  35867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35868. */
  35869. checkCollisions: boolean;
  35870. /**
  35871. * Defines the collision radius of the camera.
  35872. * This simulates a sphere around the camera.
  35873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35874. */
  35875. collisionRadius: Vector3;
  35876. protected _collider: Collider;
  35877. protected _previousPosition: Vector3;
  35878. protected _collisionVelocity: Vector3;
  35879. protected _newPosition: Vector3;
  35880. protected _previousAlpha: number;
  35881. protected _previousBeta: number;
  35882. protected _previousRadius: number;
  35883. protected _collisionTriggered: boolean;
  35884. protected _targetBoundingCenter: Nullable<Vector3>;
  35885. private _computationVector;
  35886. /**
  35887. * Instantiates a new ArcRotateCamera in a given scene
  35888. * @param name Defines the name of the camera
  35889. * @param alpha Defines the camera rotation along the logitudinal axis
  35890. * @param beta Defines the camera rotation along the latitudinal axis
  35891. * @param radius Defines the camera distance from its target
  35892. * @param target Defines the camera target
  35893. * @param scene Defines the scene the camera belongs to
  35894. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35895. */
  35896. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35897. /** @hidden */ private _initCache(): void;
  35898. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35899. protected _getTargetPosition(): Vector3;
  35900. private _storedAlpha;
  35901. private _storedBeta;
  35902. private _storedRadius;
  35903. private _storedTarget;
  35904. private _storedTargetScreenOffset;
  35905. /**
  35906. * Stores the current state of the camera (alpha, beta, radius and target)
  35907. * @returns the camera itself
  35908. */
  35909. storeState(): Camera;
  35910. /**
  35911. * @hidden
  35912. * Restored camera state. You must call storeState() first
  35913. */ private _restoreStateValues(): boolean;
  35914. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35915. /**
  35916. * Attached controls to the current camera.
  35917. * @param element Defines the element the controls should be listened from
  35918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35919. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35920. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35921. */
  35922. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35923. /**
  35924. * Detach the current controls from the camera.
  35925. * The camera will stop reacting to inputs.
  35926. * @param element Defines the element to stop listening the inputs from
  35927. */
  35928. detachControl(element: HTMLElement): void;
  35929. /** @hidden */ private _checkInputs(): void;
  35930. protected _checkLimits(): void;
  35931. /**
  35932. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35933. */
  35934. rebuildAnglesAndRadius(): void;
  35935. /**
  35936. * Use a position to define the current camera related information like aplha, beta and radius
  35937. * @param position Defines the position to set the camera at
  35938. */
  35939. setPosition(position: Vector3): void;
  35940. /**
  35941. * Defines the target the camera should look at.
  35942. * This will automatically adapt alpha beta and radius to fit within the new target.
  35943. * @param target Defines the new target as a Vector or a mesh
  35944. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35945. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35946. */
  35947. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35948. /** @hidden */ private _getViewMatrix(): Matrix;
  35949. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35950. /**
  35951. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35952. * @param meshes Defines the mesh to zoom on
  35953. * @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)
  35954. */
  35955. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35956. /**
  35957. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35958. * The target will be changed but the radius
  35959. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35960. * @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)
  35961. */
  35962. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35963. min: Vector3;
  35964. max: Vector3;
  35965. distance: number;
  35966. }, doNotUpdateMaxZ?: boolean): void;
  35967. /**
  35968. * @override
  35969. * Override Camera.createRigCamera
  35970. */
  35971. createRigCamera(name: string, cameraIndex: number): Camera;
  35972. /**
  35973. * @hidden
  35974. * @override
  35975. * Override Camera._updateRigCameras
  35976. */ private _updateRigCameras(): void;
  35977. /**
  35978. * Destroy the camera and release the current resources hold by it.
  35979. */
  35980. dispose(): void;
  35981. /**
  35982. * Gets the current object class name.
  35983. * @return the class name
  35984. */
  35985. getClassName(): string;
  35986. }
  35987. }
  35988. declare module BABYLON {
  35989. /**
  35990. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35992. */
  35993. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35994. /**
  35995. * Gets the name of the behavior.
  35996. */
  35997. readonly name: string;
  35998. private _zoomStopsAnimation;
  35999. private _idleRotationSpeed;
  36000. private _idleRotationWaitTime;
  36001. private _idleRotationSpinupTime;
  36002. /**
  36003. * Sets the flag that indicates if user zooming should stop animation.
  36004. */
  36005. /**
  36006. * Gets the flag that indicates if user zooming should stop animation.
  36007. */
  36008. zoomStopsAnimation: boolean;
  36009. /**
  36010. * Sets the default speed at which the camera rotates around the model.
  36011. */
  36012. /**
  36013. * Gets the default speed at which the camera rotates around the model.
  36014. */
  36015. idleRotationSpeed: number;
  36016. /**
  36017. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36018. */
  36019. /**
  36020. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36021. */
  36022. idleRotationWaitTime: number;
  36023. /**
  36024. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36025. */
  36026. /**
  36027. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36028. */
  36029. idleRotationSpinupTime: number;
  36030. /**
  36031. * Gets a value indicating if the camera is currently rotating because of this behavior
  36032. */
  36033. readonly rotationInProgress: boolean;
  36034. private _onPrePointerObservableObserver;
  36035. private _onAfterCheckInputsObserver;
  36036. private _attachedCamera;
  36037. private _isPointerDown;
  36038. private _lastFrameTime;
  36039. private _lastInteractionTime;
  36040. private _cameraRotationSpeed;
  36041. /**
  36042. * Initializes the behavior.
  36043. */
  36044. init(): void;
  36045. /**
  36046. * Attaches the behavior to its arc rotate camera.
  36047. * @param camera Defines the camera to attach the behavior to
  36048. */
  36049. attach(camera: ArcRotateCamera): void;
  36050. /**
  36051. * Detaches the behavior from its current arc rotate camera.
  36052. */
  36053. detach(): void;
  36054. /**
  36055. * Returns true if user is scrolling.
  36056. * @return true if user is scrolling.
  36057. */
  36058. private _userIsZooming;
  36059. private _lastFrameRadius;
  36060. private _shouldAnimationStopForInteraction;
  36061. /**
  36062. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36063. */
  36064. private _applyUserInteraction;
  36065. private _userIsMoving;
  36066. }
  36067. }
  36068. declare module BABYLON {
  36069. /**
  36070. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36071. */
  36072. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36073. private ui;
  36074. /**
  36075. * The name of the behavior
  36076. */
  36077. name: string;
  36078. /**
  36079. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36080. */
  36081. distanceAwayFromFace: number;
  36082. /**
  36083. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36084. */
  36085. distanceAwayFromBottomOfFace: number;
  36086. private _faceVectors;
  36087. private _target;
  36088. private _scene;
  36089. private _onRenderObserver;
  36090. private _tmpMatrix;
  36091. private _tmpVector;
  36092. /**
  36093. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36094. * @param ui The transform node that should be attched to the mesh
  36095. */
  36096. constructor(ui: TransformNode);
  36097. /**
  36098. * Initializes the behavior
  36099. */
  36100. init(): void;
  36101. private _closestFace;
  36102. private _zeroVector;
  36103. private _lookAtTmpMatrix;
  36104. private _lookAtToRef;
  36105. /**
  36106. * Attaches the AttachToBoxBehavior to the passed in mesh
  36107. * @param target The mesh that the specified node will be attached to
  36108. */
  36109. attach(target: Mesh): void;
  36110. /**
  36111. * Detaches the behavior from the mesh
  36112. */
  36113. detach(): void;
  36114. }
  36115. }
  36116. declare module BABYLON {
  36117. /**
  36118. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36119. */
  36120. export class FadeInOutBehavior implements Behavior<Mesh> {
  36121. /**
  36122. * Time in milliseconds to delay before fading in (Default: 0)
  36123. */
  36124. delay: number;
  36125. /**
  36126. * Time in milliseconds for the mesh to fade in (Default: 300)
  36127. */
  36128. fadeInTime: number;
  36129. private _millisecondsPerFrame;
  36130. private _hovered;
  36131. private _hoverValue;
  36132. private _ownerNode;
  36133. /**
  36134. * Instatiates the FadeInOutBehavior
  36135. */
  36136. constructor();
  36137. /**
  36138. * The name of the behavior
  36139. */
  36140. readonly name: string;
  36141. /**
  36142. * Initializes the behavior
  36143. */
  36144. init(): void;
  36145. /**
  36146. * Attaches the fade behavior on the passed in mesh
  36147. * @param ownerNode The mesh that will be faded in/out once attached
  36148. */
  36149. attach(ownerNode: Mesh): void;
  36150. /**
  36151. * Detaches the behavior from the mesh
  36152. */
  36153. detach(): void;
  36154. /**
  36155. * Triggers the mesh to begin fading in or out
  36156. * @param value if the object should fade in or out (true to fade in)
  36157. */
  36158. fadeIn(value: boolean): void;
  36159. private _update;
  36160. private _setAllVisibility;
  36161. }
  36162. }
  36163. declare module BABYLON {
  36164. /**
  36165. * Class containing a set of static utilities functions for managing Pivots
  36166. * @hidden
  36167. */
  36168. export class PivotTools {
  36169. private static _PivotCached;
  36170. private static _OldPivotPoint;
  36171. private static _PivotTranslation;
  36172. private static _PivotTmpVector;
  36173. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36174. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36175. }
  36176. }
  36177. declare module BABYLON {
  36178. /**
  36179. * Class containing static functions to help procedurally build meshes
  36180. */
  36181. export class PlaneBuilder {
  36182. /**
  36183. * Creates a plane mesh
  36184. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36185. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36186. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36188. * * 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
  36189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36190. * @param name defines the name of the mesh
  36191. * @param options defines the options used to create the mesh
  36192. * @param scene defines the hosting scene
  36193. * @returns the plane mesh
  36194. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36195. */
  36196. static CreatePlane(name: string, options: {
  36197. size?: number;
  36198. width?: number;
  36199. height?: number;
  36200. sideOrientation?: number;
  36201. frontUVs?: Vector4;
  36202. backUVs?: Vector4;
  36203. updatable?: boolean;
  36204. sourcePlane?: Plane;
  36205. }, scene?: Nullable<Scene>): Mesh;
  36206. }
  36207. }
  36208. declare module BABYLON {
  36209. /**
  36210. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36211. */
  36212. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36213. private static _AnyMouseID;
  36214. /**
  36215. * Abstract mesh the behavior is set on
  36216. */
  36217. attachedNode: AbstractMesh;
  36218. private _dragPlane;
  36219. private _scene;
  36220. private _pointerObserver;
  36221. private _beforeRenderObserver;
  36222. private static _planeScene;
  36223. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36224. /**
  36225. * 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)
  36226. */
  36227. maxDragAngle: number;
  36228. /**
  36229. * @hidden
  36230. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36231. /**
  36232. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36233. */
  36234. currentDraggingPointerID: number;
  36235. /**
  36236. * The last position where the pointer hit the drag plane in world space
  36237. */
  36238. lastDragPosition: Vector3;
  36239. /**
  36240. * If the behavior is currently in a dragging state
  36241. */
  36242. dragging: boolean;
  36243. /**
  36244. * 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)
  36245. */
  36246. dragDeltaRatio: number;
  36247. /**
  36248. * If the drag plane orientation should be updated during the dragging (Default: true)
  36249. */
  36250. updateDragPlane: boolean;
  36251. private _debugMode;
  36252. private _moving;
  36253. /**
  36254. * Fires each time the attached mesh is dragged with the pointer
  36255. * * delta between last drag position and current drag position in world space
  36256. * * dragDistance along the drag axis
  36257. * * dragPlaneNormal normal of the current drag plane used during the drag
  36258. * * dragPlanePoint in world space where the drag intersects the drag plane
  36259. */
  36260. onDragObservable: Observable<{
  36261. delta: Vector3;
  36262. dragPlanePoint: Vector3;
  36263. dragPlaneNormal: Vector3;
  36264. dragDistance: number;
  36265. pointerId: number;
  36266. }>;
  36267. /**
  36268. * Fires each time a drag begins (eg. mouse down on mesh)
  36269. */
  36270. onDragStartObservable: Observable<{
  36271. dragPlanePoint: Vector3;
  36272. pointerId: number;
  36273. }>;
  36274. /**
  36275. * Fires each time a drag ends (eg. mouse release after drag)
  36276. */
  36277. onDragEndObservable: Observable<{
  36278. dragPlanePoint: Vector3;
  36279. pointerId: number;
  36280. }>;
  36281. /**
  36282. * If the attached mesh should be moved when dragged
  36283. */
  36284. moveAttached: boolean;
  36285. /**
  36286. * If the drag behavior will react to drag events (Default: true)
  36287. */
  36288. enabled: boolean;
  36289. /**
  36290. * If pointer events should start and release the drag (Default: true)
  36291. */
  36292. startAndReleaseDragOnPointerEvents: boolean;
  36293. /**
  36294. * If camera controls should be detached during the drag
  36295. */
  36296. detachCameraControls: boolean;
  36297. /**
  36298. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36299. */
  36300. useObjectOrienationForDragging: boolean;
  36301. private _options;
  36302. /**
  36303. * Creates a pointer drag behavior that can be attached to a mesh
  36304. * @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)
  36305. */
  36306. constructor(options?: {
  36307. dragAxis?: Vector3;
  36308. dragPlaneNormal?: Vector3;
  36309. });
  36310. /**
  36311. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36312. */
  36313. validateDrag: (targetPosition: Vector3) => boolean;
  36314. /**
  36315. * The name of the behavior
  36316. */
  36317. readonly name: string;
  36318. /**
  36319. * Initializes the behavior
  36320. */
  36321. init(): void;
  36322. private _tmpVector;
  36323. private _alternatePickedPoint;
  36324. private _worldDragAxis;
  36325. private _targetPosition;
  36326. private _attachedElement;
  36327. /**
  36328. * Attaches the drag behavior the passed in mesh
  36329. * @param ownerNode The mesh that will be dragged around once attached
  36330. * @param predicate Predicate to use for pick filtering
  36331. */
  36332. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36333. /**
  36334. * Force relase the drag action by code.
  36335. */
  36336. releaseDrag(): void;
  36337. private _startDragRay;
  36338. private _lastPointerRay;
  36339. /**
  36340. * Simulates the start of a pointer drag event on the behavior
  36341. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36342. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36343. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36344. */
  36345. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36346. private _startDrag;
  36347. private _dragDelta;
  36348. private _moveDrag;
  36349. private _pickWithRayOnDragPlane;
  36350. private _pointA;
  36351. private _pointB;
  36352. private _pointC;
  36353. private _lineA;
  36354. private _lineB;
  36355. private _localAxis;
  36356. private _lookAt;
  36357. private _updateDragPlanePosition;
  36358. /**
  36359. * Detaches the behavior from the mesh
  36360. */
  36361. detach(): void;
  36362. }
  36363. }
  36364. declare module BABYLON {
  36365. /**
  36366. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36367. */
  36368. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36369. private _dragBehaviorA;
  36370. private _dragBehaviorB;
  36371. private _startDistance;
  36372. private _initialScale;
  36373. private _targetScale;
  36374. private _ownerNode;
  36375. private _sceneRenderObserver;
  36376. /**
  36377. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36378. */
  36379. constructor();
  36380. /**
  36381. * The name of the behavior
  36382. */
  36383. readonly name: string;
  36384. /**
  36385. * Initializes the behavior
  36386. */
  36387. init(): void;
  36388. private _getCurrentDistance;
  36389. /**
  36390. * Attaches the scale behavior the passed in mesh
  36391. * @param ownerNode The mesh that will be scaled around once attached
  36392. */
  36393. attach(ownerNode: Mesh): void;
  36394. /**
  36395. * Detaches the behavior from the mesh
  36396. */
  36397. detach(): void;
  36398. }
  36399. }
  36400. declare module BABYLON {
  36401. /**
  36402. * 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
  36403. */
  36404. export class SixDofDragBehavior implements Behavior<Mesh> {
  36405. private static _virtualScene;
  36406. private _ownerNode;
  36407. private _sceneRenderObserver;
  36408. private _scene;
  36409. private _targetPosition;
  36410. private _virtualOriginMesh;
  36411. private _virtualDragMesh;
  36412. private _pointerObserver;
  36413. private _moving;
  36414. private _startingOrientation;
  36415. /**
  36416. * 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)
  36417. */
  36418. private zDragFactor;
  36419. /**
  36420. * If the object should rotate to face the drag origin
  36421. */
  36422. rotateDraggedObject: boolean;
  36423. /**
  36424. * If the behavior is currently in a dragging state
  36425. */
  36426. dragging: boolean;
  36427. /**
  36428. * 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)
  36429. */
  36430. dragDeltaRatio: number;
  36431. /**
  36432. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36433. */
  36434. currentDraggingPointerID: number;
  36435. /**
  36436. * If camera controls should be detached during the drag
  36437. */
  36438. detachCameraControls: boolean;
  36439. /**
  36440. * Fires each time a drag starts
  36441. */
  36442. onDragStartObservable: Observable<{}>;
  36443. /**
  36444. * Fires each time a drag ends (eg. mouse release after drag)
  36445. */
  36446. onDragEndObservable: Observable<{}>;
  36447. /**
  36448. * 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
  36449. */
  36450. constructor();
  36451. /**
  36452. * The name of the behavior
  36453. */
  36454. readonly name: string;
  36455. /**
  36456. * Initializes the behavior
  36457. */
  36458. init(): void;
  36459. /**
  36460. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36461. */
  36462. private readonly _pointerCamera;
  36463. /**
  36464. * Attaches the scale behavior the passed in mesh
  36465. * @param ownerNode The mesh that will be scaled around once attached
  36466. */
  36467. attach(ownerNode: Mesh): void;
  36468. /**
  36469. * Detaches the behavior from the mesh
  36470. */
  36471. detach(): void;
  36472. }
  36473. }
  36474. declare module BABYLON {
  36475. /**
  36476. * Class used to apply inverse kinematics to bones
  36477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36478. */
  36479. export class BoneIKController {
  36480. private static _tmpVecs;
  36481. private static _tmpQuat;
  36482. private static _tmpMats;
  36483. /**
  36484. * Gets or sets the target mesh
  36485. */
  36486. targetMesh: AbstractMesh;
  36487. /** Gets or sets the mesh used as pole */
  36488. poleTargetMesh: AbstractMesh;
  36489. /**
  36490. * Gets or sets the bone used as pole
  36491. */
  36492. poleTargetBone: Nullable<Bone>;
  36493. /**
  36494. * Gets or sets the target position
  36495. */
  36496. targetPosition: Vector3;
  36497. /**
  36498. * Gets or sets the pole target position
  36499. */
  36500. poleTargetPosition: Vector3;
  36501. /**
  36502. * Gets or sets the pole target local offset
  36503. */
  36504. poleTargetLocalOffset: Vector3;
  36505. /**
  36506. * Gets or sets the pole angle
  36507. */
  36508. poleAngle: number;
  36509. /**
  36510. * Gets or sets the mesh associated with the controller
  36511. */
  36512. mesh: AbstractMesh;
  36513. /**
  36514. * 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)
  36515. */
  36516. slerpAmount: number;
  36517. private _bone1Quat;
  36518. private _bone1Mat;
  36519. private _bone2Ang;
  36520. private _bone1;
  36521. private _bone2;
  36522. private _bone1Length;
  36523. private _bone2Length;
  36524. private _maxAngle;
  36525. private _maxReach;
  36526. private _rightHandedSystem;
  36527. private _bendAxis;
  36528. private _slerping;
  36529. private _adjustRoll;
  36530. /**
  36531. * Gets or sets maximum allowed angle
  36532. */
  36533. maxAngle: number;
  36534. /**
  36535. * Creates a new BoneIKController
  36536. * @param mesh defines the mesh to control
  36537. * @param bone defines the bone to control
  36538. * @param options defines options to set up the controller
  36539. */
  36540. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36541. targetMesh?: AbstractMesh;
  36542. poleTargetMesh?: AbstractMesh;
  36543. poleTargetBone?: Bone;
  36544. poleTargetLocalOffset?: Vector3;
  36545. poleAngle?: number;
  36546. bendAxis?: Vector3;
  36547. maxAngle?: number;
  36548. slerpAmount?: number;
  36549. });
  36550. private _setMaxAngle;
  36551. /**
  36552. * Force the controller to update the bones
  36553. */
  36554. update(): void;
  36555. }
  36556. }
  36557. declare module BABYLON {
  36558. /**
  36559. * Class used to make a bone look toward a point in space
  36560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36561. */
  36562. export class BoneLookController {
  36563. private static _tmpVecs;
  36564. private static _tmpQuat;
  36565. private static _tmpMats;
  36566. /**
  36567. * The target Vector3 that the bone will look at
  36568. */
  36569. target: Vector3;
  36570. /**
  36571. * The mesh that the bone is attached to
  36572. */
  36573. mesh: AbstractMesh;
  36574. /**
  36575. * The bone that will be looking to the target
  36576. */
  36577. bone: Bone;
  36578. /**
  36579. * The up axis of the coordinate system that is used when the bone is rotated
  36580. */
  36581. upAxis: Vector3;
  36582. /**
  36583. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36584. */
  36585. upAxisSpace: Space;
  36586. /**
  36587. * Used to make an adjustment to the yaw of the bone
  36588. */
  36589. adjustYaw: number;
  36590. /**
  36591. * Used to make an adjustment to the pitch of the bone
  36592. */
  36593. adjustPitch: number;
  36594. /**
  36595. * Used to make an adjustment to the roll of the bone
  36596. */
  36597. adjustRoll: number;
  36598. /**
  36599. * 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)
  36600. */
  36601. slerpAmount: number;
  36602. private _minYaw;
  36603. private _maxYaw;
  36604. private _minPitch;
  36605. private _maxPitch;
  36606. private _minYawSin;
  36607. private _minYawCos;
  36608. private _maxYawSin;
  36609. private _maxYawCos;
  36610. private _midYawConstraint;
  36611. private _minPitchTan;
  36612. private _maxPitchTan;
  36613. private _boneQuat;
  36614. private _slerping;
  36615. private _transformYawPitch;
  36616. private _transformYawPitchInv;
  36617. private _firstFrameSkipped;
  36618. private _yawRange;
  36619. private _fowardAxis;
  36620. /**
  36621. * Gets or sets the minimum yaw angle that the bone can look to
  36622. */
  36623. minYaw: number;
  36624. /**
  36625. * Gets or sets the maximum yaw angle that the bone can look to
  36626. */
  36627. maxYaw: number;
  36628. /**
  36629. * Gets or sets the minimum pitch angle that the bone can look to
  36630. */
  36631. minPitch: number;
  36632. /**
  36633. * Gets or sets the maximum pitch angle that the bone can look to
  36634. */
  36635. maxPitch: number;
  36636. /**
  36637. * Create a BoneLookController
  36638. * @param mesh the mesh that the bone belongs to
  36639. * @param bone the bone that will be looking to the target
  36640. * @param target the target Vector3 to look at
  36641. * @param options optional settings:
  36642. * * maxYaw: the maximum angle the bone will yaw to
  36643. * * minYaw: the minimum angle the bone will yaw to
  36644. * * maxPitch: the maximum angle the bone will pitch to
  36645. * * minPitch: the minimum angle the bone will yaw to
  36646. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36647. * * upAxis: the up axis of the coordinate system
  36648. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36649. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36650. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36651. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36652. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36653. * * adjustRoll: used to make an adjustment to the roll of the bone
  36654. **/
  36655. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36656. maxYaw?: number;
  36657. minYaw?: number;
  36658. maxPitch?: number;
  36659. minPitch?: number;
  36660. slerpAmount?: number;
  36661. upAxis?: Vector3;
  36662. upAxisSpace?: Space;
  36663. yawAxis?: Vector3;
  36664. pitchAxis?: Vector3;
  36665. adjustYaw?: number;
  36666. adjustPitch?: number;
  36667. adjustRoll?: number;
  36668. });
  36669. /**
  36670. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36671. */
  36672. update(): void;
  36673. private _getAngleDiff;
  36674. private _getAngleBetween;
  36675. private _isAngleBetween;
  36676. }
  36677. }
  36678. declare module BABYLON {
  36679. /**
  36680. * Manage the gamepad inputs to control an arc rotate camera.
  36681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36682. */
  36683. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36684. /**
  36685. * Defines the camera the input is attached to.
  36686. */
  36687. camera: ArcRotateCamera;
  36688. /**
  36689. * Defines the gamepad the input is gathering event from.
  36690. */
  36691. gamepad: Nullable<Gamepad>;
  36692. /**
  36693. * Defines the gamepad rotation sensiblity.
  36694. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36695. */
  36696. gamepadRotationSensibility: number;
  36697. /**
  36698. * Defines the gamepad move sensiblity.
  36699. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36700. */
  36701. gamepadMoveSensibility: number;
  36702. private _onGamepadConnectedObserver;
  36703. private _onGamepadDisconnectedObserver;
  36704. /**
  36705. * Attach the input controls to a specific dom element to get the input from.
  36706. * @param element Defines the element the controls should be listened from
  36707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36708. */
  36709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36710. /**
  36711. * Detach the current controls from the specified dom element.
  36712. * @param element Defines the element to stop listening the inputs from
  36713. */
  36714. detachControl(element: Nullable<HTMLElement>): void;
  36715. /**
  36716. * Update the current camera state depending on the inputs that have been used this frame.
  36717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36718. */
  36719. checkInputs(): void;
  36720. /**
  36721. * Gets the class name of the current intput.
  36722. * @returns the class name
  36723. */
  36724. getClassName(): string;
  36725. /**
  36726. * Get the friendly name associated with the input class.
  36727. * @returns the input friendly name
  36728. */
  36729. getSimpleName(): string;
  36730. }
  36731. }
  36732. declare module BABYLON {
  36733. interface ArcRotateCameraInputsManager {
  36734. /**
  36735. * Add orientation input support to the input manager.
  36736. * @returns the current input manager
  36737. */
  36738. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36739. }
  36740. /**
  36741. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36743. */
  36744. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36745. /**
  36746. * Defines the camera the input is attached to.
  36747. */
  36748. camera: ArcRotateCamera;
  36749. /**
  36750. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36751. */
  36752. alphaCorrection: number;
  36753. /**
  36754. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36755. */
  36756. gammaCorrection: number;
  36757. private _alpha;
  36758. private _gamma;
  36759. private _dirty;
  36760. private _deviceOrientationHandler;
  36761. /**
  36762. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36763. */
  36764. constructor();
  36765. /**
  36766. * Attach the input controls to a specific dom element to get the input from.
  36767. * @param element Defines the element the controls should be listened from
  36768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36769. */
  36770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36771. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36772. /**
  36773. * Update the current camera state depending on the inputs that have been used this frame.
  36774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36775. */
  36776. checkInputs(): void;
  36777. /**
  36778. * Detach the current controls from the specified dom element.
  36779. * @param element Defines the element to stop listening the inputs from
  36780. */
  36781. detachControl(element: Nullable<HTMLElement>): void;
  36782. /**
  36783. * Gets the class name of the current intput.
  36784. * @returns the class name
  36785. */
  36786. getClassName(): string;
  36787. /**
  36788. * Get the friendly name associated with the input class.
  36789. * @returns the input friendly name
  36790. */
  36791. getSimpleName(): string;
  36792. }
  36793. }
  36794. declare module BABYLON {
  36795. /**
  36796. * Listen to mouse events to control the camera.
  36797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36798. */
  36799. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36800. /**
  36801. * Defines the camera the input is attached to.
  36802. */
  36803. camera: FlyCamera;
  36804. /**
  36805. * Defines if touch is enabled. (Default is true.)
  36806. */
  36807. touchEnabled: boolean;
  36808. /**
  36809. * Defines the buttons associated with the input to handle camera rotation.
  36810. */
  36811. buttons: number[];
  36812. /**
  36813. * Assign buttons for Yaw control.
  36814. */
  36815. buttonsYaw: number[];
  36816. /**
  36817. * Assign buttons for Pitch control.
  36818. */
  36819. buttonsPitch: number[];
  36820. /**
  36821. * Assign buttons for Roll control.
  36822. */
  36823. buttonsRoll: number[];
  36824. /**
  36825. * Detect if any button is being pressed while mouse is moved.
  36826. * -1 = Mouse locked.
  36827. * 0 = Left button.
  36828. * 1 = Middle Button.
  36829. * 2 = Right Button.
  36830. */
  36831. activeButton: number;
  36832. /**
  36833. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36834. * Higher values reduce its sensitivity.
  36835. */
  36836. angularSensibility: number;
  36837. private _mousemoveCallback;
  36838. private _observer;
  36839. private _rollObserver;
  36840. private previousPosition;
  36841. private noPreventDefault;
  36842. private element;
  36843. /**
  36844. * Listen to mouse events to control the camera.
  36845. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36847. */
  36848. constructor(touchEnabled?: boolean);
  36849. /**
  36850. * Attach the mouse control to the HTML DOM element.
  36851. * @param element Defines the element that listens to the input events.
  36852. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36853. */
  36854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36855. /**
  36856. * Detach the current controls from the specified dom element.
  36857. * @param element Defines the element to stop listening the inputs from
  36858. */
  36859. detachControl(element: Nullable<HTMLElement>): void;
  36860. /**
  36861. * Gets the class name of the current input.
  36862. * @returns the class name.
  36863. */
  36864. getClassName(): string;
  36865. /**
  36866. * Get the friendly name associated with the input class.
  36867. * @returns the input's friendly name.
  36868. */
  36869. getSimpleName(): string;
  36870. private _pointerInput;
  36871. private _onMouseMove;
  36872. /**
  36873. * Rotate camera by mouse offset.
  36874. */
  36875. private rotateCamera;
  36876. }
  36877. }
  36878. declare module BABYLON {
  36879. /**
  36880. * Default Inputs manager for the FlyCamera.
  36881. * It groups all the default supported inputs for ease of use.
  36882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36883. */
  36884. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36885. /**
  36886. * Instantiates a new FlyCameraInputsManager.
  36887. * @param camera Defines the camera the inputs belong to.
  36888. */
  36889. constructor(camera: FlyCamera);
  36890. /**
  36891. * Add keyboard input support to the input manager.
  36892. * @returns the new FlyCameraKeyboardMoveInput().
  36893. */
  36894. addKeyboard(): FlyCameraInputsManager;
  36895. /**
  36896. * Add mouse input support to the input manager.
  36897. * @param touchEnabled Enable touch screen support.
  36898. * @returns the new FlyCameraMouseInput().
  36899. */
  36900. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36901. }
  36902. }
  36903. declare module BABYLON {
  36904. /**
  36905. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36906. * such as in a 3D Space Shooter or a Flight Simulator.
  36907. */
  36908. export class FlyCamera extends TargetCamera {
  36909. /**
  36910. * Define the collision ellipsoid of the camera.
  36911. * This is helpful for simulating a camera body, like a player's body.
  36912. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36913. */
  36914. ellipsoid: Vector3;
  36915. /**
  36916. * Define an offset for the position of the ellipsoid around the camera.
  36917. * This can be helpful if the camera is attached away from the player's body center,
  36918. * such as at its head.
  36919. */
  36920. ellipsoidOffset: Vector3;
  36921. /**
  36922. * Enable or disable collisions of the camera with the rest of the scene objects.
  36923. */
  36924. checkCollisions: boolean;
  36925. /**
  36926. * Enable or disable gravity on the camera.
  36927. */
  36928. applyGravity: boolean;
  36929. /**
  36930. * Define the current direction the camera is moving to.
  36931. */
  36932. cameraDirection: Vector3;
  36933. /**
  36934. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36935. * This overrides and empties cameraRotation.
  36936. */
  36937. rotationQuaternion: Quaternion;
  36938. /**
  36939. * Track Roll to maintain the wanted Rolling when looking around.
  36940. */ private _trackRoll: number;
  36941. /**
  36942. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36943. */
  36944. rollCorrect: number;
  36945. /**
  36946. * Mimic a banked turn, Rolling the camera when Yawing.
  36947. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36948. */
  36949. bankedTurn: boolean;
  36950. /**
  36951. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36952. */
  36953. bankedTurnLimit: number;
  36954. /**
  36955. * Value of 0 disables the banked Roll.
  36956. * Value of 1 is equal to the Yaw angle in radians.
  36957. */
  36958. bankedTurnMultiplier: number;
  36959. /**
  36960. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36961. */
  36962. inputs: FlyCameraInputsManager;
  36963. /**
  36964. * Gets the input sensibility for mouse input.
  36965. * Higher values reduce sensitivity.
  36966. */
  36967. /**
  36968. * Sets the input sensibility for a mouse input.
  36969. * Higher values reduce sensitivity.
  36970. */
  36971. angularSensibility: number;
  36972. /**
  36973. * Get the keys for camera movement forward.
  36974. */
  36975. /**
  36976. * Set the keys for camera movement forward.
  36977. */
  36978. keysForward: number[];
  36979. /**
  36980. * Get the keys for camera movement backward.
  36981. */
  36982. keysBackward: number[];
  36983. /**
  36984. * Get the keys for camera movement up.
  36985. */
  36986. /**
  36987. * Set the keys for camera movement up.
  36988. */
  36989. keysUp: number[];
  36990. /**
  36991. * Get the keys for camera movement down.
  36992. */
  36993. /**
  36994. * Set the keys for camera movement down.
  36995. */
  36996. keysDown: number[];
  36997. /**
  36998. * Get the keys for camera movement left.
  36999. */
  37000. /**
  37001. * Set the keys for camera movement left.
  37002. */
  37003. keysLeft: number[];
  37004. /**
  37005. * Set the keys for camera movement right.
  37006. */
  37007. /**
  37008. * Set the keys for camera movement right.
  37009. */
  37010. keysRight: number[];
  37011. /**
  37012. * Event raised when the camera collides with a mesh in the scene.
  37013. */
  37014. onCollide: (collidedMesh: AbstractMesh) => void;
  37015. private _collider;
  37016. private _needMoveForGravity;
  37017. private _oldPosition;
  37018. private _diffPosition;
  37019. private _newPosition;
  37020. /** @hidden */ private _localDirection: Vector3;
  37021. /** @hidden */ private _transformedDirection: Vector3;
  37022. /**
  37023. * Instantiates a FlyCamera.
  37024. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37025. * such as in a 3D Space Shooter or a Flight Simulator.
  37026. * @param name Define the name of the camera in the scene.
  37027. * @param position Define the starting position of the camera in the scene.
  37028. * @param scene Define the scene the camera belongs to.
  37029. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37030. */
  37031. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37032. /**
  37033. * Attach a control to the HTML DOM element.
  37034. * @param element Defines the element that listens to the input events.
  37035. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37036. */
  37037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37038. /**
  37039. * Detach a control from the HTML DOM element.
  37040. * The camera will stop reacting to that input.
  37041. * @param element Defines the element that listens to the input events.
  37042. */
  37043. detachControl(element: HTMLElement): void;
  37044. private _collisionMask;
  37045. /**
  37046. * Get the mask that the camera ignores in collision events.
  37047. */
  37048. /**
  37049. * Set the mask that the camera ignores in collision events.
  37050. */
  37051. collisionMask: number;
  37052. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  37053. /** @hidden */
  37054. private _onCollisionPositionChange;
  37055. /** @hidden */ private _checkInputs(): void;
  37056. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  37057. /** @hidden */ private _updatePosition(): void;
  37058. /**
  37059. * Restore the Roll to its target value at the rate specified.
  37060. * @param rate - Higher means slower restoring.
  37061. * @hidden
  37062. */
  37063. restoreRoll(rate: number): void;
  37064. /**
  37065. * Destroy the camera and release the current resources held by it.
  37066. */
  37067. dispose(): void;
  37068. /**
  37069. * Get the current object class name.
  37070. * @returns the class name.
  37071. */
  37072. getClassName(): string;
  37073. }
  37074. }
  37075. declare module BABYLON {
  37076. /**
  37077. * Listen to keyboard events to control the camera.
  37078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37079. */
  37080. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37081. /**
  37082. * Defines the camera the input is attached to.
  37083. */
  37084. camera: FlyCamera;
  37085. /**
  37086. * The list of keyboard keys used to control the forward move of the camera.
  37087. */
  37088. keysForward: number[];
  37089. /**
  37090. * The list of keyboard keys used to control the backward move of the camera.
  37091. */
  37092. keysBackward: number[];
  37093. /**
  37094. * The list of keyboard keys used to control the forward move of the camera.
  37095. */
  37096. keysUp: number[];
  37097. /**
  37098. * The list of keyboard keys used to control the backward move of the camera.
  37099. */
  37100. keysDown: number[];
  37101. /**
  37102. * The list of keyboard keys used to control the right strafe move of the camera.
  37103. */
  37104. keysRight: number[];
  37105. /**
  37106. * The list of keyboard keys used to control the left strafe move of the camera.
  37107. */
  37108. keysLeft: number[];
  37109. private _keys;
  37110. private _onCanvasBlurObserver;
  37111. private _onKeyboardObserver;
  37112. private _engine;
  37113. private _scene;
  37114. /**
  37115. * Attach the input controls to a specific dom element to get the input from.
  37116. * @param element Defines the element the controls should be listened from
  37117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37118. */
  37119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37120. /**
  37121. * Detach the current controls from the specified dom element.
  37122. * @param element Defines the element to stop listening the inputs from
  37123. */
  37124. detachControl(element: Nullable<HTMLElement>): void;
  37125. /**
  37126. * Gets the class name of the current intput.
  37127. * @returns the class name
  37128. */
  37129. getClassName(): string;
  37130. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37131. /**
  37132. * Get the friendly name associated with the input class.
  37133. * @returns the input friendly name
  37134. */
  37135. getSimpleName(): string;
  37136. /**
  37137. * Update the current camera state depending on the inputs that have been used this frame.
  37138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37139. */
  37140. checkInputs(): void;
  37141. }
  37142. }
  37143. declare module BABYLON {
  37144. /**
  37145. * Manage the mouse wheel inputs to control a follow camera.
  37146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37147. */
  37148. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37149. /**
  37150. * Defines the camera the input is attached to.
  37151. */
  37152. camera: FollowCamera;
  37153. /**
  37154. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37155. */
  37156. axisControlRadius: boolean;
  37157. /**
  37158. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37159. */
  37160. axisControlHeight: boolean;
  37161. /**
  37162. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37163. */
  37164. axisControlRotation: boolean;
  37165. /**
  37166. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37167. * relation to mouseWheel events.
  37168. */
  37169. wheelPrecision: number;
  37170. /**
  37171. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37172. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37173. */
  37174. wheelDeltaPercentage: number;
  37175. private _wheel;
  37176. private _observer;
  37177. /**
  37178. * Attach the input controls to a specific dom element to get the input from.
  37179. * @param element Defines the element the controls should be listened from
  37180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37181. */
  37182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37183. /**
  37184. * Detach the current controls from the specified dom element.
  37185. * @param element Defines the element to stop listening the inputs from
  37186. */
  37187. detachControl(element: Nullable<HTMLElement>): void;
  37188. /**
  37189. * Gets the class name of the current intput.
  37190. * @returns the class name
  37191. */
  37192. getClassName(): string;
  37193. /**
  37194. * Get the friendly name associated with the input class.
  37195. * @returns the input friendly name
  37196. */
  37197. getSimpleName(): string;
  37198. }
  37199. }
  37200. declare module BABYLON {
  37201. /**
  37202. * Manage the pointers inputs to control an follow camera.
  37203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37204. */
  37205. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37206. /**
  37207. * Defines the camera the input is attached to.
  37208. */
  37209. camera: FollowCamera;
  37210. /**
  37211. * Gets the class name of the current input.
  37212. * @returns the class name
  37213. */
  37214. getClassName(): string;
  37215. /**
  37216. * Defines the pointer angular sensibility along the X axis or how fast is
  37217. * the camera rotating.
  37218. * A negative number will reverse the axis direction.
  37219. */
  37220. angularSensibilityX: number;
  37221. /**
  37222. * Defines the pointer angular sensibility along the Y axis or how fast is
  37223. * the camera rotating.
  37224. * A negative number will reverse the axis direction.
  37225. */
  37226. angularSensibilityY: number;
  37227. /**
  37228. * Defines the pointer pinch precision or how fast is the camera zooming.
  37229. * A negative number will reverse the axis direction.
  37230. */
  37231. pinchPrecision: number;
  37232. /**
  37233. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37234. * from 0.
  37235. * It defines the percentage of current camera.radius to use as delta when
  37236. * pinch zoom is used.
  37237. */
  37238. pinchDeltaPercentage: number;
  37239. /**
  37240. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37241. */
  37242. axisXControlRadius: boolean;
  37243. /**
  37244. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37245. */
  37246. axisXControlHeight: boolean;
  37247. /**
  37248. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37249. */
  37250. axisXControlRotation: boolean;
  37251. /**
  37252. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37253. */
  37254. axisYControlRadius: boolean;
  37255. /**
  37256. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37257. */
  37258. axisYControlHeight: boolean;
  37259. /**
  37260. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37261. */
  37262. axisYControlRotation: boolean;
  37263. /**
  37264. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37265. */
  37266. axisPinchControlRadius: boolean;
  37267. /**
  37268. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37269. */
  37270. axisPinchControlHeight: boolean;
  37271. /**
  37272. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37273. */
  37274. axisPinchControlRotation: boolean;
  37275. /**
  37276. * Log error messages if basic misconfiguration has occurred.
  37277. */
  37278. warningEnable: boolean;
  37279. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37280. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37281. private _warningCounter;
  37282. private _warning;
  37283. }
  37284. }
  37285. declare module BABYLON {
  37286. /**
  37287. * Default Inputs manager for the FollowCamera.
  37288. * It groups all the default supported inputs for ease of use.
  37289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37290. */
  37291. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37292. /**
  37293. * Instantiates a new FollowCameraInputsManager.
  37294. * @param camera Defines the camera the inputs belong to
  37295. */
  37296. constructor(camera: FollowCamera);
  37297. /**
  37298. * Add keyboard input support to the input manager.
  37299. * @returns the current input manager
  37300. */
  37301. addKeyboard(): FollowCameraInputsManager;
  37302. /**
  37303. * Add mouse wheel input support to the input manager.
  37304. * @returns the current input manager
  37305. */
  37306. addMouseWheel(): FollowCameraInputsManager;
  37307. /**
  37308. * Add pointers input support to the input manager.
  37309. * @returns the current input manager
  37310. */
  37311. addPointers(): FollowCameraInputsManager;
  37312. /**
  37313. * Add orientation input support to the input manager.
  37314. * @returns the current input manager
  37315. */
  37316. addVRDeviceOrientation(): FollowCameraInputsManager;
  37317. }
  37318. }
  37319. declare module BABYLON {
  37320. /**
  37321. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37322. * an arc rotate version arcFollowCamera are available.
  37323. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37324. */
  37325. export class FollowCamera extends TargetCamera {
  37326. /**
  37327. * Distance the follow camera should follow an object at
  37328. */
  37329. radius: number;
  37330. /**
  37331. * Minimum allowed distance of the camera to the axis of rotation
  37332. * (The camera can not get closer).
  37333. * This can help limiting how the Camera is able to move in the scene.
  37334. */
  37335. lowerRadiusLimit: Nullable<number>;
  37336. /**
  37337. * Maximum allowed distance of the camera to the axis of rotation
  37338. * (The camera can not get further).
  37339. * This can help limiting how the Camera is able to move in the scene.
  37340. */
  37341. upperRadiusLimit: Nullable<number>;
  37342. /**
  37343. * Define a rotation offset between the camera and the object it follows
  37344. */
  37345. rotationOffset: number;
  37346. /**
  37347. * Minimum allowed angle to camera position relative to target object.
  37348. * This can help limiting how the Camera is able to move in the scene.
  37349. */
  37350. lowerRotationOffsetLimit: Nullable<number>;
  37351. /**
  37352. * Maximum allowed angle to camera position relative to target object.
  37353. * This can help limiting how the Camera is able to move in the scene.
  37354. */
  37355. upperRotationOffsetLimit: Nullable<number>;
  37356. /**
  37357. * Define a height offset between the camera and the object it follows.
  37358. * It can help following an object from the top (like a car chaing a plane)
  37359. */
  37360. heightOffset: number;
  37361. /**
  37362. * Minimum allowed height of camera position relative to target object.
  37363. * This can help limiting how the Camera is able to move in the scene.
  37364. */
  37365. lowerHeightOffsetLimit: Nullable<number>;
  37366. /**
  37367. * Maximum allowed height of camera position relative to target object.
  37368. * This can help limiting how the Camera is able to move in the scene.
  37369. */
  37370. upperHeightOffsetLimit: Nullable<number>;
  37371. /**
  37372. * Define how fast the camera can accelerate to follow it s target.
  37373. */
  37374. cameraAcceleration: number;
  37375. /**
  37376. * Define the speed limit of the camera following an object.
  37377. */
  37378. maxCameraSpeed: number;
  37379. /**
  37380. * Define the target of the camera.
  37381. */
  37382. lockedTarget: Nullable<AbstractMesh>;
  37383. /**
  37384. * Defines the input associated with the camera.
  37385. */
  37386. inputs: FollowCameraInputsManager;
  37387. /**
  37388. * Instantiates the follow camera.
  37389. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37390. * @param name Define the name of the camera in the scene
  37391. * @param position Define the position of the camera
  37392. * @param scene Define the scene the camera belong to
  37393. * @param lockedTarget Define the target of the camera
  37394. */
  37395. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37396. private _follow;
  37397. /**
  37398. * Attached controls to the current camera.
  37399. * @param element Defines the element the controls should be listened from
  37400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37401. */
  37402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37403. /**
  37404. * Detach the current controls from the camera.
  37405. * The camera will stop reacting to inputs.
  37406. * @param element Defines the element to stop listening the inputs from
  37407. */
  37408. detachControl(element: HTMLElement): void;
  37409. /** @hidden */ private _checkInputs(): void;
  37410. private _checkLimits;
  37411. /**
  37412. * Gets the camera class name.
  37413. * @returns the class name
  37414. */
  37415. getClassName(): string;
  37416. }
  37417. /**
  37418. * Arc Rotate version of the follow camera.
  37419. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37420. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37421. */
  37422. export class ArcFollowCamera extends TargetCamera {
  37423. /** The longitudinal angle of the camera */
  37424. alpha: number;
  37425. /** The latitudinal angle of the camera */
  37426. beta: number;
  37427. /** The radius of the camera from its target */
  37428. radius: number;
  37429. /** Define the camera target (the messh it should follow) */
  37430. target: Nullable<AbstractMesh>;
  37431. private _cartesianCoordinates;
  37432. /**
  37433. * Instantiates a new ArcFollowCamera
  37434. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37435. * @param name Define the name of the camera
  37436. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37437. * @param beta Define the rotation angle of the camera around the elevation axis
  37438. * @param radius Define the radius of the camera from its target point
  37439. * @param target Define the target of the camera
  37440. * @param scene Define the scene the camera belongs to
  37441. */
  37442. constructor(name: string,
  37443. /** The longitudinal angle of the camera */
  37444. alpha: number,
  37445. /** The latitudinal angle of the camera */
  37446. beta: number,
  37447. /** The radius of the camera from its target */
  37448. radius: number,
  37449. /** Define the camera target (the messh it should follow) */
  37450. target: Nullable<AbstractMesh>, scene: Scene);
  37451. private _follow;
  37452. /** @hidden */ private _checkInputs(): void;
  37453. /**
  37454. * Returns the class name of the object.
  37455. * It is mostly used internally for serialization purposes.
  37456. */
  37457. getClassName(): string;
  37458. }
  37459. }
  37460. declare module BABYLON {
  37461. /**
  37462. * Manage the keyboard inputs to control the movement of a follow camera.
  37463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37464. */
  37465. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37466. /**
  37467. * Defines the camera the input is attached to.
  37468. */
  37469. camera: FollowCamera;
  37470. /**
  37471. * Defines the list of key codes associated with the up action (increase heightOffset)
  37472. */
  37473. keysHeightOffsetIncr: number[];
  37474. /**
  37475. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37476. */
  37477. keysHeightOffsetDecr: number[];
  37478. /**
  37479. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37480. */
  37481. keysHeightOffsetModifierAlt: boolean;
  37482. /**
  37483. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37484. */
  37485. keysHeightOffsetModifierCtrl: boolean;
  37486. /**
  37487. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37488. */
  37489. keysHeightOffsetModifierShift: boolean;
  37490. /**
  37491. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37492. */
  37493. keysRotationOffsetIncr: number[];
  37494. /**
  37495. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37496. */
  37497. keysRotationOffsetDecr: number[];
  37498. /**
  37499. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37500. */
  37501. keysRotationOffsetModifierAlt: boolean;
  37502. /**
  37503. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37504. */
  37505. keysRotationOffsetModifierCtrl: boolean;
  37506. /**
  37507. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37508. */
  37509. keysRotationOffsetModifierShift: boolean;
  37510. /**
  37511. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37512. */
  37513. keysRadiusIncr: number[];
  37514. /**
  37515. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37516. */
  37517. keysRadiusDecr: number[];
  37518. /**
  37519. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37520. */
  37521. keysRadiusModifierAlt: boolean;
  37522. /**
  37523. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37524. */
  37525. keysRadiusModifierCtrl: boolean;
  37526. /**
  37527. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37528. */
  37529. keysRadiusModifierShift: boolean;
  37530. /**
  37531. * Defines the rate of change of heightOffset.
  37532. */
  37533. heightSensibility: number;
  37534. /**
  37535. * Defines the rate of change of rotationOffset.
  37536. */
  37537. rotationSensibility: number;
  37538. /**
  37539. * Defines the rate of change of radius.
  37540. */
  37541. radiusSensibility: number;
  37542. private _keys;
  37543. private _ctrlPressed;
  37544. private _altPressed;
  37545. private _shiftPressed;
  37546. private _onCanvasBlurObserver;
  37547. private _onKeyboardObserver;
  37548. private _engine;
  37549. private _scene;
  37550. /**
  37551. * Attach the input controls to a specific dom element to get the input from.
  37552. * @param element Defines the element the controls should be listened from
  37553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37554. */
  37555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37556. /**
  37557. * Detach the current controls from the specified dom element.
  37558. * @param element Defines the element to stop listening the inputs from
  37559. */
  37560. detachControl(element: Nullable<HTMLElement>): void;
  37561. /**
  37562. * Update the current camera state depending on the inputs that have been used this frame.
  37563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37564. */
  37565. checkInputs(): void;
  37566. /**
  37567. * Gets the class name of the current input.
  37568. * @returns the class name
  37569. */
  37570. getClassName(): string;
  37571. /**
  37572. * Get the friendly name associated with the input class.
  37573. * @returns the input friendly name
  37574. */
  37575. getSimpleName(): string;
  37576. /**
  37577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37578. * allow modification of the heightOffset value.
  37579. */
  37580. private _modifierHeightOffset;
  37581. /**
  37582. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37583. * allow modification of the rotationOffset value.
  37584. */
  37585. private _modifierRotationOffset;
  37586. /**
  37587. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37588. * allow modification of the radius value.
  37589. */
  37590. private _modifierRadius;
  37591. }
  37592. }
  37593. declare module BABYLON {
  37594. interface FreeCameraInputsManager {
  37595. /**
  37596. * @hidden
  37597. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37598. /**
  37599. * Add orientation input support to the input manager.
  37600. * @returns the current input manager
  37601. */
  37602. addDeviceOrientation(): FreeCameraInputsManager;
  37603. }
  37604. /**
  37605. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37606. * Screen rotation is taken into account.
  37607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37608. */
  37609. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37610. private _camera;
  37611. private _screenOrientationAngle;
  37612. private _constantTranform;
  37613. private _screenQuaternion;
  37614. private _alpha;
  37615. private _beta;
  37616. private _gamma;
  37617. /**
  37618. * Can be used to detect if a device orientation sensor is availible on a device
  37619. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37620. * @returns a promise that will resolve on orientation change
  37621. */
  37622. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37623. /**
  37624. * @hidden
  37625. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37626. /**
  37627. * Instantiates a new input
  37628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37629. */
  37630. constructor();
  37631. /**
  37632. * Define the camera controlled by the input.
  37633. */
  37634. camera: FreeCamera;
  37635. /**
  37636. * Attach the input controls to a specific dom element to get the input from.
  37637. * @param element Defines the element the controls should be listened from
  37638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37639. */
  37640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37641. private _orientationChanged;
  37642. private _deviceOrientation;
  37643. /**
  37644. * Detach the current controls from the specified dom element.
  37645. * @param element Defines the element to stop listening the inputs from
  37646. */
  37647. detachControl(element: Nullable<HTMLElement>): void;
  37648. /**
  37649. * Update the current camera state depending on the inputs that have been used this frame.
  37650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37651. */
  37652. checkInputs(): void;
  37653. /**
  37654. * Gets the class name of the current intput.
  37655. * @returns the class name
  37656. */
  37657. getClassName(): string;
  37658. /**
  37659. * Get the friendly name associated with the input class.
  37660. * @returns the input friendly name
  37661. */
  37662. getSimpleName(): string;
  37663. }
  37664. }
  37665. declare module BABYLON {
  37666. /**
  37667. * Manage the gamepad inputs to control a free camera.
  37668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37669. */
  37670. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37671. /**
  37672. * Define the camera the input is attached to.
  37673. */
  37674. camera: FreeCamera;
  37675. /**
  37676. * Define the Gamepad controlling the input
  37677. */
  37678. gamepad: Nullable<Gamepad>;
  37679. /**
  37680. * Defines the gamepad rotation sensiblity.
  37681. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37682. */
  37683. gamepadAngularSensibility: number;
  37684. /**
  37685. * Defines the gamepad move sensiblity.
  37686. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37687. */
  37688. gamepadMoveSensibility: number;
  37689. private _onGamepadConnectedObserver;
  37690. private _onGamepadDisconnectedObserver;
  37691. private _cameraTransform;
  37692. private _deltaTransform;
  37693. private _vector3;
  37694. private _vector2;
  37695. /**
  37696. * Attach the input controls to a specific dom element to get the input from.
  37697. * @param element Defines the element the controls should be listened from
  37698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37699. */
  37700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37701. /**
  37702. * Detach the current controls from the specified dom element.
  37703. * @param element Defines the element to stop listening the inputs from
  37704. */
  37705. detachControl(element: Nullable<HTMLElement>): void;
  37706. /**
  37707. * Update the current camera state depending on the inputs that have been used this frame.
  37708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37709. */
  37710. checkInputs(): void;
  37711. /**
  37712. * Gets the class name of the current intput.
  37713. * @returns the class name
  37714. */
  37715. getClassName(): string;
  37716. /**
  37717. * Get the friendly name associated with the input class.
  37718. * @returns the input friendly name
  37719. */
  37720. getSimpleName(): string;
  37721. }
  37722. }
  37723. declare module BABYLON {
  37724. /**
  37725. * Defines the potential axis of a Joystick
  37726. */
  37727. export enum JoystickAxis {
  37728. /** X axis */
  37729. X = 0,
  37730. /** Y axis */
  37731. Y = 1,
  37732. /** Z axis */
  37733. Z = 2
  37734. }
  37735. /**
  37736. * Class used to define virtual joystick (used in touch mode)
  37737. */
  37738. export class VirtualJoystick {
  37739. /**
  37740. * Gets or sets a boolean indicating that left and right values must be inverted
  37741. */
  37742. reverseLeftRight: boolean;
  37743. /**
  37744. * Gets or sets a boolean indicating that up and down values must be inverted
  37745. */
  37746. reverseUpDown: boolean;
  37747. /**
  37748. * Gets the offset value for the position (ie. the change of the position value)
  37749. */
  37750. deltaPosition: Vector3;
  37751. /**
  37752. * Gets a boolean indicating if the virtual joystick was pressed
  37753. */
  37754. pressed: boolean;
  37755. /**
  37756. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37757. */
  37758. static Canvas: Nullable<HTMLCanvasElement>;
  37759. private static _globalJoystickIndex;
  37760. private static vjCanvasContext;
  37761. private static vjCanvasWidth;
  37762. private static vjCanvasHeight;
  37763. private static halfWidth;
  37764. private _action;
  37765. private _axisTargetedByLeftAndRight;
  37766. private _axisTargetedByUpAndDown;
  37767. private _joystickSensibility;
  37768. private _inversedSensibility;
  37769. private _joystickPointerID;
  37770. private _joystickColor;
  37771. private _joystickPointerPos;
  37772. private _joystickPreviousPointerPos;
  37773. private _joystickPointerStartPos;
  37774. private _deltaJoystickVector;
  37775. private _leftJoystick;
  37776. private _touches;
  37777. private _onPointerDownHandlerRef;
  37778. private _onPointerMoveHandlerRef;
  37779. private _onPointerUpHandlerRef;
  37780. private _onResize;
  37781. /**
  37782. * Creates a new virtual joystick
  37783. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37784. */
  37785. constructor(leftJoystick?: boolean);
  37786. /**
  37787. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37788. * @param newJoystickSensibility defines the new sensibility
  37789. */
  37790. setJoystickSensibility(newJoystickSensibility: number): void;
  37791. private _onPointerDown;
  37792. private _onPointerMove;
  37793. private _onPointerUp;
  37794. /**
  37795. * Change the color of the virtual joystick
  37796. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37797. */
  37798. setJoystickColor(newColor: string): void;
  37799. /**
  37800. * Defines a callback to call when the joystick is touched
  37801. * @param action defines the callback
  37802. */
  37803. setActionOnTouch(action: () => any): void;
  37804. /**
  37805. * Defines which axis you'd like to control for left & right
  37806. * @param axis defines the axis to use
  37807. */
  37808. setAxisForLeftRight(axis: JoystickAxis): void;
  37809. /**
  37810. * Defines which axis you'd like to control for up & down
  37811. * @param axis defines the axis to use
  37812. */
  37813. setAxisForUpDown(axis: JoystickAxis): void;
  37814. private _drawVirtualJoystick;
  37815. /**
  37816. * Release internal HTML canvas
  37817. */
  37818. releaseCanvas(): void;
  37819. }
  37820. }
  37821. declare module BABYLON {
  37822. interface FreeCameraInputsManager {
  37823. /**
  37824. * Add virtual joystick input support to the input manager.
  37825. * @returns the current input manager
  37826. */
  37827. addVirtualJoystick(): FreeCameraInputsManager;
  37828. }
  37829. /**
  37830. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37832. */
  37833. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37834. /**
  37835. * Defines the camera the input is attached to.
  37836. */
  37837. camera: FreeCamera;
  37838. private _leftjoystick;
  37839. private _rightjoystick;
  37840. /**
  37841. * Gets the left stick of the virtual joystick.
  37842. * @returns The virtual Joystick
  37843. */
  37844. getLeftJoystick(): VirtualJoystick;
  37845. /**
  37846. * Gets the right stick of the virtual joystick.
  37847. * @returns The virtual Joystick
  37848. */
  37849. getRightJoystick(): VirtualJoystick;
  37850. /**
  37851. * Update the current camera state depending on the inputs that have been used this frame.
  37852. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37853. */
  37854. checkInputs(): void;
  37855. /**
  37856. * Attach the input controls to a specific dom element to get the input from.
  37857. * @param element Defines the element the controls should be listened from
  37858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37859. */
  37860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37861. /**
  37862. * Detach the current controls from the specified dom element.
  37863. * @param element Defines the element to stop listening the inputs from
  37864. */
  37865. detachControl(element: Nullable<HTMLElement>): void;
  37866. /**
  37867. * Gets the class name of the current intput.
  37868. * @returns the class name
  37869. */
  37870. getClassName(): string;
  37871. /**
  37872. * Get the friendly name associated with the input class.
  37873. * @returns the input friendly name
  37874. */
  37875. getSimpleName(): string;
  37876. }
  37877. }
  37878. declare module BABYLON {
  37879. /**
  37880. * This represents a FPS type of camera controlled by touch.
  37881. * This is like a universal camera minus the Gamepad controls.
  37882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37883. */
  37884. export class TouchCamera extends FreeCamera {
  37885. /**
  37886. * Defines the touch sensibility for rotation.
  37887. * The higher the faster.
  37888. */
  37889. touchAngularSensibility: number;
  37890. /**
  37891. * Defines the touch sensibility for move.
  37892. * The higher the faster.
  37893. */
  37894. touchMoveSensibility: number;
  37895. /**
  37896. * Instantiates a new touch camera.
  37897. * This represents a FPS type of camera controlled by touch.
  37898. * This is like a universal camera minus the Gamepad controls.
  37899. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37900. * @param name Define the name of the camera in the scene
  37901. * @param position Define the start position of the camera in the scene
  37902. * @param scene Define the scene the camera belongs to
  37903. */
  37904. constructor(name: string, position: Vector3, scene: Scene);
  37905. /**
  37906. * Gets the current object class name.
  37907. * @return the class name
  37908. */
  37909. getClassName(): string;
  37910. /** @hidden */ private _setupInputs(): void;
  37911. }
  37912. }
  37913. declare module BABYLON {
  37914. /**
  37915. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37916. * being tilted forward or back and left or right.
  37917. */
  37918. export class DeviceOrientationCamera extends FreeCamera {
  37919. private _initialQuaternion;
  37920. private _quaternionCache;
  37921. private _tmpDragQuaternion;
  37922. private _disablePointerInputWhenUsingDeviceOrientation;
  37923. /**
  37924. * Creates a new device orientation camera
  37925. * @param name The name of the camera
  37926. * @param position The start position camera
  37927. * @param scene The scene the camera belongs to
  37928. */
  37929. constructor(name: string, position: Vector3, scene: Scene);
  37930. /**
  37931. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37932. */
  37933. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37934. private _dragFactor;
  37935. /**
  37936. * Enabled turning on the y axis when the orientation sensor is active
  37937. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37938. */
  37939. enableHorizontalDragging(dragFactor?: number): void;
  37940. /**
  37941. * Gets the current instance class name ("DeviceOrientationCamera").
  37942. * This helps avoiding instanceof at run time.
  37943. * @returns the class name
  37944. */
  37945. getClassName(): string;
  37946. /**
  37947. * @hidden
  37948. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37949. */ private _checkInputs(): void;
  37950. /**
  37951. * Reset the camera to its default orientation on the specified axis only.
  37952. * @param axis The axis to reset
  37953. */
  37954. resetToCurrentRotation(axis?: Axis): void;
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. /**
  37959. * Defines supported buttons for XBox360 compatible gamepads
  37960. */
  37961. export enum Xbox360Button {
  37962. /** A */
  37963. A = 0,
  37964. /** B */
  37965. B = 1,
  37966. /** X */
  37967. X = 2,
  37968. /** Y */
  37969. Y = 3,
  37970. /** Start */
  37971. Start = 4,
  37972. /** Back */
  37973. Back = 5,
  37974. /** Left button */
  37975. LB = 6,
  37976. /** Right button */
  37977. RB = 7,
  37978. /** Left stick */
  37979. LeftStick = 8,
  37980. /** Right stick */
  37981. RightStick = 9
  37982. }
  37983. /** Defines values for XBox360 DPad */
  37984. export enum Xbox360Dpad {
  37985. /** Up */
  37986. Up = 0,
  37987. /** Down */
  37988. Down = 1,
  37989. /** Left */
  37990. Left = 2,
  37991. /** Right */
  37992. Right = 3
  37993. }
  37994. /**
  37995. * Defines a XBox360 gamepad
  37996. */
  37997. export class Xbox360Pad extends Gamepad {
  37998. private _leftTrigger;
  37999. private _rightTrigger;
  38000. private _onlefttriggerchanged;
  38001. private _onrighttriggerchanged;
  38002. private _onbuttondown;
  38003. private _onbuttonup;
  38004. private _ondpaddown;
  38005. private _ondpadup;
  38006. /** Observable raised when a button is pressed */
  38007. onButtonDownObservable: Observable<Xbox360Button>;
  38008. /** Observable raised when a button is released */
  38009. onButtonUpObservable: Observable<Xbox360Button>;
  38010. /** Observable raised when a pad is pressed */
  38011. onPadDownObservable: Observable<Xbox360Dpad>;
  38012. /** Observable raised when a pad is released */
  38013. onPadUpObservable: Observable<Xbox360Dpad>;
  38014. private _buttonA;
  38015. private _buttonB;
  38016. private _buttonX;
  38017. private _buttonY;
  38018. private _buttonBack;
  38019. private _buttonStart;
  38020. private _buttonLB;
  38021. private _buttonRB;
  38022. private _buttonLeftStick;
  38023. private _buttonRightStick;
  38024. private _dPadUp;
  38025. private _dPadDown;
  38026. private _dPadLeft;
  38027. private _dPadRight;
  38028. private _isXboxOnePad;
  38029. /**
  38030. * Creates a new XBox360 gamepad object
  38031. * @param id defines the id of this gamepad
  38032. * @param index defines its index
  38033. * @param gamepad defines the internal HTML gamepad object
  38034. * @param xboxOne defines if it is a XBox One gamepad
  38035. */
  38036. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38037. /**
  38038. * Defines the callback to call when left trigger is pressed
  38039. * @param callback defines the callback to use
  38040. */
  38041. onlefttriggerchanged(callback: (value: number) => void): void;
  38042. /**
  38043. * Defines the callback to call when right trigger is pressed
  38044. * @param callback defines the callback to use
  38045. */
  38046. onrighttriggerchanged(callback: (value: number) => void): void;
  38047. /**
  38048. * Gets the left trigger value
  38049. */
  38050. /**
  38051. * Sets the left trigger value
  38052. */
  38053. leftTrigger: number;
  38054. /**
  38055. * Gets the right trigger value
  38056. */
  38057. /**
  38058. * Sets the right trigger value
  38059. */
  38060. rightTrigger: number;
  38061. /**
  38062. * Defines the callback to call when a button is pressed
  38063. * @param callback defines the callback to use
  38064. */
  38065. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38066. /**
  38067. * Defines the callback to call when a button is released
  38068. * @param callback defines the callback to use
  38069. */
  38070. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38071. /**
  38072. * Defines the callback to call when a pad is pressed
  38073. * @param callback defines the callback to use
  38074. */
  38075. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38076. /**
  38077. * Defines the callback to call when a pad is released
  38078. * @param callback defines the callback to use
  38079. */
  38080. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38081. private _setButtonValue;
  38082. private _setDPadValue;
  38083. /**
  38084. * Gets the value of the `A` button
  38085. */
  38086. /**
  38087. * Sets the value of the `A` button
  38088. */
  38089. buttonA: number;
  38090. /**
  38091. * Gets the value of the `B` button
  38092. */
  38093. /**
  38094. * Sets the value of the `B` button
  38095. */
  38096. buttonB: number;
  38097. /**
  38098. * Gets the value of the `X` button
  38099. */
  38100. /**
  38101. * Sets the value of the `X` button
  38102. */
  38103. buttonX: number;
  38104. /**
  38105. * Gets the value of the `Y` button
  38106. */
  38107. /**
  38108. * Sets the value of the `Y` button
  38109. */
  38110. buttonY: number;
  38111. /**
  38112. * Gets the value of the `Start` button
  38113. */
  38114. /**
  38115. * Sets the value of the `Start` button
  38116. */
  38117. buttonStart: number;
  38118. /**
  38119. * Gets the value of the `Back` button
  38120. */
  38121. /**
  38122. * Sets the value of the `Back` button
  38123. */
  38124. buttonBack: number;
  38125. /**
  38126. * Gets the value of the `Left` button
  38127. */
  38128. /**
  38129. * Sets the value of the `Left` button
  38130. */
  38131. buttonLB: number;
  38132. /**
  38133. * Gets the value of the `Right` button
  38134. */
  38135. /**
  38136. * Sets the value of the `Right` button
  38137. */
  38138. buttonRB: number;
  38139. /**
  38140. * Gets the value of the Left joystick
  38141. */
  38142. /**
  38143. * Sets the value of the Left joystick
  38144. */
  38145. buttonLeftStick: number;
  38146. /**
  38147. * Gets the value of the Right joystick
  38148. */
  38149. /**
  38150. * Sets the value of the Right joystick
  38151. */
  38152. buttonRightStick: number;
  38153. /**
  38154. * Gets the value of D-pad up
  38155. */
  38156. /**
  38157. * Sets the value of D-pad up
  38158. */
  38159. dPadUp: number;
  38160. /**
  38161. * Gets the value of D-pad down
  38162. */
  38163. /**
  38164. * Sets the value of D-pad down
  38165. */
  38166. dPadDown: number;
  38167. /**
  38168. * Gets the value of D-pad left
  38169. */
  38170. /**
  38171. * Sets the value of D-pad left
  38172. */
  38173. dPadLeft: number;
  38174. /**
  38175. * Gets the value of D-pad right
  38176. */
  38177. /**
  38178. * Sets the value of D-pad right
  38179. */
  38180. dPadRight: number;
  38181. /**
  38182. * Force the gamepad to synchronize with device values
  38183. */
  38184. update(): void;
  38185. /**
  38186. * Disposes the gamepad
  38187. */
  38188. dispose(): void;
  38189. }
  38190. }
  38191. declare module BABYLON {
  38192. /**
  38193. * Defines supported buttons for DualShock compatible gamepads
  38194. */
  38195. export enum DualShockButton {
  38196. /** Cross */
  38197. Cross = 0,
  38198. /** Circle */
  38199. Circle = 1,
  38200. /** Square */
  38201. Square = 2,
  38202. /** Triangle */
  38203. Triangle = 3,
  38204. /** Options */
  38205. Options = 4,
  38206. /** Share */
  38207. Share = 5,
  38208. /** L1 */
  38209. L1 = 6,
  38210. /** R1 */
  38211. R1 = 7,
  38212. /** Left stick */
  38213. LeftStick = 8,
  38214. /** Right stick */
  38215. RightStick = 9
  38216. }
  38217. /** Defines values for DualShock DPad */
  38218. export enum DualShockDpad {
  38219. /** Up */
  38220. Up = 0,
  38221. /** Down */
  38222. Down = 1,
  38223. /** Left */
  38224. Left = 2,
  38225. /** Right */
  38226. Right = 3
  38227. }
  38228. /**
  38229. * Defines a DualShock gamepad
  38230. */
  38231. export class DualShockPad extends Gamepad {
  38232. private _leftTrigger;
  38233. private _rightTrigger;
  38234. private _onlefttriggerchanged;
  38235. private _onrighttriggerchanged;
  38236. private _onbuttondown;
  38237. private _onbuttonup;
  38238. private _ondpaddown;
  38239. private _ondpadup;
  38240. /** Observable raised when a button is pressed */
  38241. onButtonDownObservable: Observable<DualShockButton>;
  38242. /** Observable raised when a button is released */
  38243. onButtonUpObservable: Observable<DualShockButton>;
  38244. /** Observable raised when a pad is pressed */
  38245. onPadDownObservable: Observable<DualShockDpad>;
  38246. /** Observable raised when a pad is released */
  38247. onPadUpObservable: Observable<DualShockDpad>;
  38248. private _buttonCross;
  38249. private _buttonCircle;
  38250. private _buttonSquare;
  38251. private _buttonTriangle;
  38252. private _buttonShare;
  38253. private _buttonOptions;
  38254. private _buttonL1;
  38255. private _buttonR1;
  38256. private _buttonLeftStick;
  38257. private _buttonRightStick;
  38258. private _dPadUp;
  38259. private _dPadDown;
  38260. private _dPadLeft;
  38261. private _dPadRight;
  38262. /**
  38263. * Creates a new DualShock gamepad object
  38264. * @param id defines the id of this gamepad
  38265. * @param index defines its index
  38266. * @param gamepad defines the internal HTML gamepad object
  38267. */
  38268. constructor(id: string, index: number, gamepad: any);
  38269. /**
  38270. * Defines the callback to call when left trigger is pressed
  38271. * @param callback defines the callback to use
  38272. */
  38273. onlefttriggerchanged(callback: (value: number) => void): void;
  38274. /**
  38275. * Defines the callback to call when right trigger is pressed
  38276. * @param callback defines the callback to use
  38277. */
  38278. onrighttriggerchanged(callback: (value: number) => void): void;
  38279. /**
  38280. * Gets the left trigger value
  38281. */
  38282. /**
  38283. * Sets the left trigger value
  38284. */
  38285. leftTrigger: number;
  38286. /**
  38287. * Gets the right trigger value
  38288. */
  38289. /**
  38290. * Sets the right trigger value
  38291. */
  38292. rightTrigger: number;
  38293. /**
  38294. * Defines the callback to call when a button is pressed
  38295. * @param callback defines the callback to use
  38296. */
  38297. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38298. /**
  38299. * Defines the callback to call when a button is released
  38300. * @param callback defines the callback to use
  38301. */
  38302. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38303. /**
  38304. * Defines the callback to call when a pad is pressed
  38305. * @param callback defines the callback to use
  38306. */
  38307. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38308. /**
  38309. * Defines the callback to call when a pad is released
  38310. * @param callback defines the callback to use
  38311. */
  38312. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38313. private _setButtonValue;
  38314. private _setDPadValue;
  38315. /**
  38316. * Gets the value of the `Cross` button
  38317. */
  38318. /**
  38319. * Sets the value of the `Cross` button
  38320. */
  38321. buttonCross: number;
  38322. /**
  38323. * Gets the value of the `Circle` button
  38324. */
  38325. /**
  38326. * Sets the value of the `Circle` button
  38327. */
  38328. buttonCircle: number;
  38329. /**
  38330. * Gets the value of the `Square` button
  38331. */
  38332. /**
  38333. * Sets the value of the `Square` button
  38334. */
  38335. buttonSquare: number;
  38336. /**
  38337. * Gets the value of the `Triangle` button
  38338. */
  38339. /**
  38340. * Sets the value of the `Triangle` button
  38341. */
  38342. buttonTriangle: number;
  38343. /**
  38344. * Gets the value of the `Options` button
  38345. */
  38346. /**
  38347. * Sets the value of the `Options` button
  38348. */
  38349. buttonOptions: number;
  38350. /**
  38351. * Gets the value of the `Share` button
  38352. */
  38353. /**
  38354. * Sets the value of the `Share` button
  38355. */
  38356. buttonShare: number;
  38357. /**
  38358. * Gets the value of the `L1` button
  38359. */
  38360. /**
  38361. * Sets the value of the `L1` button
  38362. */
  38363. buttonL1: number;
  38364. /**
  38365. * Gets the value of the `R1` button
  38366. */
  38367. /**
  38368. * Sets the value of the `R1` button
  38369. */
  38370. buttonR1: number;
  38371. /**
  38372. * Gets the value of the Left joystick
  38373. */
  38374. /**
  38375. * Sets the value of the Left joystick
  38376. */
  38377. buttonLeftStick: number;
  38378. /**
  38379. * Gets the value of the Right joystick
  38380. */
  38381. /**
  38382. * Sets the value of the Right joystick
  38383. */
  38384. buttonRightStick: number;
  38385. /**
  38386. * Gets the value of D-pad up
  38387. */
  38388. /**
  38389. * Sets the value of D-pad up
  38390. */
  38391. dPadUp: number;
  38392. /**
  38393. * Gets the value of D-pad down
  38394. */
  38395. /**
  38396. * Sets the value of D-pad down
  38397. */
  38398. dPadDown: number;
  38399. /**
  38400. * Gets the value of D-pad left
  38401. */
  38402. /**
  38403. * Sets the value of D-pad left
  38404. */
  38405. dPadLeft: number;
  38406. /**
  38407. * Gets the value of D-pad right
  38408. */
  38409. /**
  38410. * Sets the value of D-pad right
  38411. */
  38412. dPadRight: number;
  38413. /**
  38414. * Force the gamepad to synchronize with device values
  38415. */
  38416. update(): void;
  38417. /**
  38418. * Disposes the gamepad
  38419. */
  38420. dispose(): void;
  38421. }
  38422. }
  38423. declare module BABYLON {
  38424. /**
  38425. * Manager for handling gamepads
  38426. */
  38427. export class GamepadManager {
  38428. private _scene?;
  38429. private _babylonGamepads;
  38430. private _oneGamepadConnected;
  38431. /** @hidden */ private _isMonitoring: boolean;
  38432. private _gamepadEventSupported;
  38433. private _gamepadSupport;
  38434. /**
  38435. * observable to be triggered when the gamepad controller has been connected
  38436. */
  38437. onGamepadConnectedObservable: Observable<Gamepad>;
  38438. /**
  38439. * observable to be triggered when the gamepad controller has been disconnected
  38440. */
  38441. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38442. private _onGamepadConnectedEvent;
  38443. private _onGamepadDisconnectedEvent;
  38444. /**
  38445. * Initializes the gamepad manager
  38446. * @param _scene BabylonJS scene
  38447. */
  38448. constructor(_scene?: Scene | undefined);
  38449. /**
  38450. * The gamepads in the game pad manager
  38451. */
  38452. readonly gamepads: Gamepad[];
  38453. /**
  38454. * Get the gamepad controllers based on type
  38455. * @param type The type of gamepad controller
  38456. * @returns Nullable gamepad
  38457. */
  38458. getGamepadByType(type?: number): Nullable<Gamepad>;
  38459. /**
  38460. * Disposes the gamepad manager
  38461. */
  38462. dispose(): void;
  38463. private _addNewGamepad;
  38464. private _startMonitoringGamepads;
  38465. private _stopMonitoringGamepads;
  38466. /** @hidden */ private _checkGamepadsStatus(): void;
  38467. private _updateGamepadObjects;
  38468. }
  38469. }
  38470. declare module BABYLON {
  38471. interface Scene {
  38472. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38473. /**
  38474. * Gets the gamepad manager associated with the scene
  38475. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38476. */
  38477. gamepadManager: GamepadManager;
  38478. }
  38479. /**
  38480. * Interface representing a free camera inputs manager
  38481. */
  38482. interface FreeCameraInputsManager {
  38483. /**
  38484. * Adds gamepad input support to the FreeCameraInputsManager.
  38485. * @returns the FreeCameraInputsManager
  38486. */
  38487. addGamepad(): FreeCameraInputsManager;
  38488. }
  38489. /**
  38490. * Interface representing an arc rotate camera inputs manager
  38491. */
  38492. interface ArcRotateCameraInputsManager {
  38493. /**
  38494. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38495. * @returns the camera inputs manager
  38496. */
  38497. addGamepad(): ArcRotateCameraInputsManager;
  38498. }
  38499. /**
  38500. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38501. */
  38502. export class GamepadSystemSceneComponent implements ISceneComponent {
  38503. /**
  38504. * The component name helpfull to identify the component in the list of scene components.
  38505. */
  38506. readonly name: string;
  38507. /**
  38508. * The scene the component belongs to.
  38509. */
  38510. scene: Scene;
  38511. /**
  38512. * Creates a new instance of the component for the given scene
  38513. * @param scene Defines the scene to register the component in
  38514. */
  38515. constructor(scene: Scene);
  38516. /**
  38517. * Registers the component in a given scene
  38518. */
  38519. register(): void;
  38520. /**
  38521. * Rebuilds the elements related to this component in case of
  38522. * context lost for instance.
  38523. */
  38524. rebuild(): void;
  38525. /**
  38526. * Disposes the component and the associated ressources
  38527. */
  38528. dispose(): void;
  38529. private _beforeCameraUpdate;
  38530. }
  38531. }
  38532. declare module BABYLON {
  38533. /**
  38534. * 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,
  38535. * which still works and will still be found in many Playgrounds.
  38536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38537. */
  38538. export class UniversalCamera extends TouchCamera {
  38539. /**
  38540. * Defines the gamepad rotation sensiblity.
  38541. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38542. */
  38543. gamepadAngularSensibility: number;
  38544. /**
  38545. * Defines the gamepad move sensiblity.
  38546. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38547. */
  38548. gamepadMoveSensibility: number;
  38549. /**
  38550. * 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,
  38551. * which still works and will still be found in many Playgrounds.
  38552. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38553. * @param name Define the name of the camera in the scene
  38554. * @param position Define the start position of the camera in the scene
  38555. * @param scene Define the scene the camera belongs to
  38556. */
  38557. constructor(name: string, position: Vector3, scene: Scene);
  38558. /**
  38559. * Gets the current object class name.
  38560. * @return the class name
  38561. */
  38562. getClassName(): string;
  38563. }
  38564. }
  38565. declare module BABYLON {
  38566. /**
  38567. * This represents a FPS type of camera. This is only here for back compat purpose.
  38568. * Please use the UniversalCamera instead as both are identical.
  38569. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38570. */
  38571. export class GamepadCamera extends UniversalCamera {
  38572. /**
  38573. * Instantiates a new Gamepad Camera
  38574. * This represents a FPS type of camera. This is only here for back compat purpose.
  38575. * Please use the UniversalCamera instead as both are identical.
  38576. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38577. * @param name Define the name of the camera in the scene
  38578. * @param position Define the start position of the camera in the scene
  38579. * @param scene Define the scene the camera belongs to
  38580. */
  38581. constructor(name: string, position: Vector3, scene: Scene);
  38582. /**
  38583. * Gets the current object class name.
  38584. * @return the class name
  38585. */
  38586. getClassName(): string;
  38587. }
  38588. }
  38589. declare module BABYLON {
  38590. /** @hidden */
  38591. export var passPixelShader: {
  38592. name: string;
  38593. shader: string;
  38594. };
  38595. }
  38596. declare module BABYLON {
  38597. /** @hidden */
  38598. export var passCubePixelShader: {
  38599. name: string;
  38600. shader: string;
  38601. };
  38602. }
  38603. declare module BABYLON {
  38604. /**
  38605. * PassPostProcess which produces an output the same as it's input
  38606. */
  38607. export class PassPostProcess extends PostProcess {
  38608. /**
  38609. * Creates the PassPostProcess
  38610. * @param name The name of the effect.
  38611. * @param options The required width/height ratio to downsize to before computing the render pass.
  38612. * @param camera The camera to apply the render pass to.
  38613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38614. * @param engine The engine which the post process will be applied. (default: current engine)
  38615. * @param reusable If the post process can be reused on the same frame. (default: false)
  38616. * @param textureType The type of texture to be used when performing the post processing.
  38617. * @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)
  38618. */
  38619. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38620. }
  38621. /**
  38622. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38623. */
  38624. export class PassCubePostProcess extends PostProcess {
  38625. private _face;
  38626. /**
  38627. * Gets or sets the cube face to display.
  38628. * * 0 is +X
  38629. * * 1 is -X
  38630. * * 2 is +Y
  38631. * * 3 is -Y
  38632. * * 4 is +Z
  38633. * * 5 is -Z
  38634. */
  38635. face: number;
  38636. /**
  38637. * Creates the PassCubePostProcess
  38638. * @param name The name of the effect.
  38639. * @param options The required width/height ratio to downsize to before computing the render pass.
  38640. * @param camera The camera to apply the render pass to.
  38641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38642. * @param engine The engine which the post process will be applied. (default: current engine)
  38643. * @param reusable If the post process can be reused on the same frame. (default: false)
  38644. * @param textureType The type of texture to be used when performing the post processing.
  38645. * @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)
  38646. */
  38647. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38648. }
  38649. }
  38650. declare module BABYLON {
  38651. /** @hidden */
  38652. export var anaglyphPixelShader: {
  38653. name: string;
  38654. shader: string;
  38655. };
  38656. }
  38657. declare module BABYLON {
  38658. /**
  38659. * Postprocess used to generate anaglyphic rendering
  38660. */
  38661. export class AnaglyphPostProcess extends PostProcess {
  38662. private _passedProcess;
  38663. /**
  38664. * Creates a new AnaglyphPostProcess
  38665. * @param name defines postprocess name
  38666. * @param options defines creation options or target ratio scale
  38667. * @param rigCameras defines cameras using this postprocess
  38668. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38669. * @param engine defines hosting engine
  38670. * @param reusable defines if the postprocess will be reused multiple times per frame
  38671. */
  38672. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38673. }
  38674. }
  38675. declare module BABYLON {
  38676. /**
  38677. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38678. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38679. */
  38680. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38681. /**
  38682. * Creates a new AnaglyphArcRotateCamera
  38683. * @param name defines camera name
  38684. * @param alpha defines alpha angle (in radians)
  38685. * @param beta defines beta angle (in radians)
  38686. * @param radius defines radius
  38687. * @param target defines camera target
  38688. * @param interaxialDistance defines distance between each color axis
  38689. * @param scene defines the hosting scene
  38690. */
  38691. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38692. /**
  38693. * Gets camera class name
  38694. * @returns AnaglyphArcRotateCamera
  38695. */
  38696. getClassName(): string;
  38697. }
  38698. }
  38699. declare module BABYLON {
  38700. /**
  38701. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38702. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38703. */
  38704. export class AnaglyphFreeCamera extends FreeCamera {
  38705. /**
  38706. * Creates a new AnaglyphFreeCamera
  38707. * @param name defines camera name
  38708. * @param position defines initial position
  38709. * @param interaxialDistance defines distance between each color axis
  38710. * @param scene defines the hosting scene
  38711. */
  38712. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38713. /**
  38714. * Gets camera class name
  38715. * @returns AnaglyphFreeCamera
  38716. */
  38717. getClassName(): string;
  38718. }
  38719. }
  38720. declare module BABYLON {
  38721. /**
  38722. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38723. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38724. */
  38725. export class AnaglyphGamepadCamera extends GamepadCamera {
  38726. /**
  38727. * Creates a new AnaglyphGamepadCamera
  38728. * @param name defines camera name
  38729. * @param position defines initial position
  38730. * @param interaxialDistance defines distance between each color axis
  38731. * @param scene defines the hosting scene
  38732. */
  38733. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38734. /**
  38735. * Gets camera class name
  38736. * @returns AnaglyphGamepadCamera
  38737. */
  38738. getClassName(): string;
  38739. }
  38740. }
  38741. declare module BABYLON {
  38742. /**
  38743. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38744. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38745. */
  38746. export class AnaglyphUniversalCamera extends UniversalCamera {
  38747. /**
  38748. * Creates a new AnaglyphUniversalCamera
  38749. * @param name defines camera name
  38750. * @param position defines initial position
  38751. * @param interaxialDistance defines distance between each color axis
  38752. * @param scene defines the hosting scene
  38753. */
  38754. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38755. /**
  38756. * Gets camera class name
  38757. * @returns AnaglyphUniversalCamera
  38758. */
  38759. getClassName(): string;
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. /** @hidden */
  38764. export var stereoscopicInterlacePixelShader: {
  38765. name: string;
  38766. shader: string;
  38767. };
  38768. }
  38769. declare module BABYLON {
  38770. /**
  38771. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38772. */
  38773. export class StereoscopicInterlacePostProcess extends PostProcess {
  38774. private _stepSize;
  38775. private _passedProcess;
  38776. /**
  38777. * Initializes a StereoscopicInterlacePostProcess
  38778. * @param name The name of the effect.
  38779. * @param rigCameras The rig cameras to be appled to the post process
  38780. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38782. * @param engine The engine which the post process will be applied. (default: current engine)
  38783. * @param reusable If the post process can be reused on the same frame. (default: false)
  38784. */
  38785. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38786. }
  38787. }
  38788. declare module BABYLON {
  38789. /**
  38790. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38791. * @see http://doc.babylonjs.com/features/cameras
  38792. */
  38793. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38794. /**
  38795. * Creates a new StereoscopicArcRotateCamera
  38796. * @param name defines camera name
  38797. * @param alpha defines alpha angle (in radians)
  38798. * @param beta defines beta angle (in radians)
  38799. * @param radius defines radius
  38800. * @param target defines camera target
  38801. * @param interaxialDistance defines distance between each color axis
  38802. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38803. * @param scene defines the hosting scene
  38804. */
  38805. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38806. /**
  38807. * Gets camera class name
  38808. * @returns StereoscopicArcRotateCamera
  38809. */
  38810. getClassName(): string;
  38811. }
  38812. }
  38813. declare module BABYLON {
  38814. /**
  38815. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38816. * @see http://doc.babylonjs.com/features/cameras
  38817. */
  38818. export class StereoscopicFreeCamera extends FreeCamera {
  38819. /**
  38820. * Creates a new StereoscopicFreeCamera
  38821. * @param name defines camera name
  38822. * @param position defines initial position
  38823. * @param interaxialDistance defines distance between each color axis
  38824. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38825. * @param scene defines the hosting scene
  38826. */
  38827. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38828. /**
  38829. * Gets camera class name
  38830. * @returns StereoscopicFreeCamera
  38831. */
  38832. getClassName(): string;
  38833. }
  38834. }
  38835. declare module BABYLON {
  38836. /**
  38837. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38838. * @see http://doc.babylonjs.com/features/cameras
  38839. */
  38840. export class StereoscopicGamepadCamera extends GamepadCamera {
  38841. /**
  38842. * Creates a new StereoscopicGamepadCamera
  38843. * @param name defines camera name
  38844. * @param position defines initial position
  38845. * @param interaxialDistance defines distance between each color axis
  38846. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38847. * @param scene defines the hosting scene
  38848. */
  38849. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38850. /**
  38851. * Gets camera class name
  38852. * @returns StereoscopicGamepadCamera
  38853. */
  38854. getClassName(): string;
  38855. }
  38856. }
  38857. declare module BABYLON {
  38858. /**
  38859. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38860. * @see http://doc.babylonjs.com/features/cameras
  38861. */
  38862. export class StereoscopicUniversalCamera extends UniversalCamera {
  38863. /**
  38864. * Creates a new StereoscopicUniversalCamera
  38865. * @param name defines camera name
  38866. * @param position defines initial position
  38867. * @param interaxialDistance defines distance between each color axis
  38868. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38869. * @param scene defines the hosting scene
  38870. */
  38871. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38872. /**
  38873. * Gets camera class name
  38874. * @returns StereoscopicUniversalCamera
  38875. */
  38876. getClassName(): string;
  38877. }
  38878. }
  38879. declare module BABYLON {
  38880. /**
  38881. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38882. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38883. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38884. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38885. */
  38886. export class VirtualJoysticksCamera extends FreeCamera {
  38887. /**
  38888. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38889. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38890. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38891. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38892. * @param name Define the name of the camera in the scene
  38893. * @param position Define the start position of the camera in the scene
  38894. * @param scene Define the scene the camera belongs to
  38895. */
  38896. constructor(name: string, position: Vector3, scene: Scene);
  38897. /**
  38898. * Gets the current object class name.
  38899. * @return the class name
  38900. */
  38901. getClassName(): string;
  38902. }
  38903. }
  38904. declare module BABYLON {
  38905. /**
  38906. * This represents all the required metrics to create a VR camera.
  38907. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38908. */
  38909. export class VRCameraMetrics {
  38910. /**
  38911. * Define the horizontal resolution off the screen.
  38912. */
  38913. hResolution: number;
  38914. /**
  38915. * Define the vertical resolution off the screen.
  38916. */
  38917. vResolution: number;
  38918. /**
  38919. * Define the horizontal screen size.
  38920. */
  38921. hScreenSize: number;
  38922. /**
  38923. * Define the vertical screen size.
  38924. */
  38925. vScreenSize: number;
  38926. /**
  38927. * Define the vertical screen center position.
  38928. */
  38929. vScreenCenter: number;
  38930. /**
  38931. * Define the distance of the eyes to the screen.
  38932. */
  38933. eyeToScreenDistance: number;
  38934. /**
  38935. * Define the distance between both lenses
  38936. */
  38937. lensSeparationDistance: number;
  38938. /**
  38939. * Define the distance between both viewer's eyes.
  38940. */
  38941. interpupillaryDistance: number;
  38942. /**
  38943. * Define the distortion factor of the VR postprocess.
  38944. * Please, touch with care.
  38945. */
  38946. distortionK: number[];
  38947. /**
  38948. * Define the chromatic aberration correction factors for the VR post process.
  38949. */
  38950. chromaAbCorrection: number[];
  38951. /**
  38952. * Define the scale factor of the post process.
  38953. * The smaller the better but the slower.
  38954. */
  38955. postProcessScaleFactor: number;
  38956. /**
  38957. * Define an offset for the lens center.
  38958. */
  38959. lensCenterOffset: number;
  38960. /**
  38961. * Define if the current vr camera should compensate the distortion of the lense or not.
  38962. */
  38963. compensateDistortion: boolean;
  38964. /**
  38965. * Defines if multiview should be enabled when rendering (Default: false)
  38966. */
  38967. multiviewEnabled: boolean;
  38968. /**
  38969. * Gets the rendering aspect ratio based on the provided resolutions.
  38970. */
  38971. readonly aspectRatio: number;
  38972. /**
  38973. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38974. */
  38975. readonly aspectRatioFov: number;
  38976. /**
  38977. * @hidden
  38978. */
  38979. readonly leftHMatrix: Matrix;
  38980. /**
  38981. * @hidden
  38982. */
  38983. readonly rightHMatrix: Matrix;
  38984. /**
  38985. * @hidden
  38986. */
  38987. readonly leftPreViewMatrix: Matrix;
  38988. /**
  38989. * @hidden
  38990. */
  38991. readonly rightPreViewMatrix: Matrix;
  38992. /**
  38993. * Get the default VRMetrics based on the most generic setup.
  38994. * @returns the default vr metrics
  38995. */
  38996. static GetDefault(): VRCameraMetrics;
  38997. }
  38998. }
  38999. declare module BABYLON {
  39000. /** @hidden */
  39001. export var vrDistortionCorrectionPixelShader: {
  39002. name: string;
  39003. shader: string;
  39004. };
  39005. }
  39006. declare module BABYLON {
  39007. /**
  39008. * VRDistortionCorrectionPostProcess used for mobile VR
  39009. */
  39010. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39011. private _isRightEye;
  39012. private _distortionFactors;
  39013. private _postProcessScaleFactor;
  39014. private _lensCenterOffset;
  39015. private _scaleIn;
  39016. private _scaleFactor;
  39017. private _lensCenter;
  39018. /**
  39019. * Initializes the VRDistortionCorrectionPostProcess
  39020. * @param name The name of the effect.
  39021. * @param camera The camera to apply the render pass to.
  39022. * @param isRightEye If this is for the right eye distortion
  39023. * @param vrMetrics All the required metrics for the VR camera
  39024. */
  39025. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39026. }
  39027. }
  39028. declare module BABYLON {
  39029. /**
  39030. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39031. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39032. */
  39033. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39034. /**
  39035. * Creates a new VRDeviceOrientationArcRotateCamera
  39036. * @param name defines camera name
  39037. * @param alpha defines the camera rotation along the logitudinal axis
  39038. * @param beta defines the camera rotation along the latitudinal axis
  39039. * @param radius defines the camera distance from its target
  39040. * @param target defines the camera target
  39041. * @param scene defines the scene the camera belongs to
  39042. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39043. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39044. */
  39045. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39046. /**
  39047. * Gets camera class name
  39048. * @returns VRDeviceOrientationArcRotateCamera
  39049. */
  39050. getClassName(): string;
  39051. }
  39052. }
  39053. declare module BABYLON {
  39054. /**
  39055. * Camera used to simulate VR rendering (based on FreeCamera)
  39056. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39057. */
  39058. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39059. /**
  39060. * Creates a new VRDeviceOrientationFreeCamera
  39061. * @param name defines camera name
  39062. * @param position defines the start position of the camera
  39063. * @param scene defines the scene the camera belongs to
  39064. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39065. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39066. */
  39067. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39068. /**
  39069. * Gets camera class name
  39070. * @returns VRDeviceOrientationFreeCamera
  39071. */
  39072. getClassName(): string;
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. /**
  39077. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39078. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39079. */
  39080. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39081. /**
  39082. * Creates a new VRDeviceOrientationGamepadCamera
  39083. * @param name defines camera name
  39084. * @param position defines the start position of the camera
  39085. * @param scene defines the scene the camera belongs to
  39086. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39087. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39088. */
  39089. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39090. /**
  39091. * Gets camera class name
  39092. * @returns VRDeviceOrientationGamepadCamera
  39093. */
  39094. getClassName(): string;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * Base class of materials working in push mode in babylon JS
  39100. * @hidden
  39101. */
  39102. export class PushMaterial extends Material {
  39103. protected _activeEffect: Effect;
  39104. protected _normalMatrix: Matrix;
  39105. /**
  39106. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39107. * This means that the material can keep using a previous shader while a new one is being compiled.
  39108. * This is mostly used when shader parallel compilation is supported (true by default)
  39109. */
  39110. allowShaderHotSwapping: boolean;
  39111. constructor(name: string, scene: Scene);
  39112. getEffect(): Effect;
  39113. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39114. /**
  39115. * Binds the given world matrix to the active effect
  39116. *
  39117. * @param world the matrix to bind
  39118. */
  39119. bindOnlyWorldMatrix(world: Matrix): void;
  39120. /**
  39121. * Binds the given normal matrix to the active effect
  39122. *
  39123. * @param normalMatrix the matrix to bind
  39124. */
  39125. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39126. bind(world: Matrix, mesh?: Mesh): void;
  39127. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39128. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39129. }
  39130. }
  39131. declare module BABYLON {
  39132. /**
  39133. * This groups all the flags used to control the materials channel.
  39134. */
  39135. export class MaterialFlags {
  39136. private static _DiffuseTextureEnabled;
  39137. /**
  39138. * Are diffuse textures enabled in the application.
  39139. */
  39140. static DiffuseTextureEnabled: boolean;
  39141. private static _AmbientTextureEnabled;
  39142. /**
  39143. * Are ambient textures enabled in the application.
  39144. */
  39145. static AmbientTextureEnabled: boolean;
  39146. private static _OpacityTextureEnabled;
  39147. /**
  39148. * Are opacity textures enabled in the application.
  39149. */
  39150. static OpacityTextureEnabled: boolean;
  39151. private static _ReflectionTextureEnabled;
  39152. /**
  39153. * Are reflection textures enabled in the application.
  39154. */
  39155. static ReflectionTextureEnabled: boolean;
  39156. private static _EmissiveTextureEnabled;
  39157. /**
  39158. * Are emissive textures enabled in the application.
  39159. */
  39160. static EmissiveTextureEnabled: boolean;
  39161. private static _SpecularTextureEnabled;
  39162. /**
  39163. * Are specular textures enabled in the application.
  39164. */
  39165. static SpecularTextureEnabled: boolean;
  39166. private static _BumpTextureEnabled;
  39167. /**
  39168. * Are bump textures enabled in the application.
  39169. */
  39170. static BumpTextureEnabled: boolean;
  39171. private static _LightmapTextureEnabled;
  39172. /**
  39173. * Are lightmap textures enabled in the application.
  39174. */
  39175. static LightmapTextureEnabled: boolean;
  39176. private static _RefractionTextureEnabled;
  39177. /**
  39178. * Are refraction textures enabled in the application.
  39179. */
  39180. static RefractionTextureEnabled: boolean;
  39181. private static _ColorGradingTextureEnabled;
  39182. /**
  39183. * Are color grading textures enabled in the application.
  39184. */
  39185. static ColorGradingTextureEnabled: boolean;
  39186. private static _FresnelEnabled;
  39187. /**
  39188. * Are fresnels enabled in the application.
  39189. */
  39190. static FresnelEnabled: boolean;
  39191. private static _ClearCoatTextureEnabled;
  39192. /**
  39193. * Are clear coat textures enabled in the application.
  39194. */
  39195. static ClearCoatTextureEnabled: boolean;
  39196. private static _ClearCoatBumpTextureEnabled;
  39197. /**
  39198. * Are clear coat bump textures enabled in the application.
  39199. */
  39200. static ClearCoatBumpTextureEnabled: boolean;
  39201. private static _ClearCoatTintTextureEnabled;
  39202. /**
  39203. * Are clear coat tint textures enabled in the application.
  39204. */
  39205. static ClearCoatTintTextureEnabled: boolean;
  39206. private static _SheenTextureEnabled;
  39207. /**
  39208. * Are sheen textures enabled in the application.
  39209. */
  39210. static SheenTextureEnabled: boolean;
  39211. private static _AnisotropicTextureEnabled;
  39212. /**
  39213. * Are anisotropic textures enabled in the application.
  39214. */
  39215. static AnisotropicTextureEnabled: boolean;
  39216. private static _ThicknessTextureEnabled;
  39217. /**
  39218. * Are thickness textures enabled in the application.
  39219. */
  39220. static ThicknessTextureEnabled: boolean;
  39221. }
  39222. }
  39223. declare module BABYLON {
  39224. /** @hidden */
  39225. export var defaultFragmentDeclaration: {
  39226. name: string;
  39227. shader: string;
  39228. };
  39229. }
  39230. declare module BABYLON {
  39231. /** @hidden */
  39232. export var defaultUboDeclaration: {
  39233. name: string;
  39234. shader: string;
  39235. };
  39236. }
  39237. declare module BABYLON {
  39238. /** @hidden */
  39239. export var lightFragmentDeclaration: {
  39240. name: string;
  39241. shader: string;
  39242. };
  39243. }
  39244. declare module BABYLON {
  39245. /** @hidden */
  39246. export var lightUboDeclaration: {
  39247. name: string;
  39248. shader: string;
  39249. };
  39250. }
  39251. declare module BABYLON {
  39252. /** @hidden */
  39253. export var lightsFragmentFunctions: {
  39254. name: string;
  39255. shader: string;
  39256. };
  39257. }
  39258. declare module BABYLON {
  39259. /** @hidden */
  39260. export var shadowsFragmentFunctions: {
  39261. name: string;
  39262. shader: string;
  39263. };
  39264. }
  39265. declare module BABYLON {
  39266. /** @hidden */
  39267. export var fresnelFunction: {
  39268. name: string;
  39269. shader: string;
  39270. };
  39271. }
  39272. declare module BABYLON {
  39273. /** @hidden */
  39274. export var reflectionFunction: {
  39275. name: string;
  39276. shader: string;
  39277. };
  39278. }
  39279. declare module BABYLON {
  39280. /** @hidden */
  39281. export var bumpFragmentFunctions: {
  39282. name: string;
  39283. shader: string;
  39284. };
  39285. }
  39286. declare module BABYLON {
  39287. /** @hidden */
  39288. export var logDepthDeclaration: {
  39289. name: string;
  39290. shader: string;
  39291. };
  39292. }
  39293. declare module BABYLON {
  39294. /** @hidden */
  39295. export var bumpFragment: {
  39296. name: string;
  39297. shader: string;
  39298. };
  39299. }
  39300. declare module BABYLON {
  39301. /** @hidden */
  39302. export var depthPrePass: {
  39303. name: string;
  39304. shader: string;
  39305. };
  39306. }
  39307. declare module BABYLON {
  39308. /** @hidden */
  39309. export var lightFragment: {
  39310. name: string;
  39311. shader: string;
  39312. };
  39313. }
  39314. declare module BABYLON {
  39315. /** @hidden */
  39316. export var logDepthFragment: {
  39317. name: string;
  39318. shader: string;
  39319. };
  39320. }
  39321. declare module BABYLON {
  39322. /** @hidden */
  39323. export var defaultPixelShader: {
  39324. name: string;
  39325. shader: string;
  39326. };
  39327. }
  39328. declare module BABYLON {
  39329. /** @hidden */
  39330. export var defaultVertexDeclaration: {
  39331. name: string;
  39332. shader: string;
  39333. };
  39334. }
  39335. declare module BABYLON {
  39336. /** @hidden */
  39337. export var bumpVertexDeclaration: {
  39338. name: string;
  39339. shader: string;
  39340. };
  39341. }
  39342. declare module BABYLON {
  39343. /** @hidden */
  39344. export var bumpVertex: {
  39345. name: string;
  39346. shader: string;
  39347. };
  39348. }
  39349. declare module BABYLON {
  39350. /** @hidden */
  39351. export var fogVertex: {
  39352. name: string;
  39353. shader: string;
  39354. };
  39355. }
  39356. declare module BABYLON {
  39357. /** @hidden */
  39358. export var shadowsVertex: {
  39359. name: string;
  39360. shader: string;
  39361. };
  39362. }
  39363. declare module BABYLON {
  39364. /** @hidden */
  39365. export var pointCloudVertex: {
  39366. name: string;
  39367. shader: string;
  39368. };
  39369. }
  39370. declare module BABYLON {
  39371. /** @hidden */
  39372. export var logDepthVertex: {
  39373. name: string;
  39374. shader: string;
  39375. };
  39376. }
  39377. declare module BABYLON {
  39378. /** @hidden */
  39379. export var defaultVertexShader: {
  39380. name: string;
  39381. shader: string;
  39382. };
  39383. }
  39384. declare module BABYLON {
  39385. /** @hidden */
  39386. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39387. MAINUV1: boolean;
  39388. MAINUV2: boolean;
  39389. DIFFUSE: boolean;
  39390. DIFFUSEDIRECTUV: number;
  39391. AMBIENT: boolean;
  39392. AMBIENTDIRECTUV: number;
  39393. OPACITY: boolean;
  39394. OPACITYDIRECTUV: number;
  39395. OPACITYRGB: boolean;
  39396. REFLECTION: boolean;
  39397. EMISSIVE: boolean;
  39398. EMISSIVEDIRECTUV: number;
  39399. SPECULAR: boolean;
  39400. SPECULARDIRECTUV: number;
  39401. BUMP: boolean;
  39402. BUMPDIRECTUV: number;
  39403. PARALLAX: boolean;
  39404. PARALLAXOCCLUSION: boolean;
  39405. SPECULAROVERALPHA: boolean;
  39406. CLIPPLANE: boolean;
  39407. CLIPPLANE2: boolean;
  39408. CLIPPLANE3: boolean;
  39409. CLIPPLANE4: boolean;
  39410. ALPHATEST: boolean;
  39411. DEPTHPREPASS: boolean;
  39412. ALPHAFROMDIFFUSE: boolean;
  39413. POINTSIZE: boolean;
  39414. FOG: boolean;
  39415. SPECULARTERM: boolean;
  39416. DIFFUSEFRESNEL: boolean;
  39417. OPACITYFRESNEL: boolean;
  39418. REFLECTIONFRESNEL: boolean;
  39419. REFRACTIONFRESNEL: boolean;
  39420. EMISSIVEFRESNEL: boolean;
  39421. FRESNEL: boolean;
  39422. NORMAL: boolean;
  39423. UV1: boolean;
  39424. UV2: boolean;
  39425. VERTEXCOLOR: boolean;
  39426. VERTEXALPHA: boolean;
  39427. NUM_BONE_INFLUENCERS: number;
  39428. BonesPerMesh: number;
  39429. BONETEXTURE: boolean;
  39430. INSTANCES: boolean;
  39431. GLOSSINESS: boolean;
  39432. ROUGHNESS: boolean;
  39433. EMISSIVEASILLUMINATION: boolean;
  39434. LINKEMISSIVEWITHDIFFUSE: boolean;
  39435. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39436. LIGHTMAP: boolean;
  39437. LIGHTMAPDIRECTUV: number;
  39438. OBJECTSPACE_NORMALMAP: boolean;
  39439. USELIGHTMAPASSHADOWMAP: boolean;
  39440. REFLECTIONMAP_3D: boolean;
  39441. REFLECTIONMAP_SPHERICAL: boolean;
  39442. REFLECTIONMAP_PLANAR: boolean;
  39443. REFLECTIONMAP_CUBIC: boolean;
  39444. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39445. REFLECTIONMAP_PROJECTION: boolean;
  39446. REFLECTIONMAP_SKYBOX: boolean;
  39447. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39448. REFLECTIONMAP_EXPLICIT: boolean;
  39449. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39450. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39451. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39452. INVERTCUBICMAP: boolean;
  39453. LOGARITHMICDEPTH: boolean;
  39454. REFRACTION: boolean;
  39455. REFRACTIONMAP_3D: boolean;
  39456. REFLECTIONOVERALPHA: boolean;
  39457. TWOSIDEDLIGHTING: boolean;
  39458. SHADOWFLOAT: boolean;
  39459. MORPHTARGETS: boolean;
  39460. MORPHTARGETS_NORMAL: boolean;
  39461. MORPHTARGETS_TANGENT: boolean;
  39462. MORPHTARGETS_UV: boolean;
  39463. NUM_MORPH_INFLUENCERS: number;
  39464. NONUNIFORMSCALING: boolean;
  39465. PREMULTIPLYALPHA: boolean;
  39466. IMAGEPROCESSING: boolean;
  39467. VIGNETTE: boolean;
  39468. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39469. VIGNETTEBLENDMODEOPAQUE: boolean;
  39470. TONEMAPPING: boolean;
  39471. TONEMAPPING_ACES: boolean;
  39472. CONTRAST: boolean;
  39473. COLORCURVES: boolean;
  39474. COLORGRADING: boolean;
  39475. COLORGRADING3D: boolean;
  39476. SAMPLER3DGREENDEPTH: boolean;
  39477. SAMPLER3DBGRMAP: boolean;
  39478. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39479. MULTIVIEW: boolean;
  39480. /**
  39481. * If the reflection texture on this material is in linear color space
  39482. * @hidden
  39483. */
  39484. IS_REFLECTION_LINEAR: boolean;
  39485. /**
  39486. * If the refraction texture on this material is in linear color space
  39487. * @hidden
  39488. */
  39489. IS_REFRACTION_LINEAR: boolean;
  39490. EXPOSURE: boolean;
  39491. constructor();
  39492. setReflectionMode(modeToEnable: string): void;
  39493. }
  39494. /**
  39495. * This is the default material used in Babylon. It is the best trade off between quality
  39496. * and performances.
  39497. * @see http://doc.babylonjs.com/babylon101/materials
  39498. */
  39499. export class StandardMaterial extends PushMaterial {
  39500. private _diffuseTexture;
  39501. /**
  39502. * The basic texture of the material as viewed under a light.
  39503. */
  39504. diffuseTexture: Nullable<BaseTexture>;
  39505. private _ambientTexture;
  39506. /**
  39507. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39508. */
  39509. ambientTexture: Nullable<BaseTexture>;
  39510. private _opacityTexture;
  39511. /**
  39512. * Define the transparency of the material from a texture.
  39513. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39514. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39515. */
  39516. opacityTexture: Nullable<BaseTexture>;
  39517. private _reflectionTexture;
  39518. /**
  39519. * Define the texture used to display the reflection.
  39520. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39521. */
  39522. reflectionTexture: Nullable<BaseTexture>;
  39523. private _emissiveTexture;
  39524. /**
  39525. * Define texture of the material as if self lit.
  39526. * This will be mixed in the final result even in the absence of light.
  39527. */
  39528. emissiveTexture: Nullable<BaseTexture>;
  39529. private _specularTexture;
  39530. /**
  39531. * Define how the color and intensity of the highlight given by the light in the material.
  39532. */
  39533. specularTexture: Nullable<BaseTexture>;
  39534. private _bumpTexture;
  39535. /**
  39536. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39537. * 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.
  39538. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39539. */
  39540. bumpTexture: Nullable<BaseTexture>;
  39541. private _lightmapTexture;
  39542. /**
  39543. * Complex lighting can be computationally expensive to compute at runtime.
  39544. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39545. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39546. */
  39547. lightmapTexture: Nullable<BaseTexture>;
  39548. private _refractionTexture;
  39549. /**
  39550. * Define the texture used to display the refraction.
  39551. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39552. */
  39553. refractionTexture: Nullable<BaseTexture>;
  39554. /**
  39555. * The color of the material lit by the environmental background lighting.
  39556. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39557. */
  39558. ambientColor: Color3;
  39559. /**
  39560. * The basic color of the material as viewed under a light.
  39561. */
  39562. diffuseColor: Color3;
  39563. /**
  39564. * Define how the color and intensity of the highlight given by the light in the material.
  39565. */
  39566. specularColor: Color3;
  39567. /**
  39568. * Define the color of the material as if self lit.
  39569. * This will be mixed in the final result even in the absence of light.
  39570. */
  39571. emissiveColor: Color3;
  39572. /**
  39573. * Defines how sharp are the highlights in the material.
  39574. * The bigger the value the sharper giving a more glossy feeling to the result.
  39575. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39576. */
  39577. specularPower: number;
  39578. private _useAlphaFromDiffuseTexture;
  39579. /**
  39580. * Does the transparency come from the diffuse texture alpha channel.
  39581. */
  39582. useAlphaFromDiffuseTexture: boolean;
  39583. private _useEmissiveAsIllumination;
  39584. /**
  39585. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39586. */
  39587. useEmissiveAsIllumination: boolean;
  39588. private _linkEmissiveWithDiffuse;
  39589. /**
  39590. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39591. * the emissive level when the final color is close to one.
  39592. */
  39593. linkEmissiveWithDiffuse: boolean;
  39594. private _useSpecularOverAlpha;
  39595. /**
  39596. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39597. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39598. */
  39599. useSpecularOverAlpha: boolean;
  39600. private _useReflectionOverAlpha;
  39601. /**
  39602. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39603. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39604. */
  39605. useReflectionOverAlpha: boolean;
  39606. private _disableLighting;
  39607. /**
  39608. * Does lights from the scene impacts this material.
  39609. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39610. */
  39611. disableLighting: boolean;
  39612. private _useObjectSpaceNormalMap;
  39613. /**
  39614. * Allows using an object space normal map (instead of tangent space).
  39615. */
  39616. useObjectSpaceNormalMap: boolean;
  39617. private _useParallax;
  39618. /**
  39619. * Is parallax enabled or not.
  39620. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39621. */
  39622. useParallax: boolean;
  39623. private _useParallaxOcclusion;
  39624. /**
  39625. * Is parallax occlusion enabled or not.
  39626. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39627. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39628. */
  39629. useParallaxOcclusion: boolean;
  39630. /**
  39631. * 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.
  39632. */
  39633. parallaxScaleBias: number;
  39634. private _roughness;
  39635. /**
  39636. * Helps to define how blurry the reflections should appears in the material.
  39637. */
  39638. roughness: number;
  39639. /**
  39640. * In case of refraction, define the value of the index of refraction.
  39641. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39642. */
  39643. indexOfRefraction: number;
  39644. /**
  39645. * Invert the refraction texture alongside the y axis.
  39646. * It can be useful with procedural textures or probe for instance.
  39647. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39648. */
  39649. invertRefractionY: boolean;
  39650. /**
  39651. * Defines the alpha limits in alpha test mode.
  39652. */
  39653. alphaCutOff: number;
  39654. private _useLightmapAsShadowmap;
  39655. /**
  39656. * In case of light mapping, define whether the map contains light or shadow informations.
  39657. */
  39658. useLightmapAsShadowmap: boolean;
  39659. private _diffuseFresnelParameters;
  39660. /**
  39661. * Define the diffuse fresnel parameters of the material.
  39662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39663. */
  39664. diffuseFresnelParameters: FresnelParameters;
  39665. private _opacityFresnelParameters;
  39666. /**
  39667. * Define the opacity fresnel parameters of the material.
  39668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39669. */
  39670. opacityFresnelParameters: FresnelParameters;
  39671. private _reflectionFresnelParameters;
  39672. /**
  39673. * Define the reflection fresnel parameters of the material.
  39674. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39675. */
  39676. reflectionFresnelParameters: FresnelParameters;
  39677. private _refractionFresnelParameters;
  39678. /**
  39679. * Define the refraction fresnel parameters of the material.
  39680. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39681. */
  39682. refractionFresnelParameters: FresnelParameters;
  39683. private _emissiveFresnelParameters;
  39684. /**
  39685. * Define the emissive fresnel parameters of the material.
  39686. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39687. */
  39688. emissiveFresnelParameters: FresnelParameters;
  39689. private _useReflectionFresnelFromSpecular;
  39690. /**
  39691. * If true automatically deducts the fresnels values from the material specularity.
  39692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39693. */
  39694. useReflectionFresnelFromSpecular: boolean;
  39695. private _useGlossinessFromSpecularMapAlpha;
  39696. /**
  39697. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39698. */
  39699. useGlossinessFromSpecularMapAlpha: boolean;
  39700. private _maxSimultaneousLights;
  39701. /**
  39702. * Defines the maximum number of lights that can be used in the material
  39703. */
  39704. maxSimultaneousLights: number;
  39705. private _invertNormalMapX;
  39706. /**
  39707. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39708. */
  39709. invertNormalMapX: boolean;
  39710. private _invertNormalMapY;
  39711. /**
  39712. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39713. */
  39714. invertNormalMapY: boolean;
  39715. private _twoSidedLighting;
  39716. /**
  39717. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39718. */
  39719. twoSidedLighting: boolean;
  39720. /**
  39721. * Default configuration related to image processing available in the standard Material.
  39722. */
  39723. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39724. /**
  39725. * Gets the image processing configuration used either in this material.
  39726. */
  39727. /**
  39728. * Sets the Default image processing configuration used either in the this material.
  39729. *
  39730. * If sets to null, the scene one is in use.
  39731. */
  39732. imageProcessingConfiguration: ImageProcessingConfiguration;
  39733. /**
  39734. * Keep track of the image processing observer to allow dispose and replace.
  39735. */
  39736. private _imageProcessingObserver;
  39737. /**
  39738. * Attaches a new image processing configuration to the Standard Material.
  39739. * @param configuration
  39740. */
  39741. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39742. /**
  39743. * Gets wether the color curves effect is enabled.
  39744. */
  39745. /**
  39746. * Sets wether the color curves effect is enabled.
  39747. */
  39748. cameraColorCurvesEnabled: boolean;
  39749. /**
  39750. * Gets wether the color grading effect is enabled.
  39751. */
  39752. /**
  39753. * Gets wether the color grading effect is enabled.
  39754. */
  39755. cameraColorGradingEnabled: boolean;
  39756. /**
  39757. * Gets wether tonemapping is enabled or not.
  39758. */
  39759. /**
  39760. * Sets wether tonemapping is enabled or not
  39761. */
  39762. cameraToneMappingEnabled: boolean;
  39763. /**
  39764. * The camera exposure used on this material.
  39765. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39766. * This corresponds to a photographic exposure.
  39767. */
  39768. /**
  39769. * The camera exposure used on this material.
  39770. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39771. * This corresponds to a photographic exposure.
  39772. */
  39773. cameraExposure: number;
  39774. /**
  39775. * Gets The camera contrast used on this material.
  39776. */
  39777. /**
  39778. * Sets The camera contrast used on this material.
  39779. */
  39780. cameraContrast: number;
  39781. /**
  39782. * Gets the Color Grading 2D Lookup Texture.
  39783. */
  39784. /**
  39785. * Sets the Color Grading 2D Lookup Texture.
  39786. */
  39787. cameraColorGradingTexture: Nullable<BaseTexture>;
  39788. /**
  39789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39791. * 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;
  39792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39793. */
  39794. /**
  39795. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39796. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39797. * 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;
  39798. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39799. */
  39800. cameraColorCurves: Nullable<ColorCurves>;
  39801. /**
  39802. * Custom callback helping to override the default shader used in the material.
  39803. */
  39804. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39805. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39806. protected _worldViewProjectionMatrix: Matrix;
  39807. protected _globalAmbientColor: Color3;
  39808. protected _useLogarithmicDepth: boolean;
  39809. protected _rebuildInParallel: boolean;
  39810. /**
  39811. * Instantiates a new standard material.
  39812. * This is the default material used in Babylon. It is the best trade off between quality
  39813. * and performances.
  39814. * @see http://doc.babylonjs.com/babylon101/materials
  39815. * @param name Define the name of the material in the scene
  39816. * @param scene Define the scene the material belong to
  39817. */
  39818. constructor(name: string, scene: Scene);
  39819. /**
  39820. * Gets a boolean indicating that current material needs to register RTT
  39821. */
  39822. readonly hasRenderTargetTextures: boolean;
  39823. /**
  39824. * Gets the current class name of the material e.g. "StandardMaterial"
  39825. * Mainly use in serialization.
  39826. * @returns the class name
  39827. */
  39828. getClassName(): string;
  39829. /**
  39830. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39831. * You can try switching to logarithmic depth.
  39832. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39833. */
  39834. useLogarithmicDepth: boolean;
  39835. /**
  39836. * Specifies if the material will require alpha blending
  39837. * @returns a boolean specifying if alpha blending is needed
  39838. */
  39839. needAlphaBlending(): boolean;
  39840. /**
  39841. * Specifies if this material should be rendered in alpha test mode
  39842. * @returns a boolean specifying if an alpha test is needed.
  39843. */
  39844. needAlphaTesting(): boolean;
  39845. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39846. /**
  39847. * Get the texture used for alpha test purpose.
  39848. * @returns the diffuse texture in case of the standard material.
  39849. */
  39850. getAlphaTestTexture(): Nullable<BaseTexture>;
  39851. /**
  39852. * Get if the submesh is ready to be used and all its information available.
  39853. * Child classes can use it to update shaders
  39854. * @param mesh defines the mesh to check
  39855. * @param subMesh defines which submesh to check
  39856. * @param useInstances specifies that instances should be used
  39857. * @returns a boolean indicating that the submesh is ready or not
  39858. */
  39859. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39860. /**
  39861. * Builds the material UBO layouts.
  39862. * Used internally during the effect preparation.
  39863. */
  39864. buildUniformLayout(): void;
  39865. /**
  39866. * Unbinds the material from the mesh
  39867. */
  39868. unbind(): void;
  39869. /**
  39870. * Binds the submesh to this material by preparing the effect and shader to draw
  39871. * @param world defines the world transformation matrix
  39872. * @param mesh defines the mesh containing the submesh
  39873. * @param subMesh defines the submesh to bind the material to
  39874. */
  39875. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39876. /**
  39877. * Get the list of animatables in the material.
  39878. * @returns the list of animatables object used in the material
  39879. */
  39880. getAnimatables(): IAnimatable[];
  39881. /**
  39882. * Gets the active textures from the material
  39883. * @returns an array of textures
  39884. */
  39885. getActiveTextures(): BaseTexture[];
  39886. /**
  39887. * Specifies if the material uses a texture
  39888. * @param texture defines the texture to check against the material
  39889. * @returns a boolean specifying if the material uses the texture
  39890. */
  39891. hasTexture(texture: BaseTexture): boolean;
  39892. /**
  39893. * Disposes the material
  39894. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39895. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39896. */
  39897. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39898. /**
  39899. * Makes a duplicate of the material, and gives it a new name
  39900. * @param name defines the new name for the duplicated material
  39901. * @returns the cloned material
  39902. */
  39903. clone(name: string): StandardMaterial;
  39904. /**
  39905. * Serializes this material in a JSON representation
  39906. * @returns the serialized material object
  39907. */
  39908. serialize(): any;
  39909. /**
  39910. * Creates a standard material from parsed material data
  39911. * @param source defines the JSON representation of the material
  39912. * @param scene defines the hosting scene
  39913. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39914. * @returns a new standard material
  39915. */
  39916. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39917. /**
  39918. * Are diffuse textures enabled in the application.
  39919. */
  39920. static DiffuseTextureEnabled: boolean;
  39921. /**
  39922. * Are ambient textures enabled in the application.
  39923. */
  39924. static AmbientTextureEnabled: boolean;
  39925. /**
  39926. * Are opacity textures enabled in the application.
  39927. */
  39928. static OpacityTextureEnabled: boolean;
  39929. /**
  39930. * Are reflection textures enabled in the application.
  39931. */
  39932. static ReflectionTextureEnabled: boolean;
  39933. /**
  39934. * Are emissive textures enabled in the application.
  39935. */
  39936. static EmissiveTextureEnabled: boolean;
  39937. /**
  39938. * Are specular textures enabled in the application.
  39939. */
  39940. static SpecularTextureEnabled: boolean;
  39941. /**
  39942. * Are bump textures enabled in the application.
  39943. */
  39944. static BumpTextureEnabled: boolean;
  39945. /**
  39946. * Are lightmap textures enabled in the application.
  39947. */
  39948. static LightmapTextureEnabled: boolean;
  39949. /**
  39950. * Are refraction textures enabled in the application.
  39951. */
  39952. static RefractionTextureEnabled: boolean;
  39953. /**
  39954. * Are color grading textures enabled in the application.
  39955. */
  39956. static ColorGradingTextureEnabled: boolean;
  39957. /**
  39958. * Are fresnels enabled in the application.
  39959. */
  39960. static FresnelEnabled: boolean;
  39961. }
  39962. }
  39963. declare module BABYLON {
  39964. /** @hidden */
  39965. export var imageProcessingPixelShader: {
  39966. name: string;
  39967. shader: string;
  39968. };
  39969. }
  39970. declare module BABYLON {
  39971. /**
  39972. * ImageProcessingPostProcess
  39973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39974. */
  39975. export class ImageProcessingPostProcess extends PostProcess {
  39976. /**
  39977. * Default configuration related to image processing available in the PBR Material.
  39978. */
  39979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39980. /**
  39981. * Gets the image processing configuration used either in this material.
  39982. */
  39983. /**
  39984. * Sets the Default image processing configuration used either in the this material.
  39985. *
  39986. * If sets to null, the scene one is in use.
  39987. */
  39988. imageProcessingConfiguration: ImageProcessingConfiguration;
  39989. /**
  39990. * Keep track of the image processing observer to allow dispose and replace.
  39991. */
  39992. private _imageProcessingObserver;
  39993. /**
  39994. * Attaches a new image processing configuration to the PBR Material.
  39995. * @param configuration
  39996. */
  39997. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39998. /**
  39999. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40000. */
  40001. /**
  40002. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40003. */
  40004. colorCurves: Nullable<ColorCurves>;
  40005. /**
  40006. * Gets wether the color curves effect is enabled.
  40007. */
  40008. /**
  40009. * Sets wether the color curves effect is enabled.
  40010. */
  40011. colorCurvesEnabled: boolean;
  40012. /**
  40013. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40014. */
  40015. /**
  40016. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40017. */
  40018. colorGradingTexture: Nullable<BaseTexture>;
  40019. /**
  40020. * Gets wether the color grading effect is enabled.
  40021. */
  40022. /**
  40023. * Gets wether the color grading effect is enabled.
  40024. */
  40025. colorGradingEnabled: boolean;
  40026. /**
  40027. * Gets exposure used in the effect.
  40028. */
  40029. /**
  40030. * Sets exposure used in the effect.
  40031. */
  40032. exposure: number;
  40033. /**
  40034. * Gets wether tonemapping is enabled or not.
  40035. */
  40036. /**
  40037. * Sets wether tonemapping is enabled or not
  40038. */
  40039. toneMappingEnabled: boolean;
  40040. /**
  40041. * Gets the type of tone mapping effect.
  40042. */
  40043. /**
  40044. * Sets the type of tone mapping effect.
  40045. */
  40046. toneMappingType: number;
  40047. /**
  40048. * Gets contrast used in the effect.
  40049. */
  40050. /**
  40051. * Sets contrast used in the effect.
  40052. */
  40053. contrast: number;
  40054. /**
  40055. * Gets Vignette stretch size.
  40056. */
  40057. /**
  40058. * Sets Vignette stretch size.
  40059. */
  40060. vignetteStretch: number;
  40061. /**
  40062. * Gets Vignette centre X Offset.
  40063. */
  40064. /**
  40065. * Sets Vignette centre X Offset.
  40066. */
  40067. vignetteCentreX: number;
  40068. /**
  40069. * Gets Vignette centre Y Offset.
  40070. */
  40071. /**
  40072. * Sets Vignette centre Y Offset.
  40073. */
  40074. vignetteCentreY: number;
  40075. /**
  40076. * Gets Vignette weight or intensity of the vignette effect.
  40077. */
  40078. /**
  40079. * Sets Vignette weight or intensity of the vignette effect.
  40080. */
  40081. vignetteWeight: number;
  40082. /**
  40083. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40084. * if vignetteEnabled is set to true.
  40085. */
  40086. /**
  40087. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40088. * if vignetteEnabled is set to true.
  40089. */
  40090. vignetteColor: Color4;
  40091. /**
  40092. * Gets Camera field of view used by the Vignette effect.
  40093. */
  40094. /**
  40095. * Sets Camera field of view used by the Vignette effect.
  40096. */
  40097. vignetteCameraFov: number;
  40098. /**
  40099. * Gets the vignette blend mode allowing different kind of effect.
  40100. */
  40101. /**
  40102. * Sets the vignette blend mode allowing different kind of effect.
  40103. */
  40104. vignetteBlendMode: number;
  40105. /**
  40106. * Gets wether the vignette effect is enabled.
  40107. */
  40108. /**
  40109. * Sets wether the vignette effect is enabled.
  40110. */
  40111. vignetteEnabled: boolean;
  40112. private _fromLinearSpace;
  40113. /**
  40114. * Gets wether the input of the processing is in Gamma or Linear Space.
  40115. */
  40116. /**
  40117. * Sets wether the input of the processing is in Gamma or Linear Space.
  40118. */
  40119. fromLinearSpace: boolean;
  40120. /**
  40121. * Defines cache preventing GC.
  40122. */
  40123. private _defines;
  40124. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40125. /**
  40126. * "ImageProcessingPostProcess"
  40127. * @returns "ImageProcessingPostProcess"
  40128. */
  40129. getClassName(): string;
  40130. protected _updateParameters(): void;
  40131. dispose(camera?: Camera): void;
  40132. }
  40133. }
  40134. declare module BABYLON {
  40135. /**
  40136. * Class containing static functions to help procedurally build meshes
  40137. */
  40138. export class GroundBuilder {
  40139. /**
  40140. * Creates a ground mesh
  40141. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40142. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40144. * @param name defines the name of the mesh
  40145. * @param options defines the options used to create the mesh
  40146. * @param scene defines the hosting scene
  40147. * @returns the ground mesh
  40148. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40149. */
  40150. static CreateGround(name: string, options: {
  40151. width?: number;
  40152. height?: number;
  40153. subdivisions?: number;
  40154. subdivisionsX?: number;
  40155. subdivisionsY?: number;
  40156. updatable?: boolean;
  40157. }, scene: any): Mesh;
  40158. /**
  40159. * Creates a tiled ground mesh
  40160. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40161. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40162. * * 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
  40163. * * 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
  40164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40165. * @param name defines the name of the mesh
  40166. * @param options defines the options used to create the mesh
  40167. * @param scene defines the hosting scene
  40168. * @returns the tiled ground mesh
  40169. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40170. */
  40171. static CreateTiledGround(name: string, options: {
  40172. xmin: number;
  40173. zmin: number;
  40174. xmax: number;
  40175. zmax: number;
  40176. subdivisions?: {
  40177. w: number;
  40178. h: number;
  40179. };
  40180. precision?: {
  40181. w: number;
  40182. h: number;
  40183. };
  40184. updatable?: boolean;
  40185. }, scene?: Nullable<Scene>): Mesh;
  40186. /**
  40187. * Creates a ground mesh from a height map
  40188. * * The parameter `url` sets the URL of the height map image resource.
  40189. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40190. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40191. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40192. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40193. * * 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.
  40194. * * 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).
  40195. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40197. * @param name defines the name of the mesh
  40198. * @param url defines the url to the height map
  40199. * @param options defines the options used to create the mesh
  40200. * @param scene defines the hosting scene
  40201. * @returns the ground mesh
  40202. * @see https://doc.babylonjs.com/babylon101/height_map
  40203. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40204. */
  40205. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40206. width?: number;
  40207. height?: number;
  40208. subdivisions?: number;
  40209. minHeight?: number;
  40210. maxHeight?: number;
  40211. colorFilter?: Color3;
  40212. alphaFilter?: number;
  40213. updatable?: boolean;
  40214. onReady?: (mesh: GroundMesh) => void;
  40215. }, scene?: Nullable<Scene>): GroundMesh;
  40216. }
  40217. }
  40218. declare module BABYLON {
  40219. /**
  40220. * Class containing static functions to help procedurally build meshes
  40221. */
  40222. export class TorusBuilder {
  40223. /**
  40224. * Creates a torus mesh
  40225. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40226. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40227. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40229. * * 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
  40230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40231. * @param name defines the name of the mesh
  40232. * @param options defines the options used to create the mesh
  40233. * @param scene defines the hosting scene
  40234. * @returns the torus mesh
  40235. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40236. */
  40237. static CreateTorus(name: string, options: {
  40238. diameter?: number;
  40239. thickness?: number;
  40240. tessellation?: number;
  40241. updatable?: boolean;
  40242. sideOrientation?: number;
  40243. frontUVs?: Vector4;
  40244. backUVs?: Vector4;
  40245. }, scene: any): Mesh;
  40246. }
  40247. }
  40248. declare module BABYLON {
  40249. /**
  40250. * Class containing static functions to help procedurally build meshes
  40251. */
  40252. export class CylinderBuilder {
  40253. /**
  40254. * Creates a cylinder or a cone mesh
  40255. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40256. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40257. * * 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.
  40258. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40259. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40260. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40261. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40262. * * 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).
  40263. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40264. * * 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).
  40265. * * 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
  40266. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40267. * * 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
  40268. * * 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.
  40269. * * If `enclose` is false, a ring surface is one element.
  40270. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40271. * * 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
  40272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40273. * * 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
  40274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40275. * @param name defines the name of the mesh
  40276. * @param options defines the options used to create the mesh
  40277. * @param scene defines the hosting scene
  40278. * @returns the cylinder mesh
  40279. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40280. */
  40281. static CreateCylinder(name: string, options: {
  40282. height?: number;
  40283. diameterTop?: number;
  40284. diameterBottom?: number;
  40285. diameter?: number;
  40286. tessellation?: number;
  40287. subdivisions?: number;
  40288. arc?: number;
  40289. faceColors?: Color4[];
  40290. faceUV?: Vector4[];
  40291. updatable?: boolean;
  40292. hasRings?: boolean;
  40293. enclose?: boolean;
  40294. cap?: number;
  40295. sideOrientation?: number;
  40296. frontUVs?: Vector4;
  40297. backUVs?: Vector4;
  40298. }, scene: any): Mesh;
  40299. }
  40300. }
  40301. declare module BABYLON {
  40302. /**
  40303. * Options to modify the vr teleportation behavior.
  40304. */
  40305. export interface VRTeleportationOptions {
  40306. /**
  40307. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40308. */
  40309. floorMeshName?: string;
  40310. /**
  40311. * A list of meshes to be used as the teleportation floor. (default: empty)
  40312. */
  40313. floorMeshes?: Mesh[];
  40314. }
  40315. /**
  40316. * Options to modify the vr experience helper's behavior.
  40317. */
  40318. export interface VRExperienceHelperOptions extends WebVROptions {
  40319. /**
  40320. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40321. */
  40322. createDeviceOrientationCamera?: boolean;
  40323. /**
  40324. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40325. */
  40326. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40327. /**
  40328. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40329. */
  40330. laserToggle?: boolean;
  40331. /**
  40332. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40333. */
  40334. floorMeshes?: Mesh[];
  40335. /**
  40336. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40337. */
  40338. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40339. }
  40340. /**
  40341. * Event containing information after VR has been entered
  40342. */
  40343. export class OnAfterEnteringVRObservableEvent {
  40344. /**
  40345. * If entering vr was successful
  40346. */
  40347. success: boolean;
  40348. }
  40349. /**
  40350. * Helps to quickly add VR support to an existing scene.
  40351. * See http://doc.babylonjs.com/how_to/webvr_helper
  40352. */
  40353. export class VRExperienceHelper {
  40354. /** Options to modify the vr experience helper's behavior. */
  40355. webVROptions: VRExperienceHelperOptions;
  40356. private _scene;
  40357. private _position;
  40358. private _btnVR;
  40359. private _btnVRDisplayed;
  40360. private _webVRsupported;
  40361. private _webVRready;
  40362. private _webVRrequesting;
  40363. private _webVRpresenting;
  40364. private _hasEnteredVR;
  40365. private _fullscreenVRpresenting;
  40366. private _canvas;
  40367. private _webVRCamera;
  40368. private _vrDeviceOrientationCamera;
  40369. private _deviceOrientationCamera;
  40370. private _existingCamera;
  40371. private _onKeyDown;
  40372. private _onVrDisplayPresentChange;
  40373. private _onVRDisplayChanged;
  40374. private _onVRRequestPresentStart;
  40375. private _onVRRequestPresentComplete;
  40376. /**
  40377. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40378. */
  40379. enableGazeEvenWhenNoPointerLock: boolean;
  40380. /**
  40381. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40382. */
  40383. exitVROnDoubleTap: boolean;
  40384. /**
  40385. * Observable raised right before entering VR.
  40386. */
  40387. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40388. /**
  40389. * Observable raised when entering VR has completed.
  40390. */
  40391. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40392. /**
  40393. * Observable raised when exiting VR.
  40394. */
  40395. onExitingVRObservable: Observable<VRExperienceHelper>;
  40396. /**
  40397. * Observable raised when controller mesh is loaded.
  40398. */
  40399. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40400. /** Return this.onEnteringVRObservable
  40401. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40402. */
  40403. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40404. /** Return this.onExitingVRObservable
  40405. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40406. */
  40407. readonly onExitingVR: Observable<VRExperienceHelper>;
  40408. /** Return this.onControllerMeshLoadedObservable
  40409. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40410. */
  40411. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40412. private _rayLength;
  40413. private _useCustomVRButton;
  40414. private _teleportationRequested;
  40415. private _teleportActive;
  40416. private _floorMeshName;
  40417. private _floorMeshesCollection;
  40418. private _rotationAllowed;
  40419. private _teleportBackwardsVector;
  40420. private _teleportationTarget;
  40421. private _isDefaultTeleportationTarget;
  40422. private _postProcessMove;
  40423. private _teleportationFillColor;
  40424. private _teleportationBorderColor;
  40425. private _rotationAngle;
  40426. private _haloCenter;
  40427. private _cameraGazer;
  40428. private _padSensibilityUp;
  40429. private _padSensibilityDown;
  40430. private _leftController;
  40431. private _rightController;
  40432. /**
  40433. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40434. */
  40435. onNewMeshSelected: Observable<AbstractMesh>;
  40436. /**
  40437. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40438. * This observable will provide the mesh and the controller used to select the mesh
  40439. */
  40440. onMeshSelectedWithController: Observable<{
  40441. mesh: AbstractMesh;
  40442. controller: WebVRController;
  40443. }>;
  40444. /**
  40445. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40446. */
  40447. onNewMeshPicked: Observable<PickingInfo>;
  40448. private _circleEase;
  40449. /**
  40450. * Observable raised before camera teleportation
  40451. */
  40452. onBeforeCameraTeleport: Observable<Vector3>;
  40453. /**
  40454. * Observable raised after camera teleportation
  40455. */
  40456. onAfterCameraTeleport: Observable<Vector3>;
  40457. /**
  40458. * Observable raised when current selected mesh gets unselected
  40459. */
  40460. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40461. private _raySelectionPredicate;
  40462. /**
  40463. * To be optionaly changed by user to define custom ray selection
  40464. */
  40465. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40466. /**
  40467. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40468. */
  40469. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40470. /**
  40471. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40472. */
  40473. teleportationEnabled: boolean;
  40474. private _defaultHeight;
  40475. private _teleportationInitialized;
  40476. private _interactionsEnabled;
  40477. private _interactionsRequested;
  40478. private _displayGaze;
  40479. private _displayLaserPointer;
  40480. /**
  40481. * The mesh used to display where the user is going to teleport.
  40482. */
  40483. /**
  40484. * Sets the mesh to be used to display where the user is going to teleport.
  40485. */
  40486. teleportationTarget: Mesh;
  40487. /**
  40488. * 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
  40489. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40490. * See http://doc.babylonjs.com/resources/baking_transformations
  40491. */
  40492. gazeTrackerMesh: Mesh;
  40493. /**
  40494. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40495. */
  40496. updateGazeTrackerScale: boolean;
  40497. /**
  40498. * If the gaze trackers color should be updated when selecting meshes
  40499. */
  40500. updateGazeTrackerColor: boolean;
  40501. /**
  40502. * If the controller laser color should be updated when selecting meshes
  40503. */
  40504. updateControllerLaserColor: boolean;
  40505. /**
  40506. * The gaze tracking mesh corresponding to the left controller
  40507. */
  40508. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40509. /**
  40510. * The gaze tracking mesh corresponding to the right controller
  40511. */
  40512. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40513. /**
  40514. * If the ray of the gaze should be displayed.
  40515. */
  40516. /**
  40517. * Sets if the ray of the gaze should be displayed.
  40518. */
  40519. displayGaze: boolean;
  40520. /**
  40521. * If the ray of the LaserPointer should be displayed.
  40522. */
  40523. /**
  40524. * Sets if the ray of the LaserPointer should be displayed.
  40525. */
  40526. displayLaserPointer: boolean;
  40527. /**
  40528. * The deviceOrientationCamera used as the camera when not in VR.
  40529. */
  40530. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40531. /**
  40532. * Based on the current WebVR support, returns the current VR camera used.
  40533. */
  40534. readonly currentVRCamera: Nullable<Camera>;
  40535. /**
  40536. * The webVRCamera which is used when in VR.
  40537. */
  40538. readonly webVRCamera: WebVRFreeCamera;
  40539. /**
  40540. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40541. */
  40542. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40543. /**
  40544. * The html button that is used to trigger entering into VR.
  40545. */
  40546. readonly vrButton: Nullable<HTMLButtonElement>;
  40547. private readonly _teleportationRequestInitiated;
  40548. /**
  40549. * Defines wether or not Pointer lock should be requested when switching to
  40550. * full screen.
  40551. */
  40552. requestPointerLockOnFullScreen: boolean;
  40553. /**
  40554. * Instantiates a VRExperienceHelper.
  40555. * Helps to quickly add VR support to an existing scene.
  40556. * @param scene The scene the VRExperienceHelper belongs to.
  40557. * @param webVROptions Options to modify the vr experience helper's behavior.
  40558. */
  40559. constructor(scene: Scene,
  40560. /** Options to modify the vr experience helper's behavior. */
  40561. webVROptions?: VRExperienceHelperOptions);
  40562. private _onDefaultMeshLoaded;
  40563. private _onResize;
  40564. private _onFullscreenChange;
  40565. /**
  40566. * Gets a value indicating if we are currently in VR mode.
  40567. */
  40568. readonly isInVRMode: boolean;
  40569. private onVrDisplayPresentChange;
  40570. private onVRDisplayChanged;
  40571. private moveButtonToBottomRight;
  40572. private displayVRButton;
  40573. private updateButtonVisibility;
  40574. private _cachedAngularSensibility;
  40575. /**
  40576. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40577. * Otherwise, will use the fullscreen API.
  40578. */
  40579. enterVR(): void;
  40580. /**
  40581. * Attempt to exit VR, or fullscreen.
  40582. */
  40583. exitVR(): void;
  40584. /**
  40585. * The position of the vr experience helper.
  40586. */
  40587. /**
  40588. * Sets the position of the vr experience helper.
  40589. */
  40590. position: Vector3;
  40591. /**
  40592. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40593. */
  40594. enableInteractions(): void;
  40595. private readonly _noControllerIsActive;
  40596. private beforeRender;
  40597. private _isTeleportationFloor;
  40598. /**
  40599. * Adds a floor mesh to be used for teleportation.
  40600. * @param floorMesh the mesh to be used for teleportation.
  40601. */
  40602. addFloorMesh(floorMesh: Mesh): void;
  40603. /**
  40604. * Removes a floor mesh from being used for teleportation.
  40605. * @param floorMesh the mesh to be removed.
  40606. */
  40607. removeFloorMesh(floorMesh: Mesh): void;
  40608. /**
  40609. * Enables interactions and teleportation using the VR controllers and gaze.
  40610. * @param vrTeleportationOptions options to modify teleportation behavior.
  40611. */
  40612. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40613. private _onNewGamepadConnected;
  40614. private _tryEnableInteractionOnController;
  40615. private _onNewGamepadDisconnected;
  40616. private _enableInteractionOnController;
  40617. private _checkTeleportWithRay;
  40618. private _checkRotate;
  40619. private _checkTeleportBackwards;
  40620. private _enableTeleportationOnController;
  40621. private _createTeleportationCircles;
  40622. private _displayTeleportationTarget;
  40623. private _hideTeleportationTarget;
  40624. private _rotateCamera;
  40625. private _moveTeleportationSelectorTo;
  40626. private _workingVector;
  40627. private _workingQuaternion;
  40628. private _workingMatrix;
  40629. /**
  40630. * Teleports the users feet to the desired location
  40631. * @param location The location where the user's feet should be placed
  40632. */
  40633. teleportCamera(location: Vector3): void;
  40634. private _convertNormalToDirectionOfRay;
  40635. private _castRayAndSelectObject;
  40636. private _notifySelectedMeshUnselected;
  40637. /**
  40638. * Sets the color of the laser ray from the vr controllers.
  40639. * @param color new color for the ray.
  40640. */
  40641. changeLaserColor(color: Color3): void;
  40642. /**
  40643. * Sets the color of the ray from the vr headsets gaze.
  40644. * @param color new color for the ray.
  40645. */
  40646. changeGazeColor(color: Color3): void;
  40647. /**
  40648. * Exits VR and disposes of the vr experience helper
  40649. */
  40650. dispose(): void;
  40651. /**
  40652. * Gets the name of the VRExperienceHelper class
  40653. * @returns "VRExperienceHelper"
  40654. */
  40655. getClassName(): string;
  40656. }
  40657. }
  40658. declare module BABYLON {
  40659. /**
  40660. * Manages an XRSession to work with Babylon's engine
  40661. * @see https://doc.babylonjs.com/how_to/webxr
  40662. */
  40663. export class WebXRSessionManager implements IDisposable {
  40664. private scene;
  40665. /**
  40666. * Fires every time a new xrFrame arrives which can be used to update the camera
  40667. */
  40668. onXRFrameObservable: Observable<any>;
  40669. /**
  40670. * Fires when the xr session is ended either by the device or manually done
  40671. */
  40672. onXRSessionEnded: Observable<any>;
  40673. /**
  40674. * Underlying xr session
  40675. */
  40676. session: XRSession;
  40677. /**
  40678. * Type of reference space used when creating the session
  40679. */
  40680. referenceSpace: XRReferenceSpace;
  40681. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40682. /**
  40683. * Current XR frame
  40684. */
  40685. currentFrame: Nullable<XRFrame>;
  40686. private _xrNavigator;
  40687. private baseLayer;
  40688. /**
  40689. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40690. * @param scene The scene which the session should be created for
  40691. */
  40692. constructor(scene: Scene);
  40693. /**
  40694. * Initializes the manager
  40695. * After initialization enterXR can be called to start an XR session
  40696. * @returns Promise which resolves after it is initialized
  40697. */
  40698. initializeAsync(): Promise<void>;
  40699. /**
  40700. * Initializes an xr session
  40701. * @param xrSessionMode mode to initialize
  40702. * @returns a promise which will resolve once the session has been initialized
  40703. */
  40704. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40705. /**
  40706. * Sets the reference space on the xr session
  40707. * @param referenceSpace space to set
  40708. * @returns a promise that will resolve once the reference space has been set
  40709. */
  40710. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40711. /**
  40712. * Updates the render state of the session
  40713. * @param state state to set
  40714. * @returns a promise that resolves once the render state has been updated
  40715. */
  40716. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40717. /**
  40718. * Starts rendering to the xr layer
  40719. * @returns a promise that will resolve once rendering has started
  40720. */
  40721. startRenderingToXRAsync(): Promise<void>;
  40722. /**
  40723. * Stops the xrSession and restores the renderloop
  40724. * @returns Promise which resolves after it exits XR
  40725. */
  40726. exitXRAsync(): Promise<unknown>;
  40727. /**
  40728. * Checks if a session would be supported for the creation options specified
  40729. * @param sessionMode session mode to check if supported eg. immersive-vr
  40730. * @returns true if supported
  40731. */
  40732. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40733. /**
  40734. * @hidden
  40735. * Converts the render layer of xrSession to a render target
  40736. * @param session session to create render target for
  40737. * @param scene scene the new render target should be created for
  40738. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40739. /**
  40740. * Disposes of the session manager
  40741. */
  40742. dispose(): void;
  40743. }
  40744. }
  40745. declare module BABYLON {
  40746. /**
  40747. * WebXR Camera which holds the views for the xrSession
  40748. * @see https://doc.babylonjs.com/how_to/webxr
  40749. */
  40750. export class WebXRCamera extends FreeCamera {
  40751. private static _TmpMatrix;
  40752. /**
  40753. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40754. * @param name the name of the camera
  40755. * @param scene the scene to add the camera to
  40756. */
  40757. constructor(name: string, scene: Scene);
  40758. private _updateNumberOfRigCameras;
  40759. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40760. /**
  40761. * Updates the cameras position from the current pose information of the XR session
  40762. * @param xrSessionManager the session containing pose information
  40763. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40764. */
  40765. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40766. }
  40767. }
  40768. declare module BABYLON {
  40769. /**
  40770. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40771. */
  40772. export class WebXRManagedOutputCanvas implements IDisposable {
  40773. private helper;
  40774. private _canvas;
  40775. /**
  40776. * xrpresent context of the canvas which can be used to display/mirror xr content
  40777. */
  40778. canvasContext: WebGLRenderingContext;
  40779. /**
  40780. * xr layer for the canvas
  40781. */
  40782. xrLayer: Nullable<XRWebGLLayer>;
  40783. /**
  40784. * Initializes the xr layer for the session
  40785. * @param xrSession xr session
  40786. * @returns a promise that will resolve once the XR Layer has been created
  40787. */
  40788. initializeXRLayerAsync(xrSession: any): any;
  40789. /**
  40790. * Initializes the canvas to be added/removed upon entering/exiting xr
  40791. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40792. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40793. */
  40794. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40795. /**
  40796. * Disposes of the object
  40797. */
  40798. dispose(): void;
  40799. private _setManagedOutputCanvas;
  40800. private _addCanvas;
  40801. private _removeCanvas;
  40802. }
  40803. }
  40804. declare module BABYLON {
  40805. /**
  40806. * States of the webXR experience
  40807. */
  40808. export enum WebXRState {
  40809. /**
  40810. * Transitioning to being in XR mode
  40811. */
  40812. ENTERING_XR = 0,
  40813. /**
  40814. * Transitioning to non XR mode
  40815. */
  40816. EXITING_XR = 1,
  40817. /**
  40818. * In XR mode and presenting
  40819. */
  40820. IN_XR = 2,
  40821. /**
  40822. * Not entered XR mode
  40823. */
  40824. NOT_IN_XR = 3
  40825. }
  40826. /**
  40827. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40828. * @see https://doc.babylonjs.com/how_to/webxr
  40829. */
  40830. export class WebXRExperienceHelper implements IDisposable {
  40831. private scene;
  40832. /**
  40833. * 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
  40834. */
  40835. container: AbstractMesh;
  40836. /**
  40837. * Camera used to render xr content
  40838. */
  40839. camera: WebXRCamera;
  40840. /**
  40841. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40842. */
  40843. state: WebXRState;
  40844. private _setState;
  40845. private static _TmpVector;
  40846. /**
  40847. * Fires when the state of the experience helper has changed
  40848. */
  40849. onStateChangedObservable: Observable<WebXRState>;
  40850. /** Session manager used to keep track of xr session */
  40851. sessionManager: WebXRSessionManager;
  40852. private _nonVRCamera;
  40853. private _originalSceneAutoClear;
  40854. private _supported;
  40855. /**
  40856. * Creates the experience helper
  40857. * @param scene the scene to attach the experience helper to
  40858. * @returns a promise for the experience helper
  40859. */
  40860. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40861. /**
  40862. * Creates a WebXRExperienceHelper
  40863. * @param scene The scene the helper should be created in
  40864. */
  40865. private constructor();
  40866. /**
  40867. * Exits XR mode and returns the scene to its original state
  40868. * @returns promise that resolves after xr mode has exited
  40869. */
  40870. exitXRAsync(): Promise<unknown>;
  40871. /**
  40872. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40873. * @param sessionCreationOptions options for the XR session
  40874. * @param referenceSpaceType frame of reference of the XR session
  40875. * @param outputCanvas the output canvas that will be used to enter XR mode
  40876. * @returns promise that resolves after xr mode has entered
  40877. */
  40878. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40879. /**
  40880. * Updates the global position of the camera by moving the camera's container
  40881. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40882. * @param position The desired global position of the camera
  40883. */
  40884. setPositionOfCameraUsingContainer(position: Vector3): void;
  40885. /**
  40886. * Rotates the xr camera by rotating the camera's container around the camera's position
  40887. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40888. * @param rotation the desired quaternion rotation to apply to the camera
  40889. */
  40890. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40891. /**
  40892. * Disposes of the experience helper
  40893. */
  40894. dispose(): void;
  40895. }
  40896. }
  40897. declare module BABYLON {
  40898. /**
  40899. * Button which can be used to enter a different mode of XR
  40900. */
  40901. export class WebXREnterExitUIButton {
  40902. /** button element */
  40903. element: HTMLElement;
  40904. /** XR initialization options for the button */
  40905. sessionMode: XRSessionMode;
  40906. /** Reference space type */
  40907. referenceSpaceType: XRReferenceSpaceType;
  40908. /**
  40909. * Creates a WebXREnterExitUIButton
  40910. * @param element button element
  40911. * @param sessionMode XR initialization session mode
  40912. * @param referenceSpaceType the type of reference space to be used
  40913. */
  40914. constructor(
  40915. /** button element */
  40916. element: HTMLElement,
  40917. /** XR initialization options for the button */
  40918. sessionMode: XRSessionMode,
  40919. /** Reference space type */
  40920. referenceSpaceType: XRReferenceSpaceType);
  40921. /**
  40922. * Overwritable function which can be used to update the button's visuals when the state changes
  40923. * @param activeButton the current active button in the UI
  40924. */
  40925. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40926. }
  40927. /**
  40928. * Options to create the webXR UI
  40929. */
  40930. export class WebXREnterExitUIOptions {
  40931. /**
  40932. * Context to enter xr with
  40933. */
  40934. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40935. /**
  40936. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40937. */
  40938. customButtons?: Array<WebXREnterExitUIButton>;
  40939. }
  40940. /**
  40941. * UI to allow the user to enter/exit XR mode
  40942. */
  40943. export class WebXREnterExitUI implements IDisposable {
  40944. private scene;
  40945. private _overlay;
  40946. private _buttons;
  40947. private _activeButton;
  40948. /**
  40949. * Fired every time the active button is changed.
  40950. *
  40951. * When xr is entered via a button that launches xr that button will be the callback parameter
  40952. *
  40953. * When exiting xr the callback parameter will be null)
  40954. */
  40955. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40956. /**
  40957. * Creates UI to allow the user to enter/exit XR mode
  40958. * @param scene the scene to add the ui to
  40959. * @param helper the xr experience helper to enter/exit xr with
  40960. * @param options options to configure the UI
  40961. * @returns the created ui
  40962. */
  40963. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40964. private constructor();
  40965. private _updateButtons;
  40966. /**
  40967. * Disposes of the object
  40968. */
  40969. dispose(): void;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * Represents an XR input
  40975. */
  40976. export class WebXRController {
  40977. private scene;
  40978. /** The underlying input source for the controller */
  40979. inputSource: XRInputSource;
  40980. private parentContainer;
  40981. /**
  40982. * 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
  40983. */
  40984. grip?: AbstractMesh;
  40985. /**
  40986. * Pointer which can be used to select objects or attach a visible laser to
  40987. */
  40988. pointer: AbstractMesh;
  40989. /**
  40990. * Event that fires when the controller is removed/disposed
  40991. */
  40992. onDisposeObservable: Observable<{}>;
  40993. private _tmpMatrix;
  40994. private _tmpQuaternion;
  40995. private _tmpVector;
  40996. /**
  40997. * Creates the controller
  40998. * @see https://doc.babylonjs.com/how_to/webxr
  40999. * @param scene the scene which the controller should be associated to
  41000. * @param inputSource the underlying input source for the controller
  41001. * @param parentContainer parent that the controller meshes should be children of
  41002. */
  41003. constructor(scene: Scene,
  41004. /** The underlying input source for the controller */
  41005. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41006. /**
  41007. * Updates the controller pose based on the given XRFrame
  41008. * @param xrFrame xr frame to update the pose with
  41009. * @param referenceSpace reference space to use
  41010. */
  41011. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41012. /**
  41013. * Gets a world space ray coming from the controller
  41014. * @param result the resulting ray
  41015. */
  41016. getWorldPointerRayToRef(result: Ray): void;
  41017. /**
  41018. * Disposes of the object
  41019. */
  41020. dispose(): void;
  41021. }
  41022. }
  41023. declare module BABYLON {
  41024. /**
  41025. * XR input used to track XR inputs such as controllers/rays
  41026. */
  41027. export class WebXRInput implements IDisposable {
  41028. /**
  41029. * Base experience the input listens to
  41030. */
  41031. baseExperience: WebXRExperienceHelper;
  41032. /**
  41033. * XR controllers being tracked
  41034. */
  41035. controllers: Array<WebXRController>;
  41036. private _frameObserver;
  41037. private _stateObserver;
  41038. /**
  41039. * Event when a controller has been connected/added
  41040. */
  41041. onControllerAddedObservable: Observable<WebXRController>;
  41042. /**
  41043. * Event when a controller has been removed/disconnected
  41044. */
  41045. onControllerRemovedObservable: Observable<WebXRController>;
  41046. /**
  41047. * Initializes the WebXRInput
  41048. * @param baseExperience experience helper which the input should be created for
  41049. */
  41050. constructor(
  41051. /**
  41052. * Base experience the input listens to
  41053. */
  41054. baseExperience: WebXRExperienceHelper);
  41055. private _onInputSourcesChange;
  41056. private _addAndRemoveControllers;
  41057. /**
  41058. * Disposes of the object
  41059. */
  41060. dispose(): void;
  41061. }
  41062. }
  41063. declare module BABYLON {
  41064. /**
  41065. * Enables teleportation
  41066. */
  41067. export class WebXRControllerTeleportation {
  41068. private _teleportationFillColor;
  41069. private _teleportationBorderColor;
  41070. private _tmpRay;
  41071. private _tmpVector;
  41072. /**
  41073. * Creates a WebXRControllerTeleportation
  41074. * @param input input manager to add teleportation to
  41075. * @param floorMeshes floormeshes which can be teleported to
  41076. */
  41077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41078. }
  41079. }
  41080. declare module BABYLON {
  41081. /**
  41082. * Handles pointer input automatically for the pointer of XR controllers
  41083. */
  41084. export class WebXRControllerPointerSelection {
  41085. private static _idCounter;
  41086. private _tmpRay;
  41087. /**
  41088. * Creates a WebXRControllerPointerSelection
  41089. * @param input input manager to setup pointer selection
  41090. */
  41091. constructor(input: WebXRInput);
  41092. private _convertNormalToDirectionOfRay;
  41093. private _updatePointerDistance;
  41094. }
  41095. }
  41096. declare module BABYLON {
  41097. /**
  41098. * Class used to represent data loading progression
  41099. */
  41100. export class SceneLoaderProgressEvent {
  41101. /** defines if data length to load can be evaluated */
  41102. readonly lengthComputable: boolean;
  41103. /** defines the loaded data length */
  41104. readonly loaded: number;
  41105. /** defines the data length to load */
  41106. readonly total: number;
  41107. /**
  41108. * Create a new progress event
  41109. * @param lengthComputable defines if data length to load can be evaluated
  41110. * @param loaded defines the loaded data length
  41111. * @param total defines the data length to load
  41112. */
  41113. constructor(
  41114. /** defines if data length to load can be evaluated */
  41115. lengthComputable: boolean,
  41116. /** defines the loaded data length */
  41117. loaded: number,
  41118. /** defines the data length to load */
  41119. total: number);
  41120. /**
  41121. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41122. * @param event defines the source event
  41123. * @returns a new SceneLoaderProgressEvent
  41124. */
  41125. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41126. }
  41127. /**
  41128. * Interface used by SceneLoader plugins to define supported file extensions
  41129. */
  41130. export interface ISceneLoaderPluginExtensions {
  41131. /**
  41132. * Defines the list of supported extensions
  41133. */
  41134. [extension: string]: {
  41135. isBinary: boolean;
  41136. };
  41137. }
  41138. /**
  41139. * Interface used by SceneLoader plugin factory
  41140. */
  41141. export interface ISceneLoaderPluginFactory {
  41142. /**
  41143. * Defines the name of the factory
  41144. */
  41145. name: string;
  41146. /**
  41147. * Function called to create a new plugin
  41148. * @return the new plugin
  41149. */
  41150. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41151. /**
  41152. * Boolean indicating if the plugin can direct load specific data
  41153. */
  41154. canDirectLoad?: (data: string) => boolean;
  41155. }
  41156. /**
  41157. * Interface used to define a SceneLoader plugin
  41158. */
  41159. export interface ISceneLoaderPlugin {
  41160. /**
  41161. * The friendly name of this plugin.
  41162. */
  41163. name: string;
  41164. /**
  41165. * The file extensions supported by this plugin.
  41166. */
  41167. extensions: string | ISceneLoaderPluginExtensions;
  41168. /**
  41169. * Import meshes into a scene.
  41170. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41171. * @param scene The scene to import into
  41172. * @param data The data to import
  41173. * @param rootUrl The root url for scene and resources
  41174. * @param meshes The meshes array to import into
  41175. * @param particleSystems The particle systems array to import into
  41176. * @param skeletons The skeletons array to import into
  41177. * @param onError The callback when import fails
  41178. * @returns True if successful or false otherwise
  41179. */
  41180. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41181. /**
  41182. * Load into a scene.
  41183. * @param scene The scene to load into
  41184. * @param data The data to import
  41185. * @param rootUrl The root url for scene and resources
  41186. * @param onError The callback when import fails
  41187. * @returns true if successful or false otherwise
  41188. */
  41189. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41190. /**
  41191. * The callback that returns true if the data can be directly loaded.
  41192. */
  41193. canDirectLoad?: (data: string) => boolean;
  41194. /**
  41195. * The callback that allows custom handling of the root url based on the response url.
  41196. */
  41197. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41198. /**
  41199. * Load into an asset container.
  41200. * @param scene The scene to load into
  41201. * @param data The data to import
  41202. * @param rootUrl The root url for scene and resources
  41203. * @param onError The callback when import fails
  41204. * @returns The loaded asset container
  41205. */
  41206. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41207. }
  41208. /**
  41209. * Interface used to define an async SceneLoader plugin
  41210. */
  41211. export interface ISceneLoaderPluginAsync {
  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 onProgress The callback when the load progresses
  41227. * @param fileName Defines the name of the file to load
  41228. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41229. */
  41230. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41231. meshes: AbstractMesh[];
  41232. particleSystems: IParticleSystem[];
  41233. skeletons: Skeleton[];
  41234. animationGroups: AnimationGroup[];
  41235. }>;
  41236. /**
  41237. * Load into a scene.
  41238. * @param scene The scene to load into
  41239. * @param data The data to import
  41240. * @param rootUrl The root url for scene and resources
  41241. * @param onProgress The callback when the load progresses
  41242. * @param fileName Defines the name of the file to load
  41243. * @returns Nothing
  41244. */
  41245. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41246. /**
  41247. * The callback that returns true if the data can be directly loaded.
  41248. */
  41249. canDirectLoad?: (data: string) => boolean;
  41250. /**
  41251. * The callback that allows custom handling of the root url based on the response url.
  41252. */
  41253. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41254. /**
  41255. * Load into an asset container.
  41256. * @param scene The scene to load into
  41257. * @param data The data to import
  41258. * @param rootUrl The root url for scene and resources
  41259. * @param onProgress The callback when the load progresses
  41260. * @param fileName Defines the name of the file to load
  41261. * @returns The loaded asset container
  41262. */
  41263. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41264. }
  41265. /**
  41266. * Class used to load scene from various file formats using registered plugins
  41267. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41268. */
  41269. export class SceneLoader {
  41270. /**
  41271. * No logging while loading
  41272. */
  41273. static readonly NO_LOGGING: number;
  41274. /**
  41275. * Minimal logging while loading
  41276. */
  41277. static readonly MINIMAL_LOGGING: number;
  41278. /**
  41279. * Summary logging while loading
  41280. */
  41281. static readonly SUMMARY_LOGGING: number;
  41282. /**
  41283. * Detailled logging while loading
  41284. */
  41285. static readonly DETAILED_LOGGING: number;
  41286. /**
  41287. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41288. */
  41289. static ForceFullSceneLoadingForIncremental: boolean;
  41290. /**
  41291. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41292. */
  41293. static ShowLoadingScreen: boolean;
  41294. /**
  41295. * Defines the current logging level (while loading the scene)
  41296. * @ignorenaming
  41297. */
  41298. static loggingLevel: number;
  41299. /**
  41300. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41301. */
  41302. static CleanBoneMatrixWeights: boolean;
  41303. /**
  41304. * Event raised when a plugin is used to load a scene
  41305. */
  41306. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41307. private static _registeredPlugins;
  41308. private static _getDefaultPlugin;
  41309. private static _getPluginForExtension;
  41310. private static _getPluginForDirectLoad;
  41311. private static _getPluginForFilename;
  41312. private static _getDirectLoad;
  41313. private static _loadData;
  41314. private static _getFileInfo;
  41315. /**
  41316. * Gets a plugin that can load the given extension
  41317. * @param extension defines the extension to load
  41318. * @returns a plugin or null if none works
  41319. */
  41320. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41321. /**
  41322. * Gets a boolean indicating that the given extension can be loaded
  41323. * @param extension defines the extension to load
  41324. * @returns true if the extension is supported
  41325. */
  41326. static IsPluginForExtensionAvailable(extension: string): boolean;
  41327. /**
  41328. * Adds a new plugin to the list of registered plugins
  41329. * @param plugin defines the plugin to add
  41330. */
  41331. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41332. /**
  41333. * Import meshes into a scene
  41334. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41335. * @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)
  41336. * @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)
  41337. * @param scene the instance of BABYLON.Scene to append to
  41338. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41339. * @param onProgress a callback with a progress event for each file being loaded
  41340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41341. * @param pluginExtension the extension used to determine the plugin
  41342. * @returns The loaded plugin
  41343. */
  41344. 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>;
  41345. /**
  41346. * Import meshes into a scene
  41347. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41348. * @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)
  41349. * @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)
  41350. * @param scene the instance of BABYLON.Scene to append to
  41351. * @param onProgress a callback with a progress event for each file being loaded
  41352. * @param pluginExtension the extension used to determine the plugin
  41353. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41354. */
  41355. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41356. meshes: AbstractMesh[];
  41357. particleSystems: IParticleSystem[];
  41358. skeletons: Skeleton[];
  41359. animationGroups: AnimationGroup[];
  41360. }>;
  41361. /**
  41362. * Load a scene
  41363. * @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)
  41364. * @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)
  41365. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41366. * @param onSuccess a callback with the scene when import succeeds
  41367. * @param onProgress a callback with a progress event for each file being loaded
  41368. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41369. * @param pluginExtension the extension used to determine the plugin
  41370. * @returns The loaded plugin
  41371. */
  41372. 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>;
  41373. /**
  41374. * Load a scene
  41375. * @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)
  41376. * @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)
  41377. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41378. * @param onProgress a callback with a progress event for each file being loaded
  41379. * @param pluginExtension the extension used to determine the plugin
  41380. * @returns The loaded scene
  41381. */
  41382. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41383. /**
  41384. * Append a scene
  41385. * @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)
  41386. * @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)
  41387. * @param scene is the instance of BABYLON.Scene to append to
  41388. * @param onSuccess a callback with the scene when import succeeds
  41389. * @param onProgress a callback with a progress event for each file being loaded
  41390. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41391. * @param pluginExtension the extension used to determine the plugin
  41392. * @returns The loaded plugin
  41393. */
  41394. 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>;
  41395. /**
  41396. * Append a scene
  41397. * @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)
  41398. * @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)
  41399. * @param scene is the instance of BABYLON.Scene to append to
  41400. * @param onProgress a callback with a progress event for each file being loaded
  41401. * @param pluginExtension the extension used to determine the plugin
  41402. * @returns The given scene
  41403. */
  41404. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41405. /**
  41406. * Load a scene into an asset container
  41407. * @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)
  41408. * @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)
  41409. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41410. * @param onSuccess a callback with the scene when import succeeds
  41411. * @param onProgress a callback with a progress event for each file being loaded
  41412. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41413. * @param pluginExtension the extension used to determine the plugin
  41414. * @returns The loaded plugin
  41415. */
  41416. 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>;
  41417. /**
  41418. * Load a scene into an asset container
  41419. * @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)
  41420. * @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)
  41421. * @param scene is the instance of Scene to append to
  41422. * @param onProgress a callback with a progress event for each file being loaded
  41423. * @param pluginExtension the extension used to determine the plugin
  41424. * @returns The loaded asset container
  41425. */
  41426. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41427. }
  41428. }
  41429. declare module BABYLON {
  41430. /**
  41431. * Generic Controller
  41432. */
  41433. export class GenericController extends WebVRController {
  41434. /**
  41435. * Base Url for the controller model.
  41436. */
  41437. static readonly MODEL_BASE_URL: string;
  41438. /**
  41439. * File name for the controller model.
  41440. */
  41441. static readonly MODEL_FILENAME: string;
  41442. /**
  41443. * Creates a new GenericController from a gamepad
  41444. * @param vrGamepad the gamepad that the controller should be created from
  41445. */
  41446. constructor(vrGamepad: any);
  41447. /**
  41448. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41449. * @param scene scene in which to add meshes
  41450. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41451. */
  41452. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41453. /**
  41454. * Called once for each button that changed state since the last frame
  41455. * @param buttonIdx Which button index changed
  41456. * @param state New state of the button
  41457. * @param changes Which properties on the state changed since last frame
  41458. */
  41459. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41460. }
  41461. }
  41462. declare module BABYLON {
  41463. /**
  41464. * Defines the WindowsMotionController object that the state of the windows motion controller
  41465. */
  41466. export class WindowsMotionController extends WebVRController {
  41467. /**
  41468. * The base url used to load the left and right controller models
  41469. */
  41470. static MODEL_BASE_URL: string;
  41471. /**
  41472. * The name of the left controller model file
  41473. */
  41474. static MODEL_LEFT_FILENAME: string;
  41475. /**
  41476. * The name of the right controller model file
  41477. */
  41478. static MODEL_RIGHT_FILENAME: string;
  41479. /**
  41480. * The controller name prefix for this controller type
  41481. */
  41482. static readonly GAMEPAD_ID_PREFIX: string;
  41483. /**
  41484. * The controller id pattern for this controller type
  41485. */
  41486. private static readonly GAMEPAD_ID_PATTERN;
  41487. private _loadedMeshInfo;
  41488. private readonly _mapping;
  41489. /**
  41490. * Fired when the trackpad on this controller is clicked
  41491. */
  41492. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41493. /**
  41494. * Fired when the trackpad on this controller is modified
  41495. */
  41496. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41497. /**
  41498. * The current x and y values of this controller's trackpad
  41499. */
  41500. trackpad: StickValues;
  41501. /**
  41502. * Creates a new WindowsMotionController from a gamepad
  41503. * @param vrGamepad the gamepad that the controller should be created from
  41504. */
  41505. constructor(vrGamepad: any);
  41506. /**
  41507. * Fired when the trigger on this controller is modified
  41508. */
  41509. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41510. /**
  41511. * Fired when the menu button on this controller is modified
  41512. */
  41513. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41514. /**
  41515. * Fired when the grip button on this controller is modified
  41516. */
  41517. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41518. /**
  41519. * Fired when the thumbstick button on this controller is modified
  41520. */
  41521. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41522. /**
  41523. * Fired when the touchpad button on this controller is modified
  41524. */
  41525. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41526. /**
  41527. * Fired when the touchpad values on this controller are modified
  41528. */
  41529. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41530. private _updateTrackpad;
  41531. /**
  41532. * Called once per frame by the engine.
  41533. */
  41534. update(): void;
  41535. /**
  41536. * Called once for each button that changed state since the last frame
  41537. * @param buttonIdx Which button index changed
  41538. * @param state New state of the button
  41539. * @param changes Which properties on the state changed since last frame
  41540. */
  41541. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41542. /**
  41543. * Moves the buttons on the controller mesh based on their current state
  41544. * @param buttonName the name of the button to move
  41545. * @param buttonValue the value of the button which determines the buttons new position
  41546. */
  41547. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41548. /**
  41549. * Moves the axis on the controller mesh based on its current state
  41550. * @param axis the index of the axis
  41551. * @param axisValue the value of the axis which determines the meshes new position
  41552. * @hidden
  41553. */
  41554. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41555. /**
  41556. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41557. * @param scene scene in which to add meshes
  41558. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41559. */
  41560. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41561. /**
  41562. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41563. * can be transformed by button presses and axes values, based on this._mapping.
  41564. *
  41565. * @param scene scene in which the meshes exist
  41566. * @param meshes list of meshes that make up the controller model to process
  41567. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41568. */
  41569. private processModel;
  41570. private createMeshInfo;
  41571. /**
  41572. * Gets the ray of the controller in the direction the controller is pointing
  41573. * @param length the length the resulting ray should be
  41574. * @returns a ray in the direction the controller is pointing
  41575. */
  41576. getForwardRay(length?: number): Ray;
  41577. /**
  41578. * Disposes of the controller
  41579. */
  41580. dispose(): void;
  41581. }
  41582. }
  41583. declare module BABYLON {
  41584. /**
  41585. * Oculus Touch Controller
  41586. */
  41587. export class OculusTouchController extends WebVRController {
  41588. /**
  41589. * Base Url for the controller model.
  41590. */
  41591. static MODEL_BASE_URL: string;
  41592. /**
  41593. * File name for the left controller model.
  41594. */
  41595. static MODEL_LEFT_FILENAME: string;
  41596. /**
  41597. * File name for the right controller model.
  41598. */
  41599. static MODEL_RIGHT_FILENAME: string;
  41600. /**
  41601. * Base Url for the Quest controller model.
  41602. */
  41603. static QUEST_MODEL_BASE_URL: string;
  41604. /**
  41605. * @hidden
  41606. * If the controllers are running on a device that needs the updated Quest controller models
  41607. */ private static _IsQuest: boolean;
  41608. /**
  41609. * Fired when the secondary trigger on this controller is modified
  41610. */
  41611. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41612. /**
  41613. * Fired when the thumb rest on this controller is modified
  41614. */
  41615. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41616. /**
  41617. * Creates a new OculusTouchController from a gamepad
  41618. * @param vrGamepad the gamepad that the controller should be created from
  41619. */
  41620. constructor(vrGamepad: any);
  41621. /**
  41622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41623. * @param scene scene in which to add meshes
  41624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41625. */
  41626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41627. /**
  41628. * Fired when the A button on this controller is modified
  41629. */
  41630. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41631. /**
  41632. * Fired when the B button on this controller is modified
  41633. */
  41634. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41635. /**
  41636. * Fired when the X button on this controller is modified
  41637. */
  41638. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41639. /**
  41640. * Fired when the Y button on this controller is modified
  41641. */
  41642. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41643. /**
  41644. * Called once for each button that changed state since the last frame
  41645. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41646. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41647. * 2) secondary trigger (same)
  41648. * 3) A (right) X (left), touch, pressed = value
  41649. * 4) B / Y
  41650. * 5) thumb rest
  41651. * @param buttonIdx Which button index changed
  41652. * @param state New state of the button
  41653. * @param changes Which properties on the state changed since last frame
  41654. */
  41655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41656. }
  41657. }
  41658. declare module BABYLON {
  41659. /**
  41660. * Vive Controller
  41661. */
  41662. export class ViveController extends WebVRController {
  41663. /**
  41664. * Base Url for the controller model.
  41665. */
  41666. static MODEL_BASE_URL: string;
  41667. /**
  41668. * File name for the controller model.
  41669. */
  41670. static MODEL_FILENAME: string;
  41671. /**
  41672. * Creates a new ViveController from a gamepad
  41673. * @param vrGamepad the gamepad that the controller should be created from
  41674. */
  41675. constructor(vrGamepad: any);
  41676. /**
  41677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41678. * @param scene scene in which to add meshes
  41679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41680. */
  41681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41682. /**
  41683. * Fired when the left button on this controller is modified
  41684. */
  41685. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41686. /**
  41687. * Fired when the right button on this controller is modified
  41688. */
  41689. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41690. /**
  41691. * Fired when the menu button on this controller is modified
  41692. */
  41693. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41694. /**
  41695. * Called once for each button that changed state since the last frame
  41696. * Vive mapping:
  41697. * 0: touchpad
  41698. * 1: trigger
  41699. * 2: left AND right buttons
  41700. * 3: menu button
  41701. * @param buttonIdx Which button index changed
  41702. * @param state New state of the button
  41703. * @param changes Which properties on the state changed since last frame
  41704. */
  41705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41706. }
  41707. }
  41708. declare module BABYLON {
  41709. /**
  41710. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41711. */
  41712. export class WebXRControllerModelLoader {
  41713. /**
  41714. * Creates the WebXRControllerModelLoader
  41715. * @param input xr input that creates the controllers
  41716. */
  41717. constructor(input: WebXRInput);
  41718. }
  41719. }
  41720. declare module BABYLON {
  41721. /**
  41722. * Contains an array of blocks representing the octree
  41723. */
  41724. export interface IOctreeContainer<T> {
  41725. /**
  41726. * Blocks within the octree
  41727. */
  41728. blocks: Array<OctreeBlock<T>>;
  41729. }
  41730. /**
  41731. * Class used to store a cell in an octree
  41732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41733. */
  41734. export class OctreeBlock<T> {
  41735. /**
  41736. * Gets the content of the current block
  41737. */
  41738. entries: T[];
  41739. /**
  41740. * Gets the list of block children
  41741. */
  41742. blocks: Array<OctreeBlock<T>>;
  41743. private _depth;
  41744. private _maxDepth;
  41745. private _capacity;
  41746. private _minPoint;
  41747. private _maxPoint;
  41748. private _boundingVectors;
  41749. private _creationFunc;
  41750. /**
  41751. * Creates a new block
  41752. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41753. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41754. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41755. * @param depth defines the current depth of this block in the octree
  41756. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41757. * @param creationFunc defines a callback to call when an element is added to the block
  41758. */
  41759. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41760. /**
  41761. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41762. */
  41763. readonly capacity: number;
  41764. /**
  41765. * Gets the minimum vector (in world space) of the block's bounding box
  41766. */
  41767. readonly minPoint: Vector3;
  41768. /**
  41769. * Gets the maximum vector (in world space) of the block's bounding box
  41770. */
  41771. readonly maxPoint: Vector3;
  41772. /**
  41773. * Add a new element to this block
  41774. * @param entry defines the element to add
  41775. */
  41776. addEntry(entry: T): void;
  41777. /**
  41778. * Remove an element from this block
  41779. * @param entry defines the element to remove
  41780. */
  41781. removeEntry(entry: T): void;
  41782. /**
  41783. * Add an array of elements to this block
  41784. * @param entries defines the array of elements to add
  41785. */
  41786. addEntries(entries: T[]): void;
  41787. /**
  41788. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41789. * @param frustumPlanes defines the frustum planes to test
  41790. * @param selection defines the array to store current content if selection is positive
  41791. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41792. */
  41793. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41794. /**
  41795. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41796. * @param sphereCenter defines the bounding sphere center
  41797. * @param sphereRadius defines the bounding sphere radius
  41798. * @param selection defines the array to store current content if selection is positive
  41799. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41800. */
  41801. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41802. /**
  41803. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41804. * @param ray defines the ray to test with
  41805. * @param selection defines the array to store current content if selection is positive
  41806. */
  41807. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41808. /**
  41809. * Subdivide the content into child blocks (this block will then be empty)
  41810. */
  41811. createInnerBlocks(): void;
  41812. /**
  41813. * @hidden
  41814. */ 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;
  41815. }
  41816. }
  41817. declare module BABYLON {
  41818. /**
  41819. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41820. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41821. */
  41822. export class Octree<T> {
  41823. /** 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.) */
  41824. maxDepth: number;
  41825. /**
  41826. * Blocks within the octree containing objects
  41827. */
  41828. blocks: Array<OctreeBlock<T>>;
  41829. /**
  41830. * Content stored in the octree
  41831. */
  41832. dynamicContent: T[];
  41833. private _maxBlockCapacity;
  41834. private _selectionContent;
  41835. private _creationFunc;
  41836. /**
  41837. * Creates a octree
  41838. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41839. * @param creationFunc function to be used to instatiate the octree
  41840. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41841. * @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.)
  41842. */
  41843. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41844. /** 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.) */
  41845. maxDepth?: number);
  41846. /**
  41847. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41848. * @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);
  41849. * @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);
  41850. * @param entries meshes to be added to the octree blocks
  41851. */
  41852. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41853. /**
  41854. * Adds a mesh to the octree
  41855. * @param entry Mesh to add to the octree
  41856. */
  41857. addMesh(entry: T): void;
  41858. /**
  41859. * Remove an element from the octree
  41860. * @param entry defines the element to remove
  41861. */
  41862. removeMesh(entry: T): void;
  41863. /**
  41864. * Selects an array of meshes within the frustum
  41865. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41866. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41867. * @returns array of meshes within the frustum
  41868. */
  41869. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41870. /**
  41871. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41872. * @param sphereCenter defines the bounding sphere center
  41873. * @param sphereRadius defines the bounding sphere radius
  41874. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41875. * @returns an array of objects that intersect the sphere
  41876. */
  41877. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41878. /**
  41879. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41880. * @param ray defines the ray to test with
  41881. * @returns array of intersected objects
  41882. */
  41883. intersectsRay(ray: Ray): SmartArray<T>;
  41884. /**
  41885. * Adds a mesh into the octree block if it intersects the block
  41886. */
  41887. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41888. /**
  41889. * Adds a submesh into the octree block if it intersects the block
  41890. */
  41891. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41892. }
  41893. }
  41894. declare module BABYLON {
  41895. interface Scene {
  41896. /**
  41897. * @hidden
  41898. * Backing Filed
  41899. */ private _selectionOctree: Octree<AbstractMesh>;
  41900. /**
  41901. * Gets the octree used to boost mesh selection (picking)
  41902. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41903. */
  41904. selectionOctree: Octree<AbstractMesh>;
  41905. /**
  41906. * Creates or updates the octree used to boost selection (picking)
  41907. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41908. * @param maxCapacity defines the maximum capacity per leaf
  41909. * @param maxDepth defines the maximum depth of the octree
  41910. * @returns an octree of AbstractMesh
  41911. */
  41912. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41913. }
  41914. interface AbstractMesh {
  41915. /**
  41916. * @hidden
  41917. * Backing Field
  41918. */ private _submeshesOctree: Octree<SubMesh>;
  41919. /**
  41920. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41921. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41922. * @param maxCapacity defines the maximum size of each block (64 by default)
  41923. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41924. * @returns the new octree
  41925. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41927. */
  41928. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41929. }
  41930. /**
  41931. * Defines the octree scene component responsible to manage any octrees
  41932. * in a given scene.
  41933. */
  41934. export class OctreeSceneComponent {
  41935. /**
  41936. * The component name help to identify the component in the list of scene components.
  41937. */
  41938. readonly name: string;
  41939. /**
  41940. * The scene the component belongs to.
  41941. */
  41942. scene: Scene;
  41943. /**
  41944. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41945. */
  41946. readonly checksIsEnabled: boolean;
  41947. /**
  41948. * Creates a new instance of the component for the given scene
  41949. * @param scene Defines the scene to register the component in
  41950. */
  41951. constructor(scene: Scene);
  41952. /**
  41953. * Registers the component in a given scene
  41954. */
  41955. register(): void;
  41956. /**
  41957. * Return the list of active meshes
  41958. * @returns the list of active meshes
  41959. */
  41960. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41961. /**
  41962. * Return the list of active sub meshes
  41963. * @param mesh The mesh to get the candidates sub meshes from
  41964. * @returns the list of active sub meshes
  41965. */
  41966. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41967. private _tempRay;
  41968. /**
  41969. * Return the list of sub meshes intersecting with a given local ray
  41970. * @param mesh defines the mesh to find the submesh for
  41971. * @param localRay defines the ray in local space
  41972. * @returns the list of intersecting sub meshes
  41973. */
  41974. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41975. /**
  41976. * Return the list of sub meshes colliding with a collider
  41977. * @param mesh defines the mesh to find the submesh for
  41978. * @param collider defines the collider to evaluate the collision against
  41979. * @returns the list of colliding sub meshes
  41980. */
  41981. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41982. /**
  41983. * Rebuilds the elements related to this component in case of
  41984. * context lost for instance.
  41985. */
  41986. rebuild(): void;
  41987. /**
  41988. * Disposes the component and the associated ressources.
  41989. */
  41990. dispose(): void;
  41991. }
  41992. }
  41993. declare module BABYLON {
  41994. /**
  41995. * Renders a layer on top of an existing scene
  41996. */
  41997. export class UtilityLayerRenderer implements IDisposable {
  41998. /** the original scene that will be rendered on top of */
  41999. originalScene: Scene;
  42000. private _pointerCaptures;
  42001. private _lastPointerEvents;
  42002. private static _DefaultUtilityLayer;
  42003. private static _DefaultKeepDepthUtilityLayer;
  42004. private _sharedGizmoLight;
  42005. private _renderCamera;
  42006. /**
  42007. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42008. * @returns the camera that is used when rendering the utility layer
  42009. */
  42010. getRenderCamera(): Nullable<Camera>;
  42011. /**
  42012. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42013. * @param cam the camera that should be used when rendering the utility layer
  42014. */
  42015. setRenderCamera(cam: Nullable<Camera>): void;
  42016. /**
  42017. * @hidden
  42018. * Light which used by gizmos to get light shading
  42019. */ private _getSharedGizmoLight(): HemisphericLight;
  42020. /**
  42021. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42022. */
  42023. pickUtilitySceneFirst: boolean;
  42024. /**
  42025. * 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)
  42026. */
  42027. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42028. /**
  42029. * 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)
  42030. */
  42031. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42032. /**
  42033. * The scene that is rendered on top of the original scene
  42034. */
  42035. utilityLayerScene: Scene;
  42036. /**
  42037. * If the utility layer should automatically be rendered on top of existing scene
  42038. */
  42039. shouldRender: boolean;
  42040. /**
  42041. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42042. */
  42043. onlyCheckPointerDownEvents: boolean;
  42044. /**
  42045. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42046. */
  42047. processAllEvents: boolean;
  42048. /**
  42049. * Observable raised when the pointer move from the utility layer scene to the main scene
  42050. */
  42051. onPointerOutObservable: Observable<number>;
  42052. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42053. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42054. private _afterRenderObserver;
  42055. private _sceneDisposeObserver;
  42056. private _originalPointerObserver;
  42057. /**
  42058. * Instantiates a UtilityLayerRenderer
  42059. * @param originalScene the original scene that will be rendered on top of
  42060. * @param handleEvents boolean indicating if the utility layer should handle events
  42061. */
  42062. constructor(
  42063. /** the original scene that will be rendered on top of */
  42064. originalScene: Scene, handleEvents?: boolean);
  42065. private _notifyObservers;
  42066. /**
  42067. * Renders the utility layers scene on top of the original scene
  42068. */
  42069. render(): void;
  42070. /**
  42071. * Disposes of the renderer
  42072. */
  42073. dispose(): void;
  42074. private _updateCamera;
  42075. }
  42076. }
  42077. declare module BABYLON {
  42078. /**
  42079. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42080. */
  42081. export class Gizmo implements IDisposable {
  42082. /** The utility layer the gizmo will be added to */
  42083. gizmoLayer: UtilityLayerRenderer;
  42084. /**
  42085. * The root mesh of the gizmo
  42086. */ private _rootMesh: Mesh;
  42087. private _attachedMesh;
  42088. /**
  42089. * Ratio for the scale of the gizmo (Default: 1)
  42090. */
  42091. scaleRatio: number;
  42092. /**
  42093. * If a custom mesh has been set (Default: false)
  42094. */
  42095. protected _customMeshSet: boolean;
  42096. /**
  42097. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42098. * * When set, interactions will be enabled
  42099. */
  42100. attachedMesh: Nullable<AbstractMesh>;
  42101. /**
  42102. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42103. * @param mesh The mesh to replace the default mesh of the gizmo
  42104. */
  42105. setCustomMesh(mesh: Mesh): void;
  42106. /**
  42107. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42108. */
  42109. updateGizmoRotationToMatchAttachedMesh: boolean;
  42110. /**
  42111. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42112. */
  42113. updateGizmoPositionToMatchAttachedMesh: boolean;
  42114. /**
  42115. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42116. */
  42117. updateScale: boolean;
  42118. protected _interactionsEnabled: boolean;
  42119. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42120. private _beforeRenderObserver;
  42121. private _tempVector;
  42122. /**
  42123. * Creates a gizmo
  42124. * @param gizmoLayer The utility layer the gizmo will be added to
  42125. */
  42126. constructor(
  42127. /** The utility layer the gizmo will be added to */
  42128. gizmoLayer?: UtilityLayerRenderer);
  42129. /**
  42130. * Updates the gizmo to match the attached mesh's position/rotation
  42131. */
  42132. protected _update(): void;
  42133. /**
  42134. * Disposes of the gizmo
  42135. */
  42136. dispose(): void;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * Single plane drag gizmo
  42142. */
  42143. export class PlaneDragGizmo extends Gizmo {
  42144. /**
  42145. * Drag behavior responsible for the gizmos dragging interactions
  42146. */
  42147. dragBehavior: PointerDragBehavior;
  42148. private _pointerObserver;
  42149. /**
  42150. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42151. */
  42152. snapDistance: number;
  42153. /**
  42154. * Event that fires each time the gizmo snaps to a new location.
  42155. * * snapDistance is the the change in distance
  42156. */
  42157. onSnapObservable: Observable<{
  42158. snapDistance: number;
  42159. }>;
  42160. private _plane;
  42161. private _coloredMaterial;
  42162. private _hoverMaterial;
  42163. private _isEnabled;
  42164. private _parent;
  42165. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42166. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42167. /**
  42168. * Creates a PlaneDragGizmo
  42169. * @param gizmoLayer The utility layer the gizmo will be added to
  42170. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42171. * @param color The color of the gizmo
  42172. */
  42173. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42174. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42175. /**
  42176. * If the gizmo is enabled
  42177. */
  42178. isEnabled: boolean;
  42179. /**
  42180. * Disposes of the gizmo
  42181. */
  42182. dispose(): void;
  42183. }
  42184. }
  42185. declare module BABYLON {
  42186. /**
  42187. * Gizmo that enables dragging a mesh along 3 axis
  42188. */
  42189. export class PositionGizmo extends Gizmo {
  42190. /**
  42191. * Internal gizmo used for interactions on the x axis
  42192. */
  42193. xGizmo: AxisDragGizmo;
  42194. /**
  42195. * Internal gizmo used for interactions on the y axis
  42196. */
  42197. yGizmo: AxisDragGizmo;
  42198. /**
  42199. * Internal gizmo used for interactions on the z axis
  42200. */
  42201. zGizmo: AxisDragGizmo;
  42202. /**
  42203. * Internal gizmo used for interactions on the yz plane
  42204. */
  42205. xPlaneGizmo: PlaneDragGizmo;
  42206. /**
  42207. * Internal gizmo used for interactions on the xz plane
  42208. */
  42209. yPlaneGizmo: PlaneDragGizmo;
  42210. /**
  42211. * Internal gizmo used for interactions on the xy plane
  42212. */
  42213. zPlaneGizmo: PlaneDragGizmo;
  42214. /**
  42215. * private variables
  42216. */
  42217. private _meshAttached;
  42218. private _updateGizmoRotationToMatchAttachedMesh;
  42219. private _snapDistance;
  42220. private _scaleRatio;
  42221. /** Fires an event when any of it's sub gizmos are dragged */
  42222. onDragStartObservable: Observable<unknown>;
  42223. /** Fires an event when any of it's sub gizmos are released from dragging */
  42224. onDragEndObservable: Observable<unknown>;
  42225. /**
  42226. * If set to true, planar drag is enabled
  42227. */
  42228. private _planarGizmoEnabled;
  42229. attachedMesh: Nullable<AbstractMesh>;
  42230. /**
  42231. * Creates a PositionGizmo
  42232. * @param gizmoLayer The utility layer the gizmo will be added to
  42233. */
  42234. constructor(gizmoLayer?: UtilityLayerRenderer);
  42235. /**
  42236. * If the planar drag gizmo is enabled
  42237. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42238. */
  42239. planarGizmoEnabled: boolean;
  42240. updateGizmoRotationToMatchAttachedMesh: boolean;
  42241. /**
  42242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42243. */
  42244. snapDistance: number;
  42245. /**
  42246. * Ratio for the scale of the gizmo (Default: 1)
  42247. */
  42248. scaleRatio: number;
  42249. /**
  42250. * Disposes of the gizmo
  42251. */
  42252. dispose(): void;
  42253. /**
  42254. * CustomMeshes are not supported by this gizmo
  42255. * @param mesh The mesh to replace the default mesh of the gizmo
  42256. */
  42257. setCustomMesh(mesh: Mesh): void;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * Single axis drag gizmo
  42263. */
  42264. export class AxisDragGizmo extends Gizmo {
  42265. /**
  42266. * Drag behavior responsible for the gizmos dragging interactions
  42267. */
  42268. dragBehavior: PointerDragBehavior;
  42269. private _pointerObserver;
  42270. /**
  42271. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42272. */
  42273. snapDistance: number;
  42274. /**
  42275. * Event that fires each time the gizmo snaps to a new location.
  42276. * * snapDistance is the the change in distance
  42277. */
  42278. onSnapObservable: Observable<{
  42279. snapDistance: number;
  42280. }>;
  42281. private _isEnabled;
  42282. private _parent;
  42283. private _arrow;
  42284. private _coloredMaterial;
  42285. private _hoverMaterial;
  42286. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42287. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42288. /**
  42289. * Creates an AxisDragGizmo
  42290. * @param gizmoLayer The utility layer the gizmo will be added to
  42291. * @param dragAxis The axis which the gizmo will be able to drag on
  42292. * @param color The color of the gizmo
  42293. */
  42294. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42295. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42296. /**
  42297. * If the gizmo is enabled
  42298. */
  42299. isEnabled: boolean;
  42300. /**
  42301. * Disposes of the gizmo
  42302. */
  42303. dispose(): void;
  42304. }
  42305. }
  42306. declare module BABYLON.Debug {
  42307. /**
  42308. * The Axes viewer will show 3 axes in a specific point in space
  42309. */
  42310. export class AxesViewer {
  42311. private _xAxis;
  42312. private _yAxis;
  42313. private _zAxis;
  42314. private _scaleLinesFactor;
  42315. private _instanced;
  42316. /**
  42317. * Gets the hosting scene
  42318. */
  42319. scene: Scene;
  42320. /**
  42321. * Gets or sets a number used to scale line length
  42322. */
  42323. scaleLines: number;
  42324. /** Gets the node hierarchy used to render x-axis */
  42325. readonly xAxis: TransformNode;
  42326. /** Gets the node hierarchy used to render y-axis */
  42327. readonly yAxis: TransformNode;
  42328. /** Gets the node hierarchy used to render z-axis */
  42329. readonly zAxis: TransformNode;
  42330. /**
  42331. * Creates a new AxesViewer
  42332. * @param scene defines the hosting scene
  42333. * @param scaleLines defines a number used to scale line length (1 by default)
  42334. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42335. * @param xAxis defines the node hierarchy used to render the x-axis
  42336. * @param yAxis defines the node hierarchy used to render the y-axis
  42337. * @param zAxis defines the node hierarchy used to render the z-axis
  42338. */
  42339. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42340. /**
  42341. * Force the viewer to update
  42342. * @param position defines the position of the viewer
  42343. * @param xaxis defines the x axis of the viewer
  42344. * @param yaxis defines the y axis of the viewer
  42345. * @param zaxis defines the z axis of the viewer
  42346. */
  42347. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42348. /**
  42349. * Creates an instance of this axes viewer.
  42350. * @returns a new axes viewer with instanced meshes
  42351. */
  42352. createInstance(): AxesViewer;
  42353. /** Releases resources */
  42354. dispose(): void;
  42355. private static _SetRenderingGroupId;
  42356. }
  42357. }
  42358. declare module BABYLON.Debug {
  42359. /**
  42360. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42361. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42362. */
  42363. export class BoneAxesViewer extends AxesViewer {
  42364. /**
  42365. * Gets or sets the target mesh where to display the axes viewer
  42366. */
  42367. mesh: Nullable<Mesh>;
  42368. /**
  42369. * Gets or sets the target bone where to display the axes viewer
  42370. */
  42371. bone: Nullable<Bone>;
  42372. /** Gets current position */
  42373. pos: Vector3;
  42374. /** Gets direction of X axis */
  42375. xaxis: Vector3;
  42376. /** Gets direction of Y axis */
  42377. yaxis: Vector3;
  42378. /** Gets direction of Z axis */
  42379. zaxis: Vector3;
  42380. /**
  42381. * Creates a new BoneAxesViewer
  42382. * @param scene defines the hosting scene
  42383. * @param bone defines the target bone
  42384. * @param mesh defines the target mesh
  42385. * @param scaleLines defines a scaling factor for line length (1 by default)
  42386. */
  42387. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42388. /**
  42389. * Force the viewer to update
  42390. */
  42391. update(): void;
  42392. /** Releases resources */
  42393. dispose(): void;
  42394. }
  42395. }
  42396. declare module BABYLON {
  42397. /**
  42398. * Interface used to define scene explorer extensibility option
  42399. */
  42400. export interface IExplorerExtensibilityOption {
  42401. /**
  42402. * Define the option label
  42403. */
  42404. label: string;
  42405. /**
  42406. * Defines the action to execute on click
  42407. */
  42408. action: (entity: any) => void;
  42409. }
  42410. /**
  42411. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42412. */
  42413. export interface IExplorerExtensibilityGroup {
  42414. /**
  42415. * Defines a predicate to test if a given type mut be extended
  42416. */
  42417. predicate: (entity: any) => boolean;
  42418. /**
  42419. * Gets the list of options added to a type
  42420. */
  42421. entries: IExplorerExtensibilityOption[];
  42422. }
  42423. /**
  42424. * Interface used to define the options to use to create the Inspector
  42425. */
  42426. export interface IInspectorOptions {
  42427. /**
  42428. * Display in overlay mode (default: false)
  42429. */
  42430. overlay?: boolean;
  42431. /**
  42432. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42433. */
  42434. globalRoot?: HTMLElement;
  42435. /**
  42436. * Display the Scene explorer
  42437. */
  42438. showExplorer?: boolean;
  42439. /**
  42440. * Display the property inspector
  42441. */
  42442. showInspector?: boolean;
  42443. /**
  42444. * Display in embed mode (both panes on the right)
  42445. */
  42446. embedMode?: boolean;
  42447. /**
  42448. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42449. */
  42450. handleResize?: boolean;
  42451. /**
  42452. * Allow the panes to popup (default: true)
  42453. */
  42454. enablePopup?: boolean;
  42455. /**
  42456. * Allow the panes to be closed by users (default: true)
  42457. */
  42458. enableClose?: boolean;
  42459. /**
  42460. * Optional list of extensibility entries
  42461. */
  42462. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42463. /**
  42464. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42465. */
  42466. inspectorURL?: string;
  42467. }
  42468. interface Scene {
  42469. /**
  42470. * @hidden
  42471. * Backing field
  42472. */ private _debugLayer: DebugLayer;
  42473. /**
  42474. * Gets the debug layer (aka Inspector) associated with the scene
  42475. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42476. */
  42477. debugLayer: DebugLayer;
  42478. }
  42479. /**
  42480. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42481. * what is happening in your scene
  42482. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42483. */
  42484. export class DebugLayer {
  42485. /**
  42486. * Define the url to get the inspector script from.
  42487. * By default it uses the babylonjs CDN.
  42488. * @ignoreNaming
  42489. */
  42490. static InspectorURL: string;
  42491. private _scene;
  42492. private BJSINSPECTOR;
  42493. private _onPropertyChangedObservable?;
  42494. /**
  42495. * Observable triggered when a property is changed through the inspector.
  42496. */
  42497. readonly onPropertyChangedObservable: any;
  42498. /**
  42499. * Instantiates a new debug layer.
  42500. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42501. * what is happening in your scene
  42502. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42503. * @param scene Defines the scene to inspect
  42504. */
  42505. constructor(scene: Scene);
  42506. /** Creates the inspector window. */
  42507. private _createInspector;
  42508. /**
  42509. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42510. * @param entity defines the entity to select
  42511. * @param lineContainerTitle defines the specific block to highlight
  42512. */
  42513. select(entity: any, lineContainerTitle?: string): void;
  42514. /** Get the inspector from bundle or global */
  42515. private _getGlobalInspector;
  42516. /**
  42517. * Get if the inspector is visible or not.
  42518. * @returns true if visible otherwise, false
  42519. */
  42520. isVisible(): boolean;
  42521. /**
  42522. * Hide the inspector and close its window.
  42523. */
  42524. hide(): void;
  42525. /**
  42526. * Launch the debugLayer.
  42527. * @param config Define the configuration of the inspector
  42528. * @return a promise fulfilled when the debug layer is visible
  42529. */
  42530. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42531. }
  42532. }
  42533. declare module BABYLON {
  42534. /**
  42535. * Class containing static functions to help procedurally build meshes
  42536. */
  42537. export class BoxBuilder {
  42538. /**
  42539. * Creates a box mesh
  42540. * * The parameter `size` sets the size (float) of each box side (default 1)
  42541. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42542. * * 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)
  42543. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42545. * * 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
  42546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42547. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42548. * @param name defines the name of the mesh
  42549. * @param options defines the options used to create the mesh
  42550. * @param scene defines the hosting scene
  42551. * @returns the box mesh
  42552. */
  42553. static CreateBox(name: string, options: {
  42554. size?: number;
  42555. width?: number;
  42556. height?: number;
  42557. depth?: number;
  42558. faceUV?: Vector4[];
  42559. faceColors?: Color4[];
  42560. sideOrientation?: number;
  42561. frontUVs?: Vector4;
  42562. backUVs?: Vector4;
  42563. wrap?: boolean;
  42564. topBaseAt?: number;
  42565. bottomBaseAt?: number;
  42566. updatable?: boolean;
  42567. }, scene?: Nullable<Scene>): Mesh;
  42568. }
  42569. }
  42570. declare module BABYLON {
  42571. /**
  42572. * Class containing static functions to help procedurally build meshes
  42573. */
  42574. export class SphereBuilder {
  42575. /**
  42576. * Creates a sphere mesh
  42577. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42578. * * 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`)
  42579. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42580. * * 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
  42581. * * 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)
  42582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42583. * * 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
  42584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42585. * @param name defines the name of the mesh
  42586. * @param options defines the options used to create the mesh
  42587. * @param scene defines the hosting scene
  42588. * @returns the sphere mesh
  42589. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42590. */
  42591. static CreateSphere(name: string, options: {
  42592. segments?: number;
  42593. diameter?: number;
  42594. diameterX?: number;
  42595. diameterY?: number;
  42596. diameterZ?: number;
  42597. arc?: number;
  42598. slice?: number;
  42599. sideOrientation?: number;
  42600. frontUVs?: Vector4;
  42601. backUVs?: Vector4;
  42602. updatable?: boolean;
  42603. }, scene?: Nullable<Scene>): Mesh;
  42604. }
  42605. }
  42606. declare module BABYLON.Debug {
  42607. /**
  42608. * Used to show the physics impostor around the specific mesh
  42609. */
  42610. export class PhysicsViewer {
  42611. /** @hidden */
  42612. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42613. /** @hidden */
  42614. protected _meshes: Array<Nullable<AbstractMesh>>;
  42615. /** @hidden */
  42616. protected _scene: Nullable<Scene>;
  42617. /** @hidden */
  42618. protected _numMeshes: number;
  42619. /** @hidden */
  42620. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42621. private _renderFunction;
  42622. private _utilityLayer;
  42623. private _debugBoxMesh;
  42624. private _debugSphereMesh;
  42625. private _debugCylinderMesh;
  42626. private _debugMaterial;
  42627. private _debugMeshMeshes;
  42628. /**
  42629. * Creates a new PhysicsViewer
  42630. * @param scene defines the hosting scene
  42631. */
  42632. constructor(scene: Scene);
  42633. /** @hidden */
  42634. protected _updateDebugMeshes(): void;
  42635. /**
  42636. * Renders a specified physic impostor
  42637. * @param impostor defines the impostor to render
  42638. * @param targetMesh defines the mesh represented by the impostor
  42639. * @returns the new debug mesh used to render the impostor
  42640. */
  42641. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42642. /**
  42643. * Hides a specified physic impostor
  42644. * @param impostor defines the impostor to hide
  42645. */
  42646. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42647. private _getDebugMaterial;
  42648. private _getDebugBoxMesh;
  42649. private _getDebugSphereMesh;
  42650. private _getDebugCylinderMesh;
  42651. private _getDebugMeshMesh;
  42652. private _getDebugMesh;
  42653. /** Releases all resources */
  42654. dispose(): void;
  42655. }
  42656. }
  42657. declare module BABYLON {
  42658. /**
  42659. * Class containing static functions to help procedurally build meshes
  42660. */
  42661. export class LinesBuilder {
  42662. /**
  42663. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42664. * * 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
  42665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42666. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42667. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42668. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42669. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42670. * * 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
  42671. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42674. * @param name defines the name of the new line system
  42675. * @param options defines the options used to create the line system
  42676. * @param scene defines the hosting scene
  42677. * @returns a new line system mesh
  42678. */
  42679. static CreateLineSystem(name: string, options: {
  42680. lines: Vector3[][];
  42681. updatable?: boolean;
  42682. instance?: Nullable<LinesMesh>;
  42683. colors?: Nullable<Color4[][]>;
  42684. useVertexAlpha?: boolean;
  42685. }, scene: Nullable<Scene>): LinesMesh;
  42686. /**
  42687. * Creates a line mesh
  42688. * 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
  42689. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42690. * * The parameter `points` is an array successive Vector3
  42691. * * 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
  42692. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42693. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42694. * * When updating an instance, remember that only point positions can change, not the number of points
  42695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42697. * @param name defines the name of the new line system
  42698. * @param options defines the options used to create the line system
  42699. * @param scene defines the hosting scene
  42700. * @returns a new line mesh
  42701. */
  42702. static CreateLines(name: string, options: {
  42703. points: Vector3[];
  42704. updatable?: boolean;
  42705. instance?: Nullable<LinesMesh>;
  42706. colors?: Color4[];
  42707. useVertexAlpha?: boolean;
  42708. }, scene?: Nullable<Scene>): LinesMesh;
  42709. /**
  42710. * Creates a dashed line mesh
  42711. * * 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
  42712. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42713. * * The parameter `points` is an array successive Vector3
  42714. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42715. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42716. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42717. * * 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
  42718. * * When updating an instance, remember that only point positions can change, not the number of points
  42719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42720. * @param name defines the name of the mesh
  42721. * @param options defines the options used to create the mesh
  42722. * @param scene defines the hosting scene
  42723. * @returns the dashed line mesh
  42724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42725. */
  42726. static CreateDashedLines(name: string, options: {
  42727. points: Vector3[];
  42728. dashSize?: number;
  42729. gapSize?: number;
  42730. dashNb?: number;
  42731. updatable?: boolean;
  42732. instance?: LinesMesh;
  42733. }, scene?: Nullable<Scene>): LinesMesh;
  42734. }
  42735. }
  42736. declare module BABYLON {
  42737. /**
  42738. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42739. * in order to better appreciate the issue one might have.
  42740. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42741. */
  42742. export class RayHelper {
  42743. /**
  42744. * Defines the ray we are currently tryin to visualize.
  42745. */
  42746. ray: Nullable<Ray>;
  42747. private _renderPoints;
  42748. private _renderLine;
  42749. private _renderFunction;
  42750. private _scene;
  42751. private _updateToMeshFunction;
  42752. private _attachedToMesh;
  42753. private _meshSpaceDirection;
  42754. private _meshSpaceOrigin;
  42755. /**
  42756. * Helper function to create a colored helper in a scene in one line.
  42757. * @param ray Defines the ray we are currently tryin to visualize
  42758. * @param scene Defines the scene the ray is used in
  42759. * @param color Defines the color we want to see the ray in
  42760. * @returns The newly created ray helper.
  42761. */
  42762. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42763. /**
  42764. * Instantiate a new ray helper.
  42765. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42766. * in order to better appreciate the issue one might have.
  42767. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42768. * @param ray Defines the ray we are currently tryin to visualize
  42769. */
  42770. constructor(ray: Ray);
  42771. /**
  42772. * Shows the ray we are willing to debug.
  42773. * @param scene Defines the scene the ray needs to be rendered in
  42774. * @param color Defines the color the ray needs to be rendered in
  42775. */
  42776. show(scene: Scene, color?: Color3): void;
  42777. /**
  42778. * Hides the ray we are debugging.
  42779. */
  42780. hide(): void;
  42781. private _render;
  42782. /**
  42783. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42784. * @param mesh Defines the mesh we want the helper attached to
  42785. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42786. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42787. * @param length Defines the length of the ray
  42788. */
  42789. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42790. /**
  42791. * Detach the ray helper from the mesh it has previously been attached to.
  42792. */
  42793. detachFromMesh(): void;
  42794. private _updateToMesh;
  42795. /**
  42796. * Dispose the helper and release its associated resources.
  42797. */
  42798. dispose(): void;
  42799. }
  42800. }
  42801. declare module BABYLON.Debug {
  42802. /**
  42803. * Class used to render a debug view of a given skeleton
  42804. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42805. */
  42806. export class SkeletonViewer {
  42807. /** defines the skeleton to render */
  42808. skeleton: Skeleton;
  42809. /** defines the mesh attached to the skeleton */
  42810. mesh: AbstractMesh;
  42811. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42812. autoUpdateBonesMatrices: boolean;
  42813. /** defines the rendering group id to use with the viewer */
  42814. renderingGroupId: number;
  42815. /** Gets or sets the color used to render the skeleton */
  42816. color: Color3;
  42817. private _scene;
  42818. private _debugLines;
  42819. private _debugMesh;
  42820. private _isEnabled;
  42821. private _renderFunction;
  42822. private _utilityLayer;
  42823. /**
  42824. * Returns the mesh used to render the bones
  42825. */
  42826. readonly debugMesh: Nullable<LinesMesh>;
  42827. /**
  42828. * Creates a new SkeletonViewer
  42829. * @param skeleton defines the skeleton to render
  42830. * @param mesh defines the mesh attached to the skeleton
  42831. * @param scene defines the hosting scene
  42832. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42833. * @param renderingGroupId defines the rendering group id to use with the viewer
  42834. */
  42835. constructor(
  42836. /** defines the skeleton to render */
  42837. skeleton: Skeleton,
  42838. /** defines the mesh attached to the skeleton */
  42839. mesh: AbstractMesh, scene: Scene,
  42840. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42841. autoUpdateBonesMatrices?: boolean,
  42842. /** defines the rendering group id to use with the viewer */
  42843. renderingGroupId?: number);
  42844. /** Gets or sets a boolean indicating if the viewer is enabled */
  42845. isEnabled: boolean;
  42846. private _getBonePosition;
  42847. private _getLinesForBonesWithLength;
  42848. private _getLinesForBonesNoLength;
  42849. /** Update the viewer to sync with current skeleton state */
  42850. update(): void;
  42851. /** Release associated resources */
  42852. dispose(): void;
  42853. }
  42854. }
  42855. declare module BABYLON {
  42856. /**
  42857. * Options to create the null engine
  42858. */
  42859. export class NullEngineOptions {
  42860. /**
  42861. * Render width (Default: 512)
  42862. */
  42863. renderWidth: number;
  42864. /**
  42865. * Render height (Default: 256)
  42866. */
  42867. renderHeight: number;
  42868. /**
  42869. * Texture size (Default: 512)
  42870. */
  42871. textureSize: number;
  42872. /**
  42873. * If delta time between frames should be constant
  42874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42875. */
  42876. deterministicLockstep: boolean;
  42877. /**
  42878. * Maximum about of steps between frames (Default: 4)
  42879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42880. */
  42881. lockstepMaxSteps: number;
  42882. }
  42883. /**
  42884. * The null engine class provides support for headless version of babylon.js.
  42885. * This can be used in server side scenario or for testing purposes
  42886. */
  42887. export class NullEngine extends Engine {
  42888. private _options;
  42889. /**
  42890. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42891. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42892. * @returns true if engine is in deterministic lock step mode
  42893. */
  42894. isDeterministicLockStep(): boolean;
  42895. /**
  42896. * Gets the max steps when engine is running in deterministic lock step
  42897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42898. * @returns the max steps
  42899. */
  42900. getLockstepMaxSteps(): number;
  42901. /**
  42902. * Gets the current hardware scaling level.
  42903. * By default the hardware scaling level is computed from the window device ratio.
  42904. * 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.
  42905. * @returns a number indicating the current hardware scaling level
  42906. */
  42907. getHardwareScalingLevel(): number;
  42908. constructor(options?: NullEngineOptions);
  42909. /**
  42910. * Creates a vertex buffer
  42911. * @param vertices the data for the vertex buffer
  42912. * @returns the new WebGL static buffer
  42913. */
  42914. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42915. /**
  42916. * Creates a new index buffer
  42917. * @param indices defines the content of the index buffer
  42918. * @param updatable defines if the index buffer must be updatable
  42919. * @returns a new webGL buffer
  42920. */
  42921. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42922. /**
  42923. * Clear the current render buffer or the current render target (if any is set up)
  42924. * @param color defines the color to use
  42925. * @param backBuffer defines if the back buffer must be cleared
  42926. * @param depth defines if the depth buffer must be cleared
  42927. * @param stencil defines if the stencil buffer must be cleared
  42928. */
  42929. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42930. /**
  42931. * Gets the current render width
  42932. * @param useScreen defines if screen size must be used (or the current render target if any)
  42933. * @returns a number defining the current render width
  42934. */
  42935. getRenderWidth(useScreen?: boolean): number;
  42936. /**
  42937. * Gets the current render height
  42938. * @param useScreen defines if screen size must be used (or the current render target if any)
  42939. * @returns a number defining the current render height
  42940. */
  42941. getRenderHeight(useScreen?: boolean): number;
  42942. /**
  42943. * Set the WebGL's viewport
  42944. * @param viewport defines the viewport element to be used
  42945. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  42946. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  42947. */
  42948. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42949. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42950. /**
  42951. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42952. * @param pipelineContext defines the pipeline context to use
  42953. * @param uniformsNames defines the list of uniform names
  42954. * @returns an array of webGL uniform locations
  42955. */
  42956. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42957. /**
  42958. * Gets the lsit of active attributes for a given webGL program
  42959. * @param pipelineContext defines the pipeline context to use
  42960. * @param attributesNames defines the list of attribute names to get
  42961. * @returns an array of indices indicating the offset of each attribute
  42962. */
  42963. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42964. /**
  42965. * Binds an effect to the webGL context
  42966. * @param effect defines the effect to bind
  42967. */
  42968. bindSamplers(effect: Effect): void;
  42969. /**
  42970. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42971. * @param effect defines the effect to activate
  42972. */
  42973. enableEffect(effect: Effect): void;
  42974. /**
  42975. * Set various states to the webGL context
  42976. * @param culling defines backface culling state
  42977. * @param zOffset defines the value to apply to zOffset (0 by default)
  42978. * @param force defines if states must be applied even if cache is up to date
  42979. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42980. */
  42981. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42982. /**
  42983. * Set the value of an uniform to an array of int32
  42984. * @param uniform defines the webGL uniform location where to store the value
  42985. * @param array defines the array of int32 to store
  42986. */
  42987. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42988. /**
  42989. * Set the value of an uniform to an array of int32 (stored as vec2)
  42990. * @param uniform defines the webGL uniform location where to store the value
  42991. * @param array defines the array of int32 to store
  42992. */
  42993. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42994. /**
  42995. * Set the value of an uniform to an array of int32 (stored as vec3)
  42996. * @param uniform defines the webGL uniform location where to store the value
  42997. * @param array defines the array of int32 to store
  42998. */
  42999. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43000. /**
  43001. * Set the value of an uniform to an array of int32 (stored as vec4)
  43002. * @param uniform defines the webGL uniform location where to store the value
  43003. * @param array defines the array of int32 to store
  43004. */
  43005. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43006. /**
  43007. * Set the value of an uniform to an array of float32
  43008. * @param uniform defines the webGL uniform location where to store the value
  43009. * @param array defines the array of float32 to store
  43010. */
  43011. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43012. /**
  43013. * Set the value of an uniform to an array of float32 (stored as vec2)
  43014. * @param uniform defines the webGL uniform location where to store the value
  43015. * @param array defines the array of float32 to store
  43016. */
  43017. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43018. /**
  43019. * Set the value of an uniform to an array of float32 (stored as vec3)
  43020. * @param uniform defines the webGL uniform location where to store the value
  43021. * @param array defines the array of float32 to store
  43022. */
  43023. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43024. /**
  43025. * Set the value of an uniform to an array of float32 (stored as vec4)
  43026. * @param uniform defines the webGL uniform location where to store the value
  43027. * @param array defines the array of float32 to store
  43028. */
  43029. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43030. /**
  43031. * Set the value of an uniform to an array of number
  43032. * @param uniform defines the webGL uniform location where to store the value
  43033. * @param array defines the array of number to store
  43034. */
  43035. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43036. /**
  43037. * Set the value of an uniform to an array of number (stored as vec2)
  43038. * @param uniform defines the webGL uniform location where to store the value
  43039. * @param array defines the array of number to store
  43040. */
  43041. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43042. /**
  43043. * Set the value of an uniform to an array of number (stored as vec3)
  43044. * @param uniform defines the webGL uniform location where to store the value
  43045. * @param array defines the array of number to store
  43046. */
  43047. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43048. /**
  43049. * Set the value of an uniform to an array of number (stored as vec4)
  43050. * @param uniform defines the webGL uniform location where to store the value
  43051. * @param array defines the array of number to store
  43052. */
  43053. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43054. /**
  43055. * Set the value of an uniform to an array of float32 (stored as matrices)
  43056. * @param uniform defines the webGL uniform location where to store the value
  43057. * @param matrices defines the array of float32 to store
  43058. */
  43059. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43060. /**
  43061. * Set the value of an uniform to a matrix (3x3)
  43062. * @param uniform defines the webGL uniform location where to store the value
  43063. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43064. */
  43065. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43066. /**
  43067. * Set the value of an uniform to a matrix (2x2)
  43068. * @param uniform defines the webGL uniform location where to store the value
  43069. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43070. */
  43071. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43072. /**
  43073. * Set the value of an uniform to a number (float)
  43074. * @param uniform defines the webGL uniform location where to store the value
  43075. * @param value defines the float number to store
  43076. */
  43077. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43078. /**
  43079. * Set the value of an uniform to a vec2
  43080. * @param uniform defines the webGL uniform location where to store the value
  43081. * @param x defines the 1st component of the value
  43082. * @param y defines the 2nd component of the value
  43083. */
  43084. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43085. /**
  43086. * Set the value of an uniform to a vec3
  43087. * @param uniform defines the webGL uniform location where to store the value
  43088. * @param x defines the 1st component of the value
  43089. * @param y defines the 2nd component of the value
  43090. * @param z defines the 3rd component of the value
  43091. */
  43092. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43093. /**
  43094. * Set the value of an uniform to a boolean
  43095. * @param uniform defines the webGL uniform location where to store the value
  43096. * @param bool defines the boolean to store
  43097. */
  43098. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43099. /**
  43100. * Set the value of an uniform to a vec4
  43101. * @param uniform defines the webGL uniform location where to store the value
  43102. * @param x defines the 1st component of the value
  43103. * @param y defines the 2nd component of the value
  43104. * @param z defines the 3rd component of the value
  43105. * @param w defines the 4th component of the value
  43106. */
  43107. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43108. /**
  43109. * Sets the current alpha mode
  43110. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43111. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43112. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43113. */
  43114. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43115. /**
  43116. * Bind webGl buffers directly to the webGL context
  43117. * @param vertexBuffers defines the vertex buffer to bind
  43118. * @param indexBuffer defines the index buffer to bind
  43119. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43120. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43121. * @param effect defines the effect associated with the vertex buffer
  43122. */
  43123. bindBuffers(vertexBuffers: {
  43124. [key: string]: VertexBuffer;
  43125. }, indexBuffer: DataBuffer, effect: Effect): void;
  43126. /**
  43127. * Force the entire cache to be cleared
  43128. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43129. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43130. */
  43131. wipeCaches(bruteForce?: boolean): void;
  43132. /**
  43133. * Send a draw order
  43134. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43135. * @param indexStart defines the starting index
  43136. * @param indexCount defines the number of index to draw
  43137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43138. */
  43139. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43140. /**
  43141. * Draw a list of indexed primitives
  43142. * @param fillMode defines the primitive to use
  43143. * @param indexStart defines the starting index
  43144. * @param indexCount defines the number of index to draw
  43145. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43146. */
  43147. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43148. /**
  43149. * Draw a list of unindexed primitives
  43150. * @param fillMode defines the primitive to use
  43151. * @param verticesStart defines the index of first vertex to draw
  43152. * @param verticesCount defines the count of vertices to draw
  43153. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43154. */
  43155. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43156. /** @hidden */ private _createTexture(): WebGLTexture;
  43157. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43158. /**
  43159. * Usually called from Texture.ts.
  43160. * Passed information to create a WebGLTexture
  43161. * @param urlArg defines a value which contains one of the following:
  43162. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43163. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43164. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43165. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43166. * @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)
  43167. * @param scene needed for loading to the correct scene
  43168. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43169. * @param onLoad optional callback to be called upon successful completion
  43170. * @param onError optional callback to be called upon failure
  43171. * @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
  43172. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43173. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43174. * @param forcedExtension defines the extension to use to pick the right loader
  43175. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43176. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43177. */
  43178. 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;
  43179. /**
  43180. * Creates a new render target texture
  43181. * @param size defines the size of the texture
  43182. * @param options defines the options used to create the texture
  43183. * @returns a new render target texture stored in an InternalTexture
  43184. */
  43185. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43186. /**
  43187. * Update the sampling mode of a given texture
  43188. * @param samplingMode defines the required sampling mode
  43189. * @param texture defines the texture to update
  43190. */
  43191. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43192. /**
  43193. * Binds the frame buffer to the specified texture.
  43194. * @param texture The texture to render to or null for the default canvas
  43195. * @param faceIndex The face of the texture to render to in case of cube texture
  43196. * @param requiredWidth The width of the target to render to
  43197. * @param requiredHeight The height of the target to render to
  43198. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43199. * @param depthStencilTexture The depth stencil texture to use to render
  43200. * @param lodLevel defines le lod level to bind to the frame buffer
  43201. */
  43202. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43203. /**
  43204. * Unbind the current render target texture from the webGL context
  43205. * @param texture defines the render target texture to unbind
  43206. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43207. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43208. */
  43209. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43210. /**
  43211. * Creates a dynamic vertex buffer
  43212. * @param vertices the data for the dynamic vertex buffer
  43213. * @returns the new WebGL dynamic buffer
  43214. */
  43215. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43216. /**
  43217. * Update the content of a dynamic texture
  43218. * @param texture defines the texture to update
  43219. * @param canvas defines the canvas containing the source
  43220. * @param invertY defines if data must be stored with Y axis inverted
  43221. * @param premulAlpha defines if alpha is stored as premultiplied
  43222. * @param format defines the format of the data
  43223. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43224. */
  43225. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43226. /**
  43227. * Gets a boolean indicating if all created effects are ready
  43228. * @returns true if all effects are ready
  43229. */
  43230. areAllEffectsReady(): boolean;
  43231. /**
  43232. * @hidden
  43233. * Get the current error code of the webGL context
  43234. * @returns the error code
  43235. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43236. */
  43237. getError(): number;
  43238. /** @hidden */ private _getUnpackAlignement(): number;
  43239. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43240. /**
  43241. * Update a dynamic index buffer
  43242. * @param indexBuffer defines the target index buffer
  43243. * @param indices defines the data to update
  43244. * @param offset defines the offset in the target index buffer where update should start
  43245. */
  43246. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43247. /**
  43248. * Updates a dynamic vertex buffer.
  43249. * @param vertexBuffer the vertex buffer to update
  43250. * @param vertices the data used to update the vertex buffer
  43251. * @param byteOffset the byte offset of the data (optional)
  43252. * @param byteLength the byte length of the data (optional)
  43253. */
  43254. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43255. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43256. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43257. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43258. /**
  43259. * 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
  43260. */
  43261. releaseEffects(): void;
  43262. displayLoadingUI(): void;
  43263. hideLoadingUI(): void;
  43264. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43265. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43266. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43267. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43268. }
  43269. }
  43270. declare module BABYLON {
  43271. /** @hidden */
  43272. export class _OcclusionDataStorage {
  43273. /** @hidden */
  43274. occlusionInternalRetryCounter: number;
  43275. /** @hidden */
  43276. isOcclusionQueryInProgress: boolean;
  43277. /** @hidden */
  43278. isOccluded: boolean;
  43279. /** @hidden */
  43280. occlusionRetryCount: number;
  43281. /** @hidden */
  43282. occlusionType: number;
  43283. /** @hidden */
  43284. occlusionQueryAlgorithmType: number;
  43285. }
  43286. interface Engine {
  43287. /**
  43288. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43289. * @return the new query
  43290. */
  43291. createQuery(): WebGLQuery;
  43292. /**
  43293. * Delete and release a webGL query
  43294. * @param query defines the query to delete
  43295. * @return the current engine
  43296. */
  43297. deleteQuery(query: WebGLQuery): Engine;
  43298. /**
  43299. * Check if a given query has resolved and got its value
  43300. * @param query defines the query to check
  43301. * @returns true if the query got its value
  43302. */
  43303. isQueryResultAvailable(query: WebGLQuery): boolean;
  43304. /**
  43305. * Gets the value of a given query
  43306. * @param query defines the query to check
  43307. * @returns the value of the query
  43308. */
  43309. getQueryResult(query: WebGLQuery): number;
  43310. /**
  43311. * Initiates an occlusion query
  43312. * @param algorithmType defines the algorithm to use
  43313. * @param query defines the query to use
  43314. * @returns the current engine
  43315. * @see http://doc.babylonjs.com/features/occlusionquery
  43316. */
  43317. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43318. /**
  43319. * Ends an occlusion query
  43320. * @see http://doc.babylonjs.com/features/occlusionquery
  43321. * @param algorithmType defines the algorithm to use
  43322. * @returns the current engine
  43323. */
  43324. endOcclusionQuery(algorithmType: number): Engine;
  43325. /**
  43326. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43327. * Please note that only one query can be issued at a time
  43328. * @returns a time token used to track the time span
  43329. */
  43330. startTimeQuery(): Nullable<_TimeToken>;
  43331. /**
  43332. * Ends a time query
  43333. * @param token defines the token used to measure the time span
  43334. * @returns the time spent (in ns)
  43335. */
  43336. endTimeQuery(token: _TimeToken): int;
  43337. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43338. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43339. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43340. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43341. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43342. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43343. }
  43344. interface AbstractMesh {
  43345. /**
  43346. * Backing filed
  43347. * @hidden
  43348. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43349. /**
  43350. * Access property
  43351. * @hidden
  43352. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43353. /**
  43354. * 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.
  43355. * The default value is -1 which means don't break the query and wait till the result
  43356. * @see http://doc.babylonjs.com/features/occlusionquery
  43357. */
  43358. occlusionRetryCount: number;
  43359. /**
  43360. * 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:
  43361. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43362. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43363. * * 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.
  43364. * @see http://doc.babylonjs.com/features/occlusionquery
  43365. */
  43366. occlusionType: number;
  43367. /**
  43368. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43369. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43370. * * 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.
  43371. * @see http://doc.babylonjs.com/features/occlusionquery
  43372. */
  43373. occlusionQueryAlgorithmType: number;
  43374. /**
  43375. * 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
  43376. * @see http://doc.babylonjs.com/features/occlusionquery
  43377. */
  43378. isOccluded: boolean;
  43379. /**
  43380. * Flag to check the progress status of the query
  43381. * @see http://doc.babylonjs.com/features/occlusionquery
  43382. */
  43383. isOcclusionQueryInProgress: boolean;
  43384. }
  43385. }
  43386. declare module BABYLON {
  43387. /** @hidden */
  43388. export var _forceTransformFeedbackToBundle: boolean;
  43389. interface Engine {
  43390. /**
  43391. * Creates a webGL transform feedback object
  43392. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43393. * @returns the webGL transform feedback object
  43394. */
  43395. createTransformFeedback(): WebGLTransformFeedback;
  43396. /**
  43397. * Delete a webGL transform feedback object
  43398. * @param value defines the webGL transform feedback object to delete
  43399. */
  43400. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43401. /**
  43402. * Bind a webGL transform feedback object to the webgl context
  43403. * @param value defines the webGL transform feedback object to bind
  43404. */
  43405. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43406. /**
  43407. * Begins a transform feedback operation
  43408. * @param usePoints defines if points or triangles must be used
  43409. */
  43410. beginTransformFeedback(usePoints: boolean): void;
  43411. /**
  43412. * Ends a transform feedback operation
  43413. */
  43414. endTransformFeedback(): void;
  43415. /**
  43416. * Specify the varyings to use with transform feedback
  43417. * @param program defines the associated webGL program
  43418. * @param value defines the list of strings representing the varying names
  43419. */
  43420. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43421. /**
  43422. * Bind a webGL buffer for a transform feedback operation
  43423. * @param value defines the webGL buffer to bind
  43424. */
  43425. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43426. }
  43427. }
  43428. declare module BABYLON {
  43429. /**
  43430. * Creation options of the multi render target texture.
  43431. */
  43432. export interface IMultiRenderTargetOptions {
  43433. /**
  43434. * Define if the texture needs to create mip maps after render.
  43435. */
  43436. generateMipMaps?: boolean;
  43437. /**
  43438. * Define the types of all the draw buffers we want to create
  43439. */
  43440. types?: number[];
  43441. /**
  43442. * Define the sampling modes of all the draw buffers we want to create
  43443. */
  43444. samplingModes?: number[];
  43445. /**
  43446. * Define if a depth buffer is required
  43447. */
  43448. generateDepthBuffer?: boolean;
  43449. /**
  43450. * Define if a stencil buffer is required
  43451. */
  43452. generateStencilBuffer?: boolean;
  43453. /**
  43454. * Define if a depth texture is required instead of a depth buffer
  43455. */
  43456. generateDepthTexture?: boolean;
  43457. /**
  43458. * Define the number of desired draw buffers
  43459. */
  43460. textureCount?: number;
  43461. /**
  43462. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43463. */
  43464. doNotChangeAspectRatio?: boolean;
  43465. /**
  43466. * Define the default type of the buffers we are creating
  43467. */
  43468. defaultType?: number;
  43469. }
  43470. /**
  43471. * A multi render target, like a render target provides the ability to render to a texture.
  43472. * Unlike the render target, it can render to several draw buffers in one draw.
  43473. * This is specially interesting in deferred rendering or for any effects requiring more than
  43474. * just one color from a single pass.
  43475. */
  43476. export class MultiRenderTarget extends RenderTargetTexture {
  43477. private _internalTextures;
  43478. private _textures;
  43479. private _multiRenderTargetOptions;
  43480. /**
  43481. * Get if draw buffers are currently supported by the used hardware and browser.
  43482. */
  43483. readonly isSupported: boolean;
  43484. /**
  43485. * Get the list of textures generated by the multi render target.
  43486. */
  43487. readonly textures: Texture[];
  43488. /**
  43489. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43490. */
  43491. readonly depthTexture: Texture;
  43492. /**
  43493. * Set the wrapping mode on U of all the textures we are rendering to.
  43494. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43495. */
  43496. wrapU: number;
  43497. /**
  43498. * Set the wrapping mode on V of all the textures we are rendering to.
  43499. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43500. */
  43501. wrapV: number;
  43502. /**
  43503. * Instantiate a new multi render target texture.
  43504. * A multi render target, like a render target provides the ability to render to a texture.
  43505. * Unlike the render target, it can render to several draw buffers in one draw.
  43506. * This is specially interesting in deferred rendering or for any effects requiring more than
  43507. * just one color from a single pass.
  43508. * @param name Define the name of the texture
  43509. * @param size Define the size of the buffers to render to
  43510. * @param count Define the number of target we are rendering into
  43511. * @param scene Define the scene the texture belongs to
  43512. * @param options Define the options used to create the multi render target
  43513. */
  43514. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43515. /** @hidden */ private _rebuild(): void;
  43516. private _createInternalTextures;
  43517. private _createTextures;
  43518. /**
  43519. * Define the number of samples used if MSAA is enabled.
  43520. */
  43521. samples: number;
  43522. /**
  43523. * Resize all the textures in the multi render target.
  43524. * Be carrefull as it will recreate all the data in the new texture.
  43525. * @param size Define the new size
  43526. */
  43527. resize(size: any): void;
  43528. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43529. /**
  43530. * Dispose the render targets and their associated resources
  43531. */
  43532. dispose(): void;
  43533. /**
  43534. * Release all the underlying texture used as draw buffers.
  43535. */
  43536. releaseInternalTextures(): void;
  43537. }
  43538. }
  43539. declare module BABYLON {
  43540. interface ThinEngine {
  43541. /**
  43542. * Unbind a list of render target textures from the webGL context
  43543. * This is used only when drawBuffer extension or webGL2 are active
  43544. * @param textures defines the render target textures to unbind
  43545. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43546. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43547. */
  43548. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43549. /**
  43550. * Create a multi render target texture
  43551. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43552. * @param size defines the size of the texture
  43553. * @param options defines the creation options
  43554. * @returns the cube texture as an InternalTexture
  43555. */
  43556. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43557. /**
  43558. * Update the sample count for a given multiple render target texture
  43559. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43560. * @param textures defines the textures to update
  43561. * @param samples defines the sample count to set
  43562. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43563. */
  43564. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43565. }
  43566. }
  43567. declare module BABYLON {
  43568. /** @hidden */
  43569. export var rgbdEncodePixelShader: {
  43570. name: string;
  43571. shader: string;
  43572. };
  43573. }
  43574. declare module BABYLON {
  43575. /** @hidden */
  43576. export var rgbdDecodePixelShader: {
  43577. name: string;
  43578. shader: string;
  43579. };
  43580. }
  43581. declare module BABYLON {
  43582. /**
  43583. * Raw texture data and descriptor sufficient for WebGL texture upload
  43584. */
  43585. export interface EnvironmentTextureInfo {
  43586. /**
  43587. * Version of the environment map
  43588. */
  43589. version: number;
  43590. /**
  43591. * Width of image
  43592. */
  43593. width: number;
  43594. /**
  43595. * Irradiance information stored in the file.
  43596. */
  43597. irradiance: any;
  43598. /**
  43599. * Specular information stored in the file.
  43600. */
  43601. specular: any;
  43602. }
  43603. /**
  43604. * Defines One Image in the file. It requires only the position in the file
  43605. * as well as the length.
  43606. */
  43607. interface BufferImageData {
  43608. /**
  43609. * Length of the image data.
  43610. */
  43611. length: number;
  43612. /**
  43613. * Position of the data from the null terminator delimiting the end of the JSON.
  43614. */
  43615. position: number;
  43616. }
  43617. /**
  43618. * Defines the specular data enclosed in the file.
  43619. * This corresponds to the version 1 of the data.
  43620. */
  43621. export interface EnvironmentTextureSpecularInfoV1 {
  43622. /**
  43623. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43624. */
  43625. specularDataPosition?: number;
  43626. /**
  43627. * This contains all the images data needed to reconstruct the cubemap.
  43628. */
  43629. mipmaps: Array<BufferImageData>;
  43630. /**
  43631. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43632. */
  43633. lodGenerationScale: number;
  43634. }
  43635. /**
  43636. * Sets of helpers addressing the serialization and deserialization of environment texture
  43637. * stored in a BabylonJS env file.
  43638. * Those files are usually stored as .env files.
  43639. */
  43640. export class EnvironmentTextureTools {
  43641. /**
  43642. * Magic number identifying the env file.
  43643. */
  43644. private static _MagicBytes;
  43645. /**
  43646. * Gets the environment info from an env file.
  43647. * @param data The array buffer containing the .env bytes.
  43648. * @returns the environment file info (the json header) if successfully parsed.
  43649. */
  43650. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43651. /**
  43652. * Creates an environment texture from a loaded cube texture.
  43653. * @param texture defines the cube texture to convert in env file
  43654. * @return a promise containing the environment data if succesfull.
  43655. */
  43656. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43657. /**
  43658. * Creates a JSON representation of the spherical data.
  43659. * @param texture defines the texture containing the polynomials
  43660. * @return the JSON representation of the spherical info
  43661. */
  43662. private static _CreateEnvTextureIrradiance;
  43663. /**
  43664. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43665. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43666. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43667. * @return the views described by info providing access to the underlying buffer
  43668. */
  43669. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43670. /**
  43671. * Uploads the texture info contained in the env file to the GPU.
  43672. * @param texture defines the internal texture to upload to
  43673. * @param arrayBuffer defines the buffer cotaining the data to load
  43674. * @param info defines the texture info retrieved through the GetEnvInfo method
  43675. * @returns a promise
  43676. */
  43677. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43678. /**
  43679. * Uploads the levels of image data to the GPU.
  43680. * @param texture defines the internal texture to upload to
  43681. * @param imageData defines the array buffer views of image data [mipmap][face]
  43682. * @returns a promise
  43683. */
  43684. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43685. /**
  43686. * Uploads spherical polynomials information to the texture.
  43687. * @param texture defines the texture we are trying to upload the information to
  43688. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43689. */
  43690. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43691. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43692. }
  43693. }
  43694. declare module BABYLON {
  43695. /**
  43696. * Contains position and normal vectors for a vertex
  43697. */
  43698. export class PositionNormalVertex {
  43699. /** the position of the vertex (defaut: 0,0,0) */
  43700. position: Vector3;
  43701. /** the normal of the vertex (defaut: 0,1,0) */
  43702. normal: Vector3;
  43703. /**
  43704. * Creates a PositionNormalVertex
  43705. * @param position the position of the vertex (defaut: 0,0,0)
  43706. * @param normal the normal of the vertex (defaut: 0,1,0)
  43707. */
  43708. constructor(
  43709. /** the position of the vertex (defaut: 0,0,0) */
  43710. position?: Vector3,
  43711. /** the normal of the vertex (defaut: 0,1,0) */
  43712. normal?: Vector3);
  43713. /**
  43714. * Clones the PositionNormalVertex
  43715. * @returns the cloned PositionNormalVertex
  43716. */
  43717. clone(): PositionNormalVertex;
  43718. }
  43719. /**
  43720. * Contains position, normal and uv vectors for a vertex
  43721. */
  43722. export class PositionNormalTextureVertex {
  43723. /** the position of the vertex (defaut: 0,0,0) */
  43724. position: Vector3;
  43725. /** the normal of the vertex (defaut: 0,1,0) */
  43726. normal: Vector3;
  43727. /** the uv of the vertex (default: 0,0) */
  43728. uv: Vector2;
  43729. /**
  43730. * Creates a PositionNormalTextureVertex
  43731. * @param position the position of the vertex (defaut: 0,0,0)
  43732. * @param normal the normal of the vertex (defaut: 0,1,0)
  43733. * @param uv the uv of the vertex (default: 0,0)
  43734. */
  43735. constructor(
  43736. /** the position of the vertex (defaut: 0,0,0) */
  43737. position?: Vector3,
  43738. /** the normal of the vertex (defaut: 0,1,0) */
  43739. normal?: Vector3,
  43740. /** the uv of the vertex (default: 0,0) */
  43741. uv?: Vector2);
  43742. /**
  43743. * Clones the PositionNormalTextureVertex
  43744. * @returns the cloned PositionNormalTextureVertex
  43745. */
  43746. clone(): PositionNormalTextureVertex;
  43747. }
  43748. }
  43749. declare module BABYLON {
  43750. /** @hidden */
  43751. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43752. private _genericAttributeLocation;
  43753. private _varyingLocationCount;
  43754. private _varyingLocationMap;
  43755. private _replacements;
  43756. private _textureCount;
  43757. private _uniforms;
  43758. lineProcessor(line: string): string;
  43759. attributeProcessor(attribute: string): string;
  43760. varyingProcessor(varying: string, isFragment: boolean): string;
  43761. uniformProcessor(uniform: string): string;
  43762. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43763. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43764. }
  43765. }
  43766. declare module BABYLON {
  43767. /**
  43768. * Container for accessors for natively-stored mesh data buffers.
  43769. */
  43770. class NativeDataBuffer extends DataBuffer {
  43771. /**
  43772. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43773. */
  43774. nativeIndexBuffer?: any;
  43775. /**
  43776. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43777. */
  43778. nativeVertexBuffer?: any;
  43779. }
  43780. /** @hidden */
  43781. export class NativeEngine extends Engine {
  43782. private readonly _native;
  43783. getHardwareScalingLevel(): number;
  43784. constructor();
  43785. /**
  43786. * Can be used to override the current requestAnimationFrame requester.
  43787. * @hidden
  43788. */
  43789. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43790. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43791. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43792. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43793. recordVertexArrayObject(vertexBuffers: {
  43794. [key: string]: VertexBuffer;
  43795. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43796. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43797. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43798. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43799. /**
  43800. * Draw a list of indexed primitives
  43801. * @param fillMode defines the primitive to use
  43802. * @param indexStart defines the starting index
  43803. * @param indexCount defines the number of index to draw
  43804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43805. */
  43806. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43807. /**
  43808. * Draw a list of unindexed primitives
  43809. * @param fillMode defines the primitive to use
  43810. * @param verticesStart defines the index of first vertex to draw
  43811. * @param verticesCount defines the count of vertices to draw
  43812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43813. */
  43814. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43815. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43816. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43817. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43818. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43819. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43820. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43821. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43822. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43823. bindSamplers(effect: Effect): void;
  43824. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43825. getRenderWidth(useScreen?: boolean): number;
  43826. getRenderHeight(useScreen?: boolean): number;
  43827. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43828. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43829. /**
  43830. * Set the z offset to apply to current rendering
  43831. * @param value defines the offset to apply
  43832. */
  43833. setZOffset(value: number): void;
  43834. /**
  43835. * Gets the current value of the zOffset
  43836. * @returns the current zOffset state
  43837. */
  43838. getZOffset(): number;
  43839. /**
  43840. * Enable or disable depth buffering
  43841. * @param enable defines the state to set
  43842. */
  43843. setDepthBuffer(enable: boolean): void;
  43844. /**
  43845. * Gets a boolean indicating if depth writing is enabled
  43846. * @returns the current depth writing state
  43847. */
  43848. getDepthWrite(): boolean;
  43849. /**
  43850. * Enable or disable depth writing
  43851. * @param enable defines the state to set
  43852. */
  43853. setDepthWrite(enable: boolean): void;
  43854. /**
  43855. * Enable or disable color writing
  43856. * @param enable defines the state to set
  43857. */
  43858. setColorWrite(enable: boolean): void;
  43859. /**
  43860. * Gets a boolean indicating if color writing is enabled
  43861. * @returns the current color writing state
  43862. */
  43863. getColorWrite(): boolean;
  43864. /**
  43865. * Sets alpha constants used by some alpha blending modes
  43866. * @param r defines the red component
  43867. * @param g defines the green component
  43868. * @param b defines the blue component
  43869. * @param a defines the alpha component
  43870. */
  43871. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43872. /**
  43873. * Sets the current alpha mode
  43874. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  43875. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43876. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43877. */
  43878. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43879. /**
  43880. * Gets the current alpha mode
  43881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43882. * @returns the current alpha mode
  43883. */
  43884. getAlphaMode(): number;
  43885. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43886. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43887. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43888. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43889. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43890. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43891. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43892. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43893. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43894. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43895. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43896. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43897. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43898. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43899. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43900. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43901. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43902. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43903. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43904. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43905. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43906. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43907. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43908. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43909. /**
  43910. * Usually called from BABYLON.Texture.ts.
  43911. * Passed information to create a WebGLTexture
  43912. * @param urlArg defines a value which contains one of the following:
  43913. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43914. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43915. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43916. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43917. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43918. * @param scene needed for loading to the correct scene
  43919. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43920. * @param onLoad optional callback to be called upon successful completion
  43921. * @param onError optional callback to be called upon failure
  43922. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43923. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43924. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43925. * @param forcedExtension defines the extension to use to pick the right loader
  43926. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43927. */
  43928. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  43929. /**
  43930. * Creates a cube texture
  43931. * @param rootUrl defines the url where the files to load is located
  43932. * @param scene defines the current scene
  43933. * @param files defines the list of files to load (1 per face)
  43934. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43935. * @param onLoad defines an optional callback raised when the texture is loaded
  43936. * @param onError defines an optional callback raised if there is an issue to load the texture
  43937. * @param format defines the format of the data
  43938. * @param forcedExtension defines the extension to use to pick the right loader
  43939. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  43940. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43941. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43942. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  43943. * @returns the cube texture as an InternalTexture
  43944. */
  43945. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  43946. private _getSamplingFilter;
  43947. private static _GetNativeTextureFormat;
  43948. createRenderTargetTexture(size: number | {
  43949. width: number;
  43950. height: number;
  43951. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43952. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43953. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43954. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43955. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  43956. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  43957. /**
  43958. * Updates a dynamic vertex buffer.
  43959. * @param vertexBuffer the vertex buffer to update
  43960. * @param data the data used to update the vertex buffer
  43961. * @param byteOffset the byte offset of the data (optional)
  43962. * @param byteLength the byte length of the data (optional)
  43963. */
  43964. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  43965. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  43966. private _updateAnisotropicLevel;
  43967. private _getAddressMode;
  43968. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43969. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  43970. releaseEffects(): void;
  43971. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43972. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43973. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43974. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43975. }
  43976. }
  43977. declare module BABYLON {
  43978. /**
  43979. * Gather the list of clipboard event types as constants.
  43980. */
  43981. export class ClipboardEventTypes {
  43982. /**
  43983. * The clipboard event is fired when a copy command is active (pressed).
  43984. */
  43985. static readonly COPY: number;
  43986. /**
  43987. * The clipboard event is fired when a cut command is active (pressed).
  43988. */
  43989. static readonly CUT: number;
  43990. /**
  43991. * The clipboard event is fired when a paste command is active (pressed).
  43992. */
  43993. static readonly PASTE: number;
  43994. }
  43995. /**
  43996. * This class is used to store clipboard related info for the onClipboardObservable event.
  43997. */
  43998. export class ClipboardInfo {
  43999. /**
  44000. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44001. */
  44002. type: number;
  44003. /**
  44004. * Defines the related dom event
  44005. */
  44006. event: ClipboardEvent;
  44007. /**
  44008. *Creates an instance of ClipboardInfo.
  44009. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44010. * @param event Defines the related dom event
  44011. */
  44012. constructor(
  44013. /**
  44014. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44015. */
  44016. type: number,
  44017. /**
  44018. * Defines the related dom event
  44019. */
  44020. event: ClipboardEvent);
  44021. /**
  44022. * Get the clipboard event's type from the keycode.
  44023. * @param keyCode Defines the keyCode for the current keyboard event.
  44024. * @return {number}
  44025. */
  44026. static GetTypeFromCharacter(keyCode: number): number;
  44027. }
  44028. }
  44029. declare module BABYLON {
  44030. /**
  44031. * Google Daydream controller
  44032. */
  44033. export class DaydreamController extends WebVRController {
  44034. /**
  44035. * Base Url for the controller model.
  44036. */
  44037. static MODEL_BASE_URL: string;
  44038. /**
  44039. * File name for the controller model.
  44040. */
  44041. static MODEL_FILENAME: string;
  44042. /**
  44043. * Gamepad Id prefix used to identify Daydream Controller.
  44044. */
  44045. static readonly GAMEPAD_ID_PREFIX: string;
  44046. /**
  44047. * Creates a new DaydreamController from a gamepad
  44048. * @param vrGamepad the gamepad that the controller should be created from
  44049. */
  44050. constructor(vrGamepad: any);
  44051. /**
  44052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44053. * @param scene scene in which to add meshes
  44054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44055. */
  44056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44057. /**
  44058. * Called once for each button that changed state since the last frame
  44059. * @param buttonIdx Which button index changed
  44060. * @param state New state of the button
  44061. * @param changes Which properties on the state changed since last frame
  44062. */
  44063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44064. }
  44065. }
  44066. declare module BABYLON {
  44067. /**
  44068. * Gear VR Controller
  44069. */
  44070. export class GearVRController extends WebVRController {
  44071. /**
  44072. * Base Url for the controller model.
  44073. */
  44074. static MODEL_BASE_URL: string;
  44075. /**
  44076. * File name for the controller model.
  44077. */
  44078. static MODEL_FILENAME: string;
  44079. /**
  44080. * Gamepad Id prefix used to identify this controller.
  44081. */
  44082. static readonly GAMEPAD_ID_PREFIX: string;
  44083. private readonly _buttonIndexToObservableNameMap;
  44084. /**
  44085. * Creates a new GearVRController from a gamepad
  44086. * @param vrGamepad the gamepad that the controller should be created from
  44087. */
  44088. constructor(vrGamepad: any);
  44089. /**
  44090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44091. * @param scene scene in which to add meshes
  44092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44093. */
  44094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44095. /**
  44096. * Called once for each button that changed state since the last frame
  44097. * @param buttonIdx Which button index changed
  44098. * @param state New state of the button
  44099. * @param changes Which properties on the state changed since last frame
  44100. */
  44101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44102. }
  44103. }
  44104. declare module BABYLON {
  44105. /**
  44106. * Class containing static functions to help procedurally build meshes
  44107. */
  44108. export class PolyhedronBuilder {
  44109. /**
  44110. * Creates a polyhedron mesh
  44111. * * 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
  44112. * * The parameter `size` (positive float, default 1) sets the polygon size
  44113. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44114. * * 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`
  44115. * * 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
  44116. * * 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)`)
  44117. * * 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
  44118. * * 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
  44119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44120. * * 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
  44121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44122. * @param name defines the name of the mesh
  44123. * @param options defines the options used to create the mesh
  44124. * @param scene defines the hosting scene
  44125. * @returns the polyhedron mesh
  44126. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44127. */
  44128. static CreatePolyhedron(name: string, options: {
  44129. type?: number;
  44130. size?: number;
  44131. sizeX?: number;
  44132. sizeY?: number;
  44133. sizeZ?: number;
  44134. custom?: any;
  44135. faceUV?: Vector4[];
  44136. faceColors?: Color4[];
  44137. flat?: boolean;
  44138. updatable?: boolean;
  44139. sideOrientation?: number;
  44140. frontUVs?: Vector4;
  44141. backUVs?: Vector4;
  44142. }, scene?: Nullable<Scene>): Mesh;
  44143. }
  44144. }
  44145. declare module BABYLON {
  44146. /**
  44147. * Gizmo that enables scaling a mesh along 3 axis
  44148. */
  44149. export class ScaleGizmo extends Gizmo {
  44150. /**
  44151. * Internal gizmo used for interactions on the x axis
  44152. */
  44153. xGizmo: AxisScaleGizmo;
  44154. /**
  44155. * Internal gizmo used for interactions on the y axis
  44156. */
  44157. yGizmo: AxisScaleGizmo;
  44158. /**
  44159. * Internal gizmo used for interactions on the z axis
  44160. */
  44161. zGizmo: AxisScaleGizmo;
  44162. /**
  44163. * Internal gizmo used to scale all axis equally
  44164. */
  44165. uniformScaleGizmo: AxisScaleGizmo;
  44166. private _meshAttached;
  44167. private _updateGizmoRotationToMatchAttachedMesh;
  44168. private _snapDistance;
  44169. private _scaleRatio;
  44170. private _uniformScalingMesh;
  44171. private _octahedron;
  44172. /** Fires an event when any of it's sub gizmos are dragged */
  44173. onDragStartObservable: Observable<unknown>;
  44174. /** Fires an event when any of it's sub gizmos are released from dragging */
  44175. onDragEndObservable: Observable<unknown>;
  44176. attachedMesh: Nullable<AbstractMesh>;
  44177. /**
  44178. * Creates a ScaleGizmo
  44179. * @param gizmoLayer The utility layer the gizmo will be added to
  44180. */
  44181. constructor(gizmoLayer?: UtilityLayerRenderer);
  44182. updateGizmoRotationToMatchAttachedMesh: boolean;
  44183. /**
  44184. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44185. */
  44186. snapDistance: number;
  44187. /**
  44188. * Ratio for the scale of the gizmo (Default: 1)
  44189. */
  44190. scaleRatio: number;
  44191. /**
  44192. * Disposes of the gizmo
  44193. */
  44194. dispose(): void;
  44195. }
  44196. }
  44197. declare module BABYLON {
  44198. /**
  44199. * Single axis scale gizmo
  44200. */
  44201. export class AxisScaleGizmo extends Gizmo {
  44202. /**
  44203. * Drag behavior responsible for the gizmos dragging interactions
  44204. */
  44205. dragBehavior: PointerDragBehavior;
  44206. private _pointerObserver;
  44207. /**
  44208. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44209. */
  44210. snapDistance: number;
  44211. /**
  44212. * Event that fires each time the gizmo snaps to a new location.
  44213. * * snapDistance is the the change in distance
  44214. */
  44215. onSnapObservable: Observable<{
  44216. snapDistance: number;
  44217. }>;
  44218. /**
  44219. * If the scaling operation should be done on all axis (default: false)
  44220. */
  44221. uniformScaling: boolean;
  44222. private _isEnabled;
  44223. private _parent;
  44224. private _arrow;
  44225. private _coloredMaterial;
  44226. private _hoverMaterial;
  44227. /**
  44228. * Creates an AxisScaleGizmo
  44229. * @param gizmoLayer The utility layer the gizmo will be added to
  44230. * @param dragAxis The axis which the gizmo will be able to scale on
  44231. * @param color The color of the gizmo
  44232. */
  44233. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44234. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44235. /**
  44236. * If the gizmo is enabled
  44237. */
  44238. isEnabled: boolean;
  44239. /**
  44240. * Disposes of the gizmo
  44241. */
  44242. dispose(): void;
  44243. /**
  44244. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44245. * @param mesh The mesh to replace the default mesh of the gizmo
  44246. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44247. */
  44248. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44249. }
  44250. }
  44251. declare module BABYLON {
  44252. /**
  44253. * Bounding box gizmo
  44254. */
  44255. export class BoundingBoxGizmo extends Gizmo {
  44256. private _lineBoundingBox;
  44257. private _rotateSpheresParent;
  44258. private _scaleBoxesParent;
  44259. private _boundingDimensions;
  44260. private _renderObserver;
  44261. private _pointerObserver;
  44262. private _scaleDragSpeed;
  44263. private _tmpQuaternion;
  44264. private _tmpVector;
  44265. private _tmpRotationMatrix;
  44266. /**
  44267. * 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)
  44268. */
  44269. ignoreChildren: boolean;
  44270. /**
  44271. * 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)
  44272. */
  44273. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44274. /**
  44275. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44276. */
  44277. rotationSphereSize: number;
  44278. /**
  44279. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44280. */
  44281. scaleBoxSize: number;
  44282. /**
  44283. * 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)
  44284. */
  44285. fixedDragMeshScreenSize: boolean;
  44286. /**
  44287. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44288. */
  44289. fixedDragMeshScreenSizeDistanceFactor: number;
  44290. /**
  44291. * Fired when a rotation sphere or scale box is dragged
  44292. */
  44293. onDragStartObservable: Observable<{}>;
  44294. /**
  44295. * Fired when a scale box is dragged
  44296. */
  44297. onScaleBoxDragObservable: Observable<{}>;
  44298. /**
  44299. * Fired when a scale box drag is ended
  44300. */
  44301. onScaleBoxDragEndObservable: Observable<{}>;
  44302. /**
  44303. * Fired when a rotation sphere is dragged
  44304. */
  44305. onRotationSphereDragObservable: Observable<{}>;
  44306. /**
  44307. * Fired when a rotation sphere drag is ended
  44308. */
  44309. onRotationSphereDragEndObservable: Observable<{}>;
  44310. /**
  44311. * 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)
  44312. */
  44313. scalePivot: Nullable<Vector3>;
  44314. /**
  44315. * Mesh used as a pivot to rotate the attached mesh
  44316. */
  44317. private _anchorMesh;
  44318. private _existingMeshScale;
  44319. private _dragMesh;
  44320. private pointerDragBehavior;
  44321. private coloredMaterial;
  44322. private hoverColoredMaterial;
  44323. /**
  44324. * Sets the color of the bounding box gizmo
  44325. * @param color the color to set
  44326. */
  44327. setColor(color: Color3): void;
  44328. /**
  44329. * Creates an BoundingBoxGizmo
  44330. * @param gizmoLayer The utility layer the gizmo will be added to
  44331. * @param color The color of the gizmo
  44332. */
  44333. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44335. private _selectNode;
  44336. /**
  44337. * Updates the bounding box information for the Gizmo
  44338. */
  44339. updateBoundingBox(): void;
  44340. private _updateRotationSpheres;
  44341. private _updateScaleBoxes;
  44342. /**
  44343. * Enables rotation on the specified axis and disables rotation on the others
  44344. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44345. */
  44346. setEnabledRotationAxis(axis: string): void;
  44347. /**
  44348. * Enables/disables scaling
  44349. * @param enable if scaling should be enabled
  44350. */
  44351. setEnabledScaling(enable: boolean): void;
  44352. private _updateDummy;
  44353. /**
  44354. * Enables a pointer drag behavior on the bounding box of the gizmo
  44355. */
  44356. enableDragBehavior(): void;
  44357. /**
  44358. * Disposes of the gizmo
  44359. */
  44360. dispose(): void;
  44361. /**
  44362. * 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)
  44363. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44364. * @returns the bounding box mesh with the passed in mesh as a child
  44365. */
  44366. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44367. /**
  44368. * CustomMeshes are not supported by this gizmo
  44369. * @param mesh The mesh to replace the default mesh of the gizmo
  44370. */
  44371. setCustomMesh(mesh: Mesh): void;
  44372. }
  44373. }
  44374. declare module BABYLON {
  44375. /**
  44376. * Single plane rotation gizmo
  44377. */
  44378. export class PlaneRotationGizmo extends Gizmo {
  44379. /**
  44380. * Drag behavior responsible for the gizmos dragging interactions
  44381. */
  44382. dragBehavior: PointerDragBehavior;
  44383. private _pointerObserver;
  44384. /**
  44385. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44386. */
  44387. snapDistance: number;
  44388. /**
  44389. * Event that fires each time the gizmo snaps to a new location.
  44390. * * snapDistance is the the change in distance
  44391. */
  44392. onSnapObservable: Observable<{
  44393. snapDistance: number;
  44394. }>;
  44395. private _isEnabled;
  44396. private _parent;
  44397. /**
  44398. * Creates a PlaneRotationGizmo
  44399. * @param gizmoLayer The utility layer the gizmo will be added to
  44400. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44401. * @param color The color of the gizmo
  44402. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44403. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44404. */
  44405. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44406. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44407. /**
  44408. * If the gizmo is enabled
  44409. */
  44410. isEnabled: boolean;
  44411. /**
  44412. * Disposes of the gizmo
  44413. */
  44414. dispose(): void;
  44415. }
  44416. }
  44417. declare module BABYLON {
  44418. /**
  44419. * Gizmo that enables rotating a mesh along 3 axis
  44420. */
  44421. export class RotationGizmo extends Gizmo {
  44422. /**
  44423. * Internal gizmo used for interactions on the x axis
  44424. */
  44425. xGizmo: PlaneRotationGizmo;
  44426. /**
  44427. * Internal gizmo used for interactions on the y axis
  44428. */
  44429. yGizmo: PlaneRotationGizmo;
  44430. /**
  44431. * Internal gizmo used for interactions on the z axis
  44432. */
  44433. zGizmo: PlaneRotationGizmo;
  44434. /** Fires an event when any of it's sub gizmos are dragged */
  44435. onDragStartObservable: Observable<unknown>;
  44436. /** Fires an event when any of it's sub gizmos are released from dragging */
  44437. onDragEndObservable: Observable<unknown>;
  44438. private _meshAttached;
  44439. attachedMesh: Nullable<AbstractMesh>;
  44440. /**
  44441. * Creates a RotationGizmo
  44442. * @param gizmoLayer The utility layer the gizmo will be added to
  44443. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44444. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44445. */
  44446. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44447. updateGizmoRotationToMatchAttachedMesh: boolean;
  44448. /**
  44449. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44450. */
  44451. snapDistance: number;
  44452. /**
  44453. * Ratio for the scale of the gizmo (Default: 1)
  44454. */
  44455. scaleRatio: number;
  44456. /**
  44457. * Disposes of the gizmo
  44458. */
  44459. dispose(): void;
  44460. /**
  44461. * CustomMeshes are not supported by this gizmo
  44462. * @param mesh The mesh to replace the default mesh of the gizmo
  44463. */
  44464. setCustomMesh(mesh: Mesh): void;
  44465. }
  44466. }
  44467. declare module BABYLON {
  44468. /**
  44469. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44470. */
  44471. export class GizmoManager implements IDisposable {
  44472. private scene;
  44473. /**
  44474. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44475. */
  44476. gizmos: {
  44477. positionGizmo: Nullable<PositionGizmo>;
  44478. rotationGizmo: Nullable<RotationGizmo>;
  44479. scaleGizmo: Nullable<ScaleGizmo>;
  44480. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44481. };
  44482. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44483. clearGizmoOnEmptyPointerEvent: boolean;
  44484. /** Fires an event when the manager is attached to a mesh */
  44485. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44486. private _gizmosEnabled;
  44487. private _pointerObserver;
  44488. private _attachedMesh;
  44489. private _boundingBoxColor;
  44490. private _defaultUtilityLayer;
  44491. private _defaultKeepDepthUtilityLayer;
  44492. /**
  44493. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44494. */
  44495. boundingBoxDragBehavior: SixDofDragBehavior;
  44496. /**
  44497. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44498. */
  44499. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44500. /**
  44501. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44502. */
  44503. usePointerToAttachGizmos: boolean;
  44504. /**
  44505. * Utility layer that the bounding box gizmo belongs to
  44506. */
  44507. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44508. /**
  44509. * Utility layer that all gizmos besides bounding box belong to
  44510. */
  44511. readonly utilityLayer: UtilityLayerRenderer;
  44512. /**
  44513. * Instatiates a gizmo manager
  44514. * @param scene the scene to overlay the gizmos on top of
  44515. */
  44516. constructor(scene: Scene);
  44517. /**
  44518. * Attaches a set of gizmos to the specified mesh
  44519. * @param mesh The mesh the gizmo's should be attached to
  44520. */
  44521. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44522. /**
  44523. * If the position gizmo is enabled
  44524. */
  44525. positionGizmoEnabled: boolean;
  44526. /**
  44527. * If the rotation gizmo is enabled
  44528. */
  44529. rotationGizmoEnabled: boolean;
  44530. /**
  44531. * If the scale gizmo is enabled
  44532. */
  44533. scaleGizmoEnabled: boolean;
  44534. /**
  44535. * If the boundingBox gizmo is enabled
  44536. */
  44537. boundingBoxGizmoEnabled: boolean;
  44538. /**
  44539. * Disposes of the gizmo manager
  44540. */
  44541. dispose(): void;
  44542. }
  44543. }
  44544. declare module BABYLON {
  44545. /**
  44546. * A directional light is defined by a direction (what a surprise!).
  44547. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44548. * 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.
  44549. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44550. */
  44551. export class DirectionalLight extends ShadowLight {
  44552. private _shadowFrustumSize;
  44553. /**
  44554. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44555. */
  44556. /**
  44557. * Specifies a fix frustum size for the shadow generation.
  44558. */
  44559. shadowFrustumSize: number;
  44560. private _shadowOrthoScale;
  44561. /**
  44562. * Gets the shadow projection scale against the optimal computed one.
  44563. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44564. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44565. */
  44566. /**
  44567. * Sets the shadow projection scale against the optimal computed one.
  44568. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44569. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44570. */
  44571. shadowOrthoScale: number;
  44572. /**
  44573. * Automatically compute the projection matrix to best fit (including all the casters)
  44574. * on each frame.
  44575. */
  44576. autoUpdateExtends: boolean;
  44577. private _orthoLeft;
  44578. private _orthoRight;
  44579. private _orthoTop;
  44580. private _orthoBottom;
  44581. /**
  44582. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44583. * The directional light is emitted from everywhere in the given direction.
  44584. * It can cast shadows.
  44585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44586. * @param name The friendly name of the light
  44587. * @param direction The direction of the light
  44588. * @param scene The scene the light belongs to
  44589. */
  44590. constructor(name: string, direction: Vector3, scene: Scene);
  44591. /**
  44592. * Returns the string "DirectionalLight".
  44593. * @return The class name
  44594. */
  44595. getClassName(): string;
  44596. /**
  44597. * Returns the integer 1.
  44598. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44599. */
  44600. getTypeID(): number;
  44601. /**
  44602. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44603. * Returns the DirectionalLight Shadow projection matrix.
  44604. */
  44605. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44606. /**
  44607. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44608. * Returns the DirectionalLight Shadow projection matrix.
  44609. */
  44610. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44611. /**
  44612. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44613. * Returns the DirectionalLight Shadow projection matrix.
  44614. */
  44615. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44616. protected _buildUniformLayout(): void;
  44617. /**
  44618. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44619. * @param effect The effect to update
  44620. * @param lightIndex The index of the light in the effect to update
  44621. * @returns The directional light
  44622. */
  44623. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44624. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44625. /**
  44626. * Gets the minZ used for shadow according to both the scene and the light.
  44627. *
  44628. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44629. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44630. * @param activeCamera The camera we are returning the min for
  44631. * @returns the depth min z
  44632. */
  44633. getDepthMinZ(activeCamera: Camera): number;
  44634. /**
  44635. * Gets the maxZ used for shadow according to both the scene and the light.
  44636. *
  44637. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44638. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44639. * @param activeCamera The camera we are returning the max for
  44640. * @returns the depth max z
  44641. */
  44642. getDepthMaxZ(activeCamera: Camera): number;
  44643. /**
  44644. * Prepares the list of defines specific to the light type.
  44645. * @param defines the list of defines
  44646. * @param lightIndex defines the index of the light for the effect
  44647. */
  44648. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44649. }
  44650. }
  44651. declare module BABYLON {
  44652. /**
  44653. * Class containing static functions to help procedurally build meshes
  44654. */
  44655. export class HemisphereBuilder {
  44656. /**
  44657. * Creates a hemisphere mesh
  44658. * @param name defines the name of the mesh
  44659. * @param options defines the options used to create the mesh
  44660. * @param scene defines the hosting scene
  44661. * @returns the hemisphere mesh
  44662. */
  44663. static CreateHemisphere(name: string, options: {
  44664. segments?: number;
  44665. diameter?: number;
  44666. sideOrientation?: number;
  44667. }, scene: any): Mesh;
  44668. }
  44669. }
  44670. declare module BABYLON {
  44671. /**
  44672. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44673. * These values define a cone of light starting from the position, emitting toward the direction.
  44674. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44675. * and the exponent defines the speed of the decay of the light with distance (reach).
  44676. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44677. */
  44678. export class SpotLight extends ShadowLight {
  44679. private _angle;
  44680. private _innerAngle;
  44681. private _cosHalfAngle;
  44682. private _lightAngleScale;
  44683. private _lightAngleOffset;
  44684. /**
  44685. * Gets the cone angle of the spot light in Radians.
  44686. */
  44687. /**
  44688. * Sets the cone angle of the spot light in Radians.
  44689. */
  44690. angle: number;
  44691. /**
  44692. * Only used in gltf falloff mode, this defines the angle where
  44693. * the directional falloff will start before cutting at angle which could be seen
  44694. * as outer angle.
  44695. */
  44696. /**
  44697. * Only used in gltf falloff mode, this defines the angle where
  44698. * the directional falloff will start before cutting at angle which could be seen
  44699. * as outer angle.
  44700. */
  44701. innerAngle: number;
  44702. private _shadowAngleScale;
  44703. /**
  44704. * Allows scaling the angle of the light for shadow generation only.
  44705. */
  44706. /**
  44707. * Allows scaling the angle of the light for shadow generation only.
  44708. */
  44709. shadowAngleScale: number;
  44710. /**
  44711. * The light decay speed with the distance from the emission spot.
  44712. */
  44713. exponent: number;
  44714. private _projectionTextureMatrix;
  44715. /**
  44716. * Allows reading the projecton texture
  44717. */
  44718. readonly projectionTextureMatrix: Matrix;
  44719. protected _projectionTextureLightNear: number;
  44720. /**
  44721. * Gets the near clip of the Spotlight for texture projection.
  44722. */
  44723. /**
  44724. * Sets the near clip of the Spotlight for texture projection.
  44725. */
  44726. projectionTextureLightNear: number;
  44727. protected _projectionTextureLightFar: number;
  44728. /**
  44729. * Gets the far clip of the Spotlight for texture projection.
  44730. */
  44731. /**
  44732. * Sets the far clip of the Spotlight for texture projection.
  44733. */
  44734. projectionTextureLightFar: number;
  44735. protected _projectionTextureUpDirection: Vector3;
  44736. /**
  44737. * Gets the Up vector of the Spotlight for texture projection.
  44738. */
  44739. /**
  44740. * Sets the Up vector of the Spotlight for texture projection.
  44741. */
  44742. projectionTextureUpDirection: Vector3;
  44743. private _projectionTexture;
  44744. /**
  44745. * Gets the projection texture of the light.
  44746. */
  44747. /**
  44748. * Sets the projection texture of the light.
  44749. */
  44750. projectionTexture: Nullable<BaseTexture>;
  44751. private _projectionTextureViewLightDirty;
  44752. private _projectionTextureProjectionLightDirty;
  44753. private _projectionTextureDirty;
  44754. private _projectionTextureViewTargetVector;
  44755. private _projectionTextureViewLightMatrix;
  44756. private _projectionTextureProjectionLightMatrix;
  44757. private _projectionTextureScalingMatrix;
  44758. /**
  44759. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44760. * It can cast shadows.
  44761. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44762. * @param name The light friendly name
  44763. * @param position The position of the spot light in the scene
  44764. * @param direction The direction of the light in the scene
  44765. * @param angle The cone angle of the light in Radians
  44766. * @param exponent The light decay speed with the distance from the emission spot
  44767. * @param scene The scene the lights belongs to
  44768. */
  44769. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44770. /**
  44771. * Returns the string "SpotLight".
  44772. * @returns the class name
  44773. */
  44774. getClassName(): string;
  44775. /**
  44776. * Returns the integer 2.
  44777. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44778. */
  44779. getTypeID(): number;
  44780. /**
  44781. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44782. */
  44783. protected _setDirection(value: Vector3): void;
  44784. /**
  44785. * Overrides the position setter to recompute the projection texture view light Matrix.
  44786. */
  44787. protected _setPosition(value: Vector3): void;
  44788. /**
  44789. * 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.
  44790. * Returns the SpotLight.
  44791. */
  44792. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44793. protected _computeProjectionTextureViewLightMatrix(): void;
  44794. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44795. /**
  44796. * Main function for light texture projection matrix computing.
  44797. */
  44798. protected _computeProjectionTextureMatrix(): void;
  44799. protected _buildUniformLayout(): void;
  44800. private _computeAngleValues;
  44801. /**
  44802. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44803. * @param effect The effect to update
  44804. * @param lightIndex The index of the light in the effect to update
  44805. * @returns The spot light
  44806. */
  44807. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44809. /**
  44810. * Disposes the light and the associated resources.
  44811. */
  44812. dispose(): void;
  44813. /**
  44814. * Prepares the list of defines specific to the light type.
  44815. * @param defines the list of defines
  44816. * @param lightIndex defines the index of the light for the effect
  44817. */
  44818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44819. }
  44820. }
  44821. declare module BABYLON {
  44822. /**
  44823. * Gizmo that enables viewing a light
  44824. */
  44825. export class LightGizmo extends Gizmo {
  44826. private _lightMesh;
  44827. private _material;
  44828. private cachedPosition;
  44829. private cachedForward;
  44830. /**
  44831. * Creates a LightGizmo
  44832. * @param gizmoLayer The utility layer the gizmo will be added to
  44833. */
  44834. constructor(gizmoLayer?: UtilityLayerRenderer);
  44835. private _light;
  44836. /**
  44837. * The light that the gizmo is attached to
  44838. */
  44839. light: Nullable<Light>;
  44840. /**
  44841. * Gets the material used to render the light gizmo
  44842. */
  44843. readonly material: StandardMaterial;
  44844. /**
  44845. * @hidden
  44846. * Updates the gizmo to match the attached mesh's position/rotation
  44847. */
  44848. protected _update(): void;
  44849. private static _Scale;
  44850. /**
  44851. * Creates the lines for a light mesh
  44852. */
  44853. private static _createLightLines;
  44854. /**
  44855. * Disposes of the light gizmo
  44856. */
  44857. dispose(): void;
  44858. private static _CreateHemisphericLightMesh;
  44859. private static _CreatePointLightMesh;
  44860. private static _CreateSpotLightMesh;
  44861. private static _CreateDirectionalLightMesh;
  44862. }
  44863. }
  44864. declare module BABYLON {
  44865. /** @hidden */
  44866. export var backgroundFragmentDeclaration: {
  44867. name: string;
  44868. shader: string;
  44869. };
  44870. }
  44871. declare module BABYLON {
  44872. /** @hidden */
  44873. export var backgroundUboDeclaration: {
  44874. name: string;
  44875. shader: string;
  44876. };
  44877. }
  44878. declare module BABYLON {
  44879. /** @hidden */
  44880. export var backgroundPixelShader: {
  44881. name: string;
  44882. shader: string;
  44883. };
  44884. }
  44885. declare module BABYLON {
  44886. /** @hidden */
  44887. export var backgroundVertexDeclaration: {
  44888. name: string;
  44889. shader: string;
  44890. };
  44891. }
  44892. declare module BABYLON {
  44893. /** @hidden */
  44894. export var backgroundVertexShader: {
  44895. name: string;
  44896. shader: string;
  44897. };
  44898. }
  44899. declare module BABYLON {
  44900. /**
  44901. * Background material used to create an efficient environement around your scene.
  44902. */
  44903. export class BackgroundMaterial extends PushMaterial {
  44904. /**
  44905. * Standard reflectance value at parallel view angle.
  44906. */
  44907. static StandardReflectance0: number;
  44908. /**
  44909. * Standard reflectance value at grazing angle.
  44910. */
  44911. static StandardReflectance90: number;
  44912. protected _primaryColor: Color3;
  44913. /**
  44914. * Key light Color (multiply against the environement texture)
  44915. */
  44916. primaryColor: Color3;
  44917. protected __perceptualColor: Nullable<Color3>;
  44918. /**
  44919. * Experimental Internal Use Only.
  44920. *
  44921. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44922. * This acts as a helper to set the primary color to a more "human friendly" value.
  44923. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44924. * output color as close as possible from the chosen value.
  44925. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44926. * part of lighting setup.)
  44927. */ private _perceptualColor: Nullable<Color3>;
  44928. protected _primaryColorShadowLevel: float;
  44929. /**
  44930. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44931. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44932. */
  44933. primaryColorShadowLevel: float;
  44934. protected _primaryColorHighlightLevel: float;
  44935. /**
  44936. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44937. * The primary color is used at the level chosen to define what the white area would look.
  44938. */
  44939. primaryColorHighlightLevel: float;
  44940. protected _reflectionTexture: Nullable<BaseTexture>;
  44941. /**
  44942. * Reflection Texture used in the material.
  44943. * Should be author in a specific way for the best result (refer to the documentation).
  44944. */
  44945. reflectionTexture: Nullable<BaseTexture>;
  44946. protected _reflectionBlur: float;
  44947. /**
  44948. * Reflection Texture level of blur.
  44949. *
  44950. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44951. * texture twice.
  44952. */
  44953. reflectionBlur: float;
  44954. protected _diffuseTexture: Nullable<BaseTexture>;
  44955. /**
  44956. * Diffuse Texture used in the material.
  44957. * Should be author in a specific way for the best result (refer to the documentation).
  44958. */
  44959. diffuseTexture: Nullable<BaseTexture>;
  44960. protected _shadowLights: Nullable<IShadowLight[]>;
  44961. /**
  44962. * Specify the list of lights casting shadow on the material.
  44963. * All scene shadow lights will be included if null.
  44964. */
  44965. shadowLights: Nullable<IShadowLight[]>;
  44966. protected _shadowLevel: float;
  44967. /**
  44968. * Helps adjusting the shadow to a softer level if required.
  44969. * 0 means black shadows and 1 means no shadows.
  44970. */
  44971. shadowLevel: float;
  44972. protected _sceneCenter: Vector3;
  44973. /**
  44974. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44975. * It is usually zero but might be interesting to modify according to your setup.
  44976. */
  44977. sceneCenter: Vector3;
  44978. protected _opacityFresnel: boolean;
  44979. /**
  44980. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44981. * This helps ensuring a nice transition when the camera goes under the ground.
  44982. */
  44983. opacityFresnel: boolean;
  44984. protected _reflectionFresnel: boolean;
  44985. /**
  44986. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44987. * This helps adding a mirror texture on the ground.
  44988. */
  44989. reflectionFresnel: boolean;
  44990. protected _reflectionFalloffDistance: number;
  44991. /**
  44992. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44993. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44994. */
  44995. reflectionFalloffDistance: number;
  44996. protected _reflectionAmount: number;
  44997. /**
  44998. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44999. */
  45000. reflectionAmount: number;
  45001. protected _reflectionReflectance0: number;
  45002. /**
  45003. * This specifies the weight of the reflection at grazing angle.
  45004. */
  45005. reflectionReflectance0: number;
  45006. protected _reflectionReflectance90: number;
  45007. /**
  45008. * This specifies the weight of the reflection at a perpendicular point of view.
  45009. */
  45010. reflectionReflectance90: number;
  45011. /**
  45012. * Sets the reflection reflectance fresnel values according to the default standard
  45013. * empirically know to work well :-)
  45014. */
  45015. reflectionStandardFresnelWeight: number;
  45016. protected _useRGBColor: boolean;
  45017. /**
  45018. * Helps to directly use the maps channels instead of their level.
  45019. */
  45020. useRGBColor: boolean;
  45021. protected _enableNoise: boolean;
  45022. /**
  45023. * This helps reducing the banding effect that could occur on the background.
  45024. */
  45025. enableNoise: boolean;
  45026. /**
  45027. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45028. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45029. * Recommended to be keep at 1.0 except for special cases.
  45030. */
  45031. fovMultiplier: number;
  45032. private _fovMultiplier;
  45033. /**
  45034. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45035. */
  45036. useEquirectangularFOV: boolean;
  45037. private _maxSimultaneousLights;
  45038. /**
  45039. * Number of Simultaneous lights allowed on the material.
  45040. */
  45041. maxSimultaneousLights: int;
  45042. /**
  45043. * Default configuration related to image processing available in the Background Material.
  45044. */
  45045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45046. /**
  45047. * Keep track of the image processing observer to allow dispose and replace.
  45048. */
  45049. private _imageProcessingObserver;
  45050. /**
  45051. * Attaches a new image processing configuration to the PBR Material.
  45052. * @param configuration (if null the scene configuration will be use)
  45053. */
  45054. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45055. /**
  45056. * Gets the image processing configuration used either in this material.
  45057. */
  45058. /**
  45059. * Sets the Default image processing configuration used either in the this material.
  45060. *
  45061. * If sets to null, the scene one is in use.
  45062. */
  45063. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45064. /**
  45065. * Gets wether the color curves effect is enabled.
  45066. */
  45067. /**
  45068. * Sets wether the color curves effect is enabled.
  45069. */
  45070. cameraColorCurvesEnabled: boolean;
  45071. /**
  45072. * Gets wether the color grading effect is enabled.
  45073. */
  45074. /**
  45075. * Gets wether the color grading effect is enabled.
  45076. */
  45077. cameraColorGradingEnabled: boolean;
  45078. /**
  45079. * Gets wether tonemapping is enabled or not.
  45080. */
  45081. /**
  45082. * Sets wether tonemapping is enabled or not
  45083. */
  45084. cameraToneMappingEnabled: boolean;
  45085. /**
  45086. * The camera exposure used on this material.
  45087. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45088. * This corresponds to a photographic exposure.
  45089. */
  45090. /**
  45091. * The camera exposure used on this material.
  45092. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45093. * This corresponds to a photographic exposure.
  45094. */
  45095. cameraExposure: float;
  45096. /**
  45097. * Gets The camera contrast used on this material.
  45098. */
  45099. /**
  45100. * Sets The camera contrast used on this material.
  45101. */
  45102. cameraContrast: float;
  45103. /**
  45104. * Gets the Color Grading 2D Lookup Texture.
  45105. */
  45106. /**
  45107. * Sets the Color Grading 2D Lookup Texture.
  45108. */
  45109. cameraColorGradingTexture: Nullable<BaseTexture>;
  45110. /**
  45111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45113. * 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;
  45114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45115. */
  45116. /**
  45117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45119. * 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;
  45120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45121. */
  45122. cameraColorCurves: Nullable<ColorCurves>;
  45123. /**
  45124. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45125. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45126. */
  45127. switchToBGR: boolean;
  45128. private _renderTargets;
  45129. private _reflectionControls;
  45130. private _white;
  45131. private _primaryShadowColor;
  45132. private _primaryHighlightColor;
  45133. /**
  45134. * Instantiates a Background Material in the given scene
  45135. * @param name The friendly name of the material
  45136. * @param scene The scene to add the material to
  45137. */
  45138. constructor(name: string, scene: Scene);
  45139. /**
  45140. * Gets a boolean indicating that current material needs to register RTT
  45141. */
  45142. readonly hasRenderTargetTextures: boolean;
  45143. /**
  45144. * The entire material has been created in order to prevent overdraw.
  45145. * @returns false
  45146. */
  45147. needAlphaTesting(): boolean;
  45148. /**
  45149. * The entire material has been created in order to prevent overdraw.
  45150. * @returns true if blending is enable
  45151. */
  45152. needAlphaBlending(): boolean;
  45153. /**
  45154. * Checks wether the material is ready to be rendered for a given mesh.
  45155. * @param mesh The mesh to render
  45156. * @param subMesh The submesh to check against
  45157. * @param useInstances Specify wether or not the material is used with instances
  45158. * @returns true if all the dependencies are ready (Textures, Effects...)
  45159. */
  45160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45161. /**
  45162. * Compute the primary color according to the chosen perceptual color.
  45163. */
  45164. private _computePrimaryColorFromPerceptualColor;
  45165. /**
  45166. * Compute the highlights and shadow colors according to their chosen levels.
  45167. */
  45168. private _computePrimaryColors;
  45169. /**
  45170. * Build the uniform buffer used in the material.
  45171. */
  45172. buildUniformLayout(): void;
  45173. /**
  45174. * Unbind the material.
  45175. */
  45176. unbind(): void;
  45177. /**
  45178. * Bind only the world matrix to the material.
  45179. * @param world The world matrix to bind.
  45180. */
  45181. bindOnlyWorldMatrix(world: Matrix): void;
  45182. /**
  45183. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45184. * @param world The world matrix to bind.
  45185. * @param subMesh The submesh to bind for.
  45186. */
  45187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45188. /**
  45189. * Checks to see if a texture is used in the material.
  45190. * @param texture - Base texture to use.
  45191. * @returns - Boolean specifying if a texture is used in the material.
  45192. */
  45193. hasTexture(texture: BaseTexture): boolean;
  45194. /**
  45195. * Dispose the material.
  45196. * @param forceDisposeEffect Force disposal of the associated effect.
  45197. * @param forceDisposeTextures Force disposal of the associated textures.
  45198. */
  45199. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45200. /**
  45201. * Clones the material.
  45202. * @param name The cloned name.
  45203. * @returns The cloned material.
  45204. */
  45205. clone(name: string): BackgroundMaterial;
  45206. /**
  45207. * Serializes the current material to its JSON representation.
  45208. * @returns The JSON representation.
  45209. */
  45210. serialize(): any;
  45211. /**
  45212. * Gets the class name of the material
  45213. * @returns "BackgroundMaterial"
  45214. */
  45215. getClassName(): string;
  45216. /**
  45217. * Parse a JSON input to create back a background material.
  45218. * @param source The JSON data to parse
  45219. * @param scene The scene to create the parsed material in
  45220. * @param rootUrl The root url of the assets the material depends upon
  45221. * @returns the instantiated BackgroundMaterial.
  45222. */
  45223. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45224. }
  45225. }
  45226. declare module BABYLON {
  45227. /**
  45228. * Represents the different options available during the creation of
  45229. * a Environment helper.
  45230. *
  45231. * This can control the default ground, skybox and image processing setup of your scene.
  45232. */
  45233. export interface IEnvironmentHelperOptions {
  45234. /**
  45235. * Specifies wether or not to create a ground.
  45236. * True by default.
  45237. */
  45238. createGround: boolean;
  45239. /**
  45240. * Specifies the ground size.
  45241. * 15 by default.
  45242. */
  45243. groundSize: number;
  45244. /**
  45245. * The texture used on the ground for the main color.
  45246. * Comes from the BabylonJS CDN by default.
  45247. *
  45248. * Remarks: Can be either a texture or a url.
  45249. */
  45250. groundTexture: string | BaseTexture;
  45251. /**
  45252. * The color mixed in the ground texture by default.
  45253. * BabylonJS clearColor by default.
  45254. */
  45255. groundColor: Color3;
  45256. /**
  45257. * Specifies the ground opacity.
  45258. * 1 by default.
  45259. */
  45260. groundOpacity: number;
  45261. /**
  45262. * Enables the ground to receive shadows.
  45263. * True by default.
  45264. */
  45265. enableGroundShadow: boolean;
  45266. /**
  45267. * Helps preventing the shadow to be fully black on the ground.
  45268. * 0.5 by default.
  45269. */
  45270. groundShadowLevel: number;
  45271. /**
  45272. * Creates a mirror texture attach to the ground.
  45273. * false by default.
  45274. */
  45275. enableGroundMirror: boolean;
  45276. /**
  45277. * Specifies the ground mirror size ratio.
  45278. * 0.3 by default as the default kernel is 64.
  45279. */
  45280. groundMirrorSizeRatio: number;
  45281. /**
  45282. * Specifies the ground mirror blur kernel size.
  45283. * 64 by default.
  45284. */
  45285. groundMirrorBlurKernel: number;
  45286. /**
  45287. * Specifies the ground mirror visibility amount.
  45288. * 1 by default
  45289. */
  45290. groundMirrorAmount: number;
  45291. /**
  45292. * Specifies the ground mirror reflectance weight.
  45293. * This uses the standard weight of the background material to setup the fresnel effect
  45294. * of the mirror.
  45295. * 1 by default.
  45296. */
  45297. groundMirrorFresnelWeight: number;
  45298. /**
  45299. * Specifies the ground mirror Falloff distance.
  45300. * This can helps reducing the size of the reflection.
  45301. * 0 by Default.
  45302. */
  45303. groundMirrorFallOffDistance: number;
  45304. /**
  45305. * Specifies the ground mirror texture type.
  45306. * Unsigned Int by Default.
  45307. */
  45308. groundMirrorTextureType: number;
  45309. /**
  45310. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45311. * the shown objects.
  45312. */
  45313. groundYBias: number;
  45314. /**
  45315. * Specifies wether or not to create a skybox.
  45316. * True by default.
  45317. */
  45318. createSkybox: boolean;
  45319. /**
  45320. * Specifies the skybox size.
  45321. * 20 by default.
  45322. */
  45323. skyboxSize: number;
  45324. /**
  45325. * The texture used on the skybox for the main color.
  45326. * Comes from the BabylonJS CDN by default.
  45327. *
  45328. * Remarks: Can be either a texture or a url.
  45329. */
  45330. skyboxTexture: string | BaseTexture;
  45331. /**
  45332. * The color mixed in the skybox texture by default.
  45333. * BabylonJS clearColor by default.
  45334. */
  45335. skyboxColor: Color3;
  45336. /**
  45337. * The background rotation around the Y axis of the scene.
  45338. * This helps aligning the key lights of your scene with the background.
  45339. * 0 by default.
  45340. */
  45341. backgroundYRotation: number;
  45342. /**
  45343. * Compute automatically the size of the elements to best fit with the scene.
  45344. */
  45345. sizeAuto: boolean;
  45346. /**
  45347. * Default position of the rootMesh if autoSize is not true.
  45348. */
  45349. rootPosition: Vector3;
  45350. /**
  45351. * Sets up the image processing in the scene.
  45352. * true by default.
  45353. */
  45354. setupImageProcessing: boolean;
  45355. /**
  45356. * The texture used as your environment texture in the scene.
  45357. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45358. *
  45359. * Remarks: Can be either a texture or a url.
  45360. */
  45361. environmentTexture: string | BaseTexture;
  45362. /**
  45363. * The value of the exposure to apply to the scene.
  45364. * 0.6 by default if setupImageProcessing is true.
  45365. */
  45366. cameraExposure: number;
  45367. /**
  45368. * The value of the contrast to apply to the scene.
  45369. * 1.6 by default if setupImageProcessing is true.
  45370. */
  45371. cameraContrast: number;
  45372. /**
  45373. * Specifies wether or not tonemapping should be enabled in the scene.
  45374. * true by default if setupImageProcessing is true.
  45375. */
  45376. toneMappingEnabled: boolean;
  45377. }
  45378. /**
  45379. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45380. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45381. * It also helps with the default setup of your imageProcessing configuration.
  45382. */
  45383. export class EnvironmentHelper {
  45384. /**
  45385. * Default ground texture URL.
  45386. */
  45387. private static _groundTextureCDNUrl;
  45388. /**
  45389. * Default skybox texture URL.
  45390. */
  45391. private static _skyboxTextureCDNUrl;
  45392. /**
  45393. * Default environment texture URL.
  45394. */
  45395. private static _environmentTextureCDNUrl;
  45396. /**
  45397. * Creates the default options for the helper.
  45398. */
  45399. private static _getDefaultOptions;
  45400. private _rootMesh;
  45401. /**
  45402. * Gets the root mesh created by the helper.
  45403. */
  45404. readonly rootMesh: Mesh;
  45405. private _skybox;
  45406. /**
  45407. * Gets the skybox created by the helper.
  45408. */
  45409. readonly skybox: Nullable<Mesh>;
  45410. private _skyboxTexture;
  45411. /**
  45412. * Gets the skybox texture created by the helper.
  45413. */
  45414. readonly skyboxTexture: Nullable<BaseTexture>;
  45415. private _skyboxMaterial;
  45416. /**
  45417. * Gets the skybox material created by the helper.
  45418. */
  45419. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45420. private _ground;
  45421. /**
  45422. * Gets the ground mesh created by the helper.
  45423. */
  45424. readonly ground: Nullable<Mesh>;
  45425. private _groundTexture;
  45426. /**
  45427. * Gets the ground texture created by the helper.
  45428. */
  45429. readonly groundTexture: Nullable<BaseTexture>;
  45430. private _groundMirror;
  45431. /**
  45432. * Gets the ground mirror created by the helper.
  45433. */
  45434. readonly groundMirror: Nullable<MirrorTexture>;
  45435. /**
  45436. * Gets the ground mirror render list to helps pushing the meshes
  45437. * you wish in the ground reflection.
  45438. */
  45439. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45440. private _groundMaterial;
  45441. /**
  45442. * Gets the ground material created by the helper.
  45443. */
  45444. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45445. /**
  45446. * Stores the creation options.
  45447. */
  45448. private readonly _scene;
  45449. private _options;
  45450. /**
  45451. * This observable will be notified with any error during the creation of the environment,
  45452. * mainly texture creation errors.
  45453. */
  45454. onErrorObservable: Observable<{
  45455. message?: string;
  45456. exception?: any;
  45457. }>;
  45458. /**
  45459. * constructor
  45460. * @param options Defines the options we want to customize the helper
  45461. * @param scene The scene to add the material to
  45462. */
  45463. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45464. /**
  45465. * Updates the background according to the new options
  45466. * @param options
  45467. */
  45468. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45469. /**
  45470. * Sets the primary color of all the available elements.
  45471. * @param color the main color to affect to the ground and the background
  45472. */
  45473. setMainColor(color: Color3): void;
  45474. /**
  45475. * Setup the image processing according to the specified options.
  45476. */
  45477. private _setupImageProcessing;
  45478. /**
  45479. * Setup the environment texture according to the specified options.
  45480. */
  45481. private _setupEnvironmentTexture;
  45482. /**
  45483. * Setup the background according to the specified options.
  45484. */
  45485. private _setupBackground;
  45486. /**
  45487. * Get the scene sizes according to the setup.
  45488. */
  45489. private _getSceneSize;
  45490. /**
  45491. * Setup the ground according to the specified options.
  45492. */
  45493. private _setupGround;
  45494. /**
  45495. * Setup the ground material according to the specified options.
  45496. */
  45497. private _setupGroundMaterial;
  45498. /**
  45499. * Setup the ground diffuse texture according to the specified options.
  45500. */
  45501. private _setupGroundDiffuseTexture;
  45502. /**
  45503. * Setup the ground mirror texture according to the specified options.
  45504. */
  45505. private _setupGroundMirrorTexture;
  45506. /**
  45507. * Setup the ground to receive the mirror texture.
  45508. */
  45509. private _setupMirrorInGroundMaterial;
  45510. /**
  45511. * Setup the skybox according to the specified options.
  45512. */
  45513. private _setupSkybox;
  45514. /**
  45515. * Setup the skybox material according to the specified options.
  45516. */
  45517. private _setupSkyboxMaterial;
  45518. /**
  45519. * Setup the skybox reflection texture according to the specified options.
  45520. */
  45521. private _setupSkyboxReflectionTexture;
  45522. private _errorHandler;
  45523. /**
  45524. * Dispose all the elements created by the Helper.
  45525. */
  45526. dispose(): void;
  45527. }
  45528. }
  45529. declare module BABYLON {
  45530. /**
  45531. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45532. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45533. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45535. */
  45536. export class PhotoDome extends TransformNode {
  45537. /**
  45538. * Define the image as a Monoscopic panoramic 360 image.
  45539. */
  45540. static readonly MODE_MONOSCOPIC: number;
  45541. /**
  45542. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45543. */
  45544. static readonly MODE_TOPBOTTOM: number;
  45545. /**
  45546. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45547. */
  45548. static readonly MODE_SIDEBYSIDE: number;
  45549. private _useDirectMapping;
  45550. /**
  45551. * The texture being displayed on the sphere
  45552. */
  45553. protected _photoTexture: Texture;
  45554. /**
  45555. * Gets or sets the texture being displayed on the sphere
  45556. */
  45557. photoTexture: Texture;
  45558. /**
  45559. * Observable raised when an error occured while loading the 360 image
  45560. */
  45561. onLoadErrorObservable: Observable<string>;
  45562. /**
  45563. * The skybox material
  45564. */
  45565. protected _material: BackgroundMaterial;
  45566. /**
  45567. * The surface used for the skybox
  45568. */
  45569. protected _mesh: Mesh;
  45570. /**
  45571. * Gets the mesh used for the skybox.
  45572. */
  45573. readonly mesh: Mesh;
  45574. /**
  45575. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45576. * Also see the options.resolution property.
  45577. */
  45578. fovMultiplier: number;
  45579. private _imageMode;
  45580. /**
  45581. * Gets or set the current video mode for the video. It can be:
  45582. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45583. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45584. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45585. */
  45586. imageMode: number;
  45587. /**
  45588. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45589. * @param name Element's name, child elements will append suffixes for their own names.
  45590. * @param urlsOfPhoto defines the url of the photo to display
  45591. * @param options defines an object containing optional or exposed sub element properties
  45592. * @param onError defines a callback called when an error occured while loading the texture
  45593. */
  45594. constructor(name: string, urlOfPhoto: string, options: {
  45595. resolution?: number;
  45596. size?: number;
  45597. useDirectMapping?: boolean;
  45598. faceForward?: boolean;
  45599. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45600. private _onBeforeCameraRenderObserver;
  45601. private _changeImageMode;
  45602. /**
  45603. * Releases resources associated with this node.
  45604. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45605. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45606. */
  45607. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45608. }
  45609. }
  45610. declare module BABYLON {
  45611. /**
  45612. * Class used to host RGBD texture specific utilities
  45613. */
  45614. export class RGBDTextureTools {
  45615. /**
  45616. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45617. * @param texture the texture to expand.
  45618. */
  45619. static ExpandRGBDTexture(texture: Texture): void;
  45620. }
  45621. }
  45622. declare module BABYLON {
  45623. /**
  45624. * Class used to host texture specific utilities
  45625. */
  45626. export class BRDFTextureTools {
  45627. /**
  45628. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45629. * @param scene defines the hosting scene
  45630. * @returns the environment BRDF texture
  45631. */
  45632. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45633. private static _environmentBRDFBase64Texture;
  45634. }
  45635. }
  45636. declare module BABYLON {
  45637. /**
  45638. * @hidden
  45639. */
  45640. export interface IMaterialClearCoatDefines {
  45641. CLEARCOAT: boolean;
  45642. CLEARCOAT_DEFAULTIOR: boolean;
  45643. CLEARCOAT_TEXTURE: boolean;
  45644. CLEARCOAT_TEXTUREDIRECTUV: number;
  45645. CLEARCOAT_BUMP: boolean;
  45646. CLEARCOAT_BUMPDIRECTUV: number;
  45647. CLEARCOAT_TINT: boolean;
  45648. CLEARCOAT_TINT_TEXTURE: boolean;
  45649. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45650. /** @hidden */ private _areTexturesDirty: boolean;
  45651. }
  45652. /**
  45653. * Define the code related to the clear coat parameters of the pbr material.
  45654. */
  45655. export class PBRClearCoatConfiguration {
  45656. /**
  45657. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45658. * The default fits with a polyurethane material.
  45659. */
  45660. private static readonly _DefaultIndexOfRefraction;
  45661. private _isEnabled;
  45662. /**
  45663. * Defines if the clear coat is enabled in the material.
  45664. */
  45665. isEnabled: boolean;
  45666. /**
  45667. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45668. */
  45669. intensity: number;
  45670. /**
  45671. * Defines the clear coat layer roughness.
  45672. */
  45673. roughness: number;
  45674. private _indexOfRefraction;
  45675. /**
  45676. * Defines the index of refraction of the clear coat.
  45677. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45678. * The default fits with a polyurethane material.
  45679. * Changing the default value is more performance intensive.
  45680. */
  45681. indexOfRefraction: number;
  45682. private _texture;
  45683. /**
  45684. * Stores the clear coat values in a texture.
  45685. */
  45686. texture: Nullable<BaseTexture>;
  45687. private _bumpTexture;
  45688. /**
  45689. * Define the clear coat specific bump texture.
  45690. */
  45691. bumpTexture: Nullable<BaseTexture>;
  45692. private _isTintEnabled;
  45693. /**
  45694. * Defines if the clear coat tint is enabled in the material.
  45695. */
  45696. isTintEnabled: boolean;
  45697. /**
  45698. * Defines the clear coat tint of the material.
  45699. * This is only use if tint is enabled
  45700. */
  45701. tintColor: Color3;
  45702. /**
  45703. * Defines the distance at which the tint color should be found in the
  45704. * clear coat media.
  45705. * This is only use if tint is enabled
  45706. */
  45707. tintColorAtDistance: number;
  45708. /**
  45709. * Defines the clear coat layer thickness.
  45710. * This is only use if tint is enabled
  45711. */
  45712. tintThickness: number;
  45713. private _tintTexture;
  45714. /**
  45715. * Stores the clear tint values in a texture.
  45716. * rgb is tint
  45717. * a is a thickness factor
  45718. */
  45719. tintTexture: Nullable<BaseTexture>;
  45720. /** @hidden */
  45721. private _internalMarkAllSubMeshesAsTexturesDirty;
  45722. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45723. /**
  45724. * Instantiate a new istance of clear coat configuration.
  45725. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45726. */
  45727. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45728. /**
  45729. * Gets wehter the submesh is ready to be used or not.
  45730. * @param defines the list of "defines" to update.
  45731. * @param scene defines the scene the material belongs to.
  45732. * @param engine defines the engine the material belongs to.
  45733. * @param disableBumpMap defines wether the material disables bump or not.
  45734. * @returns - boolean indicating that the submesh is ready or not.
  45735. */
  45736. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45737. /**
  45738. * Checks to see if a texture is used in the material.
  45739. * @param defines the list of "defines" to update.
  45740. * @param scene defines the scene to the material belongs to.
  45741. */
  45742. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45743. /**
  45744. * Binds the material data.
  45745. * @param uniformBuffer defines the Uniform buffer to fill in.
  45746. * @param scene defines the scene the material belongs to.
  45747. * @param engine defines the engine the material belongs to.
  45748. * @param disableBumpMap defines wether the material disables bump or not.
  45749. * @param isFrozen defines wether the material is frozen or not.
  45750. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45751. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45752. */
  45753. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45754. /**
  45755. * Checks to see if a texture is used in the material.
  45756. * @param texture - Base texture to use.
  45757. * @returns - Boolean specifying if a texture is used in the material.
  45758. */
  45759. hasTexture(texture: BaseTexture): boolean;
  45760. /**
  45761. * Returns an array of the actively used textures.
  45762. * @param activeTextures Array of BaseTextures
  45763. */
  45764. getActiveTextures(activeTextures: BaseTexture[]): void;
  45765. /**
  45766. * Returns the animatable textures.
  45767. * @param animatables Array of animatable textures.
  45768. */
  45769. getAnimatables(animatables: IAnimatable[]): void;
  45770. /**
  45771. * Disposes the resources of the material.
  45772. * @param forceDisposeTextures - Forces the disposal of all textures.
  45773. */
  45774. dispose(forceDisposeTextures?: boolean): void;
  45775. /**
  45776. * Get the current class name of the texture useful for serialization or dynamic coding.
  45777. * @returns "PBRClearCoatConfiguration"
  45778. */
  45779. getClassName(): string;
  45780. /**
  45781. * Add fallbacks to the effect fallbacks list.
  45782. * @param defines defines the Base texture to use.
  45783. * @param fallbacks defines the current fallback list.
  45784. * @param currentRank defines the current fallback rank.
  45785. * @returns the new fallback rank.
  45786. */
  45787. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45788. /**
  45789. * Add the required uniforms to the current list.
  45790. * @param uniforms defines the current uniform list.
  45791. */
  45792. static AddUniforms(uniforms: string[]): void;
  45793. /**
  45794. * Add the required samplers to the current list.
  45795. * @param samplers defines the current sampler list.
  45796. */
  45797. static AddSamplers(samplers: string[]): void;
  45798. /**
  45799. * Add the required uniforms to the current buffer.
  45800. * @param uniformBuffer defines the current uniform buffer.
  45801. */
  45802. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45803. /**
  45804. * Makes a duplicate of the current configuration into another one.
  45805. * @param clearCoatConfiguration define the config where to copy the info
  45806. */
  45807. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45808. /**
  45809. * Serializes this clear coat configuration.
  45810. * @returns - An object with the serialized config.
  45811. */
  45812. serialize(): any;
  45813. /**
  45814. * Parses a anisotropy Configuration from a serialized object.
  45815. * @param source - Serialized object.
  45816. * @param scene Defines the scene we are parsing for
  45817. * @param rootUrl Defines the rootUrl to load from
  45818. */
  45819. parse(source: any, scene: Scene, rootUrl: string): void;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * @hidden
  45825. */
  45826. export interface IMaterialAnisotropicDefines {
  45827. ANISOTROPIC: boolean;
  45828. ANISOTROPIC_TEXTURE: boolean;
  45829. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45830. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45831. }
  45832. /**
  45833. * Define the code related to the anisotropic parameters of the pbr material.
  45834. */
  45835. export class PBRAnisotropicConfiguration {
  45836. private _isEnabled;
  45837. /**
  45838. * Defines if the anisotropy is enabled in the material.
  45839. */
  45840. isEnabled: boolean;
  45841. /**
  45842. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45843. */
  45844. intensity: number;
  45845. /**
  45846. * Defines if the effect is along the tangents, bitangents or in between.
  45847. * By default, the effect is "strectching" the highlights along the tangents.
  45848. */
  45849. direction: Vector2;
  45850. private _texture;
  45851. /**
  45852. * Stores the anisotropy values in a texture.
  45853. * rg is direction (like normal from -1 to 1)
  45854. * b is a intensity
  45855. */
  45856. texture: Nullable<BaseTexture>;
  45857. /** @hidden */
  45858. private _internalMarkAllSubMeshesAsTexturesDirty;
  45859. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45860. /**
  45861. * Instantiate a new istance of anisotropy configuration.
  45862. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45863. */
  45864. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45865. /**
  45866. * Specifies that the submesh is ready to be used.
  45867. * @param defines the list of "defines" to update.
  45868. * @param scene defines the scene the material belongs to.
  45869. * @returns - boolean indicating that the submesh is ready or not.
  45870. */
  45871. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45872. /**
  45873. * Checks to see if a texture is used in the material.
  45874. * @param defines the list of "defines" to update.
  45875. * @param mesh the mesh we are preparing the defines for.
  45876. * @param scene defines the scene the material belongs to.
  45877. */
  45878. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45879. /**
  45880. * Binds the material data.
  45881. * @param uniformBuffer defines the Uniform buffer to fill in.
  45882. * @param scene defines the scene the material belongs to.
  45883. * @param isFrozen defines wether the material is frozen or not.
  45884. */
  45885. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45886. /**
  45887. * Checks to see if a texture is used in the material.
  45888. * @param texture - Base texture to use.
  45889. * @returns - Boolean specifying if a texture is used in the material.
  45890. */
  45891. hasTexture(texture: BaseTexture): boolean;
  45892. /**
  45893. * Returns an array of the actively used textures.
  45894. * @param activeTextures Array of BaseTextures
  45895. */
  45896. getActiveTextures(activeTextures: BaseTexture[]): void;
  45897. /**
  45898. * Returns the animatable textures.
  45899. * @param animatables Array of animatable textures.
  45900. */
  45901. getAnimatables(animatables: IAnimatable[]): void;
  45902. /**
  45903. * Disposes the resources of the material.
  45904. * @param forceDisposeTextures - Forces the disposal of all textures.
  45905. */
  45906. dispose(forceDisposeTextures?: boolean): void;
  45907. /**
  45908. * Get the current class name of the texture useful for serialization or dynamic coding.
  45909. * @returns "PBRAnisotropicConfiguration"
  45910. */
  45911. getClassName(): string;
  45912. /**
  45913. * Add fallbacks to the effect fallbacks list.
  45914. * @param defines defines the Base texture to use.
  45915. * @param fallbacks defines the current fallback list.
  45916. * @param currentRank defines the current fallback rank.
  45917. * @returns the new fallback rank.
  45918. */
  45919. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45920. /**
  45921. * Add the required uniforms to the current list.
  45922. * @param uniforms defines the current uniform list.
  45923. */
  45924. static AddUniforms(uniforms: string[]): void;
  45925. /**
  45926. * Add the required uniforms to the current buffer.
  45927. * @param uniformBuffer defines the current uniform buffer.
  45928. */
  45929. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45930. /**
  45931. * Add the required samplers to the current list.
  45932. * @param samplers defines the current sampler list.
  45933. */
  45934. static AddSamplers(samplers: string[]): void;
  45935. /**
  45936. * Makes a duplicate of the current configuration into another one.
  45937. * @param anisotropicConfiguration define the config where to copy the info
  45938. */
  45939. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45940. /**
  45941. * Serializes this anisotropy configuration.
  45942. * @returns - An object with the serialized config.
  45943. */
  45944. serialize(): any;
  45945. /**
  45946. * Parses a anisotropy Configuration from a serialized object.
  45947. * @param source - Serialized object.
  45948. * @param scene Defines the scene we are parsing for
  45949. * @param rootUrl Defines the rootUrl to load from
  45950. */
  45951. parse(source: any, scene: Scene, rootUrl: string): void;
  45952. }
  45953. }
  45954. declare module BABYLON {
  45955. /**
  45956. * @hidden
  45957. */
  45958. export interface IMaterialBRDFDefines {
  45959. BRDF_V_HEIGHT_CORRELATED: boolean;
  45960. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45961. SPHERICAL_HARMONICS: boolean;
  45962. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  45963. /** @hidden */ private _areMiscDirty: boolean;
  45964. }
  45965. /**
  45966. * Define the code related to the BRDF parameters of the pbr material.
  45967. */
  45968. export class PBRBRDFConfiguration {
  45969. /**
  45970. * Default value used for the energy conservation.
  45971. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45972. */
  45973. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45974. /**
  45975. * Default value used for the Smith Visibility Height Correlated mode.
  45976. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45977. */
  45978. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45979. /**
  45980. * Default value used for the IBL diffuse part.
  45981. * This can help switching back to the polynomials mode globally which is a tiny bit
  45982. * less GPU intensive at the drawback of a lower quality.
  45983. */
  45984. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45985. /**
  45986. * Default value used for activating energy conservation for the specular workflow.
  45987. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  45988. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  45989. */
  45990. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  45991. private _useEnergyConservation;
  45992. /**
  45993. * Defines if the material uses energy conservation.
  45994. */
  45995. useEnergyConservation: boolean;
  45996. private _useSmithVisibilityHeightCorrelated;
  45997. /**
  45998. * LEGACY Mode set to false
  45999. * Defines if the material uses height smith correlated visibility term.
  46000. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46001. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46002. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46003. * Not relying on height correlated will also disable energy conservation.
  46004. */
  46005. useSmithVisibilityHeightCorrelated: boolean;
  46006. private _useSphericalHarmonics;
  46007. /**
  46008. * LEGACY Mode set to false
  46009. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46010. * diffuse part of the IBL.
  46011. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46012. * to the ground truth.
  46013. */
  46014. useSphericalHarmonics: boolean;
  46015. private _useSpecularGlossinessInputEnergyConservation;
  46016. /**
  46017. * Defines if the material uses energy conservation, when the specular workflow is active.
  46018. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46019. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46020. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46021. */
  46022. useSpecularGlossinessInputEnergyConservation: boolean;
  46023. /** @hidden */
  46024. private _internalMarkAllSubMeshesAsMiscDirty;
  46025. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46026. /**
  46027. * Instantiate a new istance of clear coat configuration.
  46028. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46029. */
  46030. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46031. /**
  46032. * Checks to see if a texture is used in the material.
  46033. * @param defines the list of "defines" to update.
  46034. */
  46035. prepareDefines(defines: IMaterialBRDFDefines): void;
  46036. /**
  46037. * Get the current class name of the texture useful for serialization or dynamic coding.
  46038. * @returns "PBRClearCoatConfiguration"
  46039. */
  46040. getClassName(): string;
  46041. /**
  46042. * Makes a duplicate of the current configuration into another one.
  46043. * @param brdfConfiguration define the config where to copy the info
  46044. */
  46045. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46046. /**
  46047. * Serializes this BRDF configuration.
  46048. * @returns - An object with the serialized config.
  46049. */
  46050. serialize(): any;
  46051. /**
  46052. * Parses a anisotropy Configuration from a serialized object.
  46053. * @param source - Serialized object.
  46054. * @param scene Defines the scene we are parsing for
  46055. * @param rootUrl Defines the rootUrl to load from
  46056. */
  46057. parse(source: any, scene: Scene, rootUrl: string): void;
  46058. }
  46059. }
  46060. declare module BABYLON {
  46061. /**
  46062. * @hidden
  46063. */
  46064. export interface IMaterialSheenDefines {
  46065. SHEEN: boolean;
  46066. SHEEN_TEXTURE: boolean;
  46067. SHEEN_TEXTUREDIRECTUV: number;
  46068. SHEEN_LINKWITHALBEDO: boolean;
  46069. /** @hidden */ private _areTexturesDirty: boolean;
  46070. }
  46071. /**
  46072. * Define the code related to the Sheen parameters of the pbr material.
  46073. */
  46074. export class PBRSheenConfiguration {
  46075. private _isEnabled;
  46076. /**
  46077. * Defines if the material uses sheen.
  46078. */
  46079. isEnabled: boolean;
  46080. private _linkSheenWithAlbedo;
  46081. /**
  46082. * Defines if the sheen is linked to the sheen color.
  46083. */
  46084. linkSheenWithAlbedo: boolean;
  46085. /**
  46086. * Defines the sheen intensity.
  46087. */
  46088. intensity: number;
  46089. /**
  46090. * Defines the sheen color.
  46091. */
  46092. color: Color3;
  46093. private _texture;
  46094. /**
  46095. * Stores the sheen tint values in a texture.
  46096. * rgb is tint
  46097. * a is a intensity
  46098. */
  46099. texture: Nullable<BaseTexture>;
  46100. /** @hidden */
  46101. private _internalMarkAllSubMeshesAsTexturesDirty;
  46102. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46103. /**
  46104. * Instantiate a new istance of clear coat configuration.
  46105. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46106. */
  46107. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46108. /**
  46109. * Specifies that the submesh is ready to be used.
  46110. * @param defines the list of "defines" to update.
  46111. * @param scene defines the scene the material belongs to.
  46112. * @returns - boolean indicating that the submesh is ready or not.
  46113. */
  46114. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46115. /**
  46116. * Checks to see if a texture is used in the material.
  46117. * @param defines the list of "defines" to update.
  46118. * @param scene defines the scene the material belongs to.
  46119. */
  46120. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46121. /**
  46122. * Binds the material data.
  46123. * @param uniformBuffer defines the Uniform buffer to fill in.
  46124. * @param scene defines the scene the material belongs to.
  46125. * @param isFrozen defines wether the material is frozen or not.
  46126. */
  46127. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46128. /**
  46129. * Checks to see if a texture is used in the material.
  46130. * @param texture - Base texture to use.
  46131. * @returns - Boolean specifying if a texture is used in the material.
  46132. */
  46133. hasTexture(texture: BaseTexture): boolean;
  46134. /**
  46135. * Returns an array of the actively used textures.
  46136. * @param activeTextures Array of BaseTextures
  46137. */
  46138. getActiveTextures(activeTextures: BaseTexture[]): void;
  46139. /**
  46140. * Returns the animatable textures.
  46141. * @param animatables Array of animatable textures.
  46142. */
  46143. getAnimatables(animatables: IAnimatable[]): void;
  46144. /**
  46145. * Disposes the resources of the material.
  46146. * @param forceDisposeTextures - Forces the disposal of all textures.
  46147. */
  46148. dispose(forceDisposeTextures?: boolean): void;
  46149. /**
  46150. * Get the current class name of the texture useful for serialization or dynamic coding.
  46151. * @returns "PBRSheenConfiguration"
  46152. */
  46153. getClassName(): string;
  46154. /**
  46155. * Add fallbacks to the effect fallbacks list.
  46156. * @param defines defines the Base texture to use.
  46157. * @param fallbacks defines the current fallback list.
  46158. * @param currentRank defines the current fallback rank.
  46159. * @returns the new fallback rank.
  46160. */
  46161. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46162. /**
  46163. * Add the required uniforms to the current list.
  46164. * @param uniforms defines the current uniform list.
  46165. */
  46166. static AddUniforms(uniforms: string[]): void;
  46167. /**
  46168. * Add the required uniforms to the current buffer.
  46169. * @param uniformBuffer defines the current uniform buffer.
  46170. */
  46171. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46172. /**
  46173. * Add the required samplers to the current list.
  46174. * @param samplers defines the current sampler list.
  46175. */
  46176. static AddSamplers(samplers: string[]): void;
  46177. /**
  46178. * Makes a duplicate of the current configuration into another one.
  46179. * @param sheenConfiguration define the config where to copy the info
  46180. */
  46181. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46182. /**
  46183. * Serializes this BRDF configuration.
  46184. * @returns - An object with the serialized config.
  46185. */
  46186. serialize(): any;
  46187. /**
  46188. * Parses a anisotropy Configuration from a serialized object.
  46189. * @param source - Serialized object.
  46190. * @param scene Defines the scene we are parsing for
  46191. * @param rootUrl Defines the rootUrl to load from
  46192. */
  46193. parse(source: any, scene: Scene, rootUrl: string): void;
  46194. }
  46195. }
  46196. declare module BABYLON {
  46197. /**
  46198. * @hidden
  46199. */
  46200. export interface IMaterialSubSurfaceDefines {
  46201. SUBSURFACE: boolean;
  46202. SS_REFRACTION: boolean;
  46203. SS_TRANSLUCENCY: boolean;
  46204. SS_SCATERRING: boolean;
  46205. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46206. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46207. SS_REFRACTIONMAP_3D: boolean;
  46208. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46209. SS_LODINREFRACTIONALPHA: boolean;
  46210. SS_GAMMAREFRACTION: boolean;
  46211. SS_RGBDREFRACTION: boolean;
  46212. SS_LINEARSPECULARREFRACTION: boolean;
  46213. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46214. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46215. /** @hidden */ private _areTexturesDirty: boolean;
  46216. }
  46217. /**
  46218. * Define the code related to the sub surface parameters of the pbr material.
  46219. */
  46220. export class PBRSubSurfaceConfiguration {
  46221. private _isRefractionEnabled;
  46222. /**
  46223. * Defines if the refraction is enabled in the material.
  46224. */
  46225. isRefractionEnabled: boolean;
  46226. private _isTranslucencyEnabled;
  46227. /**
  46228. * Defines if the translucency is enabled in the material.
  46229. */
  46230. isTranslucencyEnabled: boolean;
  46231. private _isScatteringEnabled;
  46232. /**
  46233. * Defines the refraction intensity of the material.
  46234. * The refraction when enabled replaces the Diffuse part of the material.
  46235. * The intensity helps transitionning between diffuse and refraction.
  46236. */
  46237. refractionIntensity: number;
  46238. /**
  46239. * Defines the translucency intensity of the material.
  46240. * When translucency has been enabled, this defines how much of the "translucency"
  46241. * is addded to the diffuse part of the material.
  46242. */
  46243. translucencyIntensity: number;
  46244. /**
  46245. * Defines the scattering intensity of the material.
  46246. * When scattering has been enabled, this defines how much of the "scattered light"
  46247. * is addded to the diffuse part of the material.
  46248. */
  46249. scatteringIntensity: number;
  46250. private _thicknessTexture;
  46251. /**
  46252. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46253. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46254. * 0 would mean minimumThickness
  46255. * 1 would mean maximumThickness
  46256. * The other channels might be use as a mask to vary the different effects intensity.
  46257. */
  46258. thicknessTexture: Nullable<BaseTexture>;
  46259. private _refractionTexture;
  46260. /**
  46261. * Defines the texture to use for refraction.
  46262. */
  46263. refractionTexture: Nullable<BaseTexture>;
  46264. private _indexOfRefraction;
  46265. /**
  46266. * Defines the index of refraction used in the material.
  46267. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46268. */
  46269. indexOfRefraction: number;
  46270. private _invertRefractionY;
  46271. /**
  46272. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46273. */
  46274. invertRefractionY: boolean;
  46275. private _linkRefractionWithTransparency;
  46276. /**
  46277. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46278. * Materials half opaque for instance using refraction could benefit from this control.
  46279. */
  46280. linkRefractionWithTransparency: boolean;
  46281. /**
  46282. * Defines the minimum thickness stored in the thickness map.
  46283. * If no thickness map is defined, this value will be used to simulate thickness.
  46284. */
  46285. minimumThickness: number;
  46286. /**
  46287. * Defines the maximum thickness stored in the thickness map.
  46288. */
  46289. maximumThickness: number;
  46290. /**
  46291. * Defines the volume tint of the material.
  46292. * This is used for both translucency and scattering.
  46293. */
  46294. tintColor: Color3;
  46295. /**
  46296. * Defines the distance at which the tint color should be found in the media.
  46297. * This is used for refraction only.
  46298. */
  46299. tintColorAtDistance: number;
  46300. /**
  46301. * Defines how far each channel transmit through the media.
  46302. * It is defined as a color to simplify it selection.
  46303. */
  46304. diffusionDistance: Color3;
  46305. private _useMaskFromThicknessTexture;
  46306. /**
  46307. * Stores the intensity of the different subsurface effects in the thickness texture.
  46308. * * the green channel is the translucency intensity.
  46309. * * the blue channel is the scattering intensity.
  46310. * * the alpha channel is the refraction intensity.
  46311. */
  46312. useMaskFromThicknessTexture: boolean;
  46313. /** @hidden */
  46314. private _internalMarkAllSubMeshesAsTexturesDirty;
  46315. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46316. /**
  46317. * Instantiate a new istance of sub surface configuration.
  46318. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46319. */
  46320. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46321. /**
  46322. * Gets wehter the submesh is ready to be used or not.
  46323. * @param defines the list of "defines" to update.
  46324. * @param scene defines the scene the material belongs to.
  46325. * @returns - boolean indicating that the submesh is ready or not.
  46326. */
  46327. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46328. /**
  46329. * Checks to see if a texture is used in the material.
  46330. * @param defines the list of "defines" to update.
  46331. * @param scene defines the scene to the material belongs to.
  46332. */
  46333. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46334. /**
  46335. * Binds the material data.
  46336. * @param uniformBuffer defines the Uniform buffer to fill in.
  46337. * @param scene defines the scene the material belongs to.
  46338. * @param engine defines the engine the material belongs to.
  46339. * @param isFrozen defines wether the material is frozen or not.
  46340. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46341. */
  46342. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46343. /**
  46344. * Unbinds the material from the mesh.
  46345. * @param activeEffect defines the effect that should be unbound from.
  46346. * @returns true if unbound, otherwise false
  46347. */
  46348. unbind(activeEffect: Effect): boolean;
  46349. /**
  46350. * Returns the texture used for refraction or null if none is used.
  46351. * @param scene defines the scene the material belongs to.
  46352. * @returns - Refraction texture if present. If no refraction texture and refraction
  46353. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46354. */
  46355. private _getRefractionTexture;
  46356. /**
  46357. * Returns true if alpha blending should be disabled.
  46358. */
  46359. readonly disableAlphaBlending: boolean;
  46360. /**
  46361. * Fills the list of render target textures.
  46362. * @param renderTargets the list of render targets to update
  46363. */
  46364. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46365. /**
  46366. * Checks to see if a texture is used in the material.
  46367. * @param texture - Base texture to use.
  46368. * @returns - Boolean specifying if a texture is used in the material.
  46369. */
  46370. hasTexture(texture: BaseTexture): boolean;
  46371. /**
  46372. * Gets a boolean indicating that current material needs to register RTT
  46373. * @returns true if this uses a render target otherwise false.
  46374. */
  46375. hasRenderTargetTextures(): boolean;
  46376. /**
  46377. * Returns an array of the actively used textures.
  46378. * @param activeTextures Array of BaseTextures
  46379. */
  46380. getActiveTextures(activeTextures: BaseTexture[]): void;
  46381. /**
  46382. * Returns the animatable textures.
  46383. * @param animatables Array of animatable textures.
  46384. */
  46385. getAnimatables(animatables: IAnimatable[]): void;
  46386. /**
  46387. * Disposes the resources of the material.
  46388. * @param forceDisposeTextures - Forces the disposal of all textures.
  46389. */
  46390. dispose(forceDisposeTextures?: boolean): void;
  46391. /**
  46392. * Get the current class name of the texture useful for serialization or dynamic coding.
  46393. * @returns "PBRSubSurfaceConfiguration"
  46394. */
  46395. getClassName(): string;
  46396. /**
  46397. * Add fallbacks to the effect fallbacks list.
  46398. * @param defines defines the Base texture to use.
  46399. * @param fallbacks defines the current fallback list.
  46400. * @param currentRank defines the current fallback rank.
  46401. * @returns the new fallback rank.
  46402. */
  46403. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46404. /**
  46405. * Add the required uniforms to the current list.
  46406. * @param uniforms defines the current uniform list.
  46407. */
  46408. static AddUniforms(uniforms: string[]): void;
  46409. /**
  46410. * Add the required samplers to the current list.
  46411. * @param samplers defines the current sampler list.
  46412. */
  46413. static AddSamplers(samplers: string[]): void;
  46414. /**
  46415. * Add the required uniforms to the current buffer.
  46416. * @param uniformBuffer defines the current uniform buffer.
  46417. */
  46418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46419. /**
  46420. * Makes a duplicate of the current configuration into another one.
  46421. * @param configuration define the config where to copy the info
  46422. */
  46423. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46424. /**
  46425. * Serializes this Sub Surface configuration.
  46426. * @returns - An object with the serialized config.
  46427. */
  46428. serialize(): any;
  46429. /**
  46430. * Parses a anisotropy Configuration from a serialized object.
  46431. * @param source - Serialized object.
  46432. * @param scene Defines the scene we are parsing for
  46433. * @param rootUrl Defines the rootUrl to load from
  46434. */
  46435. parse(source: any, scene: Scene, rootUrl: string): void;
  46436. }
  46437. }
  46438. declare module BABYLON {
  46439. /** @hidden */
  46440. export var pbrFragmentDeclaration: {
  46441. name: string;
  46442. shader: string;
  46443. };
  46444. }
  46445. declare module BABYLON {
  46446. /** @hidden */
  46447. export var pbrUboDeclaration: {
  46448. name: string;
  46449. shader: string;
  46450. };
  46451. }
  46452. declare module BABYLON {
  46453. /** @hidden */
  46454. export var pbrFragmentExtraDeclaration: {
  46455. name: string;
  46456. shader: string;
  46457. };
  46458. }
  46459. declare module BABYLON {
  46460. /** @hidden */
  46461. export var pbrFragmentSamplersDeclaration: {
  46462. name: string;
  46463. shader: string;
  46464. };
  46465. }
  46466. declare module BABYLON {
  46467. /** @hidden */
  46468. export var pbrHelperFunctions: {
  46469. name: string;
  46470. shader: string;
  46471. };
  46472. }
  46473. declare module BABYLON {
  46474. /** @hidden */
  46475. export var harmonicsFunctions: {
  46476. name: string;
  46477. shader: string;
  46478. };
  46479. }
  46480. declare module BABYLON {
  46481. /** @hidden */
  46482. export var pbrDirectLightingSetupFunctions: {
  46483. name: string;
  46484. shader: string;
  46485. };
  46486. }
  46487. declare module BABYLON {
  46488. /** @hidden */
  46489. export var pbrDirectLightingFalloffFunctions: {
  46490. name: string;
  46491. shader: string;
  46492. };
  46493. }
  46494. declare module BABYLON {
  46495. /** @hidden */
  46496. export var pbrBRDFFunctions: {
  46497. name: string;
  46498. shader: string;
  46499. };
  46500. }
  46501. declare module BABYLON {
  46502. /** @hidden */
  46503. export var pbrDirectLightingFunctions: {
  46504. name: string;
  46505. shader: string;
  46506. };
  46507. }
  46508. declare module BABYLON {
  46509. /** @hidden */
  46510. export var pbrIBLFunctions: {
  46511. name: string;
  46512. shader: string;
  46513. };
  46514. }
  46515. declare module BABYLON {
  46516. /** @hidden */
  46517. export var pbrDebug: {
  46518. name: string;
  46519. shader: string;
  46520. };
  46521. }
  46522. declare module BABYLON {
  46523. /** @hidden */
  46524. export var pbrPixelShader: {
  46525. name: string;
  46526. shader: string;
  46527. };
  46528. }
  46529. declare module BABYLON {
  46530. /** @hidden */
  46531. export var pbrVertexDeclaration: {
  46532. name: string;
  46533. shader: string;
  46534. };
  46535. }
  46536. declare module BABYLON {
  46537. /** @hidden */
  46538. export var pbrVertexShader: {
  46539. name: string;
  46540. shader: string;
  46541. };
  46542. }
  46543. declare module BABYLON {
  46544. /**
  46545. * Manages the defines for the PBR Material.
  46546. * @hidden
  46547. */
  46548. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46549. PBR: boolean;
  46550. MAINUV1: boolean;
  46551. MAINUV2: boolean;
  46552. UV1: boolean;
  46553. UV2: boolean;
  46554. ALBEDO: boolean;
  46555. ALBEDODIRECTUV: number;
  46556. VERTEXCOLOR: boolean;
  46557. AMBIENT: boolean;
  46558. AMBIENTDIRECTUV: number;
  46559. AMBIENTINGRAYSCALE: boolean;
  46560. OPACITY: boolean;
  46561. VERTEXALPHA: boolean;
  46562. OPACITYDIRECTUV: number;
  46563. OPACITYRGB: boolean;
  46564. ALPHATEST: boolean;
  46565. DEPTHPREPASS: boolean;
  46566. ALPHABLEND: boolean;
  46567. ALPHAFROMALBEDO: boolean;
  46568. ALPHATESTVALUE: string;
  46569. SPECULAROVERALPHA: boolean;
  46570. RADIANCEOVERALPHA: boolean;
  46571. ALPHAFRESNEL: boolean;
  46572. LINEARALPHAFRESNEL: boolean;
  46573. PREMULTIPLYALPHA: boolean;
  46574. EMISSIVE: boolean;
  46575. EMISSIVEDIRECTUV: number;
  46576. REFLECTIVITY: boolean;
  46577. REFLECTIVITYDIRECTUV: number;
  46578. SPECULARTERM: boolean;
  46579. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46580. MICROSURFACEAUTOMATIC: boolean;
  46581. LODBASEDMICROSFURACE: boolean;
  46582. MICROSURFACEMAP: boolean;
  46583. MICROSURFACEMAPDIRECTUV: number;
  46584. METALLICWORKFLOW: boolean;
  46585. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46586. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46587. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46588. AOSTOREINMETALMAPRED: boolean;
  46589. ENVIRONMENTBRDF: boolean;
  46590. ENVIRONMENTBRDF_RGBD: boolean;
  46591. NORMAL: boolean;
  46592. TANGENT: boolean;
  46593. BUMP: boolean;
  46594. BUMPDIRECTUV: number;
  46595. OBJECTSPACE_NORMALMAP: boolean;
  46596. PARALLAX: boolean;
  46597. PARALLAXOCCLUSION: boolean;
  46598. NORMALXYSCALE: boolean;
  46599. LIGHTMAP: boolean;
  46600. LIGHTMAPDIRECTUV: number;
  46601. USELIGHTMAPASSHADOWMAP: boolean;
  46602. GAMMALIGHTMAP: boolean;
  46603. RGBDLIGHTMAP: boolean;
  46604. REFLECTION: boolean;
  46605. REFLECTIONMAP_3D: boolean;
  46606. REFLECTIONMAP_SPHERICAL: boolean;
  46607. REFLECTIONMAP_PLANAR: boolean;
  46608. REFLECTIONMAP_CUBIC: boolean;
  46609. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46610. REFLECTIONMAP_PROJECTION: boolean;
  46611. REFLECTIONMAP_SKYBOX: boolean;
  46612. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46613. REFLECTIONMAP_EXPLICIT: boolean;
  46614. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46615. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46616. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46617. INVERTCUBICMAP: boolean;
  46618. USESPHERICALFROMREFLECTIONMAP: boolean;
  46619. USEIRRADIANCEMAP: boolean;
  46620. SPHERICAL_HARMONICS: boolean;
  46621. USESPHERICALINVERTEX: boolean;
  46622. REFLECTIONMAP_OPPOSITEZ: boolean;
  46623. LODINREFLECTIONALPHA: boolean;
  46624. GAMMAREFLECTION: boolean;
  46625. RGBDREFLECTION: boolean;
  46626. LINEARSPECULARREFLECTION: boolean;
  46627. RADIANCEOCCLUSION: boolean;
  46628. HORIZONOCCLUSION: boolean;
  46629. INSTANCES: boolean;
  46630. NUM_BONE_INFLUENCERS: number;
  46631. BonesPerMesh: number;
  46632. BONETEXTURE: boolean;
  46633. NONUNIFORMSCALING: boolean;
  46634. MORPHTARGETS: boolean;
  46635. MORPHTARGETS_NORMAL: boolean;
  46636. MORPHTARGETS_TANGENT: boolean;
  46637. MORPHTARGETS_UV: boolean;
  46638. NUM_MORPH_INFLUENCERS: number;
  46639. IMAGEPROCESSING: boolean;
  46640. VIGNETTE: boolean;
  46641. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46642. VIGNETTEBLENDMODEOPAQUE: boolean;
  46643. TONEMAPPING: boolean;
  46644. TONEMAPPING_ACES: boolean;
  46645. CONTRAST: boolean;
  46646. COLORCURVES: boolean;
  46647. COLORGRADING: boolean;
  46648. COLORGRADING3D: boolean;
  46649. SAMPLER3DGREENDEPTH: boolean;
  46650. SAMPLER3DBGRMAP: boolean;
  46651. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46652. EXPOSURE: boolean;
  46653. MULTIVIEW: boolean;
  46654. USEPHYSICALLIGHTFALLOFF: boolean;
  46655. USEGLTFLIGHTFALLOFF: boolean;
  46656. TWOSIDEDLIGHTING: boolean;
  46657. SHADOWFLOAT: boolean;
  46658. CLIPPLANE: boolean;
  46659. CLIPPLANE2: boolean;
  46660. CLIPPLANE3: boolean;
  46661. CLIPPLANE4: boolean;
  46662. POINTSIZE: boolean;
  46663. FOG: boolean;
  46664. LOGARITHMICDEPTH: boolean;
  46665. FORCENORMALFORWARD: boolean;
  46666. SPECULARAA: boolean;
  46667. CLEARCOAT: boolean;
  46668. CLEARCOAT_DEFAULTIOR: boolean;
  46669. CLEARCOAT_TEXTURE: boolean;
  46670. CLEARCOAT_TEXTUREDIRECTUV: number;
  46671. CLEARCOAT_BUMP: boolean;
  46672. CLEARCOAT_BUMPDIRECTUV: number;
  46673. CLEARCOAT_TINT: boolean;
  46674. CLEARCOAT_TINT_TEXTURE: boolean;
  46675. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46676. ANISOTROPIC: boolean;
  46677. ANISOTROPIC_TEXTURE: boolean;
  46678. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46679. BRDF_V_HEIGHT_CORRELATED: boolean;
  46680. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46681. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46682. SHEEN: boolean;
  46683. SHEEN_TEXTURE: boolean;
  46684. SHEEN_TEXTUREDIRECTUV: number;
  46685. SHEEN_LINKWITHALBEDO: boolean;
  46686. SUBSURFACE: boolean;
  46687. SS_REFRACTION: boolean;
  46688. SS_TRANSLUCENCY: boolean;
  46689. SS_SCATERRING: boolean;
  46690. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46691. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46692. SS_REFRACTIONMAP_3D: boolean;
  46693. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46694. SS_LODINREFRACTIONALPHA: boolean;
  46695. SS_GAMMAREFRACTION: boolean;
  46696. SS_RGBDREFRACTION: boolean;
  46697. SS_LINEARSPECULARREFRACTION: boolean;
  46698. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46699. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46700. UNLIT: boolean;
  46701. DEBUGMODE: number;
  46702. /**
  46703. * Initializes the PBR Material defines.
  46704. */
  46705. constructor();
  46706. /**
  46707. * Resets the PBR Material defines.
  46708. */
  46709. reset(): void;
  46710. }
  46711. /**
  46712. * The Physically based material base class of BJS.
  46713. *
  46714. * This offers the main features of a standard PBR material.
  46715. * For more information, please refer to the documentation :
  46716. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46717. */
  46718. export abstract class PBRBaseMaterial extends PushMaterial {
  46719. /**
  46720. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46721. */
  46722. static readonly PBRMATERIAL_OPAQUE: number;
  46723. /**
  46724. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46725. */
  46726. static readonly PBRMATERIAL_ALPHATEST: number;
  46727. /**
  46728. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46729. */
  46730. static readonly PBRMATERIAL_ALPHABLEND: number;
  46731. /**
  46732. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46733. * They are also discarded below the alpha cutoff threshold to improve performances.
  46734. */
  46735. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46736. /**
  46737. * Defines the default value of how much AO map is occluding the analytical lights
  46738. * (point spot...).
  46739. */
  46740. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46741. /**
  46742. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46743. */
  46744. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46745. /**
  46746. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46747. * to enhance interoperability with other engines.
  46748. */
  46749. static readonly LIGHTFALLOFF_GLTF: number;
  46750. /**
  46751. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46752. * to enhance interoperability with other materials.
  46753. */
  46754. static readonly LIGHTFALLOFF_STANDARD: number;
  46755. /**
  46756. * Intensity of the direct lights e.g. the four lights available in your scene.
  46757. * This impacts both the direct diffuse and specular highlights.
  46758. */
  46759. protected _directIntensity: number;
  46760. /**
  46761. * Intensity of the emissive part of the material.
  46762. * This helps controlling the emissive effect without modifying the emissive color.
  46763. */
  46764. protected _emissiveIntensity: number;
  46765. /**
  46766. * Intensity of the environment e.g. how much the environment will light the object
  46767. * either through harmonics for rough material or through the refelction for shiny ones.
  46768. */
  46769. protected _environmentIntensity: number;
  46770. /**
  46771. * This is a special control allowing the reduction of the specular highlights coming from the
  46772. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46773. */
  46774. protected _specularIntensity: number;
  46775. /**
  46776. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46777. */
  46778. private _lightingInfos;
  46779. /**
  46780. * Debug Control allowing disabling the bump map on this material.
  46781. */
  46782. protected _disableBumpMap: boolean;
  46783. /**
  46784. * AKA Diffuse Texture in standard nomenclature.
  46785. */
  46786. protected _albedoTexture: Nullable<BaseTexture>;
  46787. /**
  46788. * AKA Occlusion Texture in other nomenclature.
  46789. */
  46790. protected _ambientTexture: Nullable<BaseTexture>;
  46791. /**
  46792. * AKA Occlusion Texture Intensity in other nomenclature.
  46793. */
  46794. protected _ambientTextureStrength: number;
  46795. /**
  46796. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46797. * 1 means it completely occludes it
  46798. * 0 mean it has no impact
  46799. */
  46800. protected _ambientTextureImpactOnAnalyticalLights: number;
  46801. /**
  46802. * Stores the alpha values in a texture.
  46803. */
  46804. protected _opacityTexture: Nullable<BaseTexture>;
  46805. /**
  46806. * Stores the reflection values in a texture.
  46807. */
  46808. protected _reflectionTexture: Nullable<BaseTexture>;
  46809. /**
  46810. * Stores the emissive values in a texture.
  46811. */
  46812. protected _emissiveTexture: Nullable<BaseTexture>;
  46813. /**
  46814. * AKA Specular texture in other nomenclature.
  46815. */
  46816. protected _reflectivityTexture: Nullable<BaseTexture>;
  46817. /**
  46818. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46819. */
  46820. protected _metallicTexture: Nullable<BaseTexture>;
  46821. /**
  46822. * Specifies the metallic scalar of the metallic/roughness workflow.
  46823. * Can also be used to scale the metalness values of the metallic texture.
  46824. */
  46825. protected _metallic: Nullable<number>;
  46826. /**
  46827. * Specifies the roughness scalar of the metallic/roughness workflow.
  46828. * Can also be used to scale the roughness values of the metallic texture.
  46829. */
  46830. protected _roughness: Nullable<number>;
  46831. /**
  46832. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46833. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46834. */
  46835. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46836. /**
  46837. * Stores surface normal data used to displace a mesh in a texture.
  46838. */
  46839. protected _bumpTexture: Nullable<BaseTexture>;
  46840. /**
  46841. * Stores the pre-calculated light information of a mesh in a texture.
  46842. */
  46843. protected _lightmapTexture: Nullable<BaseTexture>;
  46844. /**
  46845. * The color of a material in ambient lighting.
  46846. */
  46847. protected _ambientColor: Color3;
  46848. /**
  46849. * AKA Diffuse Color in other nomenclature.
  46850. */
  46851. protected _albedoColor: Color3;
  46852. /**
  46853. * AKA Specular Color in other nomenclature.
  46854. */
  46855. protected _reflectivityColor: Color3;
  46856. /**
  46857. * The color applied when light is reflected from a material.
  46858. */
  46859. protected _reflectionColor: Color3;
  46860. /**
  46861. * The color applied when light is emitted from a material.
  46862. */
  46863. protected _emissiveColor: Color3;
  46864. /**
  46865. * AKA Glossiness in other nomenclature.
  46866. */
  46867. protected _microSurface: number;
  46868. /**
  46869. * Specifies that the material will use the light map as a show map.
  46870. */
  46871. protected _useLightmapAsShadowmap: boolean;
  46872. /**
  46873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46874. * makes the reflect vector face the model (under horizon).
  46875. */
  46876. protected _useHorizonOcclusion: boolean;
  46877. /**
  46878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46879. * too much the area relying on ambient texture to define their ambient occlusion.
  46880. */
  46881. protected _useRadianceOcclusion: boolean;
  46882. /**
  46883. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46884. */
  46885. protected _useAlphaFromAlbedoTexture: boolean;
  46886. /**
  46887. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46888. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46889. */
  46890. protected _useSpecularOverAlpha: boolean;
  46891. /**
  46892. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46893. */
  46894. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46895. /**
  46896. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46897. */
  46898. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46899. /**
  46900. * Specifies if the metallic texture contains the roughness information in its green channel.
  46901. */
  46902. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46903. /**
  46904. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46905. */
  46906. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46907. /**
  46908. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46909. */
  46910. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46911. /**
  46912. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46913. */
  46914. protected _useAmbientInGrayScale: boolean;
  46915. /**
  46916. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46917. * The material will try to infer what glossiness each pixel should be.
  46918. */
  46919. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46920. /**
  46921. * Defines the falloff type used in this material.
  46922. * It by default is Physical.
  46923. */
  46924. protected _lightFalloff: number;
  46925. /**
  46926. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46927. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46928. */
  46929. protected _useRadianceOverAlpha: boolean;
  46930. /**
  46931. * Allows using an object space normal map (instead of tangent space).
  46932. */
  46933. protected _useObjectSpaceNormalMap: boolean;
  46934. /**
  46935. * Allows using the bump map in parallax mode.
  46936. */
  46937. protected _useParallax: boolean;
  46938. /**
  46939. * Allows using the bump map in parallax occlusion mode.
  46940. */
  46941. protected _useParallaxOcclusion: boolean;
  46942. /**
  46943. * Controls the scale bias of the parallax mode.
  46944. */
  46945. protected _parallaxScaleBias: number;
  46946. /**
  46947. * If sets to true, disables all the lights affecting the material.
  46948. */
  46949. protected _disableLighting: boolean;
  46950. /**
  46951. * Number of Simultaneous lights allowed on the material.
  46952. */
  46953. protected _maxSimultaneousLights: number;
  46954. /**
  46955. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46956. */
  46957. protected _invertNormalMapX: boolean;
  46958. /**
  46959. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46960. */
  46961. protected _invertNormalMapY: boolean;
  46962. /**
  46963. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46964. */
  46965. protected _twoSidedLighting: boolean;
  46966. /**
  46967. * Defines the alpha limits in alpha test mode.
  46968. */
  46969. protected _alphaCutOff: number;
  46970. /**
  46971. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46972. */
  46973. protected _forceAlphaTest: boolean;
  46974. /**
  46975. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46976. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46977. */
  46978. protected _useAlphaFresnel: boolean;
  46979. /**
  46980. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46981. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46982. */
  46983. protected _useLinearAlphaFresnel: boolean;
  46984. /**
  46985. * The transparency mode of the material.
  46986. */
  46987. protected _transparencyMode: Nullable<number>;
  46988. /**
  46989. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46990. * from cos thetav and roughness:
  46991. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46992. */
  46993. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46994. /**
  46995. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46996. */
  46997. protected _forceIrradianceInFragment: boolean;
  46998. /**
  46999. * Force normal to face away from face.
  47000. */
  47001. protected _forceNormalForward: boolean;
  47002. /**
  47003. * Enables specular anti aliasing in the PBR shader.
  47004. * It will both interacts on the Geometry for analytical and IBL lighting.
  47005. * It also prefilter the roughness map based on the bump values.
  47006. */
  47007. protected _enableSpecularAntiAliasing: boolean;
  47008. /**
  47009. * Default configuration related to image processing available in the PBR Material.
  47010. */
  47011. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47012. /**
  47013. * Keep track of the image processing observer to allow dispose and replace.
  47014. */
  47015. private _imageProcessingObserver;
  47016. /**
  47017. * Attaches a new image processing configuration to the PBR Material.
  47018. * @param configuration
  47019. */
  47020. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47021. /**
  47022. * Stores the available render targets.
  47023. */
  47024. private _renderTargets;
  47025. /**
  47026. * Sets the global ambient color for the material used in lighting calculations.
  47027. */
  47028. private _globalAmbientColor;
  47029. /**
  47030. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47031. */
  47032. private _useLogarithmicDepth;
  47033. /**
  47034. * If set to true, no lighting calculations will be applied.
  47035. */
  47036. private _unlit;
  47037. private _debugMode;
  47038. /**
  47039. * @hidden
  47040. * This is reserved for the inspector.
  47041. * Defines the material debug mode.
  47042. * It helps seeing only some components of the material while troubleshooting.
  47043. */
  47044. debugMode: number;
  47045. /**
  47046. * @hidden
  47047. * This is reserved for the inspector.
  47048. * Specify from where on screen the debug mode should start.
  47049. * The value goes from -1 (full screen) to 1 (not visible)
  47050. * It helps with side by side comparison against the final render
  47051. * This defaults to -1
  47052. */
  47053. private debugLimit;
  47054. /**
  47055. * @hidden
  47056. * This is reserved for the inspector.
  47057. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47058. * You can use the factor to better multiply the final value.
  47059. */
  47060. private debugFactor;
  47061. /**
  47062. * Defines the clear coat layer parameters for the material.
  47063. */
  47064. readonly clearCoat: PBRClearCoatConfiguration;
  47065. /**
  47066. * Defines the anisotropic parameters for the material.
  47067. */
  47068. readonly anisotropy: PBRAnisotropicConfiguration;
  47069. /**
  47070. * Defines the BRDF parameters for the material.
  47071. */
  47072. readonly brdf: PBRBRDFConfiguration;
  47073. /**
  47074. * Defines the Sheen parameters for the material.
  47075. */
  47076. readonly sheen: PBRSheenConfiguration;
  47077. /**
  47078. * Defines the SubSurface parameters for the material.
  47079. */
  47080. readonly subSurface: PBRSubSurfaceConfiguration;
  47081. /**
  47082. * Custom callback helping to override the default shader used in the material.
  47083. */
  47084. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47085. protected _rebuildInParallel: boolean;
  47086. /**
  47087. * Instantiates a new PBRMaterial instance.
  47088. *
  47089. * @param name The material name
  47090. * @param scene The scene the material will be use in.
  47091. */
  47092. constructor(name: string, scene: Scene);
  47093. /**
  47094. * Gets a boolean indicating that current material needs to register RTT
  47095. */
  47096. readonly hasRenderTargetTextures: boolean;
  47097. /**
  47098. * Gets the name of the material class.
  47099. */
  47100. getClassName(): string;
  47101. /**
  47102. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47103. */
  47104. /**
  47105. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47106. */
  47107. useLogarithmicDepth: boolean;
  47108. /**
  47109. * Gets the current transparency mode.
  47110. */
  47111. /**
  47112. * Sets the transparency mode of the material.
  47113. *
  47114. * | Value | Type | Description |
  47115. * | ----- | ----------------------------------- | ----------- |
  47116. * | 0 | OPAQUE | |
  47117. * | 1 | ALPHATEST | |
  47118. * | 2 | ALPHABLEND | |
  47119. * | 3 | ALPHATESTANDBLEND | |
  47120. *
  47121. */
  47122. transparencyMode: Nullable<number>;
  47123. /**
  47124. * Returns true if alpha blending should be disabled.
  47125. */
  47126. private readonly _disableAlphaBlending;
  47127. /**
  47128. * Specifies whether or not this material should be rendered in alpha blend mode.
  47129. */
  47130. needAlphaBlending(): boolean;
  47131. /**
  47132. * Specifies if the mesh will require alpha blending.
  47133. * @param mesh - BJS mesh.
  47134. */
  47135. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47136. /**
  47137. * Specifies whether or not this material should be rendered in alpha test mode.
  47138. */
  47139. needAlphaTesting(): boolean;
  47140. /**
  47141. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47142. */
  47143. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47144. /**
  47145. * Gets the texture used for the alpha test.
  47146. */
  47147. getAlphaTestTexture(): Nullable<BaseTexture>;
  47148. /**
  47149. * Specifies that the submesh is ready to be used.
  47150. * @param mesh - BJS mesh.
  47151. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47152. * @param useInstances - Specifies that instances should be used.
  47153. * @returns - boolean indicating that the submesh is ready or not.
  47154. */
  47155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47156. /**
  47157. * Specifies if the material uses metallic roughness workflow.
  47158. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47159. */
  47160. isMetallicWorkflow(): boolean;
  47161. private _prepareEffect;
  47162. private _prepareDefines;
  47163. /**
  47164. * Force shader compilation
  47165. */
  47166. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47167. clipPlane: boolean;
  47168. }>): void;
  47169. /**
  47170. * Initializes the uniform buffer layout for the shader.
  47171. */
  47172. buildUniformLayout(): void;
  47173. /**
  47174. * Unbinds the material from the mesh
  47175. */
  47176. unbind(): void;
  47177. /**
  47178. * Binds the submesh data.
  47179. * @param world - The world matrix.
  47180. * @param mesh - The BJS mesh.
  47181. * @param subMesh - A submesh of the BJS mesh.
  47182. */
  47183. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47184. /**
  47185. * Returns the animatable textures.
  47186. * @returns - Array of animatable textures.
  47187. */
  47188. getAnimatables(): IAnimatable[];
  47189. /**
  47190. * Returns the texture used for reflections.
  47191. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47192. */
  47193. private _getReflectionTexture;
  47194. /**
  47195. * Returns an array of the actively used textures.
  47196. * @returns - Array of BaseTextures
  47197. */
  47198. getActiveTextures(): BaseTexture[];
  47199. /**
  47200. * Checks to see if a texture is used in the material.
  47201. * @param texture - Base texture to use.
  47202. * @returns - Boolean specifying if a texture is used in the material.
  47203. */
  47204. hasTexture(texture: BaseTexture): boolean;
  47205. /**
  47206. * Disposes the resources of the material.
  47207. * @param forceDisposeEffect - Forces the disposal of effects.
  47208. * @param forceDisposeTextures - Forces the disposal of all textures.
  47209. */
  47210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47211. }
  47212. }
  47213. declare module BABYLON {
  47214. /**
  47215. * The Physically based material of BJS.
  47216. *
  47217. * This offers the main features of a standard PBR material.
  47218. * For more information, please refer to the documentation :
  47219. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47220. */
  47221. export class PBRMaterial extends PBRBaseMaterial {
  47222. /**
  47223. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47224. */
  47225. static readonly PBRMATERIAL_OPAQUE: number;
  47226. /**
  47227. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47228. */
  47229. static readonly PBRMATERIAL_ALPHATEST: number;
  47230. /**
  47231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47232. */
  47233. static readonly PBRMATERIAL_ALPHABLEND: number;
  47234. /**
  47235. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47236. * They are also discarded below the alpha cutoff threshold to improve performances.
  47237. */
  47238. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47239. /**
  47240. * Defines the default value of how much AO map is occluding the analytical lights
  47241. * (point spot...).
  47242. */
  47243. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47244. /**
  47245. * Intensity of the direct lights e.g. the four lights available in your scene.
  47246. * This impacts both the direct diffuse and specular highlights.
  47247. */
  47248. directIntensity: number;
  47249. /**
  47250. * Intensity of the emissive part of the material.
  47251. * This helps controlling the emissive effect without modifying the emissive color.
  47252. */
  47253. emissiveIntensity: number;
  47254. /**
  47255. * Intensity of the environment e.g. how much the environment will light the object
  47256. * either through harmonics for rough material or through the refelction for shiny ones.
  47257. */
  47258. environmentIntensity: number;
  47259. /**
  47260. * This is a special control allowing the reduction of the specular highlights coming from the
  47261. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47262. */
  47263. specularIntensity: number;
  47264. /**
  47265. * Debug Control allowing disabling the bump map on this material.
  47266. */
  47267. disableBumpMap: boolean;
  47268. /**
  47269. * AKA Diffuse Texture in standard nomenclature.
  47270. */
  47271. albedoTexture: BaseTexture;
  47272. /**
  47273. * AKA Occlusion Texture in other nomenclature.
  47274. */
  47275. ambientTexture: BaseTexture;
  47276. /**
  47277. * AKA Occlusion Texture Intensity in other nomenclature.
  47278. */
  47279. ambientTextureStrength: number;
  47280. /**
  47281. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47282. * 1 means it completely occludes it
  47283. * 0 mean it has no impact
  47284. */
  47285. ambientTextureImpactOnAnalyticalLights: number;
  47286. /**
  47287. * Stores the alpha values in a texture.
  47288. */
  47289. opacityTexture: BaseTexture;
  47290. /**
  47291. * Stores the reflection values in a texture.
  47292. */
  47293. reflectionTexture: Nullable<BaseTexture>;
  47294. /**
  47295. * Stores the emissive values in a texture.
  47296. */
  47297. emissiveTexture: BaseTexture;
  47298. /**
  47299. * AKA Specular texture in other nomenclature.
  47300. */
  47301. reflectivityTexture: BaseTexture;
  47302. /**
  47303. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47304. */
  47305. metallicTexture: BaseTexture;
  47306. /**
  47307. * Specifies the metallic scalar of the metallic/roughness workflow.
  47308. * Can also be used to scale the metalness values of the metallic texture.
  47309. */
  47310. metallic: Nullable<number>;
  47311. /**
  47312. * Specifies the roughness scalar of the metallic/roughness workflow.
  47313. * Can also be used to scale the roughness values of the metallic texture.
  47314. */
  47315. roughness: Nullable<number>;
  47316. /**
  47317. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47318. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47319. */
  47320. microSurfaceTexture: BaseTexture;
  47321. /**
  47322. * Stores surface normal data used to displace a mesh in a texture.
  47323. */
  47324. bumpTexture: BaseTexture;
  47325. /**
  47326. * Stores the pre-calculated light information of a mesh in a texture.
  47327. */
  47328. lightmapTexture: BaseTexture;
  47329. /**
  47330. * Stores the refracted light information in a texture.
  47331. */
  47332. refractionTexture: Nullable<BaseTexture>;
  47333. /**
  47334. * The color of a material in ambient lighting.
  47335. */
  47336. ambientColor: Color3;
  47337. /**
  47338. * AKA Diffuse Color in other nomenclature.
  47339. */
  47340. albedoColor: Color3;
  47341. /**
  47342. * AKA Specular Color in other nomenclature.
  47343. */
  47344. reflectivityColor: Color3;
  47345. /**
  47346. * The color reflected from the material.
  47347. */
  47348. reflectionColor: Color3;
  47349. /**
  47350. * The color emitted from the material.
  47351. */
  47352. emissiveColor: Color3;
  47353. /**
  47354. * AKA Glossiness in other nomenclature.
  47355. */
  47356. microSurface: number;
  47357. /**
  47358. * source material index of refraction (IOR)' / 'destination material IOR.
  47359. */
  47360. indexOfRefraction: number;
  47361. /**
  47362. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47363. */
  47364. invertRefractionY: boolean;
  47365. /**
  47366. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47367. * Materials half opaque for instance using refraction could benefit from this control.
  47368. */
  47369. linkRefractionWithTransparency: boolean;
  47370. /**
  47371. * If true, the light map contains occlusion information instead of lighting info.
  47372. */
  47373. useLightmapAsShadowmap: boolean;
  47374. /**
  47375. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47376. */
  47377. useAlphaFromAlbedoTexture: boolean;
  47378. /**
  47379. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47380. */
  47381. forceAlphaTest: boolean;
  47382. /**
  47383. * Defines the alpha limits in alpha test mode.
  47384. */
  47385. alphaCutOff: number;
  47386. /**
  47387. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47388. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47389. */
  47390. useSpecularOverAlpha: boolean;
  47391. /**
  47392. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47393. */
  47394. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47395. /**
  47396. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47397. */
  47398. useRoughnessFromMetallicTextureAlpha: boolean;
  47399. /**
  47400. * Specifies if the metallic texture contains the roughness information in its green channel.
  47401. */
  47402. useRoughnessFromMetallicTextureGreen: boolean;
  47403. /**
  47404. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47405. */
  47406. useMetallnessFromMetallicTextureBlue: boolean;
  47407. /**
  47408. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47409. */
  47410. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47411. /**
  47412. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47413. */
  47414. useAmbientInGrayScale: boolean;
  47415. /**
  47416. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47417. * The material will try to infer what glossiness each pixel should be.
  47418. */
  47419. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47420. /**
  47421. * BJS is using an harcoded light falloff based on a manually sets up range.
  47422. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47423. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47424. */
  47425. /**
  47426. * BJS is using an harcoded light falloff based on a manually sets up range.
  47427. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47428. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47429. */
  47430. usePhysicalLightFalloff: boolean;
  47431. /**
  47432. * In order to support the falloff compatibility with gltf, a special mode has been added
  47433. * to reproduce the gltf light falloff.
  47434. */
  47435. /**
  47436. * In order to support the falloff compatibility with gltf, a special mode has been added
  47437. * to reproduce the gltf light falloff.
  47438. */
  47439. useGLTFLightFalloff: boolean;
  47440. /**
  47441. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47442. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47443. */
  47444. useRadianceOverAlpha: boolean;
  47445. /**
  47446. * Allows using an object space normal map (instead of tangent space).
  47447. */
  47448. useObjectSpaceNormalMap: boolean;
  47449. /**
  47450. * Allows using the bump map in parallax mode.
  47451. */
  47452. useParallax: boolean;
  47453. /**
  47454. * Allows using the bump map in parallax occlusion mode.
  47455. */
  47456. useParallaxOcclusion: boolean;
  47457. /**
  47458. * Controls the scale bias of the parallax mode.
  47459. */
  47460. parallaxScaleBias: number;
  47461. /**
  47462. * If sets to true, disables all the lights affecting the material.
  47463. */
  47464. disableLighting: boolean;
  47465. /**
  47466. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47467. */
  47468. forceIrradianceInFragment: boolean;
  47469. /**
  47470. * Number of Simultaneous lights allowed on the material.
  47471. */
  47472. maxSimultaneousLights: number;
  47473. /**
  47474. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47475. */
  47476. invertNormalMapX: boolean;
  47477. /**
  47478. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47479. */
  47480. invertNormalMapY: boolean;
  47481. /**
  47482. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47483. */
  47484. twoSidedLighting: boolean;
  47485. /**
  47486. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47487. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47488. */
  47489. useAlphaFresnel: boolean;
  47490. /**
  47491. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47492. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47493. */
  47494. useLinearAlphaFresnel: boolean;
  47495. /**
  47496. * Let user defines the brdf lookup texture used for IBL.
  47497. * A default 8bit version is embedded but you could point at :
  47498. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47499. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47500. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47501. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47502. */
  47503. environmentBRDFTexture: Nullable<BaseTexture>;
  47504. /**
  47505. * Force normal to face away from face.
  47506. */
  47507. forceNormalForward: boolean;
  47508. /**
  47509. * Enables specular anti aliasing in the PBR shader.
  47510. * It will both interacts on the Geometry for analytical and IBL lighting.
  47511. * It also prefilter the roughness map based on the bump values.
  47512. */
  47513. enableSpecularAntiAliasing: boolean;
  47514. /**
  47515. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47516. * makes the reflect vector face the model (under horizon).
  47517. */
  47518. useHorizonOcclusion: boolean;
  47519. /**
  47520. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47521. * too much the area relying on ambient texture to define their ambient occlusion.
  47522. */
  47523. useRadianceOcclusion: boolean;
  47524. /**
  47525. * If set to true, no lighting calculations will be applied.
  47526. */
  47527. unlit: boolean;
  47528. /**
  47529. * Gets the image processing configuration used either in this material.
  47530. */
  47531. /**
  47532. * Sets the Default image processing configuration used either in the this material.
  47533. *
  47534. * If sets to null, the scene one is in use.
  47535. */
  47536. imageProcessingConfiguration: ImageProcessingConfiguration;
  47537. /**
  47538. * Gets wether the color curves effect is enabled.
  47539. */
  47540. /**
  47541. * Sets wether the color curves effect is enabled.
  47542. */
  47543. cameraColorCurvesEnabled: boolean;
  47544. /**
  47545. * Gets wether the color grading effect is enabled.
  47546. */
  47547. /**
  47548. * Gets wether the color grading effect is enabled.
  47549. */
  47550. cameraColorGradingEnabled: boolean;
  47551. /**
  47552. * Gets wether tonemapping is enabled or not.
  47553. */
  47554. /**
  47555. * Sets wether tonemapping is enabled or not
  47556. */
  47557. cameraToneMappingEnabled: boolean;
  47558. /**
  47559. * The camera exposure used on this material.
  47560. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47561. * This corresponds to a photographic exposure.
  47562. */
  47563. /**
  47564. * The camera exposure used on this material.
  47565. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47566. * This corresponds to a photographic exposure.
  47567. */
  47568. cameraExposure: number;
  47569. /**
  47570. * Gets The camera contrast used on this material.
  47571. */
  47572. /**
  47573. * Sets The camera contrast used on this material.
  47574. */
  47575. cameraContrast: number;
  47576. /**
  47577. * Gets the Color Grading 2D Lookup Texture.
  47578. */
  47579. /**
  47580. * Sets the Color Grading 2D Lookup Texture.
  47581. */
  47582. cameraColorGradingTexture: Nullable<BaseTexture>;
  47583. /**
  47584. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47585. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47586. * 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;
  47587. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47588. */
  47589. /**
  47590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47592. * 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;
  47593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47594. */
  47595. cameraColorCurves: Nullable<ColorCurves>;
  47596. /**
  47597. * Instantiates a new PBRMaterial instance.
  47598. *
  47599. * @param name The material name
  47600. * @param scene The scene the material will be use in.
  47601. */
  47602. constructor(name: string, scene: Scene);
  47603. /**
  47604. * Returns the name of this material class.
  47605. */
  47606. getClassName(): string;
  47607. /**
  47608. * Makes a duplicate of the current material.
  47609. * @param name - name to use for the new material.
  47610. */
  47611. clone(name: string): PBRMaterial;
  47612. /**
  47613. * Serializes this PBR Material.
  47614. * @returns - An object with the serialized material.
  47615. */
  47616. serialize(): any;
  47617. /**
  47618. * Parses a PBR Material from a serialized object.
  47619. * @param source - Serialized object.
  47620. * @param scene - BJS scene instance.
  47621. * @param rootUrl - url for the scene object
  47622. * @returns - PBRMaterial
  47623. */
  47624. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47625. }
  47626. }
  47627. declare module BABYLON {
  47628. /**
  47629. * Direct draw surface info
  47630. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47631. */
  47632. export interface DDSInfo {
  47633. /**
  47634. * Width of the texture
  47635. */
  47636. width: number;
  47637. /**
  47638. * Width of the texture
  47639. */
  47640. height: number;
  47641. /**
  47642. * Number of Mipmaps for the texture
  47643. * @see https://en.wikipedia.org/wiki/Mipmap
  47644. */
  47645. mipmapCount: number;
  47646. /**
  47647. * If the textures format is a known fourCC format
  47648. * @see https://www.fourcc.org/
  47649. */
  47650. isFourCC: boolean;
  47651. /**
  47652. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47653. */
  47654. isRGB: boolean;
  47655. /**
  47656. * If the texture is a lumincance format
  47657. */
  47658. isLuminance: boolean;
  47659. /**
  47660. * If this is a cube texture
  47661. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47662. */
  47663. isCube: boolean;
  47664. /**
  47665. * If the texture is a compressed format eg. FOURCC_DXT1
  47666. */
  47667. isCompressed: boolean;
  47668. /**
  47669. * The dxgiFormat of the texture
  47670. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47671. */
  47672. dxgiFormat: number;
  47673. /**
  47674. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47675. */
  47676. textureType: number;
  47677. /**
  47678. * Sphericle polynomial created for the dds texture
  47679. */
  47680. sphericalPolynomial?: SphericalPolynomial;
  47681. }
  47682. /**
  47683. * Class used to provide DDS decompression tools
  47684. */
  47685. export class DDSTools {
  47686. /**
  47687. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47688. */
  47689. static StoreLODInAlphaChannel: boolean;
  47690. /**
  47691. * Gets DDS information from an array buffer
  47692. * @param arrayBuffer defines the array buffer to read data from
  47693. * @returns the DDS information
  47694. */
  47695. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47696. private static _FloatView;
  47697. private static _Int32View;
  47698. private static _ToHalfFloat;
  47699. private static _FromHalfFloat;
  47700. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47701. private static _GetHalfFloatRGBAArrayBuffer;
  47702. private static _GetFloatRGBAArrayBuffer;
  47703. private static _GetFloatAsUIntRGBAArrayBuffer;
  47704. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47705. private static _GetRGBAArrayBuffer;
  47706. private static _ExtractLongWordOrder;
  47707. private static _GetRGBArrayBuffer;
  47708. private static _GetLuminanceArrayBuffer;
  47709. /**
  47710. * Uploads DDS Levels to a Babylon Texture
  47711. * @hidden
  47712. */
  47713. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47714. }
  47715. interface ThinEngine {
  47716. /**
  47717. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47718. * @param rootUrl defines the url where the file to load is located
  47719. * @param scene defines the current scene
  47720. * @param lodScale defines scale to apply to the mip map selection
  47721. * @param lodOffset defines offset to apply to the mip map selection
  47722. * @param onLoad defines an optional callback raised when the texture is loaded
  47723. * @param onError defines an optional callback raised if there is an issue to load the texture
  47724. * @param format defines the format of the data
  47725. * @param forcedExtension defines the extension to use to pick the right loader
  47726. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47727. * @returns the cube texture as an InternalTexture
  47728. */
  47729. 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;
  47730. }
  47731. }
  47732. declare module BABYLON {
  47733. /**
  47734. * Implementation of the DDS Texture Loader.
  47735. * @hidden
  47736. */
  47737. export class _DDSTextureLoader implements IInternalTextureLoader {
  47738. /**
  47739. * Defines wether the loader supports cascade loading the different faces.
  47740. */
  47741. readonly supportCascades: boolean;
  47742. /**
  47743. * This returns if the loader support the current file information.
  47744. * @param extension defines the file extension of the file being loaded
  47745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47746. * @param fallback defines the fallback internal texture if any
  47747. * @param isBase64 defines whether the texture is encoded as a base64
  47748. * @param isBuffer defines whether the texture data are stored as a buffer
  47749. * @returns true if the loader can load the specified file
  47750. */
  47751. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47752. /**
  47753. * Transform the url before loading if required.
  47754. * @param rootUrl the url of the texture
  47755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47756. * @returns the transformed texture
  47757. */
  47758. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47759. /**
  47760. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47761. * @param rootUrl the url of the texture
  47762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47763. * @returns the fallback texture
  47764. */
  47765. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47766. /**
  47767. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47768. * @param data contains the texture data
  47769. * @param texture defines the BabylonJS internal texture
  47770. * @param createPolynomials will be true if polynomials have been requested
  47771. * @param onLoad defines the callback to trigger once the texture is ready
  47772. * @param onError defines the callback to trigger in case of error
  47773. */
  47774. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47775. /**
  47776. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47777. * @param data contains the texture data
  47778. * @param texture defines the BabylonJS internal texture
  47779. * @param callback defines the method to call once ready to upload
  47780. */
  47781. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47782. }
  47783. }
  47784. declare module BABYLON {
  47785. /**
  47786. * Implementation of the ENV Texture Loader.
  47787. * @hidden
  47788. */
  47789. export class _ENVTextureLoader implements IInternalTextureLoader {
  47790. /**
  47791. * Defines wether the loader supports cascade loading the different faces.
  47792. */
  47793. readonly supportCascades: boolean;
  47794. /**
  47795. * This returns if the loader support the current file information.
  47796. * @param extension defines the file extension of the file being loaded
  47797. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47798. * @param fallback defines the fallback internal texture if any
  47799. * @param isBase64 defines whether the texture is encoded as a base64
  47800. * @param isBuffer defines whether the texture data are stored as a buffer
  47801. * @returns true if the loader can load the specified file
  47802. */
  47803. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47804. /**
  47805. * Transform the url before loading if required.
  47806. * @param rootUrl the url of the texture
  47807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47808. * @returns the transformed texture
  47809. */
  47810. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47811. /**
  47812. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47813. * @param rootUrl the url of the texture
  47814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47815. * @returns the fallback texture
  47816. */
  47817. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47818. /**
  47819. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47820. * @param data contains the texture data
  47821. * @param texture defines the BabylonJS internal texture
  47822. * @param createPolynomials will be true if polynomials have been requested
  47823. * @param onLoad defines the callback to trigger once the texture is ready
  47824. * @param onError defines the callback to trigger in case of error
  47825. */
  47826. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47827. /**
  47828. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47829. * @param data contains the texture data
  47830. * @param texture defines the BabylonJS internal texture
  47831. * @param callback defines the method to call once ready to upload
  47832. */
  47833. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47834. }
  47835. }
  47836. declare module BABYLON {
  47837. /**
  47838. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47839. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47840. */
  47841. export class KhronosTextureContainer {
  47842. /** contents of the KTX container file */
  47843. arrayBuffer: any;
  47844. private static HEADER_LEN;
  47845. private static COMPRESSED_2D;
  47846. private static COMPRESSED_3D;
  47847. private static TEX_2D;
  47848. private static TEX_3D;
  47849. /**
  47850. * Gets the openGL type
  47851. */
  47852. glType: number;
  47853. /**
  47854. * Gets the openGL type size
  47855. */
  47856. glTypeSize: number;
  47857. /**
  47858. * Gets the openGL format
  47859. */
  47860. glFormat: number;
  47861. /**
  47862. * Gets the openGL internal format
  47863. */
  47864. glInternalFormat: number;
  47865. /**
  47866. * Gets the base internal format
  47867. */
  47868. glBaseInternalFormat: number;
  47869. /**
  47870. * Gets image width in pixel
  47871. */
  47872. pixelWidth: number;
  47873. /**
  47874. * Gets image height in pixel
  47875. */
  47876. pixelHeight: number;
  47877. /**
  47878. * Gets image depth in pixels
  47879. */
  47880. pixelDepth: number;
  47881. /**
  47882. * Gets the number of array elements
  47883. */
  47884. numberOfArrayElements: number;
  47885. /**
  47886. * Gets the number of faces
  47887. */
  47888. numberOfFaces: number;
  47889. /**
  47890. * Gets the number of mipmap levels
  47891. */
  47892. numberOfMipmapLevels: number;
  47893. /**
  47894. * Gets the bytes of key value data
  47895. */
  47896. bytesOfKeyValueData: number;
  47897. /**
  47898. * Gets the load type
  47899. */
  47900. loadType: number;
  47901. /**
  47902. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47903. */
  47904. isInvalid: boolean;
  47905. /**
  47906. * Creates a new KhronosTextureContainer
  47907. * @param arrayBuffer contents of the KTX container file
  47908. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47909. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47910. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47911. */
  47912. constructor(
  47913. /** contents of the KTX container file */
  47914. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47915. /**
  47916. * Uploads KTX content to a Babylon Texture.
  47917. * It is assumed that the texture has already been created & is currently bound
  47918. * @hidden
  47919. */
  47920. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47921. private _upload2DCompressedLevels;
  47922. }
  47923. }
  47924. declare module BABYLON {
  47925. /**
  47926. * Implementation of the KTX Texture Loader.
  47927. * @hidden
  47928. */
  47929. export class _KTXTextureLoader implements IInternalTextureLoader {
  47930. /**
  47931. * Defines wether the loader supports cascade loading the different faces.
  47932. */
  47933. readonly supportCascades: boolean;
  47934. /**
  47935. * This returns if the loader support the current file information.
  47936. * @param extension defines the file extension of the file being loaded
  47937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47938. * @param fallback defines the fallback internal texture if any
  47939. * @param isBase64 defines whether the texture is encoded as a base64
  47940. * @param isBuffer defines whether the texture data are stored as a buffer
  47941. * @returns true if the loader can load the specified file
  47942. */
  47943. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47944. /**
  47945. * Transform the url before loading if required.
  47946. * @param rootUrl the url of the texture
  47947. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47948. * @returns the transformed texture
  47949. */
  47950. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47951. /**
  47952. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47953. * @param rootUrl the url of the texture
  47954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47955. * @returns the fallback texture
  47956. */
  47957. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47958. /**
  47959. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47960. * @param data contains the texture data
  47961. * @param texture defines the BabylonJS internal texture
  47962. * @param createPolynomials will be true if polynomials have been requested
  47963. * @param onLoad defines the callback to trigger once the texture is ready
  47964. * @param onError defines the callback to trigger in case of error
  47965. */
  47966. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47967. /**
  47968. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47969. * @param data contains the texture data
  47970. * @param texture defines the BabylonJS internal texture
  47971. * @param callback defines the method to call once ready to upload
  47972. */
  47973. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47974. }
  47975. }
  47976. declare module BABYLON {
  47977. /**
  47978. * Options for the default xr helper
  47979. */
  47980. export class WebXRDefaultExperienceOptions {
  47981. /**
  47982. * Floor meshes that should be used for teleporting
  47983. */
  47984. floorMeshes: Array<AbstractMesh>;
  47985. }
  47986. /**
  47987. * Default experience which provides a similar setup to the previous webVRExperience
  47988. */
  47989. export class WebXRDefaultExperience {
  47990. /**
  47991. * Base experience
  47992. */
  47993. baseExperience: WebXRExperienceHelper;
  47994. /**
  47995. * Input experience extension
  47996. */
  47997. input: WebXRInput;
  47998. /**
  47999. * Loads the controller models
  48000. */
  48001. controllerModelLoader: WebXRControllerModelLoader;
  48002. /**
  48003. * Enables laser pointer and selection
  48004. */
  48005. pointerSelection: WebXRControllerPointerSelection;
  48006. /**
  48007. * Enables teleportation
  48008. */
  48009. teleportation: WebXRControllerTeleportation;
  48010. /**
  48011. * Enables ui for enetering/exiting xr
  48012. */
  48013. enterExitUI: WebXREnterExitUI;
  48014. /**
  48015. * Default output canvas xr should render to
  48016. */
  48017. outputCanvas: WebXRManagedOutputCanvas;
  48018. /**
  48019. * Creates the default xr experience
  48020. * @param scene scene
  48021. * @param options options for basic configuration
  48022. * @returns resulting WebXRDefaultExperience
  48023. */
  48024. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48025. private constructor();
  48026. /**
  48027. * DIsposes of the experience helper
  48028. */
  48029. dispose(): void;
  48030. }
  48031. }
  48032. declare module BABYLON {
  48033. /** @hidden */
  48034. export var _forceSceneHelpersToBundle: boolean;
  48035. interface Scene {
  48036. /**
  48037. * Creates a default light for the scene.
  48038. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48039. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48040. */
  48041. createDefaultLight(replace?: boolean): void;
  48042. /**
  48043. * Creates a default camera for the scene.
  48044. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48045. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48046. * @param replace has default false, when true replaces the active camera in the scene
  48047. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48048. */
  48049. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48050. /**
  48051. * Creates a default camera and a default light.
  48052. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48053. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48054. * @param replace has the default false, when true replaces the active camera/light in the scene
  48055. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48056. */
  48057. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48058. /**
  48059. * Creates a new sky box
  48060. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48061. * @param environmentTexture defines the texture to use as environment texture
  48062. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48063. * @param scale defines the overall scale of the skybox
  48064. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48065. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48066. * @returns a new mesh holding the sky box
  48067. */
  48068. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48069. /**
  48070. * Creates a new environment
  48071. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48072. * @param options defines the options you can use to configure the environment
  48073. * @returns the new EnvironmentHelper
  48074. */
  48075. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48076. /**
  48077. * Creates a new VREXperienceHelper
  48078. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48079. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48080. * @returns a new VREXperienceHelper
  48081. */
  48082. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48083. /**
  48084. * Creates a new WebXRDefaultExperience
  48085. * @see http://doc.babylonjs.com/how_to/webxr
  48086. * @param options experience options
  48087. * @returns a promise for a new WebXRDefaultExperience
  48088. */
  48089. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48095. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48096. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48097. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48098. */
  48099. export class VideoDome extends TransformNode {
  48100. /**
  48101. * Define the video source as a Monoscopic panoramic 360 video.
  48102. */
  48103. static readonly MODE_MONOSCOPIC: number;
  48104. /**
  48105. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48106. */
  48107. static readonly MODE_TOPBOTTOM: number;
  48108. /**
  48109. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48110. */
  48111. static readonly MODE_SIDEBYSIDE: number;
  48112. private _halfDome;
  48113. private _useDirectMapping;
  48114. /**
  48115. * The video texture being displayed on the sphere
  48116. */
  48117. protected _videoTexture: VideoTexture;
  48118. /**
  48119. * Gets the video texture being displayed on the sphere
  48120. */
  48121. readonly videoTexture: VideoTexture;
  48122. /**
  48123. * The skybox material
  48124. */
  48125. protected _material: BackgroundMaterial;
  48126. /**
  48127. * The surface used for the skybox
  48128. */
  48129. protected _mesh: Mesh;
  48130. /**
  48131. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48132. */
  48133. private _halfDomeMask;
  48134. /**
  48135. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48136. * Also see the options.resolution property.
  48137. */
  48138. fovMultiplier: number;
  48139. private _videoMode;
  48140. /**
  48141. * Gets or set the current video mode for the video. It can be:
  48142. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48143. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48144. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48145. */
  48146. videoMode: number;
  48147. /**
  48148. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48149. *
  48150. */
  48151. /**
  48152. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48153. */
  48154. halfDome: boolean;
  48155. /**
  48156. * Oberserver used in Stereoscopic VR Mode.
  48157. */
  48158. private _onBeforeCameraRenderObserver;
  48159. /**
  48160. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48161. * @param name Element's name, child elements will append suffixes for their own names.
  48162. * @param urlsOrVideo defines the url(s) or the video element to use
  48163. * @param options An object containing optional or exposed sub element properties
  48164. */
  48165. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48166. resolution?: number;
  48167. clickToPlay?: boolean;
  48168. autoPlay?: boolean;
  48169. loop?: boolean;
  48170. size?: number;
  48171. poster?: string;
  48172. faceForward?: boolean;
  48173. useDirectMapping?: boolean;
  48174. halfDomeMode?: boolean;
  48175. }, scene: Scene);
  48176. private _changeVideoMode;
  48177. /**
  48178. * Releases resources associated with this node.
  48179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48181. */
  48182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48183. }
  48184. }
  48185. declare module BABYLON {
  48186. /**
  48187. * This class can be used to get instrumentation data from a Babylon engine
  48188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48189. */
  48190. export class EngineInstrumentation implements IDisposable {
  48191. /**
  48192. * Define the instrumented engine.
  48193. */
  48194. engine: Engine;
  48195. private _captureGPUFrameTime;
  48196. private _gpuFrameTimeToken;
  48197. private _gpuFrameTime;
  48198. private _captureShaderCompilationTime;
  48199. private _shaderCompilationTime;
  48200. private _onBeginFrameObserver;
  48201. private _onEndFrameObserver;
  48202. private _onBeforeShaderCompilationObserver;
  48203. private _onAfterShaderCompilationObserver;
  48204. /**
  48205. * Gets the perf counter used for GPU frame time
  48206. */
  48207. readonly gpuFrameTimeCounter: PerfCounter;
  48208. /**
  48209. * Gets the GPU frame time capture status
  48210. */
  48211. /**
  48212. * Enable or disable the GPU frame time capture
  48213. */
  48214. captureGPUFrameTime: boolean;
  48215. /**
  48216. * Gets the perf counter used for shader compilation time
  48217. */
  48218. readonly shaderCompilationTimeCounter: PerfCounter;
  48219. /**
  48220. * Gets the shader compilation time capture status
  48221. */
  48222. /**
  48223. * Enable or disable the shader compilation time capture
  48224. */
  48225. captureShaderCompilationTime: boolean;
  48226. /**
  48227. * Instantiates a new engine instrumentation.
  48228. * This class can be used to get instrumentation data from a Babylon engine
  48229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48230. * @param engine Defines the engine to instrument
  48231. */
  48232. constructor(
  48233. /**
  48234. * Define the instrumented engine.
  48235. */
  48236. engine: Engine);
  48237. /**
  48238. * Dispose and release associated resources.
  48239. */
  48240. dispose(): void;
  48241. }
  48242. }
  48243. declare module BABYLON {
  48244. /**
  48245. * This class can be used to get instrumentation data from a Babylon engine
  48246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48247. */
  48248. export class SceneInstrumentation implements IDisposable {
  48249. /**
  48250. * Defines the scene to instrument
  48251. */
  48252. scene: Scene;
  48253. private _captureActiveMeshesEvaluationTime;
  48254. private _activeMeshesEvaluationTime;
  48255. private _captureRenderTargetsRenderTime;
  48256. private _renderTargetsRenderTime;
  48257. private _captureFrameTime;
  48258. private _frameTime;
  48259. private _captureRenderTime;
  48260. private _renderTime;
  48261. private _captureInterFrameTime;
  48262. private _interFrameTime;
  48263. private _captureParticlesRenderTime;
  48264. private _particlesRenderTime;
  48265. private _captureSpritesRenderTime;
  48266. private _spritesRenderTime;
  48267. private _capturePhysicsTime;
  48268. private _physicsTime;
  48269. private _captureAnimationsTime;
  48270. private _animationsTime;
  48271. private _captureCameraRenderTime;
  48272. private _cameraRenderTime;
  48273. private _onBeforeActiveMeshesEvaluationObserver;
  48274. private _onAfterActiveMeshesEvaluationObserver;
  48275. private _onBeforeRenderTargetsRenderObserver;
  48276. private _onAfterRenderTargetsRenderObserver;
  48277. private _onAfterRenderObserver;
  48278. private _onBeforeDrawPhaseObserver;
  48279. private _onAfterDrawPhaseObserver;
  48280. private _onBeforeAnimationsObserver;
  48281. private _onBeforeParticlesRenderingObserver;
  48282. private _onAfterParticlesRenderingObserver;
  48283. private _onBeforeSpritesRenderingObserver;
  48284. private _onAfterSpritesRenderingObserver;
  48285. private _onBeforePhysicsObserver;
  48286. private _onAfterPhysicsObserver;
  48287. private _onAfterAnimationsObserver;
  48288. private _onBeforeCameraRenderObserver;
  48289. private _onAfterCameraRenderObserver;
  48290. /**
  48291. * Gets the perf counter used for active meshes evaluation time
  48292. */
  48293. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48294. /**
  48295. * Gets the active meshes evaluation time capture status
  48296. */
  48297. /**
  48298. * Enable or disable the active meshes evaluation time capture
  48299. */
  48300. captureActiveMeshesEvaluationTime: boolean;
  48301. /**
  48302. * Gets the perf counter used for render targets render time
  48303. */
  48304. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48305. /**
  48306. * Gets the render targets render time capture status
  48307. */
  48308. /**
  48309. * Enable or disable the render targets render time capture
  48310. */
  48311. captureRenderTargetsRenderTime: boolean;
  48312. /**
  48313. * Gets the perf counter used for particles render time
  48314. */
  48315. readonly particlesRenderTimeCounter: PerfCounter;
  48316. /**
  48317. * Gets the particles render time capture status
  48318. */
  48319. /**
  48320. * Enable or disable the particles render time capture
  48321. */
  48322. captureParticlesRenderTime: boolean;
  48323. /**
  48324. * Gets the perf counter used for sprites render time
  48325. */
  48326. readonly spritesRenderTimeCounter: PerfCounter;
  48327. /**
  48328. * Gets the sprites render time capture status
  48329. */
  48330. /**
  48331. * Enable or disable the sprites render time capture
  48332. */
  48333. captureSpritesRenderTime: boolean;
  48334. /**
  48335. * Gets the perf counter used for physics time
  48336. */
  48337. readonly physicsTimeCounter: PerfCounter;
  48338. /**
  48339. * Gets the physics time capture status
  48340. */
  48341. /**
  48342. * Enable or disable the physics time capture
  48343. */
  48344. capturePhysicsTime: boolean;
  48345. /**
  48346. * Gets the perf counter used for animations time
  48347. */
  48348. readonly animationsTimeCounter: PerfCounter;
  48349. /**
  48350. * Gets the animations time capture status
  48351. */
  48352. /**
  48353. * Enable or disable the animations time capture
  48354. */
  48355. captureAnimationsTime: boolean;
  48356. /**
  48357. * Gets the perf counter used for frame time capture
  48358. */
  48359. readonly frameTimeCounter: PerfCounter;
  48360. /**
  48361. * Gets the frame time capture status
  48362. */
  48363. /**
  48364. * Enable or disable the frame time capture
  48365. */
  48366. captureFrameTime: boolean;
  48367. /**
  48368. * Gets the perf counter used for inter-frames time capture
  48369. */
  48370. readonly interFrameTimeCounter: PerfCounter;
  48371. /**
  48372. * Gets the inter-frames time capture status
  48373. */
  48374. /**
  48375. * Enable or disable the inter-frames time capture
  48376. */
  48377. captureInterFrameTime: boolean;
  48378. /**
  48379. * Gets the perf counter used for render time capture
  48380. */
  48381. readonly renderTimeCounter: PerfCounter;
  48382. /**
  48383. * Gets the render time capture status
  48384. */
  48385. /**
  48386. * Enable or disable the render time capture
  48387. */
  48388. captureRenderTime: boolean;
  48389. /**
  48390. * Gets the perf counter used for camera render time capture
  48391. */
  48392. readonly cameraRenderTimeCounter: PerfCounter;
  48393. /**
  48394. * Gets the camera render time capture status
  48395. */
  48396. /**
  48397. * Enable or disable the camera render time capture
  48398. */
  48399. captureCameraRenderTime: boolean;
  48400. /**
  48401. * Gets the perf counter used for draw calls
  48402. */
  48403. readonly drawCallsCounter: PerfCounter;
  48404. /**
  48405. * Instantiates a new scene instrumentation.
  48406. * This class can be used to get instrumentation data from a Babylon engine
  48407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48408. * @param scene Defines the scene to instrument
  48409. */
  48410. constructor(
  48411. /**
  48412. * Defines the scene to instrument
  48413. */
  48414. scene: Scene);
  48415. /**
  48416. * Dispose and release associated resources.
  48417. */
  48418. dispose(): void;
  48419. }
  48420. }
  48421. declare module BABYLON {
  48422. /** @hidden */
  48423. export var glowMapGenerationPixelShader: {
  48424. name: string;
  48425. shader: string;
  48426. };
  48427. }
  48428. declare module BABYLON {
  48429. /** @hidden */
  48430. export var glowMapGenerationVertexShader: {
  48431. name: string;
  48432. shader: string;
  48433. };
  48434. }
  48435. declare module BABYLON {
  48436. /**
  48437. * Effect layer options. This helps customizing the behaviour
  48438. * of the effect layer.
  48439. */
  48440. export interface IEffectLayerOptions {
  48441. /**
  48442. * Multiplication factor apply to the canvas size to compute the render target size
  48443. * used to generated the objects (the smaller the faster).
  48444. */
  48445. mainTextureRatio: number;
  48446. /**
  48447. * Enforces a fixed size texture to ensure effect stability across devices.
  48448. */
  48449. mainTextureFixedSize?: number;
  48450. /**
  48451. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48452. */
  48453. alphaBlendingMode: number;
  48454. /**
  48455. * The camera attached to the layer.
  48456. */
  48457. camera: Nullable<Camera>;
  48458. /**
  48459. * The rendering group to draw the layer in.
  48460. */
  48461. renderingGroupId: number;
  48462. }
  48463. /**
  48464. * The effect layer Helps adding post process effect blended with the main pass.
  48465. *
  48466. * This can be for instance use to generate glow or higlight effects on the scene.
  48467. *
  48468. * The effect layer class can not be used directly and is intented to inherited from to be
  48469. * customized per effects.
  48470. */
  48471. export abstract class EffectLayer {
  48472. private _vertexBuffers;
  48473. private _indexBuffer;
  48474. private _cachedDefines;
  48475. private _effectLayerMapGenerationEffect;
  48476. private _effectLayerOptions;
  48477. private _mergeEffect;
  48478. protected _scene: Scene;
  48479. protected _engine: Engine;
  48480. protected _maxSize: number;
  48481. protected _mainTextureDesiredSize: ISize;
  48482. protected _mainTexture: RenderTargetTexture;
  48483. protected _shouldRender: boolean;
  48484. protected _postProcesses: PostProcess[];
  48485. protected _textures: BaseTexture[];
  48486. protected _emissiveTextureAndColor: {
  48487. texture: Nullable<BaseTexture>;
  48488. color: Color4;
  48489. };
  48490. /**
  48491. * The name of the layer
  48492. */
  48493. name: string;
  48494. /**
  48495. * The clear color of the texture used to generate the glow map.
  48496. */
  48497. neutralColor: Color4;
  48498. /**
  48499. * Specifies wether the highlight layer is enabled or not.
  48500. */
  48501. isEnabled: boolean;
  48502. /**
  48503. * Gets the camera attached to the layer.
  48504. */
  48505. readonly camera: Nullable<Camera>;
  48506. /**
  48507. * Gets the rendering group id the layer should render in.
  48508. */
  48509. renderingGroupId: number;
  48510. /**
  48511. * An event triggered when the effect layer has been disposed.
  48512. */
  48513. onDisposeObservable: Observable<EffectLayer>;
  48514. /**
  48515. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48516. */
  48517. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48518. /**
  48519. * An event triggered when the generated texture is being merged in the scene.
  48520. */
  48521. onBeforeComposeObservable: Observable<EffectLayer>;
  48522. /**
  48523. * An event triggered when the generated texture has been merged in the scene.
  48524. */
  48525. onAfterComposeObservable: Observable<EffectLayer>;
  48526. /**
  48527. * An event triggered when the efffect layer changes its size.
  48528. */
  48529. onSizeChangedObservable: Observable<EffectLayer>;
  48530. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48531. /**
  48532. * Instantiates a new effect Layer and references it in the scene.
  48533. * @param name The name of the layer
  48534. * @param scene The scene to use the layer in
  48535. */
  48536. constructor(
  48537. /** The Friendly of the effect in the scene */
  48538. name: string, scene: Scene);
  48539. /**
  48540. * Get the effect name of the layer.
  48541. * @return The effect name
  48542. */
  48543. abstract getEffectName(): string;
  48544. /**
  48545. * Checks for the readiness of the element composing the layer.
  48546. * @param subMesh the mesh to check for
  48547. * @param useInstances specify wether or not to use instances to render the mesh
  48548. * @return true if ready otherwise, false
  48549. */
  48550. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48551. /**
  48552. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48553. * @returns true if the effect requires stencil during the main canvas render pass.
  48554. */
  48555. abstract needStencil(): boolean;
  48556. /**
  48557. * Create the merge effect. This is the shader use to blit the information back
  48558. * to the main canvas at the end of the scene rendering.
  48559. * @returns The effect containing the shader used to merge the effect on the main canvas
  48560. */
  48561. protected abstract _createMergeEffect(): Effect;
  48562. /**
  48563. * Creates the render target textures and post processes used in the effect layer.
  48564. */
  48565. protected abstract _createTextureAndPostProcesses(): void;
  48566. /**
  48567. * Implementation specific of rendering the generating effect on the main canvas.
  48568. * @param effect The effect used to render through
  48569. */
  48570. protected abstract _internalRender(effect: Effect): void;
  48571. /**
  48572. * Sets the required values for both the emissive texture and and the main color.
  48573. */
  48574. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48575. /**
  48576. * Free any resources and references associated to a mesh.
  48577. * Internal use
  48578. * @param mesh The mesh to free.
  48579. */
  48580. abstract _disposeMesh(mesh: Mesh): void;
  48581. /**
  48582. * Serializes this layer (Glow or Highlight for example)
  48583. * @returns a serialized layer object
  48584. */
  48585. abstract serialize?(): any;
  48586. /**
  48587. * Initializes the effect layer with the required options.
  48588. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48589. */
  48590. protected _init(options: Partial<IEffectLayerOptions>): void;
  48591. /**
  48592. * Generates the index buffer of the full screen quad blending to the main canvas.
  48593. */
  48594. private _generateIndexBuffer;
  48595. /**
  48596. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48597. */
  48598. private _generateVertexBuffer;
  48599. /**
  48600. * Sets the main texture desired size which is the closest power of two
  48601. * of the engine canvas size.
  48602. */
  48603. private _setMainTextureSize;
  48604. /**
  48605. * Creates the main texture for the effect layer.
  48606. */
  48607. protected _createMainTexture(): void;
  48608. /**
  48609. * Adds specific effects defines.
  48610. * @param defines The defines to add specifics to.
  48611. */
  48612. protected _addCustomEffectDefines(defines: string[]): void;
  48613. /**
  48614. * Checks for the readiness of the element composing the layer.
  48615. * @param subMesh the mesh to check for
  48616. * @param useInstances specify wether or not to use instances to render the mesh
  48617. * @param emissiveTexture the associated emissive texture used to generate the glow
  48618. * @return true if ready otherwise, false
  48619. */
  48620. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48621. /**
  48622. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48623. */
  48624. render(): void;
  48625. /**
  48626. * Determine if a given mesh will be used in the current effect.
  48627. * @param mesh mesh to test
  48628. * @returns true if the mesh will be used
  48629. */
  48630. hasMesh(mesh: AbstractMesh): boolean;
  48631. /**
  48632. * Returns true if the layer contains information to display, otherwise false.
  48633. * @returns true if the glow layer should be rendered
  48634. */
  48635. shouldRender(): boolean;
  48636. /**
  48637. * Returns true if the mesh should render, otherwise false.
  48638. * @param mesh The mesh to render
  48639. * @returns true if it should render otherwise false
  48640. */
  48641. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48642. /**
  48643. * Returns true if the mesh can be rendered, otherwise false.
  48644. * @param mesh The mesh to render
  48645. * @param material The material used on the mesh
  48646. * @returns true if it can be rendered otherwise false
  48647. */
  48648. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48649. /**
  48650. * Returns true if the mesh should render, otherwise false.
  48651. * @param mesh The mesh to render
  48652. * @returns true if it should render otherwise false
  48653. */
  48654. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48655. /**
  48656. * Renders the submesh passed in parameter to the generation map.
  48657. */
  48658. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48659. /**
  48660. * Rebuild the required buffers.
  48661. * @hidden Internal use only.
  48662. */ private _rebuild(): void;
  48663. /**
  48664. * Dispose only the render target textures and post process.
  48665. */
  48666. private _disposeTextureAndPostProcesses;
  48667. /**
  48668. * Dispose the highlight layer and free resources.
  48669. */
  48670. dispose(): void;
  48671. /**
  48672. * Gets the class name of the effect layer
  48673. * @returns the string with the class name of the effect layer
  48674. */
  48675. getClassName(): string;
  48676. /**
  48677. * Creates an effect layer from parsed effect layer data
  48678. * @param parsedEffectLayer defines effect layer data
  48679. * @param scene defines the current scene
  48680. * @param rootUrl defines the root URL containing the effect layer information
  48681. * @returns a parsed effect Layer
  48682. */
  48683. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48684. }
  48685. }
  48686. declare module BABYLON {
  48687. interface AbstractScene {
  48688. /**
  48689. * The list of effect layers (highlights/glow) added to the scene
  48690. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48691. * @see http://doc.babylonjs.com/how_to/glow_layer
  48692. */
  48693. effectLayers: Array<EffectLayer>;
  48694. /**
  48695. * Removes the given effect layer from this scene.
  48696. * @param toRemove defines the effect layer to remove
  48697. * @returns the index of the removed effect layer
  48698. */
  48699. removeEffectLayer(toRemove: EffectLayer): number;
  48700. /**
  48701. * Adds the given effect layer to this scene
  48702. * @param newEffectLayer defines the effect layer to add
  48703. */
  48704. addEffectLayer(newEffectLayer: EffectLayer): void;
  48705. }
  48706. /**
  48707. * Defines the layer scene component responsible to manage any effect layers
  48708. * in a given scene.
  48709. */
  48710. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48711. /**
  48712. * The component name helpfull to identify the component in the list of scene components.
  48713. */
  48714. readonly name: string;
  48715. /**
  48716. * The scene the component belongs to.
  48717. */
  48718. scene: Scene;
  48719. private _engine;
  48720. private _renderEffects;
  48721. private _needStencil;
  48722. private _previousStencilState;
  48723. /**
  48724. * Creates a new instance of the component for the given scene
  48725. * @param scene Defines the scene to register the component in
  48726. */
  48727. constructor(scene: Scene);
  48728. /**
  48729. * Registers the component in a given scene
  48730. */
  48731. register(): void;
  48732. /**
  48733. * Rebuilds the elements related to this component in case of
  48734. * context lost for instance.
  48735. */
  48736. rebuild(): void;
  48737. /**
  48738. * Serializes the component data to the specified json object
  48739. * @param serializationObject The object to serialize to
  48740. */
  48741. serialize(serializationObject: any): void;
  48742. /**
  48743. * Adds all the elements from the container to the scene
  48744. * @param container the container holding the elements
  48745. */
  48746. addFromContainer(container: AbstractScene): void;
  48747. /**
  48748. * Removes all the elements in the container from the scene
  48749. * @param container contains the elements to remove
  48750. * @param dispose if the removed element should be disposed (default: false)
  48751. */
  48752. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48753. /**
  48754. * Disposes the component and the associated ressources.
  48755. */
  48756. dispose(): void;
  48757. private _isReadyForMesh;
  48758. private _renderMainTexture;
  48759. private _setStencil;
  48760. private _setStencilBack;
  48761. private _draw;
  48762. private _drawCamera;
  48763. private _drawRenderingGroup;
  48764. }
  48765. }
  48766. declare module BABYLON {
  48767. /** @hidden */
  48768. export var glowMapMergePixelShader: {
  48769. name: string;
  48770. shader: string;
  48771. };
  48772. }
  48773. declare module BABYLON {
  48774. /** @hidden */
  48775. export var glowMapMergeVertexShader: {
  48776. name: string;
  48777. shader: string;
  48778. };
  48779. }
  48780. declare module BABYLON {
  48781. interface AbstractScene {
  48782. /**
  48783. * Return a the first highlight layer of the scene with a given name.
  48784. * @param name The name of the highlight layer to look for.
  48785. * @return The highlight layer if found otherwise null.
  48786. */
  48787. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48788. }
  48789. /**
  48790. * Glow layer options. This helps customizing the behaviour
  48791. * of the glow layer.
  48792. */
  48793. export interface IGlowLayerOptions {
  48794. /**
  48795. * Multiplication factor apply to the canvas size to compute the render target size
  48796. * used to generated the glowing objects (the smaller the faster).
  48797. */
  48798. mainTextureRatio: number;
  48799. /**
  48800. * Enforces a fixed size texture to ensure resize independant blur.
  48801. */
  48802. mainTextureFixedSize?: number;
  48803. /**
  48804. * How big is the kernel of the blur texture.
  48805. */
  48806. blurKernelSize: number;
  48807. /**
  48808. * The camera attached to the layer.
  48809. */
  48810. camera: Nullable<Camera>;
  48811. /**
  48812. * Enable MSAA by chosing the number of samples.
  48813. */
  48814. mainTextureSamples?: number;
  48815. /**
  48816. * The rendering group to draw the layer in.
  48817. */
  48818. renderingGroupId: number;
  48819. }
  48820. /**
  48821. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48822. *
  48823. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48824. * glowy meshes to your scene.
  48825. *
  48826. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48827. */
  48828. export class GlowLayer extends EffectLayer {
  48829. /**
  48830. * Effect Name of the layer.
  48831. */
  48832. static readonly EffectName: string;
  48833. /**
  48834. * The default blur kernel size used for the glow.
  48835. */
  48836. static DefaultBlurKernelSize: number;
  48837. /**
  48838. * The default texture size ratio used for the glow.
  48839. */
  48840. static DefaultTextureRatio: number;
  48841. /**
  48842. * Sets the kernel size of the blur.
  48843. */
  48844. /**
  48845. * Gets the kernel size of the blur.
  48846. */
  48847. blurKernelSize: number;
  48848. /**
  48849. * Sets the glow intensity.
  48850. */
  48851. /**
  48852. * Gets the glow intensity.
  48853. */
  48854. intensity: number;
  48855. private _options;
  48856. private _intensity;
  48857. private _horizontalBlurPostprocess1;
  48858. private _verticalBlurPostprocess1;
  48859. private _horizontalBlurPostprocess2;
  48860. private _verticalBlurPostprocess2;
  48861. private _blurTexture1;
  48862. private _blurTexture2;
  48863. private _postProcesses1;
  48864. private _postProcesses2;
  48865. private _includedOnlyMeshes;
  48866. private _excludedMeshes;
  48867. /**
  48868. * Callback used to let the user override the color selection on a per mesh basis
  48869. */
  48870. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48871. /**
  48872. * Callback used to let the user override the texture selection on a per mesh basis
  48873. */
  48874. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48875. /**
  48876. * Instantiates a new glow Layer and references it to the scene.
  48877. * @param name The name of the layer
  48878. * @param scene The scene to use the layer in
  48879. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48880. */
  48881. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48882. /**
  48883. * Get the effect name of the layer.
  48884. * @return The effect name
  48885. */
  48886. getEffectName(): string;
  48887. /**
  48888. * Create the merge effect. This is the shader use to blit the information back
  48889. * to the main canvas at the end of the scene rendering.
  48890. */
  48891. protected _createMergeEffect(): Effect;
  48892. /**
  48893. * Creates the render target textures and post processes used in the glow layer.
  48894. */
  48895. protected _createTextureAndPostProcesses(): void;
  48896. /**
  48897. * Checks for the readiness of the element composing the layer.
  48898. * @param subMesh the mesh to check for
  48899. * @param useInstances specify wether or not to use instances to render the mesh
  48900. * @param emissiveTexture the associated emissive texture used to generate the glow
  48901. * @return true if ready otherwise, false
  48902. */
  48903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48904. /**
  48905. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48906. */
  48907. needStencil(): boolean;
  48908. /**
  48909. * Returns true if the mesh can be rendered, otherwise false.
  48910. * @param mesh The mesh to render
  48911. * @param material The material used on the mesh
  48912. * @returns true if it can be rendered otherwise false
  48913. */
  48914. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48915. /**
  48916. * Implementation specific of rendering the generating effect on the main canvas.
  48917. * @param effect The effect used to render through
  48918. */
  48919. protected _internalRender(effect: Effect): void;
  48920. /**
  48921. * Sets the required values for both the emissive texture and and the main color.
  48922. */
  48923. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48924. /**
  48925. * Returns true if the mesh should render, otherwise false.
  48926. * @param mesh The mesh to render
  48927. * @returns true if it should render otherwise false
  48928. */
  48929. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48930. /**
  48931. * Adds specific effects defines.
  48932. * @param defines The defines to add specifics to.
  48933. */
  48934. protected _addCustomEffectDefines(defines: string[]): void;
  48935. /**
  48936. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48937. * @param mesh The mesh to exclude from the glow layer
  48938. */
  48939. addExcludedMesh(mesh: Mesh): void;
  48940. /**
  48941. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48942. * @param mesh The mesh to remove
  48943. */
  48944. removeExcludedMesh(mesh: Mesh): void;
  48945. /**
  48946. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48947. * @param mesh The mesh to include in the glow layer
  48948. */
  48949. addIncludedOnlyMesh(mesh: Mesh): void;
  48950. /**
  48951. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48952. * @param mesh The mesh to remove
  48953. */
  48954. removeIncludedOnlyMesh(mesh: Mesh): void;
  48955. /**
  48956. * Determine if a given mesh will be used in the glow layer
  48957. * @param mesh The mesh to test
  48958. * @returns true if the mesh will be highlighted by the current glow layer
  48959. */
  48960. hasMesh(mesh: AbstractMesh): boolean;
  48961. /**
  48962. * Free any resources and references associated to a mesh.
  48963. * Internal use
  48964. * @param mesh The mesh to free.
  48965. * @hidden
  48966. */ private _disposeMesh(mesh: Mesh): void;
  48967. /**
  48968. * Gets the class name of the effect layer
  48969. * @returns the string with the class name of the effect layer
  48970. */
  48971. getClassName(): string;
  48972. /**
  48973. * Serializes this glow layer
  48974. * @returns a serialized glow layer object
  48975. */
  48976. serialize(): any;
  48977. /**
  48978. * Creates a Glow Layer from parsed glow layer data
  48979. * @param parsedGlowLayer defines glow layer data
  48980. * @param scene defines the current scene
  48981. * @param rootUrl defines the root URL containing the glow layer information
  48982. * @returns a parsed Glow Layer
  48983. */
  48984. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48985. }
  48986. }
  48987. declare module BABYLON {
  48988. /** @hidden */
  48989. export var glowBlurPostProcessPixelShader: {
  48990. name: string;
  48991. shader: string;
  48992. };
  48993. }
  48994. declare module BABYLON {
  48995. interface AbstractScene {
  48996. /**
  48997. * Return a the first highlight layer of the scene with a given name.
  48998. * @param name The name of the highlight layer to look for.
  48999. * @return The highlight layer if found otherwise null.
  49000. */
  49001. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49002. }
  49003. /**
  49004. * Highlight layer options. This helps customizing the behaviour
  49005. * of the highlight layer.
  49006. */
  49007. export interface IHighlightLayerOptions {
  49008. /**
  49009. * Multiplication factor apply to the canvas size to compute the render target size
  49010. * used to generated the glowing objects (the smaller the faster).
  49011. */
  49012. mainTextureRatio: number;
  49013. /**
  49014. * Enforces a fixed size texture to ensure resize independant blur.
  49015. */
  49016. mainTextureFixedSize?: number;
  49017. /**
  49018. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49019. * of the picture to blur (the smaller the faster).
  49020. */
  49021. blurTextureSizeRatio: number;
  49022. /**
  49023. * How big in texel of the blur texture is the vertical blur.
  49024. */
  49025. blurVerticalSize: number;
  49026. /**
  49027. * How big in texel of the blur texture is the horizontal blur.
  49028. */
  49029. blurHorizontalSize: number;
  49030. /**
  49031. * Alpha blending mode used to apply the blur. Default is combine.
  49032. */
  49033. alphaBlendingMode: number;
  49034. /**
  49035. * The camera attached to the layer.
  49036. */
  49037. camera: Nullable<Camera>;
  49038. /**
  49039. * Should we display highlight as a solid stroke?
  49040. */
  49041. isStroke?: boolean;
  49042. /**
  49043. * The rendering group to draw the layer in.
  49044. */
  49045. renderingGroupId: number;
  49046. }
  49047. /**
  49048. * The highlight layer Helps adding a glow effect around a mesh.
  49049. *
  49050. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49051. * glowy meshes to your scene.
  49052. *
  49053. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49054. */
  49055. export class HighlightLayer extends EffectLayer {
  49056. name: string;
  49057. /**
  49058. * Effect Name of the highlight layer.
  49059. */
  49060. static readonly EffectName: string;
  49061. /**
  49062. * The neutral color used during the preparation of the glow effect.
  49063. * This is black by default as the blend operation is a blend operation.
  49064. */
  49065. static NeutralColor: Color4;
  49066. /**
  49067. * Stencil value used for glowing meshes.
  49068. */
  49069. static GlowingMeshStencilReference: number;
  49070. /**
  49071. * Stencil value used for the other meshes in the scene.
  49072. */
  49073. static NormalMeshStencilReference: number;
  49074. /**
  49075. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49076. */
  49077. innerGlow: boolean;
  49078. /**
  49079. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49080. */
  49081. outerGlow: boolean;
  49082. /**
  49083. * Specifies the horizontal size of the blur.
  49084. */
  49085. /**
  49086. * Gets the horizontal size of the blur.
  49087. */
  49088. blurHorizontalSize: number;
  49089. /**
  49090. * Specifies the vertical size of the blur.
  49091. */
  49092. /**
  49093. * Gets the vertical size of the blur.
  49094. */
  49095. blurVerticalSize: number;
  49096. /**
  49097. * An event triggered when the highlight layer is being blurred.
  49098. */
  49099. onBeforeBlurObservable: Observable<HighlightLayer>;
  49100. /**
  49101. * An event triggered when the highlight layer has been blurred.
  49102. */
  49103. onAfterBlurObservable: Observable<HighlightLayer>;
  49104. private _instanceGlowingMeshStencilReference;
  49105. private _options;
  49106. private _downSamplePostprocess;
  49107. private _horizontalBlurPostprocess;
  49108. private _verticalBlurPostprocess;
  49109. private _blurTexture;
  49110. private _meshes;
  49111. private _excludedMeshes;
  49112. /**
  49113. * Instantiates a new highlight Layer and references it to the scene..
  49114. * @param name The name of the layer
  49115. * @param scene The scene to use the layer in
  49116. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49117. */
  49118. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49119. /**
  49120. * Get the effect name of the layer.
  49121. * @return The effect name
  49122. */
  49123. getEffectName(): string;
  49124. /**
  49125. * Create the merge effect. This is the shader use to blit the information back
  49126. * to the main canvas at the end of the scene rendering.
  49127. */
  49128. protected _createMergeEffect(): Effect;
  49129. /**
  49130. * Creates the render target textures and post processes used in the highlight layer.
  49131. */
  49132. protected _createTextureAndPostProcesses(): void;
  49133. /**
  49134. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49135. */
  49136. needStencil(): boolean;
  49137. /**
  49138. * Checks for the readiness of the element composing the layer.
  49139. * @param subMesh the mesh to check for
  49140. * @param useInstances specify wether or not to use instances to render the mesh
  49141. * @param emissiveTexture the associated emissive texture used to generate the glow
  49142. * @return true if ready otherwise, false
  49143. */
  49144. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49145. /**
  49146. * Implementation specific of rendering the generating effect on the main canvas.
  49147. * @param effect The effect used to render through
  49148. */
  49149. protected _internalRender(effect: Effect): void;
  49150. /**
  49151. * Returns true if the layer contains information to display, otherwise false.
  49152. */
  49153. shouldRender(): boolean;
  49154. /**
  49155. * Returns true if the mesh should render, otherwise false.
  49156. * @param mesh The mesh to render
  49157. * @returns true if it should render otherwise false
  49158. */
  49159. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49160. /**
  49161. * Sets the required values for both the emissive texture and and the main color.
  49162. */
  49163. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49164. /**
  49165. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49166. * @param mesh The mesh to exclude from the highlight layer
  49167. */
  49168. addExcludedMesh(mesh: Mesh): void;
  49169. /**
  49170. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49171. * @param mesh The mesh to highlight
  49172. */
  49173. removeExcludedMesh(mesh: Mesh): void;
  49174. /**
  49175. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49176. * @param mesh mesh to test
  49177. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49178. */
  49179. hasMesh(mesh: AbstractMesh): boolean;
  49180. /**
  49181. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49182. * @param mesh The mesh to highlight
  49183. * @param color The color of the highlight
  49184. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49185. */
  49186. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49187. /**
  49188. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49189. * @param mesh The mesh to highlight
  49190. */
  49191. removeMesh(mesh: Mesh): void;
  49192. /**
  49193. * Force the stencil to the normal expected value for none glowing parts
  49194. */
  49195. private _defaultStencilReference;
  49196. /**
  49197. * Free any resources and references associated to a mesh.
  49198. * Internal use
  49199. * @param mesh The mesh to free.
  49200. * @hidden
  49201. */ private _disposeMesh(mesh: Mesh): void;
  49202. /**
  49203. * Dispose the highlight layer and free resources.
  49204. */
  49205. dispose(): void;
  49206. /**
  49207. * Gets the class name of the effect layer
  49208. * @returns the string with the class name of the effect layer
  49209. */
  49210. getClassName(): string;
  49211. /**
  49212. * Serializes this Highlight layer
  49213. * @returns a serialized Highlight layer object
  49214. */
  49215. serialize(): any;
  49216. /**
  49217. * Creates a Highlight layer from parsed Highlight layer data
  49218. * @param parsedHightlightLayer defines the Highlight layer data
  49219. * @param scene defines the current scene
  49220. * @param rootUrl defines the root URL containing the Highlight layer information
  49221. * @returns a parsed Highlight layer
  49222. */
  49223. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49224. }
  49225. }
  49226. declare module BABYLON {
  49227. interface AbstractScene {
  49228. /**
  49229. * The list of layers (background and foreground) of the scene
  49230. */
  49231. layers: Array<Layer>;
  49232. }
  49233. /**
  49234. * Defines the layer scene component responsible to manage any layers
  49235. * in a given scene.
  49236. */
  49237. export class LayerSceneComponent implements ISceneComponent {
  49238. /**
  49239. * The component name helpfull to identify the component in the list of scene components.
  49240. */
  49241. readonly name: string;
  49242. /**
  49243. * The scene the component belongs to.
  49244. */
  49245. scene: Scene;
  49246. private _engine;
  49247. /**
  49248. * Creates a new instance of the component for the given scene
  49249. * @param scene Defines the scene to register the component in
  49250. */
  49251. constructor(scene: Scene);
  49252. /**
  49253. * Registers the component in a given scene
  49254. */
  49255. register(): void;
  49256. /**
  49257. * Rebuilds the elements related to this component in case of
  49258. * context lost for instance.
  49259. */
  49260. rebuild(): void;
  49261. /**
  49262. * Disposes the component and the associated ressources.
  49263. */
  49264. dispose(): void;
  49265. private _draw;
  49266. private _drawCameraPredicate;
  49267. private _drawCameraBackground;
  49268. private _drawCameraForeground;
  49269. private _drawRenderTargetPredicate;
  49270. private _drawRenderTargetBackground;
  49271. private _drawRenderTargetForeground;
  49272. /**
  49273. * Adds all the elements from the container to the scene
  49274. * @param container the container holding the elements
  49275. */
  49276. addFromContainer(container: AbstractScene): void;
  49277. /**
  49278. * Removes all the elements in the container from the scene
  49279. * @param container contains the elements to remove
  49280. * @param dispose if the removed element should be disposed (default: false)
  49281. */
  49282. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /** @hidden */
  49287. export var layerPixelShader: {
  49288. name: string;
  49289. shader: string;
  49290. };
  49291. }
  49292. declare module BABYLON {
  49293. /** @hidden */
  49294. export var layerVertexShader: {
  49295. name: string;
  49296. shader: string;
  49297. };
  49298. }
  49299. declare module BABYLON {
  49300. /**
  49301. * This represents a full screen 2d layer.
  49302. * This can be useful to display a picture in the background of your scene for instance.
  49303. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49304. */
  49305. export class Layer {
  49306. /**
  49307. * Define the name of the layer.
  49308. */
  49309. name: string;
  49310. /**
  49311. * Define the texture the layer should display.
  49312. */
  49313. texture: Nullable<Texture>;
  49314. /**
  49315. * Is the layer in background or foreground.
  49316. */
  49317. isBackground: boolean;
  49318. /**
  49319. * Define the color of the layer (instead of texture).
  49320. */
  49321. color: Color4;
  49322. /**
  49323. * Define the scale of the layer in order to zoom in out of the texture.
  49324. */
  49325. scale: Vector2;
  49326. /**
  49327. * Define an offset for the layer in order to shift the texture.
  49328. */
  49329. offset: Vector2;
  49330. /**
  49331. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49332. */
  49333. alphaBlendingMode: number;
  49334. /**
  49335. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49336. * Alpha test will not mix with the background color in case of transparency.
  49337. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49338. */
  49339. alphaTest: boolean;
  49340. /**
  49341. * Define a mask to restrict the layer to only some of the scene cameras.
  49342. */
  49343. layerMask: number;
  49344. /**
  49345. * Define the list of render target the layer is visible into.
  49346. */
  49347. renderTargetTextures: RenderTargetTexture[];
  49348. /**
  49349. * Define if the layer is only used in renderTarget or if it also
  49350. * renders in the main frame buffer of the canvas.
  49351. */
  49352. renderOnlyInRenderTargetTextures: boolean;
  49353. private _scene;
  49354. private _vertexBuffers;
  49355. private _indexBuffer;
  49356. private _effect;
  49357. private _alphaTestEffect;
  49358. /**
  49359. * An event triggered when the layer is disposed.
  49360. */
  49361. onDisposeObservable: Observable<Layer>;
  49362. private _onDisposeObserver;
  49363. /**
  49364. * Back compatibility with callback before the onDisposeObservable existed.
  49365. * The set callback will be triggered when the layer has been disposed.
  49366. */
  49367. onDispose: () => void;
  49368. /**
  49369. * An event triggered before rendering the scene
  49370. */
  49371. onBeforeRenderObservable: Observable<Layer>;
  49372. private _onBeforeRenderObserver;
  49373. /**
  49374. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49375. * The set callback will be triggered just before rendering the layer.
  49376. */
  49377. onBeforeRender: () => void;
  49378. /**
  49379. * An event triggered after rendering the scene
  49380. */
  49381. onAfterRenderObservable: Observable<Layer>;
  49382. private _onAfterRenderObserver;
  49383. /**
  49384. * Back compatibility with callback before the onAfterRenderObservable existed.
  49385. * The set callback will be triggered just after rendering the layer.
  49386. */
  49387. onAfterRender: () => void;
  49388. /**
  49389. * Instantiates a new layer.
  49390. * This represents a full screen 2d layer.
  49391. * This can be useful to display a picture in the background of your scene for instance.
  49392. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49393. * @param name Define the name of the layer in the scene
  49394. * @param imgUrl Define the url of the texture to display in the layer
  49395. * @param scene Define the scene the layer belongs to
  49396. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49397. * @param color Defines a color for the layer
  49398. */
  49399. constructor(
  49400. /**
  49401. * Define the name of the layer.
  49402. */
  49403. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49404. private _createIndexBuffer;
  49405. /** @hidden */ private _rebuild(): void;
  49406. /**
  49407. * Renders the layer in the scene.
  49408. */
  49409. render(): void;
  49410. /**
  49411. * Disposes and releases the associated ressources.
  49412. */
  49413. dispose(): void;
  49414. }
  49415. }
  49416. declare module BABYLON {
  49417. /** @hidden */
  49418. export var lensFlarePixelShader: {
  49419. name: string;
  49420. shader: string;
  49421. };
  49422. }
  49423. declare module BABYLON {
  49424. /** @hidden */
  49425. export var lensFlareVertexShader: {
  49426. name: string;
  49427. shader: string;
  49428. };
  49429. }
  49430. declare module BABYLON {
  49431. /**
  49432. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49433. * It is usually composed of several `lensFlare`.
  49434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49435. */
  49436. export class LensFlareSystem {
  49437. /**
  49438. * Define the name of the lens flare system
  49439. */
  49440. name: string;
  49441. /**
  49442. * List of lens flares used in this system.
  49443. */
  49444. lensFlares: LensFlare[];
  49445. /**
  49446. * Define a limit from the border the lens flare can be visible.
  49447. */
  49448. borderLimit: number;
  49449. /**
  49450. * Define a viewport border we do not want to see the lens flare in.
  49451. */
  49452. viewportBorder: number;
  49453. /**
  49454. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49455. */
  49456. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49457. /**
  49458. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49459. */
  49460. layerMask: number;
  49461. /**
  49462. * Define the id of the lens flare system in the scene.
  49463. * (equal to name by default)
  49464. */
  49465. id: string;
  49466. private _scene;
  49467. private _emitter;
  49468. private _vertexBuffers;
  49469. private _indexBuffer;
  49470. private _effect;
  49471. private _positionX;
  49472. private _positionY;
  49473. private _isEnabled;
  49474. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49475. /**
  49476. * Instantiates a lens flare system.
  49477. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49478. * It is usually composed of several `lensFlare`.
  49479. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49480. * @param name Define the name of the lens flare system in the scene
  49481. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49482. * @param scene Define the scene the lens flare system belongs to
  49483. */
  49484. constructor(
  49485. /**
  49486. * Define the name of the lens flare system
  49487. */
  49488. name: string, emitter: any, scene: Scene);
  49489. /**
  49490. * Define if the lens flare system is enabled.
  49491. */
  49492. isEnabled: boolean;
  49493. /**
  49494. * Get the scene the effects belongs to.
  49495. * @returns the scene holding the lens flare system
  49496. */
  49497. getScene(): Scene;
  49498. /**
  49499. * Get the emitter of the lens flare system.
  49500. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49501. * @returns the emitter of the lens flare system
  49502. */
  49503. getEmitter(): any;
  49504. /**
  49505. * Set the emitter of the lens flare system.
  49506. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49507. * @param newEmitter Define the new emitter of the system
  49508. */
  49509. setEmitter(newEmitter: any): void;
  49510. /**
  49511. * Get the lens flare system emitter position.
  49512. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49513. * @returns the position
  49514. */
  49515. getEmitterPosition(): Vector3;
  49516. /**
  49517. * @hidden
  49518. */
  49519. computeEffectivePosition(globalViewport: Viewport): boolean;
  49520. /** @hidden */ private _isVisible(): boolean;
  49521. /**
  49522. * @hidden
  49523. */
  49524. render(): boolean;
  49525. /**
  49526. * Dispose and release the lens flare with its associated resources.
  49527. */
  49528. dispose(): void;
  49529. /**
  49530. * Parse a lens flare system from a JSON repressentation
  49531. * @param parsedLensFlareSystem Define the JSON to parse
  49532. * @param scene Define the scene the parsed system should be instantiated in
  49533. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49534. * @returns the parsed system
  49535. */
  49536. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49537. /**
  49538. * Serialize the current Lens Flare System into a JSON representation.
  49539. * @returns the serialized JSON
  49540. */
  49541. serialize(): any;
  49542. }
  49543. }
  49544. declare module BABYLON {
  49545. /**
  49546. * This represents one of the lens effect in a `lensFlareSystem`.
  49547. * It controls one of the indiviual texture used in the effect.
  49548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49549. */
  49550. export class LensFlare {
  49551. /**
  49552. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49553. */
  49554. size: number;
  49555. /**
  49556. * 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.
  49557. */
  49558. position: number;
  49559. /**
  49560. * Define the lens color.
  49561. */
  49562. color: Color3;
  49563. /**
  49564. * Define the lens texture.
  49565. */
  49566. texture: Nullable<Texture>;
  49567. /**
  49568. * Define the alpha mode to render this particular lens.
  49569. */
  49570. alphaMode: number;
  49571. private _system;
  49572. /**
  49573. * Creates a new Lens Flare.
  49574. * This represents one of the lens effect in a `lensFlareSystem`.
  49575. * It controls one of the indiviual texture used in the effect.
  49576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49577. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49578. * @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.
  49579. * @param color Define the lens color
  49580. * @param imgUrl Define the lens texture url
  49581. * @param system Define the `lensFlareSystem` this flare is part of
  49582. * @returns The newly created Lens Flare
  49583. */
  49584. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49585. /**
  49586. * Instantiates a new Lens Flare.
  49587. * This represents one of the lens effect in a `lensFlareSystem`.
  49588. * It controls one of the indiviual texture used in the effect.
  49589. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49590. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49591. * @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.
  49592. * @param color Define the lens color
  49593. * @param imgUrl Define the lens texture url
  49594. * @param system Define the `lensFlareSystem` this flare is part of
  49595. */
  49596. constructor(
  49597. /**
  49598. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49599. */
  49600. size: number,
  49601. /**
  49602. * 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.
  49603. */
  49604. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49605. /**
  49606. * Dispose and release the lens flare with its associated resources.
  49607. */
  49608. dispose(): void;
  49609. }
  49610. }
  49611. declare module BABYLON {
  49612. interface AbstractScene {
  49613. /**
  49614. * The list of lens flare system added to the scene
  49615. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49616. */
  49617. lensFlareSystems: Array<LensFlareSystem>;
  49618. /**
  49619. * Removes the given lens flare system from this scene.
  49620. * @param toRemove The lens flare system to remove
  49621. * @returns The index of the removed lens flare system
  49622. */
  49623. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49624. /**
  49625. * Adds the given lens flare system to this scene
  49626. * @param newLensFlareSystem The lens flare system to add
  49627. */
  49628. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49629. /**
  49630. * Gets a lens flare system using its name
  49631. * @param name defines the name to look for
  49632. * @returns the lens flare system or null if not found
  49633. */
  49634. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49635. /**
  49636. * Gets a lens flare system using its id
  49637. * @param id defines the id to look for
  49638. * @returns the lens flare system or null if not found
  49639. */
  49640. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49641. }
  49642. /**
  49643. * Defines the lens flare scene component responsible to manage any lens flares
  49644. * in a given scene.
  49645. */
  49646. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49647. /**
  49648. * The component name helpfull to identify the component in the list of scene components.
  49649. */
  49650. readonly name: string;
  49651. /**
  49652. * The scene the component belongs to.
  49653. */
  49654. scene: Scene;
  49655. /**
  49656. * Creates a new instance of the component for the given scene
  49657. * @param scene Defines the scene to register the component in
  49658. */
  49659. constructor(scene: Scene);
  49660. /**
  49661. * Registers the component in a given scene
  49662. */
  49663. register(): void;
  49664. /**
  49665. * Rebuilds the elements related to this component in case of
  49666. * context lost for instance.
  49667. */
  49668. rebuild(): void;
  49669. /**
  49670. * Adds all the elements from the container to the scene
  49671. * @param container the container holding the elements
  49672. */
  49673. addFromContainer(container: AbstractScene): void;
  49674. /**
  49675. * Removes all the elements in the container from the scene
  49676. * @param container contains the elements to remove
  49677. * @param dispose if the removed element should be disposed (default: false)
  49678. */
  49679. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49680. /**
  49681. * Serializes the component data to the specified json object
  49682. * @param serializationObject The object to serialize to
  49683. */
  49684. serialize(serializationObject: any): void;
  49685. /**
  49686. * Disposes the component and the associated ressources.
  49687. */
  49688. dispose(): void;
  49689. private _draw;
  49690. }
  49691. }
  49692. declare module BABYLON {
  49693. /**
  49694. * Defines the shadow generator component responsible to manage any shadow generators
  49695. * in a given scene.
  49696. */
  49697. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49698. /**
  49699. * The component name helpfull to identify the component in the list of scene components.
  49700. */
  49701. readonly name: string;
  49702. /**
  49703. * The scene the component belongs to.
  49704. */
  49705. scene: Scene;
  49706. /**
  49707. * Creates a new instance of the component for the given scene
  49708. * @param scene Defines the scene to register the component in
  49709. */
  49710. constructor(scene: Scene);
  49711. /**
  49712. * Registers the component in a given scene
  49713. */
  49714. register(): void;
  49715. /**
  49716. * Rebuilds the elements related to this component in case of
  49717. * context lost for instance.
  49718. */
  49719. rebuild(): void;
  49720. /**
  49721. * Serializes the component data to the specified json object
  49722. * @param serializationObject The object to serialize to
  49723. */
  49724. serialize(serializationObject: any): void;
  49725. /**
  49726. * Adds all the elements from the container to the scene
  49727. * @param container the container holding the elements
  49728. */
  49729. addFromContainer(container: AbstractScene): void;
  49730. /**
  49731. * Removes all the elements in the container from the scene
  49732. * @param container contains the elements to remove
  49733. * @param dispose if the removed element should be disposed (default: false)
  49734. */
  49735. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49736. /**
  49737. * Rebuilds the elements related to this component in case of
  49738. * context lost for instance.
  49739. */
  49740. dispose(): void;
  49741. private _gatherRenderTargets;
  49742. }
  49743. }
  49744. declare module BABYLON {
  49745. /**
  49746. * A point light is a light defined by an unique point in world space.
  49747. * The light is emitted in every direction from this point.
  49748. * A good example of a point light is a standard light bulb.
  49749. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49750. */
  49751. export class PointLight extends ShadowLight {
  49752. private _shadowAngle;
  49753. /**
  49754. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49755. * This specifies what angle the shadow will use to be created.
  49756. *
  49757. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49758. */
  49759. /**
  49760. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49761. * This specifies what angle the shadow will use to be created.
  49762. *
  49763. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49764. */
  49765. shadowAngle: number;
  49766. /**
  49767. * Gets the direction if it has been set.
  49768. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49769. */
  49770. /**
  49771. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49772. */
  49773. direction: Vector3;
  49774. /**
  49775. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49776. * A PointLight emits the light in every direction.
  49777. * It can cast shadows.
  49778. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49779. * ```javascript
  49780. * var pointLight = new PointLight("pl", camera.position, scene);
  49781. * ```
  49782. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49783. * @param name The light friendly name
  49784. * @param position The position of the point light in the scene
  49785. * @param scene The scene the lights belongs to
  49786. */
  49787. constructor(name: string, position: Vector3, scene: Scene);
  49788. /**
  49789. * Returns the string "PointLight"
  49790. * @returns the class name
  49791. */
  49792. getClassName(): string;
  49793. /**
  49794. * Returns the integer 0.
  49795. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49796. */
  49797. getTypeID(): number;
  49798. /**
  49799. * Specifies wether or not the shadowmap should be a cube texture.
  49800. * @returns true if the shadowmap needs to be a cube texture.
  49801. */
  49802. needCube(): boolean;
  49803. /**
  49804. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49805. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49806. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49807. */
  49808. getShadowDirection(faceIndex?: number): Vector3;
  49809. /**
  49810. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49811. * - fov = PI / 2
  49812. * - aspect ratio : 1.0
  49813. * - z-near and far equal to the active camera minZ and maxZ.
  49814. * Returns the PointLight.
  49815. */
  49816. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49817. protected _buildUniformLayout(): void;
  49818. /**
  49819. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49820. * @param effect The effect to update
  49821. * @param lightIndex The index of the light in the effect to update
  49822. * @returns The point light
  49823. */
  49824. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49825. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49826. /**
  49827. * Prepares the list of defines specific to the light type.
  49828. * @param defines the list of defines
  49829. * @param lightIndex defines the index of the light for the effect
  49830. */
  49831. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49832. }
  49833. }
  49834. declare module BABYLON {
  49835. /**
  49836. * Header information of HDR texture files.
  49837. */
  49838. export interface HDRInfo {
  49839. /**
  49840. * The height of the texture in pixels.
  49841. */
  49842. height: number;
  49843. /**
  49844. * The width of the texture in pixels.
  49845. */
  49846. width: number;
  49847. /**
  49848. * The index of the beginning of the data in the binary file.
  49849. */
  49850. dataPosition: number;
  49851. }
  49852. /**
  49853. * This groups tools to convert HDR texture to native colors array.
  49854. */
  49855. export class HDRTools {
  49856. private static Ldexp;
  49857. private static Rgbe2float;
  49858. private static readStringLine;
  49859. /**
  49860. * Reads header information from an RGBE texture stored in a native array.
  49861. * More information on this format are available here:
  49862. * https://en.wikipedia.org/wiki/RGBE_image_format
  49863. *
  49864. * @param uint8array The binary file stored in native array.
  49865. * @return The header information.
  49866. */
  49867. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49868. /**
  49869. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49870. * This RGBE texture needs to store the information as a panorama.
  49871. *
  49872. * More information on this format are available here:
  49873. * https://en.wikipedia.org/wiki/RGBE_image_format
  49874. *
  49875. * @param buffer The binary file stored in an array buffer.
  49876. * @param size The expected size of the extracted cubemap.
  49877. * @return The Cube Map information.
  49878. */
  49879. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49880. /**
  49881. * Returns the pixels data extracted from an RGBE texture.
  49882. * This pixels will be stored left to right up to down in the R G B order in one array.
  49883. *
  49884. * More information on this format are available here:
  49885. * https://en.wikipedia.org/wiki/RGBE_image_format
  49886. *
  49887. * @param uint8array The binary file stored in an array buffer.
  49888. * @param hdrInfo The header information of the file.
  49889. * @return The pixels data in RGB right to left up to down order.
  49890. */
  49891. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49892. private static RGBE_ReadPixels_RLE;
  49893. }
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * This represents a texture coming from an HDR input.
  49898. *
  49899. * The only supported format is currently panorama picture stored in RGBE format.
  49900. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49901. */
  49902. export class HDRCubeTexture extends BaseTexture {
  49903. private static _facesMapping;
  49904. private _generateHarmonics;
  49905. private _noMipmap;
  49906. private _textureMatrix;
  49907. private _size;
  49908. private _onLoad;
  49909. private _onError;
  49910. /**
  49911. * The texture URL.
  49912. */
  49913. url: string;
  49914. /**
  49915. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49916. */
  49917. coordinatesMode: number;
  49918. protected _isBlocking: boolean;
  49919. /**
  49920. * Sets wether or not the texture is blocking during loading.
  49921. */
  49922. /**
  49923. * Gets wether or not the texture is blocking during loading.
  49924. */
  49925. isBlocking: boolean;
  49926. protected _rotationY: number;
  49927. /**
  49928. * Sets texture matrix rotation angle around Y axis in radians.
  49929. */
  49930. /**
  49931. * Gets texture matrix rotation angle around Y axis radians.
  49932. */
  49933. rotationY: number;
  49934. /**
  49935. * Gets or sets the center of the bounding box associated with the cube texture
  49936. * It must define where the camera used to render the texture was set
  49937. */
  49938. boundingBoxPosition: Vector3;
  49939. private _boundingBoxSize;
  49940. /**
  49941. * Gets or sets the size of the bounding box associated with the cube texture
  49942. * When defined, the cubemap will switch to local mode
  49943. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49944. * @example https://www.babylonjs-playground.com/#RNASML
  49945. */
  49946. boundingBoxSize: Vector3;
  49947. /**
  49948. * Instantiates an HDRTexture from the following parameters.
  49949. *
  49950. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49951. * @param scene The scene the texture will be used in
  49952. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49953. * @param noMipmap Forces to not generate the mipmap if true
  49954. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49955. * @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)
  49956. * @param reserved Reserved flag for internal use.
  49957. */
  49958. 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>);
  49959. /**
  49960. * Get the current class name of the texture useful for serialization or dynamic coding.
  49961. * @returns "HDRCubeTexture"
  49962. */
  49963. getClassName(): string;
  49964. /**
  49965. * Occurs when the file is raw .hdr file.
  49966. */
  49967. private loadTexture;
  49968. clone(): HDRCubeTexture;
  49969. delayLoad(): void;
  49970. /**
  49971. * Get the texture reflection matrix used to rotate/transform the reflection.
  49972. * @returns the reflection matrix
  49973. */
  49974. getReflectionTextureMatrix(): Matrix;
  49975. /**
  49976. * Set the texture reflection matrix used to rotate/transform the reflection.
  49977. * @param value Define the reflection matrix to set
  49978. */
  49979. setReflectionTextureMatrix(value: Matrix): void;
  49980. /**
  49981. * Parses a JSON representation of an HDR Texture in order to create the texture
  49982. * @param parsedTexture Define the JSON representation
  49983. * @param scene Define the scene the texture should be created in
  49984. * @param rootUrl Define the root url in case we need to load relative dependencies
  49985. * @returns the newly created texture after parsing
  49986. */
  49987. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49988. serialize(): any;
  49989. }
  49990. }
  49991. declare module BABYLON {
  49992. /**
  49993. * Class used to control physics engine
  49994. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49995. */
  49996. export class PhysicsEngine implements IPhysicsEngine {
  49997. private _physicsPlugin;
  49998. /**
  49999. * Global value used to control the smallest number supported by the simulation
  50000. */
  50001. static Epsilon: number;
  50002. private _impostors;
  50003. private _joints;
  50004. /**
  50005. * Gets the gravity vector used by the simulation
  50006. */
  50007. gravity: Vector3;
  50008. /**
  50009. * Factory used to create the default physics plugin.
  50010. * @returns The default physics plugin
  50011. */
  50012. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50013. /**
  50014. * Creates a new Physics Engine
  50015. * @param gravity defines the gravity vector used by the simulation
  50016. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50017. */
  50018. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50019. /**
  50020. * Sets the gravity vector used by the simulation
  50021. * @param gravity defines the gravity vector to use
  50022. */
  50023. setGravity(gravity: Vector3): void;
  50024. /**
  50025. * Set the time step of the physics engine.
  50026. * Default is 1/60.
  50027. * To slow it down, enter 1/600 for example.
  50028. * To speed it up, 1/30
  50029. * @param newTimeStep defines the new timestep to apply to this world.
  50030. */
  50031. setTimeStep(newTimeStep?: number): void;
  50032. /**
  50033. * Get the time step of the physics engine.
  50034. * @returns the current time step
  50035. */
  50036. getTimeStep(): number;
  50037. /**
  50038. * Release all resources
  50039. */
  50040. dispose(): void;
  50041. /**
  50042. * Gets the name of the current physics plugin
  50043. * @returns the name of the plugin
  50044. */
  50045. getPhysicsPluginName(): string;
  50046. /**
  50047. * Adding a new impostor for the impostor tracking.
  50048. * This will be done by the impostor itself.
  50049. * @param impostor the impostor to add
  50050. */
  50051. addImpostor(impostor: PhysicsImpostor): void;
  50052. /**
  50053. * Remove an impostor from the engine.
  50054. * This impostor and its mesh will not longer be updated by the physics engine.
  50055. * @param impostor the impostor to remove
  50056. */
  50057. removeImpostor(impostor: PhysicsImpostor): void;
  50058. /**
  50059. * Add a joint to the physics engine
  50060. * @param mainImpostor defines the main impostor to which the joint is added.
  50061. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50062. * @param joint defines the joint that will connect both impostors.
  50063. */
  50064. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50065. /**
  50066. * Removes a joint from the simulation
  50067. * @param mainImpostor defines the impostor used with the joint
  50068. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50069. * @param joint defines the joint to remove
  50070. */
  50071. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50072. /**
  50073. * Called by the scene. No need to call it.
  50074. * @param delta defines the timespam between frames
  50075. */ private _step(delta: number): void;
  50076. /**
  50077. * Gets the current plugin used to run the simulation
  50078. * @returns current plugin
  50079. */
  50080. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50081. /**
  50082. * Gets the list of physic impostors
  50083. * @returns an array of PhysicsImpostor
  50084. */
  50085. getImpostors(): Array<PhysicsImpostor>;
  50086. /**
  50087. * Gets the impostor for a physics enabled object
  50088. * @param object defines the object impersonated by the impostor
  50089. * @returns the PhysicsImpostor or null if not found
  50090. */
  50091. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50092. /**
  50093. * Gets the impostor for a physics body object
  50094. * @param body defines physics body used by the impostor
  50095. * @returns the PhysicsImpostor or null if not found
  50096. */
  50097. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50098. /**
  50099. * Does a raycast in the physics world
  50100. * @param from when should the ray start?
  50101. * @param to when should the ray end?
  50102. * @returns PhysicsRaycastResult
  50103. */
  50104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50105. }
  50106. }
  50107. declare module BABYLON {
  50108. /** @hidden */
  50109. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50110. private _useDeltaForWorldStep;
  50111. world: any;
  50112. name: string;
  50113. private _physicsMaterials;
  50114. private _fixedTimeStep;
  50115. private _cannonRaycastResult;
  50116. private _raycastResult;
  50117. private _physicsBodysToRemoveAfterStep;
  50118. BJSCANNON: any;
  50119. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50120. setGravity(gravity: Vector3): void;
  50121. setTimeStep(timeStep: number): void;
  50122. getTimeStep(): number;
  50123. executeStep(delta: number): void;
  50124. private _removeMarkedPhysicsBodiesFromWorld;
  50125. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50127. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50128. private _processChildMeshes;
  50129. removePhysicsBody(impostor: PhysicsImpostor): void;
  50130. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50131. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50132. private _addMaterial;
  50133. private _checkWithEpsilon;
  50134. private _createShape;
  50135. private _createHeightmap;
  50136. private _minus90X;
  50137. private _plus90X;
  50138. private _tmpPosition;
  50139. private _tmpDeltaPosition;
  50140. private _tmpUnityRotation;
  50141. private _updatePhysicsBodyTransformation;
  50142. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50143. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50144. isSupported(): boolean;
  50145. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50147. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50148. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50150. getBodyMass(impostor: PhysicsImpostor): number;
  50151. getBodyFriction(impostor: PhysicsImpostor): number;
  50152. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50153. getBodyRestitution(impostor: PhysicsImpostor): number;
  50154. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50155. sleepBody(impostor: PhysicsImpostor): void;
  50156. wakeUpBody(impostor: PhysicsImpostor): void;
  50157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50158. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50159. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50160. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50161. getRadius(impostor: PhysicsImpostor): number;
  50162. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50163. dispose(): void;
  50164. private _extendNamespace;
  50165. /**
  50166. * Does a raycast in the physics world
  50167. * @param from when should the ray start?
  50168. * @param to when should the ray end?
  50169. * @returns PhysicsRaycastResult
  50170. */
  50171. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50172. }
  50173. }
  50174. declare module BABYLON {
  50175. /** @hidden */
  50176. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50177. world: any;
  50178. name: string;
  50179. BJSOIMO: any;
  50180. private _raycastResult;
  50181. constructor(iterations?: number, oimoInjection?: any);
  50182. setGravity(gravity: Vector3): void;
  50183. setTimeStep(timeStep: number): void;
  50184. getTimeStep(): number;
  50185. private _tmpImpostorsArray;
  50186. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50187. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50188. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50189. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50190. private _tmpPositionVector;
  50191. removePhysicsBody(impostor: PhysicsImpostor): void;
  50192. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50193. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50194. isSupported(): boolean;
  50195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50196. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50197. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50198. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50199. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50200. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50201. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50202. getBodyMass(impostor: PhysicsImpostor): number;
  50203. getBodyFriction(impostor: PhysicsImpostor): number;
  50204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50205. getBodyRestitution(impostor: PhysicsImpostor): number;
  50206. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50207. sleepBody(impostor: PhysicsImpostor): void;
  50208. wakeUpBody(impostor: PhysicsImpostor): void;
  50209. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50210. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50211. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50212. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50213. getRadius(impostor: PhysicsImpostor): number;
  50214. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50215. dispose(): void;
  50216. /**
  50217. * Does a raycast in the physics world
  50218. * @param from when should the ray start?
  50219. * @param to when should the ray end?
  50220. * @returns PhysicsRaycastResult
  50221. */
  50222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50223. }
  50224. }
  50225. declare module BABYLON {
  50226. /**
  50227. * Class containing static functions to help procedurally build meshes
  50228. */
  50229. export class RibbonBuilder {
  50230. /**
  50231. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50232. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50233. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50234. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50235. * * 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
  50236. * * 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
  50237. * * 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
  50238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50239. * * 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
  50240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50241. * * 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
  50242. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50243. * * 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
  50244. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50246. * @param name defines the name of the mesh
  50247. * @param options defines the options used to create the mesh
  50248. * @param scene defines the hosting scene
  50249. * @returns the ribbon mesh
  50250. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50252. */
  50253. static CreateRibbon(name: string, options: {
  50254. pathArray: Vector3[][];
  50255. closeArray?: boolean;
  50256. closePath?: boolean;
  50257. offset?: number;
  50258. updatable?: boolean;
  50259. sideOrientation?: number;
  50260. frontUVs?: Vector4;
  50261. backUVs?: Vector4;
  50262. instance?: Mesh;
  50263. invertUV?: boolean;
  50264. uvs?: Vector2[];
  50265. colors?: Color4[];
  50266. }, scene?: Nullable<Scene>): Mesh;
  50267. }
  50268. }
  50269. declare module BABYLON {
  50270. /**
  50271. * Class containing static functions to help procedurally build meshes
  50272. */
  50273. export class ShapeBuilder {
  50274. /**
  50275. * 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.
  50276. * * 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.
  50277. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50278. * * 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.
  50279. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50280. * * 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
  50281. * * 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
  50282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50284. * * 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
  50285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50287. * @param name defines the name of the mesh
  50288. * @param options defines the options used to create the mesh
  50289. * @param scene defines the hosting scene
  50290. * @returns the extruded shape mesh
  50291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50293. */
  50294. static ExtrudeShape(name: string, options: {
  50295. shape: Vector3[];
  50296. path: Vector3[];
  50297. scale?: number;
  50298. rotation?: number;
  50299. cap?: number;
  50300. updatable?: boolean;
  50301. sideOrientation?: number;
  50302. frontUVs?: Vector4;
  50303. backUVs?: Vector4;
  50304. instance?: Mesh;
  50305. invertUV?: boolean;
  50306. }, scene?: Nullable<Scene>): Mesh;
  50307. /**
  50308. * Creates an custom extruded shape mesh.
  50309. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50310. * * 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.
  50311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50312. * * 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
  50313. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50314. * * 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
  50315. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50316. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50317. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50318. * * 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
  50319. * * 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
  50320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50322. * * 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
  50323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50325. * @param name defines the name of the mesh
  50326. * @param options defines the options used to create the mesh
  50327. * @param scene defines the hosting scene
  50328. * @returns the custom extruded shape mesh
  50329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50332. */
  50333. static ExtrudeShapeCustom(name: string, options: {
  50334. shape: Vector3[];
  50335. path: Vector3[];
  50336. scaleFunction?: any;
  50337. rotationFunction?: any;
  50338. ribbonCloseArray?: boolean;
  50339. ribbonClosePath?: boolean;
  50340. cap?: number;
  50341. updatable?: boolean;
  50342. sideOrientation?: number;
  50343. frontUVs?: Vector4;
  50344. backUVs?: Vector4;
  50345. instance?: Mesh;
  50346. invertUV?: boolean;
  50347. }, scene?: Nullable<Scene>): Mesh;
  50348. private static _ExtrudeShapeGeneric;
  50349. }
  50350. }
  50351. declare module BABYLON {
  50352. /**
  50353. * AmmoJS Physics plugin
  50354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50355. * @see https://github.com/kripken/ammo.js/
  50356. */
  50357. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50358. private _useDeltaForWorldStep;
  50359. /**
  50360. * Reference to the Ammo library
  50361. */
  50362. bjsAMMO: any;
  50363. /**
  50364. * Created ammoJS world which physics bodies are added to
  50365. */
  50366. world: any;
  50367. /**
  50368. * Name of the plugin
  50369. */
  50370. name: string;
  50371. private _timeStep;
  50372. private _fixedTimeStep;
  50373. private _maxSteps;
  50374. private _tmpQuaternion;
  50375. private _tmpAmmoTransform;
  50376. private _tmpAmmoQuaternion;
  50377. private _tmpAmmoConcreteContactResultCallback;
  50378. private _collisionConfiguration;
  50379. private _dispatcher;
  50380. private _overlappingPairCache;
  50381. private _solver;
  50382. private _softBodySolver;
  50383. private _tmpAmmoVectorA;
  50384. private _tmpAmmoVectorB;
  50385. private _tmpAmmoVectorC;
  50386. private _tmpAmmoVectorD;
  50387. private _tmpContactCallbackResult;
  50388. private _tmpAmmoVectorRCA;
  50389. private _tmpAmmoVectorRCB;
  50390. private _raycastResult;
  50391. private static readonly DISABLE_COLLISION_FLAG;
  50392. private static readonly KINEMATIC_FLAG;
  50393. private static readonly DISABLE_DEACTIVATION_FLAG;
  50394. /**
  50395. * Initializes the ammoJS plugin
  50396. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50397. * @param ammoInjection can be used to inject your own ammo reference
  50398. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50399. */
  50400. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50401. /**
  50402. * Sets the gravity of the physics world (m/(s^2))
  50403. * @param gravity Gravity to set
  50404. */
  50405. setGravity(gravity: Vector3): void;
  50406. /**
  50407. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50408. * @param timeStep timestep to use in seconds
  50409. */
  50410. setTimeStep(timeStep: number): void;
  50411. /**
  50412. * 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)
  50413. * @param fixedTimeStep fixedTimeStep to use in seconds
  50414. */
  50415. setFixedTimeStep(fixedTimeStep: number): void;
  50416. /**
  50417. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50418. * @param maxSteps the maximum number of steps by the physics engine per frame
  50419. */
  50420. setMaxSteps(maxSteps: number): void;
  50421. /**
  50422. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50423. * @returns the current timestep in seconds
  50424. */
  50425. getTimeStep(): number;
  50426. private _isImpostorInContact;
  50427. private _isImpostorPairInContact;
  50428. private _stepSimulation;
  50429. /**
  50430. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50431. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50432. * After the step the babylon meshes are set to the position of the physics imposters
  50433. * @param delta amount of time to step forward
  50434. * @param impostors array of imposters to update before/after the step
  50435. */
  50436. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50437. /**
  50438. * Update babylon mesh to match physics world object
  50439. * @param impostor imposter to match
  50440. */
  50441. private _afterSoftStep;
  50442. /**
  50443. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50444. * @param impostor imposter to match
  50445. */
  50446. private _ropeStep;
  50447. /**
  50448. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50449. * @param impostor imposter to match
  50450. */
  50451. private _softbodyOrClothStep;
  50452. private _tmpVector;
  50453. private _tmpMatrix;
  50454. /**
  50455. * Applies an impulse on the imposter
  50456. * @param impostor imposter to apply impulse to
  50457. * @param force amount of force to be applied to the imposter
  50458. * @param contactPoint the location to apply the impulse on the imposter
  50459. */
  50460. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50461. /**
  50462. * Applies a force on the imposter
  50463. * @param impostor imposter to apply force
  50464. * @param force amount of force to be applied to the imposter
  50465. * @param contactPoint the location to apply the force on the imposter
  50466. */
  50467. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50468. /**
  50469. * Creates a physics body using the plugin
  50470. * @param impostor the imposter to create the physics body on
  50471. */
  50472. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50473. /**
  50474. * Removes the physics body from the imposter and disposes of the body's memory
  50475. * @param impostor imposter to remove the physics body from
  50476. */
  50477. removePhysicsBody(impostor: PhysicsImpostor): void;
  50478. /**
  50479. * Generates a joint
  50480. * @param impostorJoint the imposter joint to create the joint with
  50481. */
  50482. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50483. /**
  50484. * Removes a joint
  50485. * @param impostorJoint the imposter joint to remove the joint from
  50486. */
  50487. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50488. private _addMeshVerts;
  50489. /**
  50490. * Initialise the soft body vertices to match its object's (mesh) vertices
  50491. * Softbody vertices (nodes) are in world space and to match this
  50492. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50493. * @param impostor to create the softbody for
  50494. */
  50495. private _softVertexData;
  50496. /**
  50497. * Create an impostor's soft body
  50498. * @param impostor to create the softbody for
  50499. */
  50500. private _createSoftbody;
  50501. /**
  50502. * Create cloth for an impostor
  50503. * @param impostor to create the softbody for
  50504. */
  50505. private _createCloth;
  50506. /**
  50507. * Create rope for an impostor
  50508. * @param impostor to create the softbody for
  50509. */
  50510. private _createRope;
  50511. private _addHullVerts;
  50512. private _createShape;
  50513. /**
  50514. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50515. * @param impostor imposter containing the physics body and babylon object
  50516. */
  50517. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50518. /**
  50519. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50520. * @param impostor imposter containing the physics body and babylon object
  50521. * @param newPosition new position
  50522. * @param newRotation new rotation
  50523. */
  50524. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50525. /**
  50526. * If this plugin is supported
  50527. * @returns true if its supported
  50528. */
  50529. isSupported(): boolean;
  50530. /**
  50531. * Sets the linear velocity of the physics body
  50532. * @param impostor imposter to set the velocity on
  50533. * @param velocity velocity to set
  50534. */
  50535. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50536. /**
  50537. * Sets the angular velocity of the physics body
  50538. * @param impostor imposter to set the velocity on
  50539. * @param velocity velocity to set
  50540. */
  50541. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50542. /**
  50543. * gets the linear velocity
  50544. * @param impostor imposter to get linear velocity from
  50545. * @returns linear velocity
  50546. */
  50547. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50548. /**
  50549. * gets the angular velocity
  50550. * @param impostor imposter to get angular velocity from
  50551. * @returns angular velocity
  50552. */
  50553. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50554. /**
  50555. * Sets the mass of physics body
  50556. * @param impostor imposter to set the mass on
  50557. * @param mass mass to set
  50558. */
  50559. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50560. /**
  50561. * Gets the mass of the physics body
  50562. * @param impostor imposter to get the mass from
  50563. * @returns mass
  50564. */
  50565. getBodyMass(impostor: PhysicsImpostor): number;
  50566. /**
  50567. * Gets friction of the impostor
  50568. * @param impostor impostor to get friction from
  50569. * @returns friction value
  50570. */
  50571. getBodyFriction(impostor: PhysicsImpostor): number;
  50572. /**
  50573. * Sets friction of the impostor
  50574. * @param impostor impostor to set friction on
  50575. * @param friction friction value
  50576. */
  50577. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50578. /**
  50579. * Gets restitution of the impostor
  50580. * @param impostor impostor to get restitution from
  50581. * @returns restitution value
  50582. */
  50583. getBodyRestitution(impostor: PhysicsImpostor): number;
  50584. /**
  50585. * Sets resitution of the impostor
  50586. * @param impostor impostor to set resitution on
  50587. * @param restitution resitution value
  50588. */
  50589. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50590. /**
  50591. * Gets pressure inside the impostor
  50592. * @param impostor impostor to get pressure from
  50593. * @returns pressure value
  50594. */
  50595. getBodyPressure(impostor: PhysicsImpostor): number;
  50596. /**
  50597. * Sets pressure inside a soft body impostor
  50598. * Cloth and rope must remain 0 pressure
  50599. * @param impostor impostor to set pressure on
  50600. * @param pressure pressure value
  50601. */
  50602. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50603. /**
  50604. * Gets stiffness of the impostor
  50605. * @param impostor impostor to get stiffness from
  50606. * @returns pressure value
  50607. */
  50608. getBodyStiffness(impostor: PhysicsImpostor): number;
  50609. /**
  50610. * Sets stiffness of the impostor
  50611. * @param impostor impostor to set stiffness on
  50612. * @param stiffness stiffness value from 0 to 1
  50613. */
  50614. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50615. /**
  50616. * Gets velocityIterations of the impostor
  50617. * @param impostor impostor to get velocity iterations from
  50618. * @returns velocityIterations value
  50619. */
  50620. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50621. /**
  50622. * Sets velocityIterations of the impostor
  50623. * @param impostor impostor to set velocity iterations on
  50624. * @param velocityIterations velocityIterations value
  50625. */
  50626. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50627. /**
  50628. * Gets positionIterations of the impostor
  50629. * @param impostor impostor to get position iterations from
  50630. * @returns positionIterations value
  50631. */
  50632. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50633. /**
  50634. * Sets positionIterations of the impostor
  50635. * @param impostor impostor to set position on
  50636. * @param positionIterations positionIterations value
  50637. */
  50638. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50639. /**
  50640. * Append an anchor to a cloth object
  50641. * @param impostor is the cloth impostor to add anchor to
  50642. * @param otherImpostor is the rigid impostor to anchor to
  50643. * @param width ratio across width from 0 to 1
  50644. * @param height ratio up height from 0 to 1
  50645. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50646. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50647. */
  50648. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50649. /**
  50650. * Append an hook to a rope object
  50651. * @param impostor is the rope impostor to add hook to
  50652. * @param otherImpostor is the rigid impostor to hook to
  50653. * @param length ratio along the rope from 0 to 1
  50654. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50655. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50656. */
  50657. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50658. /**
  50659. * Sleeps the physics body and stops it from being active
  50660. * @param impostor impostor to sleep
  50661. */
  50662. sleepBody(impostor: PhysicsImpostor): void;
  50663. /**
  50664. * Activates the physics body
  50665. * @param impostor impostor to activate
  50666. */
  50667. wakeUpBody(impostor: PhysicsImpostor): void;
  50668. /**
  50669. * Updates the distance parameters of the joint
  50670. * @param joint joint to update
  50671. * @param maxDistance maximum distance of the joint
  50672. * @param minDistance minimum distance of the joint
  50673. */
  50674. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50675. /**
  50676. * Sets a motor on the joint
  50677. * @param joint joint to set motor on
  50678. * @param speed speed of the motor
  50679. * @param maxForce maximum force of the motor
  50680. * @param motorIndex index of the motor
  50681. */
  50682. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50683. /**
  50684. * Sets the motors limit
  50685. * @param joint joint to set limit on
  50686. * @param upperLimit upper limit
  50687. * @param lowerLimit lower limit
  50688. */
  50689. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50690. /**
  50691. * Syncs the position and rotation of a mesh with the impostor
  50692. * @param mesh mesh to sync
  50693. * @param impostor impostor to update the mesh with
  50694. */
  50695. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50696. /**
  50697. * Gets the radius of the impostor
  50698. * @param impostor impostor to get radius from
  50699. * @returns the radius
  50700. */
  50701. getRadius(impostor: PhysicsImpostor): number;
  50702. /**
  50703. * Gets the box size of the impostor
  50704. * @param impostor impostor to get box size from
  50705. * @param result the resulting box size
  50706. */
  50707. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50708. /**
  50709. * Disposes of the impostor
  50710. */
  50711. dispose(): void;
  50712. /**
  50713. * Does a raycast in the physics world
  50714. * @param from when should the ray start?
  50715. * @param to when should the ray end?
  50716. * @returns PhysicsRaycastResult
  50717. */
  50718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50719. }
  50720. }
  50721. declare module BABYLON {
  50722. interface AbstractScene {
  50723. /**
  50724. * The list of reflection probes added to the scene
  50725. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50726. */
  50727. reflectionProbes: Array<ReflectionProbe>;
  50728. /**
  50729. * Removes the given reflection probe from this scene.
  50730. * @param toRemove The reflection probe to remove
  50731. * @returns The index of the removed reflection probe
  50732. */
  50733. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50734. /**
  50735. * Adds the given reflection probe to this scene.
  50736. * @param newReflectionProbe The reflection probe to add
  50737. */
  50738. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50739. }
  50740. /**
  50741. * Class used to generate realtime reflection / refraction cube textures
  50742. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50743. */
  50744. export class ReflectionProbe {
  50745. /** defines the name of the probe */
  50746. name: string;
  50747. private _scene;
  50748. private _renderTargetTexture;
  50749. private _projectionMatrix;
  50750. private _viewMatrix;
  50751. private _target;
  50752. private _add;
  50753. private _attachedMesh;
  50754. private _invertYAxis;
  50755. /** Gets or sets probe position (center of the cube map) */
  50756. position: Vector3;
  50757. /**
  50758. * Creates a new reflection probe
  50759. * @param name defines the name of the probe
  50760. * @param size defines the texture resolution (for each face)
  50761. * @param scene defines the hosting scene
  50762. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50763. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50764. */
  50765. constructor(
  50766. /** defines the name of the probe */
  50767. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50768. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50769. samples: number;
  50770. /** Gets or sets the refresh rate to use (on every frame by default) */
  50771. refreshRate: number;
  50772. /**
  50773. * Gets the hosting scene
  50774. * @returns a Scene
  50775. */
  50776. getScene(): Scene;
  50777. /** Gets the internal CubeTexture used to render to */
  50778. readonly cubeTexture: RenderTargetTexture;
  50779. /** Gets the list of meshes to render */
  50780. readonly renderList: Nullable<AbstractMesh[]>;
  50781. /**
  50782. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50783. * @param mesh defines the mesh to attach to
  50784. */
  50785. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50786. /**
  50787. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50788. * @param renderingGroupId The rendering group id corresponding to its index
  50789. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50790. */
  50791. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50792. /**
  50793. * Clean all associated resources
  50794. */
  50795. dispose(): void;
  50796. /**
  50797. * Converts the reflection probe information to a readable string for debug purpose.
  50798. * @param fullDetails Supports for multiple levels of logging within scene loading
  50799. * @returns the human readable reflection probe info
  50800. */
  50801. toString(fullDetails?: boolean): string;
  50802. /**
  50803. * Get the class name of the relfection probe.
  50804. * @returns "ReflectionProbe"
  50805. */
  50806. getClassName(): string;
  50807. /**
  50808. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50809. * @returns The JSON representation of the texture
  50810. */
  50811. serialize(): any;
  50812. /**
  50813. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50814. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50815. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50816. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50817. * @returns The parsed reflection probe if successful
  50818. */
  50819. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50820. }
  50821. }
  50822. declare module BABYLON {
  50823. /** @hidden */
  50824. export var _BabylonLoaderRegistered: boolean;
  50825. }
  50826. declare module BABYLON {
  50827. /**
  50828. * The Physically based simple base material of BJS.
  50829. *
  50830. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50831. * It is used as the base class for both the specGloss and metalRough conventions.
  50832. */
  50833. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50834. /**
  50835. * Number of Simultaneous lights allowed on the material.
  50836. */
  50837. maxSimultaneousLights: number;
  50838. /**
  50839. * If sets to true, disables all the lights affecting the material.
  50840. */
  50841. disableLighting: boolean;
  50842. /**
  50843. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50844. */
  50845. environmentTexture: BaseTexture;
  50846. /**
  50847. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50848. */
  50849. invertNormalMapX: boolean;
  50850. /**
  50851. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50852. */
  50853. invertNormalMapY: boolean;
  50854. /**
  50855. * Normal map used in the model.
  50856. */
  50857. normalTexture: BaseTexture;
  50858. /**
  50859. * Emissivie color used to self-illuminate the model.
  50860. */
  50861. emissiveColor: Color3;
  50862. /**
  50863. * Emissivie texture used to self-illuminate the model.
  50864. */
  50865. emissiveTexture: BaseTexture;
  50866. /**
  50867. * Occlusion Channel Strenght.
  50868. */
  50869. occlusionStrength: number;
  50870. /**
  50871. * Occlusion Texture of the material (adding extra occlusion effects).
  50872. */
  50873. occlusionTexture: BaseTexture;
  50874. /**
  50875. * Defines the alpha limits in alpha test mode.
  50876. */
  50877. alphaCutOff: number;
  50878. /**
  50879. * Gets the current double sided mode.
  50880. */
  50881. /**
  50882. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50883. */
  50884. doubleSided: boolean;
  50885. /**
  50886. * Stores the pre-calculated light information of a mesh in a texture.
  50887. */
  50888. lightmapTexture: BaseTexture;
  50889. /**
  50890. * If true, the light map contains occlusion information instead of lighting info.
  50891. */
  50892. useLightmapAsShadowmap: boolean;
  50893. /**
  50894. * Instantiates a new PBRMaterial instance.
  50895. *
  50896. * @param name The material name
  50897. * @param scene The scene the material will be use in.
  50898. */
  50899. constructor(name: string, scene: Scene);
  50900. getClassName(): string;
  50901. }
  50902. }
  50903. declare module BABYLON {
  50904. /**
  50905. * The PBR material of BJS following the metal roughness convention.
  50906. *
  50907. * This fits to the PBR convention in the GLTF definition:
  50908. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50909. */
  50910. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50911. /**
  50912. * The base color has two different interpretations depending on the value of metalness.
  50913. * When the material is a metal, the base color is the specific measured reflectance value
  50914. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50915. * of the material.
  50916. */
  50917. baseColor: Color3;
  50918. /**
  50919. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50920. * well as opacity information in the alpha channel.
  50921. */
  50922. baseTexture: BaseTexture;
  50923. /**
  50924. * Specifies the metallic scalar value of the material.
  50925. * Can also be used to scale the metalness values of the metallic texture.
  50926. */
  50927. metallic: number;
  50928. /**
  50929. * Specifies the roughness scalar value of the material.
  50930. * Can also be used to scale the roughness values of the metallic texture.
  50931. */
  50932. roughness: number;
  50933. /**
  50934. * Texture containing both the metallic value in the B channel and the
  50935. * roughness value in the G channel to keep better precision.
  50936. */
  50937. metallicRoughnessTexture: BaseTexture;
  50938. /**
  50939. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50940. *
  50941. * @param name The material name
  50942. * @param scene The scene the material will be use in.
  50943. */
  50944. constructor(name: string, scene: Scene);
  50945. /**
  50946. * Return the currrent class name of the material.
  50947. */
  50948. getClassName(): string;
  50949. /**
  50950. * Makes a duplicate of the current material.
  50951. * @param name - name to use for the new material.
  50952. */
  50953. clone(name: string): PBRMetallicRoughnessMaterial;
  50954. /**
  50955. * Serialize the material to a parsable JSON object.
  50956. */
  50957. serialize(): any;
  50958. /**
  50959. * Parses a JSON object correponding to the serialize function.
  50960. */
  50961. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * The PBR material of BJS following the specular glossiness convention.
  50967. *
  50968. * This fits to the PBR convention in the GLTF definition:
  50969. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50970. */
  50971. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50972. /**
  50973. * Specifies the diffuse color of the material.
  50974. */
  50975. diffuseColor: Color3;
  50976. /**
  50977. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50978. * channel.
  50979. */
  50980. diffuseTexture: BaseTexture;
  50981. /**
  50982. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50983. */
  50984. specularColor: Color3;
  50985. /**
  50986. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50987. */
  50988. glossiness: number;
  50989. /**
  50990. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50991. */
  50992. specularGlossinessTexture: BaseTexture;
  50993. /**
  50994. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50995. *
  50996. * @param name The material name
  50997. * @param scene The scene the material will be use in.
  50998. */
  50999. constructor(name: string, scene: Scene);
  51000. /**
  51001. * Return the currrent class name of the material.
  51002. */
  51003. getClassName(): string;
  51004. /**
  51005. * Makes a duplicate of the current material.
  51006. * @param name - name to use for the new material.
  51007. */
  51008. clone(name: string): PBRSpecularGlossinessMaterial;
  51009. /**
  51010. * Serialize the material to a parsable JSON object.
  51011. */
  51012. serialize(): any;
  51013. /**
  51014. * Parses a JSON object correponding to the serialize function.
  51015. */
  51016. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51017. }
  51018. }
  51019. declare module BABYLON {
  51020. /**
  51021. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51022. * It can help converting any input color in a desired output one. This can then be used to create effects
  51023. * from sepia, black and white to sixties or futuristic rendering...
  51024. *
  51025. * The only supported format is currently 3dl.
  51026. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51027. */
  51028. export class ColorGradingTexture extends BaseTexture {
  51029. /**
  51030. * The current texture matrix. (will always be identity in color grading texture)
  51031. */
  51032. private _textureMatrix;
  51033. /**
  51034. * The texture URL.
  51035. */
  51036. url: string;
  51037. /**
  51038. * Empty line regex stored for GC.
  51039. */
  51040. private static _noneEmptyLineRegex;
  51041. private _engine;
  51042. /**
  51043. * Instantiates a ColorGradingTexture from the following parameters.
  51044. *
  51045. * @param url The location of the color gradind data (currently only supporting 3dl)
  51046. * @param scene The scene the texture will be used in
  51047. */
  51048. constructor(url: string, scene: Scene);
  51049. /**
  51050. * Returns the texture matrix used in most of the material.
  51051. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51052. */
  51053. getTextureMatrix(): Matrix;
  51054. /**
  51055. * Occurs when the file being loaded is a .3dl LUT file.
  51056. */
  51057. private load3dlTexture;
  51058. /**
  51059. * Starts the loading process of the texture.
  51060. */
  51061. private loadTexture;
  51062. /**
  51063. * Clones the color gradind texture.
  51064. */
  51065. clone(): ColorGradingTexture;
  51066. /**
  51067. * Called during delayed load for textures.
  51068. */
  51069. delayLoad(): void;
  51070. /**
  51071. * Parses a color grading texture serialized by Babylon.
  51072. * @param parsedTexture The texture information being parsedTexture
  51073. * @param scene The scene to load the texture in
  51074. * @param rootUrl The root url of the data assets to load
  51075. * @return A color gradind texture
  51076. */
  51077. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51078. /**
  51079. * Serializes the LUT texture to json format.
  51080. */
  51081. serialize(): any;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. /**
  51086. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51087. */
  51088. export class EquiRectangularCubeTexture extends BaseTexture {
  51089. /** The six faces of the cube. */
  51090. private static _FacesMapping;
  51091. private _noMipmap;
  51092. private _onLoad;
  51093. private _onError;
  51094. /** The size of the cubemap. */
  51095. private _size;
  51096. /** The buffer of the image. */
  51097. private _buffer;
  51098. /** The width of the input image. */
  51099. private _width;
  51100. /** The height of the input image. */
  51101. private _height;
  51102. /** The URL to the image. */
  51103. url: string;
  51104. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51105. coordinatesMode: number;
  51106. /**
  51107. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51108. * @param url The location of the image
  51109. * @param scene The scene the texture will be used in
  51110. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51111. * @param noMipmap Forces to not generate the mipmap if true
  51112. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51113. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51114. * @param onLoad — defines a callback called when texture is loaded
  51115. * @param onError — defines a callback called if there is an error
  51116. */
  51117. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51118. /**
  51119. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51120. */
  51121. private loadImage;
  51122. /**
  51123. * Convert the image buffer into a cubemap and create a CubeTexture.
  51124. */
  51125. private loadTexture;
  51126. /**
  51127. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51128. * @param buffer The ArrayBuffer that should be converted.
  51129. * @returns The buffer as Float32Array.
  51130. */
  51131. private getFloat32ArrayFromArrayBuffer;
  51132. /**
  51133. * Get the current class name of the texture useful for serialization or dynamic coding.
  51134. * @returns "EquiRectangularCubeTexture"
  51135. */
  51136. getClassName(): string;
  51137. /**
  51138. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51139. * @returns A clone of the current EquiRectangularCubeTexture.
  51140. */
  51141. clone(): EquiRectangularCubeTexture;
  51142. }
  51143. }
  51144. declare module BABYLON {
  51145. /**
  51146. * Based on jsTGALoader - Javascript loader for TGA file
  51147. * By Vincent Thibault
  51148. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51149. */
  51150. export class TGATools {
  51151. private static _TYPE_INDEXED;
  51152. private static _TYPE_RGB;
  51153. private static _TYPE_GREY;
  51154. private static _TYPE_RLE_INDEXED;
  51155. private static _TYPE_RLE_RGB;
  51156. private static _TYPE_RLE_GREY;
  51157. private static _ORIGIN_MASK;
  51158. private static _ORIGIN_SHIFT;
  51159. private static _ORIGIN_BL;
  51160. private static _ORIGIN_BR;
  51161. private static _ORIGIN_UL;
  51162. private static _ORIGIN_UR;
  51163. /**
  51164. * Gets the header of a TGA file
  51165. * @param data defines the TGA data
  51166. * @returns the header
  51167. */
  51168. static GetTGAHeader(data: Uint8Array): any;
  51169. /**
  51170. * Uploads TGA content to a Babylon Texture
  51171. * @hidden
  51172. */
  51173. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51174. /** @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;
  51175. /** @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;
  51176. /** @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;
  51177. /** @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;
  51178. /** @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;
  51179. /** @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;
  51180. }
  51181. }
  51182. declare module BABYLON {
  51183. /**
  51184. * Implementation of the TGA Texture Loader.
  51185. * @hidden
  51186. */
  51187. export class _TGATextureLoader implements IInternalTextureLoader {
  51188. /**
  51189. * Defines wether the loader supports cascade loading the different faces.
  51190. */
  51191. readonly supportCascades: boolean;
  51192. /**
  51193. * This returns if the loader support the current file information.
  51194. * @param extension defines the file extension of the file being loaded
  51195. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51196. * @param fallback defines the fallback internal texture if any
  51197. * @param isBase64 defines whether the texture is encoded as a base64
  51198. * @param isBuffer defines whether the texture data are stored as a buffer
  51199. * @returns true if the loader can load the specified file
  51200. */
  51201. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51202. /**
  51203. * Transform the url before loading if required.
  51204. * @param rootUrl the url of the texture
  51205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51206. * @returns the transformed texture
  51207. */
  51208. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51209. /**
  51210. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51211. * @param rootUrl the url of the texture
  51212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51213. * @returns the fallback texture
  51214. */
  51215. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51216. /**
  51217. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51218. * @param data contains the texture data
  51219. * @param texture defines the BabylonJS internal texture
  51220. * @param createPolynomials will be true if polynomials have been requested
  51221. * @param onLoad defines the callback to trigger once the texture is ready
  51222. * @param onError defines the callback to trigger in case of error
  51223. */
  51224. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51225. /**
  51226. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51227. * @param data contains the texture data
  51228. * @param texture defines the BabylonJS internal texture
  51229. * @param callback defines the method to call once ready to upload
  51230. */
  51231. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51232. }
  51233. }
  51234. declare module BABYLON {
  51235. /**
  51236. * Info about the .basis files
  51237. */
  51238. class BasisFileInfo {
  51239. /**
  51240. * If the file has alpha
  51241. */
  51242. hasAlpha: boolean;
  51243. /**
  51244. * Info about each image of the basis file
  51245. */
  51246. images: Array<{
  51247. levels: Array<{
  51248. width: number;
  51249. height: number;
  51250. transcodedPixels: ArrayBufferView;
  51251. }>;
  51252. }>;
  51253. }
  51254. /**
  51255. * Result of transcoding a basis file
  51256. */
  51257. class TranscodeResult {
  51258. /**
  51259. * Info about the .basis file
  51260. */
  51261. fileInfo: BasisFileInfo;
  51262. /**
  51263. * Format to use when loading the file
  51264. */
  51265. format: number;
  51266. }
  51267. /**
  51268. * Configuration options for the Basis transcoder
  51269. */
  51270. export class BasisTranscodeConfiguration {
  51271. /**
  51272. * Supported compression formats used to determine the supported output format of the transcoder
  51273. */
  51274. supportedCompressionFormats?: {
  51275. /**
  51276. * etc1 compression format
  51277. */
  51278. etc1?: boolean;
  51279. /**
  51280. * s3tc compression format
  51281. */
  51282. s3tc?: boolean;
  51283. /**
  51284. * pvrtc compression format
  51285. */
  51286. pvrtc?: boolean;
  51287. /**
  51288. * etc2 compression format
  51289. */
  51290. etc2?: boolean;
  51291. };
  51292. /**
  51293. * If mipmap levels should be loaded for transcoded images (Default: true)
  51294. */
  51295. loadMipmapLevels?: boolean;
  51296. /**
  51297. * Index of a single image to load (Default: all images)
  51298. */
  51299. loadSingleImage?: number;
  51300. }
  51301. /**
  51302. * Used to load .Basis files
  51303. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51304. */
  51305. export class BasisTools {
  51306. private static _IgnoreSupportedFormats;
  51307. /**
  51308. * URL to use when loading the basis transcoder
  51309. */
  51310. static JSModuleURL: string;
  51311. /**
  51312. * URL to use when loading the wasm module for the transcoder
  51313. */
  51314. static WasmModuleURL: string;
  51315. /**
  51316. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51317. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51318. * @returns internal format corresponding to the Basis format
  51319. */
  51320. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51321. private static _WorkerPromise;
  51322. private static _Worker;
  51323. private static _actionId;
  51324. private static _CreateWorkerAsync;
  51325. /**
  51326. * Transcodes a loaded image file to compressed pixel data
  51327. * @param imageData image data to transcode
  51328. * @param config configuration options for the transcoding
  51329. * @returns a promise resulting in the transcoded image
  51330. */
  51331. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51332. /**
  51333. * Loads a texture from the transcode result
  51334. * @param texture texture load to
  51335. * @param transcodeResult the result of transcoding the basis file to load from
  51336. */
  51337. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51338. }
  51339. }
  51340. declare module BABYLON {
  51341. /**
  51342. * Loader for .basis file format
  51343. */
  51344. export class _BasisTextureLoader implements IInternalTextureLoader {
  51345. /**
  51346. * Defines whether the loader supports cascade loading the different faces.
  51347. */
  51348. readonly supportCascades: boolean;
  51349. /**
  51350. * This returns if the loader support the current file information.
  51351. * @param extension defines the file extension of the file being loaded
  51352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51353. * @param fallback defines the fallback internal texture if any
  51354. * @param isBase64 defines whether the texture is encoded as a base64
  51355. * @param isBuffer defines whether the texture data are stored as a buffer
  51356. * @returns true if the loader can load the specified file
  51357. */
  51358. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51359. /**
  51360. * Transform the url before loading if required.
  51361. * @param rootUrl the url of the texture
  51362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51363. * @returns the transformed texture
  51364. */
  51365. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51366. /**
  51367. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51368. * @param rootUrl the url of the texture
  51369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51370. * @returns the fallback texture
  51371. */
  51372. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51373. /**
  51374. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51375. * @param data contains the texture data
  51376. * @param texture defines the BabylonJS internal texture
  51377. * @param createPolynomials will be true if polynomials have been requested
  51378. * @param onLoad defines the callback to trigger once the texture is ready
  51379. * @param onError defines the callback to trigger in case of error
  51380. */
  51381. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51382. /**
  51383. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51384. * @param data contains the texture data
  51385. * @param texture defines the BabylonJS internal texture
  51386. * @param callback defines the method to call once ready to upload
  51387. */
  51388. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51389. }
  51390. }
  51391. declare module BABYLON {
  51392. /**
  51393. * 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.
  51394. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51395. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51396. */
  51397. export class CustomProceduralTexture extends ProceduralTexture {
  51398. private _animate;
  51399. private _time;
  51400. private _config;
  51401. private _texturePath;
  51402. /**
  51403. * Instantiates a new Custom Procedural Texture.
  51404. * 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.
  51405. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51406. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51407. * @param name Define the name of the texture
  51408. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51409. * @param size Define the size of the texture to create
  51410. * @param scene Define the scene the texture belongs to
  51411. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51412. * @param generateMipMaps Define if the texture should creates mip maps or not
  51413. */
  51414. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51415. private _loadJson;
  51416. /**
  51417. * Is the texture ready to be used ? (rendered at least once)
  51418. * @returns true if ready, otherwise, false.
  51419. */
  51420. isReady(): boolean;
  51421. /**
  51422. * Render the texture to its associated render target.
  51423. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51424. */
  51425. render(useCameraPostProcess?: boolean): void;
  51426. /**
  51427. * Update the list of dependant textures samplers in the shader.
  51428. */
  51429. updateTextures(): void;
  51430. /**
  51431. * Update the uniform values of the procedural texture in the shader.
  51432. */
  51433. updateShaderUniforms(): void;
  51434. /**
  51435. * Define if the texture animates or not.
  51436. */
  51437. animate: boolean;
  51438. }
  51439. }
  51440. declare module BABYLON {
  51441. /** @hidden */
  51442. export var noisePixelShader: {
  51443. name: string;
  51444. shader: string;
  51445. };
  51446. }
  51447. declare module BABYLON {
  51448. /**
  51449. * Class used to generate noise procedural textures
  51450. */
  51451. export class NoiseProceduralTexture extends ProceduralTexture {
  51452. private _time;
  51453. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51454. brightness: number;
  51455. /** Defines the number of octaves to process */
  51456. octaves: number;
  51457. /** Defines the level of persistence (0.8 by default) */
  51458. persistence: number;
  51459. /** Gets or sets animation speed factor (default is 1) */
  51460. animationSpeedFactor: number;
  51461. /**
  51462. * Creates a new NoiseProceduralTexture
  51463. * @param name defines the name fo the texture
  51464. * @param size defines the size of the texture (default is 256)
  51465. * @param scene defines the hosting scene
  51466. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51467. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51468. */
  51469. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51470. private _updateShaderUniforms;
  51471. protected _getDefines(): string;
  51472. /** Generate the current state of the procedural texture */
  51473. render(useCameraPostProcess?: boolean): void;
  51474. /**
  51475. * Serializes this noise procedural texture
  51476. * @returns a serialized noise procedural texture object
  51477. */
  51478. serialize(): any;
  51479. /**
  51480. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51481. * @param parsedTexture defines parsed texture data
  51482. * @param scene defines the current scene
  51483. * @param rootUrl defines the root URL containing noise procedural texture information
  51484. * @returns a parsed NoiseProceduralTexture
  51485. */
  51486. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51487. }
  51488. }
  51489. declare module BABYLON {
  51490. /**
  51491. * Raw cube texture where the raw buffers are passed in
  51492. */
  51493. export class RawCubeTexture extends CubeTexture {
  51494. /**
  51495. * Creates a cube texture where the raw buffers are passed in.
  51496. * @param scene defines the scene the texture is attached to
  51497. * @param data defines the array of data to use to create each face
  51498. * @param size defines the size of the textures
  51499. * @param format defines the format of the data
  51500. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51501. * @param generateMipMaps defines if the engine should generate the mip levels
  51502. * @param invertY defines if data must be stored with Y axis inverted
  51503. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51504. * @param compression defines the compression used (null by default)
  51505. */
  51506. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51507. /**
  51508. * Updates the raw cube texture.
  51509. * @param data defines the data to store
  51510. * @param format defines the data format
  51511. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51512. * @param invertY defines if data must be stored with Y axis inverted
  51513. * @param compression defines the compression used (null by default)
  51514. * @param level defines which level of the texture to update
  51515. */
  51516. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51517. /**
  51518. * Updates a raw cube texture with RGBD encoded data.
  51519. * @param data defines the array of data [mipmap][face] to use to create each face
  51520. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51521. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51522. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51523. * @returns a promsie that resolves when the operation is complete
  51524. */
  51525. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51526. /**
  51527. * Clones the raw cube texture.
  51528. * @return a new cube texture
  51529. */
  51530. clone(): CubeTexture;
  51531. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51532. }
  51533. }
  51534. declare module BABYLON {
  51535. /**
  51536. * Class used to store 3D textures containing user data
  51537. */
  51538. export class RawTexture3D extends Texture {
  51539. /** Gets or sets the texture format to use */
  51540. format: number;
  51541. private _engine;
  51542. /**
  51543. * Create a new RawTexture3D
  51544. * @param data defines the data of the texture
  51545. * @param width defines the width of the texture
  51546. * @param height defines the height of the texture
  51547. * @param depth defines the depth of the texture
  51548. * @param format defines the texture format to use
  51549. * @param scene defines the hosting scene
  51550. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51551. * @param invertY defines if texture must be stored with Y axis inverted
  51552. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51553. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51554. */
  51555. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51556. /** Gets or sets the texture format to use */
  51557. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51558. /**
  51559. * Update the texture with new data
  51560. * @param data defines the data to store in the texture
  51561. */
  51562. update(data: ArrayBufferView): void;
  51563. }
  51564. }
  51565. declare module BABYLON {
  51566. /**
  51567. * Creates a refraction texture used by refraction channel of the standard material.
  51568. * It is like a mirror but to see through a material.
  51569. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51570. */
  51571. export class RefractionTexture extends RenderTargetTexture {
  51572. /**
  51573. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51574. * 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.
  51575. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51576. */
  51577. refractionPlane: Plane;
  51578. /**
  51579. * Define how deep under the surface we should see.
  51580. */
  51581. depth: number;
  51582. /**
  51583. * Creates a refraction texture used by refraction channel of the standard material.
  51584. * It is like a mirror but to see through a material.
  51585. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51586. * @param name Define the texture name
  51587. * @param size Define the size of the underlying texture
  51588. * @param scene Define the scene the refraction belongs to
  51589. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51590. */
  51591. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51592. /**
  51593. * Clone the refraction texture.
  51594. * @returns the cloned texture
  51595. */
  51596. clone(): RefractionTexture;
  51597. /**
  51598. * Serialize the texture to a JSON representation you could use in Parse later on
  51599. * @returns the serialized JSON representation
  51600. */
  51601. serialize(): any;
  51602. }
  51603. }
  51604. declare module BABYLON {
  51605. /**
  51606. * Defines the options related to the creation of an HtmlElementTexture
  51607. */
  51608. export interface IHtmlElementTextureOptions {
  51609. /**
  51610. * Defines wether mip maps should be created or not.
  51611. */
  51612. generateMipMaps?: boolean;
  51613. /**
  51614. * Defines the sampling mode of the texture.
  51615. */
  51616. samplingMode?: number;
  51617. /**
  51618. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51619. */
  51620. engine: Nullable<Engine>;
  51621. /**
  51622. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51623. */
  51624. scene: Nullable<Scene>;
  51625. }
  51626. /**
  51627. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51628. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51629. * is automatically managed.
  51630. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51631. * in your application.
  51632. *
  51633. * As the update is not automatic, you need to call them manually.
  51634. */
  51635. export class HtmlElementTexture extends BaseTexture {
  51636. /**
  51637. * The texture URL.
  51638. */
  51639. element: HTMLVideoElement | HTMLCanvasElement;
  51640. private static readonly DefaultOptions;
  51641. private _textureMatrix;
  51642. private _engine;
  51643. private _isVideo;
  51644. private _generateMipMaps;
  51645. private _samplingMode;
  51646. /**
  51647. * Instantiates a HtmlElementTexture from the following parameters.
  51648. *
  51649. * @param name Defines the name of the texture
  51650. * @param element Defines the video or canvas the texture is filled with
  51651. * @param options Defines the other none mandatory texture creation options
  51652. */
  51653. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51654. private _createInternalTexture;
  51655. /**
  51656. * Returns the texture matrix used in most of the material.
  51657. */
  51658. getTextureMatrix(): Matrix;
  51659. /**
  51660. * Updates the content of the texture.
  51661. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51662. */
  51663. update(invertY?: Nullable<boolean>): void;
  51664. }
  51665. }
  51666. declare module BABYLON {
  51667. /**
  51668. * Enum used to define the target of a block
  51669. */
  51670. export enum NodeMaterialBlockTargets {
  51671. /** Vertex shader */
  51672. Vertex = 1,
  51673. /** Fragment shader */
  51674. Fragment = 2,
  51675. /** Neutral */
  51676. Neutral = 4,
  51677. /** Vertex and Fragment */
  51678. VertexAndFragment = 3
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /**
  51683. * Defines the kind of connection point for node based material
  51684. */
  51685. export enum NodeMaterialBlockConnectionPointTypes {
  51686. /** Float */
  51687. Float = 1,
  51688. /** Int */
  51689. Int = 2,
  51690. /** Vector2 */
  51691. Vector2 = 4,
  51692. /** Vector3 */
  51693. Vector3 = 8,
  51694. /** Vector4 */
  51695. Vector4 = 16,
  51696. /** Color3 */
  51697. Color3 = 32,
  51698. /** Color4 */
  51699. Color4 = 64,
  51700. /** Matrix */
  51701. Matrix = 128,
  51702. /** Detect type based on connection */
  51703. AutoDetect = 1024,
  51704. /** Output type that will be defined by input type */
  51705. BasedOnInput = 2048
  51706. }
  51707. }
  51708. declare module BABYLON {
  51709. /**
  51710. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51711. */
  51712. export enum NodeMaterialBlockConnectionPointMode {
  51713. /** Value is an uniform */
  51714. Uniform = 0,
  51715. /** Value is a mesh attribute */
  51716. Attribute = 1,
  51717. /** Value is a varying between vertex and fragment shaders */
  51718. Varying = 2,
  51719. /** Mode is undefined */
  51720. Undefined = 3
  51721. }
  51722. }
  51723. declare module BABYLON {
  51724. /**
  51725. * Enum used to define system values e.g. values automatically provided by the system
  51726. */
  51727. export enum NodeMaterialSystemValues {
  51728. /** World */
  51729. World = 1,
  51730. /** View */
  51731. View = 2,
  51732. /** Projection */
  51733. Projection = 3,
  51734. /** ViewProjection */
  51735. ViewProjection = 4,
  51736. /** WorldView */
  51737. WorldView = 5,
  51738. /** WorldViewProjection */
  51739. WorldViewProjection = 6,
  51740. /** CameraPosition */
  51741. CameraPosition = 7,
  51742. /** Fog Color */
  51743. FogColor = 8
  51744. }
  51745. }
  51746. declare module BABYLON {
  51747. /**
  51748. * Root class for all node material optimizers
  51749. */
  51750. export class NodeMaterialOptimizer {
  51751. /**
  51752. * Function used to optimize a NodeMaterial graph
  51753. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51754. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51755. */
  51756. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51757. }
  51758. }
  51759. declare module BABYLON {
  51760. /**
  51761. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51762. */
  51763. export class TransformBlock extends NodeMaterialBlock {
  51764. /**
  51765. * Defines the value to use to complement W value to transform it to a Vector4
  51766. */
  51767. complementW: number;
  51768. /**
  51769. * Defines the value to use to complement z value to transform it to a Vector4
  51770. */
  51771. complementZ: number;
  51772. /**
  51773. * Creates a new TransformBlock
  51774. * @param name defines the block name
  51775. */
  51776. constructor(name: string);
  51777. /**
  51778. * Gets the current class name
  51779. * @returns the class name
  51780. */
  51781. getClassName(): string;
  51782. /**
  51783. * Gets the vector input
  51784. */
  51785. readonly vector: NodeMaterialConnectionPoint;
  51786. /**
  51787. * Gets the output component
  51788. */
  51789. readonly output: NodeMaterialConnectionPoint;
  51790. /**
  51791. * Gets the matrix transform input
  51792. */
  51793. readonly transform: NodeMaterialConnectionPoint;
  51794. protected _buildBlock(state: NodeMaterialBuildState): this;
  51795. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51796. protected _dumpPropertiesCode(): string;
  51797. }
  51798. }
  51799. declare module BABYLON {
  51800. /**
  51801. * Block used to output the vertex position
  51802. */
  51803. export class VertexOutputBlock extends NodeMaterialBlock {
  51804. /**
  51805. * Creates a new VertexOutputBlock
  51806. * @param name defines the block name
  51807. */
  51808. constructor(name: string);
  51809. /**
  51810. * Gets the current class name
  51811. * @returns the class name
  51812. */
  51813. getClassName(): string;
  51814. /**
  51815. * Gets the vector input component
  51816. */
  51817. readonly vector: NodeMaterialConnectionPoint;
  51818. protected _buildBlock(state: NodeMaterialBuildState): this;
  51819. }
  51820. }
  51821. declare module BABYLON {
  51822. /**
  51823. * Block used to output the final color
  51824. */
  51825. export class FragmentOutputBlock extends NodeMaterialBlock {
  51826. /**
  51827. * Create a new FragmentOutputBlock
  51828. * @param name defines the block name
  51829. */
  51830. constructor(name: string);
  51831. /**
  51832. * Gets the current class name
  51833. * @returns the class name
  51834. */
  51835. getClassName(): string;
  51836. /**
  51837. * Gets the rgba input component
  51838. */
  51839. readonly rgba: NodeMaterialConnectionPoint;
  51840. /**
  51841. * Gets the rgb input component
  51842. */
  51843. readonly rgb: NodeMaterialConnectionPoint;
  51844. /**
  51845. * Gets the a input component
  51846. */
  51847. readonly a: NodeMaterialConnectionPoint;
  51848. protected _buildBlock(state: NodeMaterialBuildState): this;
  51849. }
  51850. }
  51851. declare module BABYLON {
  51852. /**
  51853. * Block used to read a reflection texture from a sampler
  51854. */
  51855. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51856. private _define3DName;
  51857. private _defineCubicName;
  51858. private _defineExplicitName;
  51859. private _defineProjectionName;
  51860. private _defineLocalCubicName;
  51861. private _defineSphericalName;
  51862. private _definePlanarName;
  51863. private _defineEquirectangularName;
  51864. private _defineMirroredEquirectangularFixedName;
  51865. private _defineEquirectangularFixedName;
  51866. private _defineSkyboxName;
  51867. private _cubeSamplerName;
  51868. private _2DSamplerName;
  51869. private _positionUVWName;
  51870. private _directionWName;
  51871. private _reflectionCoordsName;
  51872. private _reflection2DCoordsName;
  51873. private _reflectionColorName;
  51874. private _reflectionMatrixName;
  51875. /**
  51876. * Gets or sets the texture associated with the node
  51877. */
  51878. texture: Nullable<BaseTexture>;
  51879. /**
  51880. * Create a new TextureBlock
  51881. * @param name defines the block name
  51882. */
  51883. constructor(name: string);
  51884. /**
  51885. * Gets the current class name
  51886. * @returns the class name
  51887. */
  51888. getClassName(): string;
  51889. /**
  51890. * Gets the world position input component
  51891. */
  51892. readonly position: NodeMaterialConnectionPoint;
  51893. /**
  51894. * Gets the world position input component
  51895. */
  51896. readonly worldPosition: NodeMaterialConnectionPoint;
  51897. /**
  51898. * Gets the world normal input component
  51899. */
  51900. readonly worldNormal: NodeMaterialConnectionPoint;
  51901. /**
  51902. * Gets the world input component
  51903. */
  51904. readonly world: NodeMaterialConnectionPoint;
  51905. /**
  51906. * Gets the camera (or eye) position component
  51907. */
  51908. readonly cameraPosition: NodeMaterialConnectionPoint;
  51909. /**
  51910. * Gets the view input component
  51911. */
  51912. readonly view: NodeMaterialConnectionPoint;
  51913. /**
  51914. * Gets the rgb output component
  51915. */
  51916. readonly rgb: NodeMaterialConnectionPoint;
  51917. /**
  51918. * Gets the r output component
  51919. */
  51920. readonly r: NodeMaterialConnectionPoint;
  51921. /**
  51922. * Gets the g output component
  51923. */
  51924. readonly g: NodeMaterialConnectionPoint;
  51925. /**
  51926. * Gets the b output component
  51927. */
  51928. readonly b: NodeMaterialConnectionPoint;
  51929. autoConfigure(material: NodeMaterial): void;
  51930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51931. isReady(): boolean;
  51932. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51933. private _injectVertexCode;
  51934. private _writeOutput;
  51935. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51936. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51937. }
  51938. }
  51939. declare module BABYLON {
  51940. /**
  51941. * Interface used to configure the node material editor
  51942. */
  51943. export interface INodeMaterialEditorOptions {
  51944. /** Define the URl to load node editor script */
  51945. editorURL?: string;
  51946. }
  51947. /** @hidden */
  51948. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51949. /** BONES */
  51950. NUM_BONE_INFLUENCERS: number;
  51951. BonesPerMesh: number;
  51952. BONETEXTURE: boolean;
  51953. /** MORPH TARGETS */
  51954. MORPHTARGETS: boolean;
  51955. MORPHTARGETS_NORMAL: boolean;
  51956. MORPHTARGETS_TANGENT: boolean;
  51957. MORPHTARGETS_UV: boolean;
  51958. NUM_MORPH_INFLUENCERS: number;
  51959. /** IMAGE PROCESSING */
  51960. IMAGEPROCESSING: boolean;
  51961. VIGNETTE: boolean;
  51962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51963. VIGNETTEBLENDMODEOPAQUE: boolean;
  51964. TONEMAPPING: boolean;
  51965. TONEMAPPING_ACES: boolean;
  51966. CONTRAST: boolean;
  51967. EXPOSURE: boolean;
  51968. COLORCURVES: boolean;
  51969. COLORGRADING: boolean;
  51970. COLORGRADING3D: boolean;
  51971. SAMPLER3DGREENDEPTH: boolean;
  51972. SAMPLER3DBGRMAP: boolean;
  51973. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51974. /** MISC. */
  51975. BUMPDIRECTUV: number;
  51976. constructor();
  51977. setValue(name: string, value: boolean): void;
  51978. }
  51979. /**
  51980. * Class used to configure NodeMaterial
  51981. */
  51982. export interface INodeMaterialOptions {
  51983. /**
  51984. * Defines if blocks should emit comments
  51985. */
  51986. emitComments: boolean;
  51987. }
  51988. /**
  51989. * Class used to create a node based material built by assembling shader blocks
  51990. */
  51991. export class NodeMaterial extends PushMaterial {
  51992. private static _BuildIdGenerator;
  51993. private _options;
  51994. private _vertexCompilationState;
  51995. private _fragmentCompilationState;
  51996. private _sharedData;
  51997. private _buildId;
  51998. private _buildWasSuccessful;
  51999. private _cachedWorldViewMatrix;
  52000. private _cachedWorldViewProjectionMatrix;
  52001. private _optimizers;
  52002. private _animationFrame;
  52003. /** Define the URl to load node editor script */
  52004. static EditorURL: string;
  52005. private BJSNODEMATERIALEDITOR;
  52006. /** Get the inspector from bundle or global */
  52007. private _getGlobalNodeMaterialEditor;
  52008. /**
  52009. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  52010. */
  52011. ignoreAlpha: boolean;
  52012. /**
  52013. * Defines the maximum number of lights that can be used in the material
  52014. */
  52015. maxSimultaneousLights: number;
  52016. /**
  52017. * Observable raised when the material is built
  52018. */
  52019. onBuildObservable: Observable<NodeMaterial>;
  52020. /**
  52021. * Gets or sets the root nodes of the material vertex shader
  52022. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52023. /**
  52024. * Gets or sets the root nodes of the material fragment (pixel) shader
  52025. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52026. /** Gets or sets options to control the node material overall behavior */
  52027. options: INodeMaterialOptions;
  52028. /**
  52029. * Default configuration related to image processing available in the standard Material.
  52030. */
  52031. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52032. /**
  52033. * Gets the image processing configuration used either in this material.
  52034. */
  52035. /**
  52036. * Sets the Default image processing configuration used either in the this material.
  52037. *
  52038. * If sets to null, the scene one is in use.
  52039. */
  52040. imageProcessingConfiguration: ImageProcessingConfiguration;
  52041. /**
  52042. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52043. */
  52044. attachedBlocks: NodeMaterialBlock[];
  52045. /**
  52046. * Create a new node based material
  52047. * @param name defines the material name
  52048. * @param scene defines the hosting scene
  52049. * @param options defines creation option
  52050. */
  52051. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52052. /**
  52053. * Gets the current class name of the material e.g. "NodeMaterial"
  52054. * @returns the class name
  52055. */
  52056. getClassName(): string;
  52057. /**
  52058. * Keep track of the image processing observer to allow dispose and replace.
  52059. */
  52060. private _imageProcessingObserver;
  52061. /**
  52062. * Attaches a new image processing configuration to the Standard Material.
  52063. * @param configuration
  52064. */
  52065. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52066. /**
  52067. * Get a block by its name
  52068. * @param name defines the name of the block to retrieve
  52069. * @returns the required block or null if not found
  52070. */
  52071. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52072. /**
  52073. * Get a block by its name
  52074. * @param predicate defines the predicate used to find the good candidate
  52075. * @returns the required block or null if not found
  52076. */
  52077. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52078. /**
  52079. * Get an input block by its name
  52080. * @param predicate defines the predicate used to find the good candidate
  52081. * @returns the required input block or null if not found
  52082. */
  52083. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52084. /**
  52085. * Gets the list of input blocks attached to this material
  52086. * @returns an array of InputBlocks
  52087. */
  52088. getInputBlocks(): InputBlock[];
  52089. /**
  52090. * Adds a new optimizer to the list of optimizers
  52091. * @param optimizer defines the optimizers to add
  52092. * @returns the current material
  52093. */
  52094. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52095. /**
  52096. * Remove an optimizer from the list of optimizers
  52097. * @param optimizer defines the optimizers to remove
  52098. * @returns the current material
  52099. */
  52100. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52101. /**
  52102. * Add a new block to the list of output nodes
  52103. * @param node defines the node to add
  52104. * @returns the current material
  52105. */
  52106. addOutputNode(node: NodeMaterialBlock): this;
  52107. /**
  52108. * Remove a block from the list of root nodes
  52109. * @param node defines the node to remove
  52110. * @returns the current material
  52111. */
  52112. removeOutputNode(node: NodeMaterialBlock): this;
  52113. private _addVertexOutputNode;
  52114. private _removeVertexOutputNode;
  52115. private _addFragmentOutputNode;
  52116. private _removeFragmentOutputNode;
  52117. /**
  52118. * Specifies if the material will require alpha blending
  52119. * @returns a boolean specifying if alpha blending is needed
  52120. */
  52121. needAlphaBlending(): boolean;
  52122. /**
  52123. * Specifies if this material should be rendered in alpha test mode
  52124. * @returns a boolean specifying if an alpha test is needed.
  52125. */
  52126. needAlphaTesting(): boolean;
  52127. private _initializeBlock;
  52128. private _resetDualBlocks;
  52129. /**
  52130. * Build the material and generates the inner effect
  52131. * @param verbose defines if the build should log activity
  52132. */
  52133. build(verbose?: boolean): void;
  52134. /**
  52135. * Runs an otpimization phase to try to improve the shader code
  52136. */
  52137. optimize(): void;
  52138. private _prepareDefinesForAttributes;
  52139. /**
  52140. * Get if the submesh is ready to be used and all its information available.
  52141. * Child classes can use it to update shaders
  52142. * @param mesh defines the mesh to check
  52143. * @param subMesh defines which submesh to check
  52144. * @param useInstances specifies that instances should be used
  52145. * @returns a boolean indicating that the submesh is ready or not
  52146. */
  52147. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52148. /**
  52149. * Get a string representing the shaders built by the current node graph
  52150. */
  52151. readonly compiledShaders: string;
  52152. /**
  52153. * Binds the world matrix to the material
  52154. * @param world defines the world transformation matrix
  52155. */
  52156. bindOnlyWorldMatrix(world: Matrix): void;
  52157. /**
  52158. * Binds the submesh to this material by preparing the effect and shader to draw
  52159. * @param world defines the world transformation matrix
  52160. * @param mesh defines the mesh containing the submesh
  52161. * @param subMesh defines the submesh to bind the material to
  52162. */
  52163. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52164. /**
  52165. * Gets the active textures from the material
  52166. * @returns an array of textures
  52167. */
  52168. getActiveTextures(): BaseTexture[];
  52169. /**
  52170. * Gets the list of texture blocks
  52171. * @returns an array of texture blocks
  52172. */
  52173. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52174. /**
  52175. * Specifies if the material uses a texture
  52176. * @param texture defines the texture to check against the material
  52177. * @returns a boolean specifying if the material uses the texture
  52178. */
  52179. hasTexture(texture: BaseTexture): boolean;
  52180. /**
  52181. * Disposes the material
  52182. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52183. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52184. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52185. */
  52186. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52187. /** Creates the node editor window. */
  52188. private _createNodeEditor;
  52189. /**
  52190. * Launch the node material editor
  52191. * @param config Define the configuration of the editor
  52192. * @return a promise fulfilled when the node editor is visible
  52193. */
  52194. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52195. /**
  52196. * Clear the current material
  52197. */
  52198. clear(): void;
  52199. /**
  52200. * Clear the current material and set it to a default state
  52201. */
  52202. setToDefault(): void;
  52203. /**
  52204. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52205. * @param url defines the url to load from
  52206. * @returns a promise that will fullfil when the material is fully loaded
  52207. */
  52208. loadAsync(url: string): Promise<unknown>;
  52209. private _gatherBlocks;
  52210. /**
  52211. * Generate a string containing the code declaration required to create an equivalent of this material
  52212. * @returns a string
  52213. */
  52214. generateCode(): string;
  52215. /**
  52216. * Serializes this material in a JSON representation
  52217. * @returns the serialized material object
  52218. */
  52219. serialize(): any;
  52220. private _restoreConnections;
  52221. /**
  52222. * Clear the current graph and load a new one from a serialization object
  52223. * @param source defines the JSON representation of the material
  52224. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52225. */
  52226. loadFromSerialization(source: any, rootUrl?: string): void;
  52227. /**
  52228. * Creates a node material from parsed material data
  52229. * @param source defines the JSON representation of the material
  52230. * @param scene defines the hosting scene
  52231. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52232. * @returns a new node material
  52233. */
  52234. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52235. /**
  52236. * Creates a new node material set to default basic configuration
  52237. * @param name defines the name of the material
  52238. * @param scene defines the hosting scene
  52239. * @returns a new NodeMaterial
  52240. */
  52241. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52242. }
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * Block used to read a texture from a sampler
  52247. */
  52248. export class TextureBlock extends NodeMaterialBlock {
  52249. private _defineName;
  52250. private _samplerName;
  52251. private _transformedUVName;
  52252. private _textureTransformName;
  52253. private _textureInfoName;
  52254. private _mainUVName;
  52255. private _mainUVDefineName;
  52256. /**
  52257. * Gets or sets the texture associated with the node
  52258. */
  52259. texture: Nullable<Texture>;
  52260. /**
  52261. * Create a new TextureBlock
  52262. * @param name defines the block name
  52263. */
  52264. constructor(name: string);
  52265. /**
  52266. * Gets the current class name
  52267. * @returns the class name
  52268. */
  52269. getClassName(): string;
  52270. /**
  52271. * Gets the uv input component
  52272. */
  52273. readonly uv: NodeMaterialConnectionPoint;
  52274. /**
  52275. * Gets the rgba output component
  52276. */
  52277. readonly rgba: NodeMaterialConnectionPoint;
  52278. /**
  52279. * Gets the rgb output component
  52280. */
  52281. readonly rgb: NodeMaterialConnectionPoint;
  52282. /**
  52283. * Gets the r output component
  52284. */
  52285. readonly r: NodeMaterialConnectionPoint;
  52286. /**
  52287. * Gets the g output component
  52288. */
  52289. readonly g: NodeMaterialConnectionPoint;
  52290. /**
  52291. * Gets the b output component
  52292. */
  52293. readonly b: NodeMaterialConnectionPoint;
  52294. /**
  52295. * Gets the a output component
  52296. */
  52297. readonly a: NodeMaterialConnectionPoint;
  52298. readonly target: NodeMaterialBlockTargets;
  52299. autoConfigure(material: NodeMaterial): void;
  52300. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52302. isReady(): boolean;
  52303. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52304. private readonly _isMixed;
  52305. private _injectVertexCode;
  52306. private _writeOutput;
  52307. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52308. protected _dumpPropertiesCode(): string;
  52309. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52310. }
  52311. }
  52312. declare module BABYLON {
  52313. /**
  52314. * Class used to store shared data between 2 NodeMaterialBuildState
  52315. */
  52316. export class NodeMaterialBuildStateSharedData {
  52317. /**
  52318. * Gets the list of emitted varyings
  52319. */
  52320. temps: string[];
  52321. /**
  52322. * Gets the list of emitted varyings
  52323. */
  52324. varyings: string[];
  52325. /**
  52326. * Gets the varying declaration string
  52327. */
  52328. varyingDeclaration: string;
  52329. /**
  52330. * Input blocks
  52331. */
  52332. inputBlocks: InputBlock[];
  52333. /**
  52334. * Input blocks
  52335. */
  52336. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52337. /**
  52338. * Bindable blocks (Blocks that need to set data to the effect)
  52339. */
  52340. bindableBlocks: NodeMaterialBlock[];
  52341. /**
  52342. * List of blocks that can provide a compilation fallback
  52343. */
  52344. blocksWithFallbacks: NodeMaterialBlock[];
  52345. /**
  52346. * List of blocks that can provide a define update
  52347. */
  52348. blocksWithDefines: NodeMaterialBlock[];
  52349. /**
  52350. * List of blocks that can provide a repeatable content
  52351. */
  52352. repeatableContentBlocks: NodeMaterialBlock[];
  52353. /**
  52354. * List of blocks that can provide a dynamic list of uniforms
  52355. */
  52356. dynamicUniformBlocks: NodeMaterialBlock[];
  52357. /**
  52358. * List of blocks that can block the isReady function for the material
  52359. */
  52360. blockingBlocks: NodeMaterialBlock[];
  52361. /**
  52362. * Gets the list of animated inputs
  52363. */
  52364. animatedInputs: InputBlock[];
  52365. /**
  52366. * Build Id used to avoid multiple recompilations
  52367. */
  52368. buildId: number;
  52369. /** List of emitted variables */
  52370. variableNames: {
  52371. [key: string]: number;
  52372. };
  52373. /** List of emitted defines */
  52374. defineNames: {
  52375. [key: string]: number;
  52376. };
  52377. /** Should emit comments? */
  52378. emitComments: boolean;
  52379. /** Emit build activity */
  52380. verbose: boolean;
  52381. /** Gets or sets the hosting scene */
  52382. scene: Scene;
  52383. /**
  52384. * Gets the compilation hints emitted at compilation time
  52385. */
  52386. hints: {
  52387. needWorldViewMatrix: boolean;
  52388. needWorldViewProjectionMatrix: boolean;
  52389. needAlphaBlending: boolean;
  52390. needAlphaTesting: boolean;
  52391. };
  52392. /**
  52393. * List of compilation checks
  52394. */
  52395. checks: {
  52396. emitVertex: boolean;
  52397. emitFragment: boolean;
  52398. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52399. };
  52400. /** Creates a new shared data */
  52401. constructor();
  52402. /**
  52403. * Emits console errors and exceptions if there is a failing check
  52404. */
  52405. emitErrors(): void;
  52406. }
  52407. }
  52408. declare module BABYLON {
  52409. /**
  52410. * Class used to store node based material build state
  52411. */
  52412. export class NodeMaterialBuildState {
  52413. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52414. supportUniformBuffers: boolean;
  52415. /**
  52416. * Gets the list of emitted attributes
  52417. */
  52418. attributes: string[];
  52419. /**
  52420. * Gets the list of emitted uniforms
  52421. */
  52422. uniforms: string[];
  52423. /**
  52424. * Gets the list of emitted constants
  52425. */
  52426. constants: string[];
  52427. /**
  52428. * Gets the list of emitted uniform buffers
  52429. */
  52430. uniformBuffers: string[];
  52431. /**
  52432. * Gets the list of emitted samplers
  52433. */
  52434. samplers: string[];
  52435. /**
  52436. * Gets the list of emitted functions
  52437. */
  52438. functions: {
  52439. [key: string]: string;
  52440. };
  52441. /**
  52442. * Gets the list of emitted extensions
  52443. */
  52444. extensions: {
  52445. [key: string]: string;
  52446. };
  52447. /**
  52448. * Gets the target of the compilation state
  52449. */
  52450. target: NodeMaterialBlockTargets;
  52451. /**
  52452. * Gets the list of emitted counters
  52453. */
  52454. counters: {
  52455. [key: string]: number;
  52456. };
  52457. /**
  52458. * Shared data between multiple NodeMaterialBuildState instances
  52459. */
  52460. sharedData: NodeMaterialBuildStateSharedData;
  52461. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  52462. /** @hidden */ private _attributeDeclaration: string;
  52463. /** @hidden */ private _uniformDeclaration: string;
  52464. /** @hidden */ private _constantDeclaration: string;
  52465. /** @hidden */ private _samplerDeclaration: string;
  52466. /** @hidden */ private _varyingTransfer: string;
  52467. private _repeatableContentAnchorIndex;
  52468. /** @hidden */ private _builtCompilationString: string;
  52469. /**
  52470. * Gets the emitted compilation strings
  52471. */
  52472. compilationString: string;
  52473. /**
  52474. * Finalize the compilation strings
  52475. * @param state defines the current compilation state
  52476. */
  52477. finalize(state: NodeMaterialBuildState): void;
  52478. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52479. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52480. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52481. /** @hidden */ private _excludeVariableName(name: string): void;
  52482. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52483. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52484. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52485. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52486. replaceStrings?: {
  52487. search: RegExp;
  52488. replace: string;
  52489. }[];
  52490. repeatKey?: string;
  52491. }): string;
  52492. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52493. repeatKey?: string;
  52494. removeAttributes?: boolean;
  52495. removeUniforms?: boolean;
  52496. removeVaryings?: boolean;
  52497. removeIfDef?: boolean;
  52498. replaceStrings?: {
  52499. search: RegExp;
  52500. replace: string;
  52501. }[];
  52502. }, storeKey?: string): void;
  52503. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52504. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52505. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /**
  52510. * Defines a block that can be used inside a node based material
  52511. */
  52512. export class NodeMaterialBlock {
  52513. private _buildId;
  52514. private _buildTarget;
  52515. private _target;
  52516. private _isFinalMerger;
  52517. private _isInput;
  52518. /** @hidden */ private _codeVariableName: string;
  52519. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52520. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52521. /** @hidden */ private _preparationId: number;
  52522. /**
  52523. * Gets or sets the name of the block
  52524. */
  52525. name: string;
  52526. /**
  52527. * Gets or sets the unique id of the node
  52528. */
  52529. uniqueId: number;
  52530. /**
  52531. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52532. */
  52533. readonly isFinalMerger: boolean;
  52534. /**
  52535. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52536. */
  52537. readonly isInput: boolean;
  52538. /**
  52539. * Gets or sets the build Id
  52540. */
  52541. buildId: number;
  52542. /**
  52543. * Gets or sets the target of the block
  52544. */
  52545. target: NodeMaterialBlockTargets;
  52546. /**
  52547. * Gets the list of input points
  52548. */
  52549. readonly inputs: NodeMaterialConnectionPoint[];
  52550. /** Gets the list of output points */
  52551. readonly outputs: NodeMaterialConnectionPoint[];
  52552. /**
  52553. * Find an input by its name
  52554. * @param name defines the name of the input to look for
  52555. * @returns the input or null if not found
  52556. */
  52557. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52558. /**
  52559. * Find an output by its name
  52560. * @param name defines the name of the outputto look for
  52561. * @returns the output or null if not found
  52562. */
  52563. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52564. /**
  52565. * Creates a new NodeMaterialBlock
  52566. * @param name defines the block name
  52567. * @param target defines the target of that block (Vertex by default)
  52568. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52569. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52570. */
  52571. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52572. /**
  52573. * Initialize the block and prepare the context for build
  52574. * @param state defines the state that will be used for the build
  52575. */
  52576. initialize(state: NodeMaterialBuildState): void;
  52577. /**
  52578. * Bind data to effect. Will only be called for blocks with isBindable === true
  52579. * @param effect defines the effect to bind data to
  52580. * @param nodeMaterial defines the hosting NodeMaterial
  52581. * @param mesh defines the mesh that will be rendered
  52582. */
  52583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52584. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52585. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52586. protected _writeFloat(value: number): string;
  52587. /**
  52588. * Gets the current class name e.g. "NodeMaterialBlock"
  52589. * @returns the class name
  52590. */
  52591. getClassName(): string;
  52592. /**
  52593. * Register a new input. Must be called inside a block constructor
  52594. * @param name defines the connection point name
  52595. * @param type defines the connection point type
  52596. * @param isOptional defines a boolean indicating that this input can be omitted
  52597. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52598. * @returns the current block
  52599. */
  52600. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52601. /**
  52602. * Register a new output. Must be called inside a block constructor
  52603. * @param name defines the connection point name
  52604. * @param type defines the connection point type
  52605. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52606. * @returns the current block
  52607. */
  52608. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52609. /**
  52610. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52611. * @param forOutput defines an optional connection point to check compatibility with
  52612. * @returns the first available input or null
  52613. */
  52614. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52615. /**
  52616. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52617. * @param forBlock defines an optional block to check compatibility with
  52618. * @returns the first available input or null
  52619. */
  52620. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52621. /**
  52622. * Gets the sibling of the given output
  52623. * @param current defines the current output
  52624. * @returns the next output in the list or null
  52625. */
  52626. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52627. /**
  52628. * Connect current block with another block
  52629. * @param other defines the block to connect with
  52630. * @param options define the various options to help pick the right connections
  52631. * @returns the current block
  52632. */
  52633. connectTo(other: NodeMaterialBlock, options?: {
  52634. input?: string;
  52635. output?: string;
  52636. outputSwizzle?: string;
  52637. }): this | undefined;
  52638. protected _buildBlock(state: NodeMaterialBuildState): void;
  52639. /**
  52640. * Add uniforms, samplers and uniform buffers at compilation time
  52641. * @param state defines the state to update
  52642. * @param nodeMaterial defines the node material requesting the update
  52643. * @param defines defines the material defines to update
  52644. */
  52645. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52646. /**
  52647. * Add potential fallbacks if shader compilation fails
  52648. * @param mesh defines the mesh to be rendered
  52649. * @param fallbacks defines the current prioritized list of fallbacks
  52650. */
  52651. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52652. /**
  52653. * Initialize defines for shader compilation
  52654. * @param mesh defines the mesh to be rendered
  52655. * @param nodeMaterial defines the node material requesting the update
  52656. * @param defines defines the material defines to update
  52657. * @param useInstances specifies that instances should be used
  52658. */
  52659. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52660. /**
  52661. * Update defines for shader compilation
  52662. * @param mesh defines the mesh to be rendered
  52663. * @param nodeMaterial defines the node material requesting the update
  52664. * @param defines defines the material defines to update
  52665. * @param useInstances specifies that instances should be used
  52666. */
  52667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52668. /**
  52669. * Lets the block try to connect some inputs automatically
  52670. * @param material defines the hosting NodeMaterial
  52671. */
  52672. autoConfigure(material: NodeMaterial): void;
  52673. /**
  52674. * Function called when a block is declared as repeatable content generator
  52675. * @param vertexShaderState defines the current compilation state for the vertex shader
  52676. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52677. * @param mesh defines the mesh to be rendered
  52678. * @param defines defines the material defines to update
  52679. */
  52680. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52681. /**
  52682. * Checks if the block is ready
  52683. * @param mesh defines the mesh to be rendered
  52684. * @param nodeMaterial defines the node material requesting the update
  52685. * @param defines defines the material defines to update
  52686. * @param useInstances specifies that instances should be used
  52687. * @returns true if the block is ready
  52688. */
  52689. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52690. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52691. private _processBuild;
  52692. /**
  52693. * Compile the current node and generate the shader code
  52694. * @param state defines the current compilation state (uniforms, samplers, current string)
  52695. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52696. * @returns true if already built
  52697. */
  52698. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52699. protected _inputRename(name: string): string;
  52700. protected _outputRename(name: string): string;
  52701. protected _dumpPropertiesCode(): string;
  52702. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52703. /**
  52704. * Clone the current block to a new identical block
  52705. * @param scene defines the hosting scene
  52706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52707. * @returns a copy of the current block
  52708. */
  52709. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52710. /**
  52711. * Serializes this block in a JSON representation
  52712. * @returns the serialized block object
  52713. */
  52714. serialize(): any;
  52715. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52716. }
  52717. }
  52718. declare module BABYLON {
  52719. /**
  52720. * Enum defining the type of animations supported by InputBlock
  52721. */
  52722. export enum AnimatedInputBlockTypes {
  52723. /** No animation */
  52724. None = 0,
  52725. /** Time based animation. Will only work for floats */
  52726. Time = 1
  52727. }
  52728. }
  52729. declare module BABYLON {
  52730. /**
  52731. * Block used to expose an input value
  52732. */
  52733. export class InputBlock extends NodeMaterialBlock {
  52734. private _mode;
  52735. private _associatedVariableName;
  52736. private _storedValue;
  52737. private _valueCallback;
  52738. private _type;
  52739. private _animationType;
  52740. /** Gets or set a value used to limit the range of float values */
  52741. min: number;
  52742. /** Gets or set a value used to limit the range of float values */
  52743. max: number;
  52744. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52745. matrixMode: number;
  52746. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52747. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52748. visibleInInspector: boolean;
  52749. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  52750. isConstant: boolean;
  52751. /**
  52752. * Gets or sets the connection point type (default is float)
  52753. */
  52754. readonly type: NodeMaterialBlockConnectionPointTypes;
  52755. /**
  52756. * Creates a new InputBlock
  52757. * @param name defines the block name
  52758. * @param target defines the target of that block (Vertex by default)
  52759. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52760. */
  52761. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52762. /**
  52763. * Gets the output component
  52764. */
  52765. readonly output: NodeMaterialConnectionPoint;
  52766. /**
  52767. * Set the source of this connection point to a vertex attribute
  52768. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52769. * @returns the current connection point
  52770. */
  52771. setAsAttribute(attributeName?: string): InputBlock;
  52772. /**
  52773. * Set the source of this connection point to a system value
  52774. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52775. * @returns the current connection point
  52776. */
  52777. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52778. /**
  52779. * Gets or sets the value of that point.
  52780. * Please note that this value will be ignored if valueCallback is defined
  52781. */
  52782. value: any;
  52783. /**
  52784. * Gets or sets a callback used to get the value of that point.
  52785. * Please note that setting this value will force the connection point to ignore the value property
  52786. */
  52787. valueCallback: () => any;
  52788. /**
  52789. * Gets or sets the associated variable name in the shader
  52790. */
  52791. associatedVariableName: string;
  52792. /** Gets or sets the type of animation applied to the input */
  52793. animationType: AnimatedInputBlockTypes;
  52794. /**
  52795. * Gets a boolean indicating that this connection point not defined yet
  52796. */
  52797. readonly isUndefined: boolean;
  52798. /**
  52799. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52800. * In this case the connection point name must be the name of the uniform to use.
  52801. * Can only be set on inputs
  52802. */
  52803. isUniform: boolean;
  52804. /**
  52805. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52806. * In this case the connection point name must be the name of the attribute to use
  52807. * Can only be set on inputs
  52808. */
  52809. isAttribute: boolean;
  52810. /**
  52811. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52812. * Can only be set on exit points
  52813. */
  52814. isVarying: boolean;
  52815. /**
  52816. * Gets a boolean indicating that the current connection point is a system value
  52817. */
  52818. readonly isSystemValue: boolean;
  52819. /**
  52820. * Gets or sets the current well known value or null if not defined as a system value
  52821. */
  52822. systemValue: Nullable<NodeMaterialSystemValues>;
  52823. /**
  52824. * Gets the current class name
  52825. * @returns the class name
  52826. */
  52827. getClassName(): string;
  52828. /**
  52829. * Animate the input if animationType !== None
  52830. * @param scene defines the rendering scene
  52831. */
  52832. animate(scene: Scene): void;
  52833. private _emitDefine;
  52834. initialize(state: NodeMaterialBuildState): void;
  52835. /**
  52836. * Set the input block to its default value (based on its type)
  52837. */
  52838. setDefaultValue(): void;
  52839. private _emitConstant;
  52840. private _emit;
  52841. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52842. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52843. protected _buildBlock(state: NodeMaterialBuildState): void;
  52844. protected _dumpPropertiesCode(): string;
  52845. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52846. }
  52847. }
  52848. declare module BABYLON {
  52849. /**
  52850. * Defines a connection point for a block
  52851. */
  52852. export class NodeMaterialConnectionPoint {
  52853. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52854. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52855. private _endpoints;
  52856. private _associatedVariableName;
  52857. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52858. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52859. private _type;
  52860. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52861. /**
  52862. * Gets or sets the additional types supported by this connection point
  52863. */
  52864. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52865. /**
  52866. * Gets or sets the additional types excluded by this connection point
  52867. */
  52868. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52869. /**
  52870. * Gets or sets the associated variable name in the shader
  52871. */
  52872. associatedVariableName: string;
  52873. /**
  52874. * Gets or sets the connection point type (default is float)
  52875. */
  52876. type: NodeMaterialBlockConnectionPointTypes;
  52877. /**
  52878. * Gets or sets the connection point name
  52879. */
  52880. name: string;
  52881. /**
  52882. * Gets or sets a boolean indicating that this connection point can be omitted
  52883. */
  52884. isOptional: boolean;
  52885. /**
  52886. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52887. */
  52888. define: string;
  52889. /** Gets or sets the target of that connection point */
  52890. target: NodeMaterialBlockTargets;
  52891. /**
  52892. * Gets a boolean indicating that the current point is connected
  52893. */
  52894. readonly isConnected: boolean;
  52895. /**
  52896. * Gets a boolean indicating that the current point is connected to an input block
  52897. */
  52898. readonly isConnectedToInputBlock: boolean;
  52899. /**
  52900. * Gets a the connected input block (if any)
  52901. */
  52902. readonly connectInputBlock: Nullable<InputBlock>;
  52903. /** Get the other side of the connection (if any) */
  52904. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52905. /** Get the block that owns this connection point */
  52906. readonly ownerBlock: NodeMaterialBlock;
  52907. /** Get the block connected on the other side of this connection (if any) */
  52908. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52909. /** Get the block connected on the endpoints of this connection (if any) */
  52910. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52911. /** Gets the list of connected endpoints */
  52912. readonly endpoints: NodeMaterialConnectionPoint[];
  52913. /** Gets a boolean indicating if that output point is connected to at least one input */
  52914. readonly hasEndpoints: boolean;
  52915. /**
  52916. * Creates a new connection point
  52917. * @param name defines the connection point name
  52918. * @param ownerBlock defines the block hosting this connection point
  52919. */
  52920. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52921. /**
  52922. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52923. * @returns the class name
  52924. */
  52925. getClassName(): string;
  52926. /**
  52927. * Gets an boolean indicating if the current point can be connected to another point
  52928. * @param connectionPoint defines the other connection point
  52929. * @returns true if the connection is possible
  52930. */
  52931. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52932. /**
  52933. * Connect this point to another connection point
  52934. * @param connectionPoint defines the other connection point
  52935. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52936. * @returns the current connection point
  52937. */
  52938. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52939. /**
  52940. * Disconnect this point from one of his endpoint
  52941. * @param endpoint defines the other connection point
  52942. * @returns the current connection point
  52943. */
  52944. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52945. /**
  52946. * Serializes this point in a JSON representation
  52947. * @returns the serialized point object
  52948. */
  52949. serialize(): any;
  52950. }
  52951. }
  52952. declare module BABYLON {
  52953. /**
  52954. * Block used to add support for vertex skinning (bones)
  52955. */
  52956. export class BonesBlock extends NodeMaterialBlock {
  52957. /**
  52958. * Creates a new BonesBlock
  52959. * @param name defines the block name
  52960. */
  52961. constructor(name: string);
  52962. /**
  52963. * Initialize the block and prepare the context for build
  52964. * @param state defines the state that will be used for the build
  52965. */
  52966. initialize(state: NodeMaterialBuildState): void;
  52967. /**
  52968. * Gets the current class name
  52969. * @returns the class name
  52970. */
  52971. getClassName(): string;
  52972. /**
  52973. * Gets the matrix indices input component
  52974. */
  52975. readonly matricesIndices: NodeMaterialConnectionPoint;
  52976. /**
  52977. * Gets the matrix weights input component
  52978. */
  52979. readonly matricesWeights: NodeMaterialConnectionPoint;
  52980. /**
  52981. * Gets the extra matrix indices input component
  52982. */
  52983. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52984. /**
  52985. * Gets the extra matrix weights input component
  52986. */
  52987. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52988. /**
  52989. * Gets the world input component
  52990. */
  52991. readonly world: NodeMaterialConnectionPoint;
  52992. /**
  52993. * Gets the output component
  52994. */
  52995. readonly output: NodeMaterialConnectionPoint;
  52996. autoConfigure(material: NodeMaterial): void;
  52997. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53000. protected _buildBlock(state: NodeMaterialBuildState): this;
  53001. }
  53002. }
  53003. declare module BABYLON {
  53004. /**
  53005. * Block used to add support for instances
  53006. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53007. */
  53008. export class InstancesBlock extends NodeMaterialBlock {
  53009. /**
  53010. * Creates a new InstancesBlock
  53011. * @param name defines the block name
  53012. */
  53013. constructor(name: string);
  53014. /**
  53015. * Gets the current class name
  53016. * @returns the class name
  53017. */
  53018. getClassName(): string;
  53019. /**
  53020. * Gets the first world row input component
  53021. */
  53022. readonly world0: NodeMaterialConnectionPoint;
  53023. /**
  53024. * Gets the second world row input component
  53025. */
  53026. readonly world1: NodeMaterialConnectionPoint;
  53027. /**
  53028. * Gets the third world row input component
  53029. */
  53030. readonly world2: NodeMaterialConnectionPoint;
  53031. /**
  53032. * Gets the forth world row input component
  53033. */
  53034. readonly world3: NodeMaterialConnectionPoint;
  53035. /**
  53036. * Gets the world input component
  53037. */
  53038. readonly world: NodeMaterialConnectionPoint;
  53039. /**
  53040. * Gets the output component
  53041. */
  53042. readonly output: NodeMaterialConnectionPoint;
  53043. autoConfigure(material: NodeMaterial): void;
  53044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53045. protected _buildBlock(state: NodeMaterialBuildState): this;
  53046. }
  53047. }
  53048. declare module BABYLON {
  53049. /**
  53050. * Block used to add morph targets support to vertex shader
  53051. */
  53052. export class MorphTargetsBlock extends NodeMaterialBlock {
  53053. private _repeatableContentAnchor;
  53054. private _repeatebleContentGenerated;
  53055. /**
  53056. * Create a new MorphTargetsBlock
  53057. * @param name defines the block name
  53058. */
  53059. constructor(name: string);
  53060. /**
  53061. * Gets the current class name
  53062. * @returns the class name
  53063. */
  53064. getClassName(): string;
  53065. /**
  53066. * Gets the position input component
  53067. */
  53068. readonly position: NodeMaterialConnectionPoint;
  53069. /**
  53070. * Gets the normal input component
  53071. */
  53072. readonly normal: NodeMaterialConnectionPoint;
  53073. /**
  53074. * Gets the tangent input component
  53075. */
  53076. readonly tangent: NodeMaterialConnectionPoint;
  53077. /**
  53078. * Gets the tangent input component
  53079. */
  53080. readonly uv: NodeMaterialConnectionPoint;
  53081. /**
  53082. * Gets the position output component
  53083. */
  53084. readonly positionOutput: NodeMaterialConnectionPoint;
  53085. /**
  53086. * Gets the normal output component
  53087. */
  53088. readonly normalOutput: NodeMaterialConnectionPoint;
  53089. /**
  53090. * Gets the tangent output component
  53091. */
  53092. readonly tangentOutput: NodeMaterialConnectionPoint;
  53093. /**
  53094. * Gets the tangent output component
  53095. */
  53096. readonly uvOutput: NodeMaterialConnectionPoint;
  53097. initialize(state: NodeMaterialBuildState): void;
  53098. autoConfigure(material: NodeMaterial): void;
  53099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53100. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53101. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53102. protected _buildBlock(state: NodeMaterialBuildState): this;
  53103. }
  53104. }
  53105. declare module BABYLON {
  53106. /**
  53107. * Block used to get data information from a light
  53108. */
  53109. export class LightInformationBlock extends NodeMaterialBlock {
  53110. private _lightDataUniformName;
  53111. private _lightColorUniformName;
  53112. private _lightTypeDefineName;
  53113. /**
  53114. * Gets or sets the light associated with this block
  53115. */
  53116. light: Nullable<Light>;
  53117. /**
  53118. * Creates a new LightInformationBlock
  53119. * @param name defines the block name
  53120. */
  53121. constructor(name: string);
  53122. /**
  53123. * Gets the current class name
  53124. * @returns the class name
  53125. */
  53126. getClassName(): string;
  53127. /**
  53128. * Gets the world position input component
  53129. */
  53130. readonly worldPosition: NodeMaterialConnectionPoint;
  53131. /**
  53132. * Gets the direction output component
  53133. */
  53134. readonly direction: NodeMaterialConnectionPoint;
  53135. /**
  53136. * Gets the direction output component
  53137. */
  53138. readonly color: NodeMaterialConnectionPoint;
  53139. /**
  53140. * Gets the direction output component
  53141. */
  53142. readonly intensity: NodeMaterialConnectionPoint;
  53143. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53145. protected _buildBlock(state: NodeMaterialBuildState): this;
  53146. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53147. }
  53148. }
  53149. declare module BABYLON {
  53150. /**
  53151. * Block used to add image processing support to fragment shader
  53152. */
  53153. export class ImageProcessingBlock extends NodeMaterialBlock {
  53154. /**
  53155. * Create a new ImageProcessingBlock
  53156. * @param name defines the block name
  53157. */
  53158. constructor(name: string);
  53159. /**
  53160. * Gets the current class name
  53161. * @returns the class name
  53162. */
  53163. getClassName(): string;
  53164. /**
  53165. * Gets the color input component
  53166. */
  53167. readonly color: NodeMaterialConnectionPoint;
  53168. /**
  53169. * Gets the output component
  53170. */
  53171. readonly output: NodeMaterialConnectionPoint;
  53172. /**
  53173. * Initialize the block and prepare the context for build
  53174. * @param state defines the state that will be used for the build
  53175. */
  53176. initialize(state: NodeMaterialBuildState): void;
  53177. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53180. protected _buildBlock(state: NodeMaterialBuildState): this;
  53181. }
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * Block used to pertub normals based on a normal map
  53186. */
  53187. export class PerturbNormalBlock extends NodeMaterialBlock {
  53188. private _tangentSpaceParameterName;
  53189. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53190. invertX: boolean;
  53191. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53192. invertY: boolean;
  53193. /**
  53194. * Create a new PerturbNormalBlock
  53195. * @param name defines the block name
  53196. */
  53197. constructor(name: string);
  53198. /**
  53199. * Gets the current class name
  53200. * @returns the class name
  53201. */
  53202. getClassName(): string;
  53203. /**
  53204. * Gets the world position input component
  53205. */
  53206. readonly worldPosition: NodeMaterialConnectionPoint;
  53207. /**
  53208. * Gets the world normal input component
  53209. */
  53210. readonly worldNormal: NodeMaterialConnectionPoint;
  53211. /**
  53212. * Gets the uv input component
  53213. */
  53214. readonly uv: NodeMaterialConnectionPoint;
  53215. /**
  53216. * Gets the normal map color input component
  53217. */
  53218. readonly normalMapColor: NodeMaterialConnectionPoint;
  53219. /**
  53220. * Gets the strength input component
  53221. */
  53222. readonly strength: NodeMaterialConnectionPoint;
  53223. /**
  53224. * Gets the output component
  53225. */
  53226. readonly output: NodeMaterialConnectionPoint;
  53227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53228. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53229. autoConfigure(material: NodeMaterial): void;
  53230. protected _buildBlock(state: NodeMaterialBuildState): this;
  53231. protected _dumpPropertiesCode(): string;
  53232. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53233. }
  53234. }
  53235. declare module BABYLON {
  53236. /**
  53237. * Block used to discard a pixel if a value is smaller than a cutoff
  53238. */
  53239. export class DiscardBlock extends NodeMaterialBlock {
  53240. /**
  53241. * Create a new DiscardBlock
  53242. * @param name defines the block name
  53243. */
  53244. constructor(name: string);
  53245. /**
  53246. * Gets the current class name
  53247. * @returns the class name
  53248. */
  53249. getClassName(): string;
  53250. /**
  53251. * Gets the color input component
  53252. */
  53253. readonly value: NodeMaterialConnectionPoint;
  53254. /**
  53255. * Gets the cutoff input component
  53256. */
  53257. readonly cutoff: NodeMaterialConnectionPoint;
  53258. protected _buildBlock(state: NodeMaterialBuildState): this;
  53259. }
  53260. }
  53261. declare module BABYLON {
  53262. /**
  53263. * Block used to add support for scene fog
  53264. */
  53265. export class FogBlock extends NodeMaterialBlock {
  53266. private _fogDistanceName;
  53267. private _fogParameters;
  53268. /**
  53269. * Create a new FogBlock
  53270. * @param name defines the block name
  53271. */
  53272. constructor(name: string);
  53273. /**
  53274. * Gets the current class name
  53275. * @returns the class name
  53276. */
  53277. getClassName(): string;
  53278. /**
  53279. * Gets the world position input component
  53280. */
  53281. readonly worldPosition: NodeMaterialConnectionPoint;
  53282. /**
  53283. * Gets the view input component
  53284. */
  53285. readonly view: NodeMaterialConnectionPoint;
  53286. /**
  53287. * Gets the color input component
  53288. */
  53289. readonly input: NodeMaterialConnectionPoint;
  53290. /**
  53291. * Gets the fog color input component
  53292. */
  53293. readonly fogColor: NodeMaterialConnectionPoint;
  53294. /**
  53295. * Gets the output component
  53296. */
  53297. readonly output: NodeMaterialConnectionPoint;
  53298. autoConfigure(material: NodeMaterial): void;
  53299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53300. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53301. protected _buildBlock(state: NodeMaterialBuildState): this;
  53302. }
  53303. }
  53304. declare module BABYLON {
  53305. /**
  53306. * Block used to add light in the fragment shader
  53307. */
  53308. export class LightBlock extends NodeMaterialBlock {
  53309. private _lightId;
  53310. /**
  53311. * Gets or sets the light associated with this block
  53312. */
  53313. light: Nullable<Light>;
  53314. /**
  53315. * Create a new LightBlock
  53316. * @param name defines the block name
  53317. */
  53318. constructor(name: string);
  53319. /**
  53320. * Gets the current class name
  53321. * @returns the class name
  53322. */
  53323. getClassName(): string;
  53324. /**
  53325. * Gets the world position input component
  53326. */
  53327. readonly worldPosition: NodeMaterialConnectionPoint;
  53328. /**
  53329. * Gets the world normal input component
  53330. */
  53331. readonly worldNormal: NodeMaterialConnectionPoint;
  53332. /**
  53333. * Gets the camera (or eye) position component
  53334. */
  53335. readonly cameraPosition: NodeMaterialConnectionPoint;
  53336. /**
  53337. * Gets the glossiness component
  53338. */
  53339. readonly glossiness: NodeMaterialConnectionPoint;
  53340. /**
  53341. * Gets the glossinness power component
  53342. */
  53343. readonly glossPower: NodeMaterialConnectionPoint;
  53344. /**
  53345. * Gets the diffuse color component
  53346. */
  53347. readonly diffuseColor: NodeMaterialConnectionPoint;
  53348. /**
  53349. * Gets the specular color component
  53350. */
  53351. readonly specularColor: NodeMaterialConnectionPoint;
  53352. /**
  53353. * Gets the diffuse output component
  53354. */
  53355. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53356. /**
  53357. * Gets the specular output component
  53358. */
  53359. readonly specularOutput: NodeMaterialConnectionPoint;
  53360. autoConfigure(material: NodeMaterial): void;
  53361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53362. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53363. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53364. private _injectVertexCode;
  53365. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53366. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53367. }
  53368. }
  53369. declare module BABYLON {
  53370. /**
  53371. * Block used to multiply 2 values
  53372. */
  53373. export class MultiplyBlock extends NodeMaterialBlock {
  53374. /**
  53375. * Creates a new MultiplyBlock
  53376. * @param name defines the block name
  53377. */
  53378. constructor(name: string);
  53379. /**
  53380. * Gets the current class name
  53381. * @returns the class name
  53382. */
  53383. getClassName(): string;
  53384. /**
  53385. * Gets the left operand input component
  53386. */
  53387. readonly left: NodeMaterialConnectionPoint;
  53388. /**
  53389. * Gets the right operand input component
  53390. */
  53391. readonly right: NodeMaterialConnectionPoint;
  53392. /**
  53393. * Gets the output component
  53394. */
  53395. readonly output: NodeMaterialConnectionPoint;
  53396. protected _buildBlock(state: NodeMaterialBuildState): this;
  53397. }
  53398. }
  53399. declare module BABYLON {
  53400. /**
  53401. * Block used to add 2 vectors
  53402. */
  53403. export class AddBlock extends NodeMaterialBlock {
  53404. /**
  53405. * Creates a new AddBlock
  53406. * @param name defines the block name
  53407. */
  53408. constructor(name: string);
  53409. /**
  53410. * Gets the current class name
  53411. * @returns the class name
  53412. */
  53413. getClassName(): string;
  53414. /**
  53415. * Gets the left operand input component
  53416. */
  53417. readonly left: NodeMaterialConnectionPoint;
  53418. /**
  53419. * Gets the right operand input component
  53420. */
  53421. readonly right: NodeMaterialConnectionPoint;
  53422. /**
  53423. * Gets the output component
  53424. */
  53425. readonly output: NodeMaterialConnectionPoint;
  53426. protected _buildBlock(state: NodeMaterialBuildState): this;
  53427. }
  53428. }
  53429. declare module BABYLON {
  53430. /**
  53431. * Block used to scale a vector by a float
  53432. */
  53433. export class ScaleBlock extends NodeMaterialBlock {
  53434. /**
  53435. * Creates a new ScaleBlock
  53436. * @param name defines the block name
  53437. */
  53438. constructor(name: string);
  53439. /**
  53440. * Gets the current class name
  53441. * @returns the class name
  53442. */
  53443. getClassName(): string;
  53444. /**
  53445. * Gets the input component
  53446. */
  53447. readonly input: NodeMaterialConnectionPoint;
  53448. /**
  53449. * Gets the factor input component
  53450. */
  53451. readonly factor: NodeMaterialConnectionPoint;
  53452. /**
  53453. * Gets the output component
  53454. */
  53455. readonly output: NodeMaterialConnectionPoint;
  53456. protected _buildBlock(state: NodeMaterialBuildState): this;
  53457. }
  53458. }
  53459. declare module BABYLON {
  53460. /**
  53461. * Block used to clamp a float
  53462. */
  53463. export class ClampBlock extends NodeMaterialBlock {
  53464. /** Gets or sets the minimum range */
  53465. minimum: number;
  53466. /** Gets or sets the maximum range */
  53467. maximum: number;
  53468. /**
  53469. * Creates a new ClampBlock
  53470. * @param name defines the block name
  53471. */
  53472. constructor(name: string);
  53473. /**
  53474. * Gets the current class name
  53475. * @returns the class name
  53476. */
  53477. getClassName(): string;
  53478. /**
  53479. * Gets the value input component
  53480. */
  53481. readonly value: NodeMaterialConnectionPoint;
  53482. /**
  53483. * Gets the output component
  53484. */
  53485. readonly output: NodeMaterialConnectionPoint;
  53486. protected _buildBlock(state: NodeMaterialBuildState): this;
  53487. protected _dumpPropertiesCode(): string;
  53488. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53489. }
  53490. }
  53491. declare module BABYLON {
  53492. /**
  53493. * Block used to apply a cross product between 2 vectors
  53494. */
  53495. export class CrossBlock extends NodeMaterialBlock {
  53496. /**
  53497. * Creates a new CrossBlock
  53498. * @param name defines the block name
  53499. */
  53500. constructor(name: string);
  53501. /**
  53502. * Gets the current class name
  53503. * @returns the class name
  53504. */
  53505. getClassName(): string;
  53506. /**
  53507. * Gets the left operand input component
  53508. */
  53509. readonly left: NodeMaterialConnectionPoint;
  53510. /**
  53511. * Gets the right operand input component
  53512. */
  53513. readonly right: NodeMaterialConnectionPoint;
  53514. /**
  53515. * Gets the output component
  53516. */
  53517. readonly output: NodeMaterialConnectionPoint;
  53518. protected _buildBlock(state: NodeMaterialBuildState): this;
  53519. }
  53520. }
  53521. declare module BABYLON {
  53522. /**
  53523. * Block used to apply a dot product between 2 vectors
  53524. */
  53525. export class DotBlock extends NodeMaterialBlock {
  53526. /**
  53527. * Creates a new DotBlock
  53528. * @param name defines the block name
  53529. */
  53530. constructor(name: string);
  53531. /**
  53532. * Gets the current class name
  53533. * @returns the class name
  53534. */
  53535. getClassName(): string;
  53536. /**
  53537. * Gets the left operand input component
  53538. */
  53539. readonly left: NodeMaterialConnectionPoint;
  53540. /**
  53541. * Gets the right operand input component
  53542. */
  53543. readonly right: NodeMaterialConnectionPoint;
  53544. /**
  53545. * Gets the output component
  53546. */
  53547. readonly output: NodeMaterialConnectionPoint;
  53548. protected _buildBlock(state: NodeMaterialBuildState): this;
  53549. }
  53550. }
  53551. declare module BABYLON {
  53552. /**
  53553. * Block used to remap a float from a range to a new one
  53554. */
  53555. export class RemapBlock extends NodeMaterialBlock {
  53556. /**
  53557. * Gets or sets the source range
  53558. */
  53559. sourceRange: Vector2;
  53560. /**
  53561. * Gets or sets the target range
  53562. */
  53563. targetRange: Vector2;
  53564. /**
  53565. * Creates a new RemapBlock
  53566. * @param name defines the block name
  53567. */
  53568. constructor(name: string);
  53569. /**
  53570. * Gets the current class name
  53571. * @returns the class name
  53572. */
  53573. getClassName(): string;
  53574. /**
  53575. * Gets the input component
  53576. */
  53577. readonly input: NodeMaterialConnectionPoint;
  53578. /**
  53579. * Gets the source min input component
  53580. */
  53581. readonly sourceMin: NodeMaterialConnectionPoint;
  53582. /**
  53583. * Gets the source max input component
  53584. */
  53585. readonly sourceMax: NodeMaterialConnectionPoint;
  53586. /**
  53587. * Gets the target min input component
  53588. */
  53589. readonly targetMin: NodeMaterialConnectionPoint;
  53590. /**
  53591. * Gets the target max input component
  53592. */
  53593. readonly targetMax: NodeMaterialConnectionPoint;
  53594. /**
  53595. * Gets the output component
  53596. */
  53597. readonly output: NodeMaterialConnectionPoint;
  53598. protected _buildBlock(state: NodeMaterialBuildState): this;
  53599. protected _dumpPropertiesCode(): string;
  53600. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53601. }
  53602. }
  53603. declare module BABYLON {
  53604. /**
  53605. * Block used to normalize a vector
  53606. */
  53607. export class NormalizeBlock extends NodeMaterialBlock {
  53608. /**
  53609. * Creates a new NormalizeBlock
  53610. * @param name defines the block name
  53611. */
  53612. constructor(name: string);
  53613. /**
  53614. * Gets the current class name
  53615. * @returns the class name
  53616. */
  53617. getClassName(): string;
  53618. /**
  53619. * Gets the input component
  53620. */
  53621. readonly input: NodeMaterialConnectionPoint;
  53622. /**
  53623. * Gets the output component
  53624. */
  53625. readonly output: NodeMaterialConnectionPoint;
  53626. protected _buildBlock(state: NodeMaterialBuildState): this;
  53627. }
  53628. }
  53629. declare module BABYLON {
  53630. /**
  53631. * Operations supported by the Trigonometry block
  53632. */
  53633. export enum TrigonometryBlockOperations {
  53634. /** Cos */
  53635. Cos = 0,
  53636. /** Sin */
  53637. Sin = 1,
  53638. /** Abs */
  53639. Abs = 2,
  53640. /** Exp */
  53641. Exp = 3,
  53642. /** Exp2 */
  53643. Exp2 = 4,
  53644. /** Round */
  53645. Round = 5,
  53646. /** Floor */
  53647. Floor = 6,
  53648. /** Ceiling */
  53649. Ceiling = 7,
  53650. /** Square root */
  53651. Sqrt = 8,
  53652. /** Log */
  53653. Log = 9,
  53654. /** Tangent */
  53655. Tan = 10,
  53656. /** Arc tangent */
  53657. ATan = 11,
  53658. /** Arc cosinus */
  53659. ACos = 12,
  53660. /** Arc sinus */
  53661. ASin = 13,
  53662. /** Fraction */
  53663. Fract = 14,
  53664. /** Sign */
  53665. Sign = 15
  53666. }
  53667. /**
  53668. * Block used to apply trigonometry operation to floats
  53669. */
  53670. export class TrigonometryBlock extends NodeMaterialBlock {
  53671. /**
  53672. * Gets or sets the operation applied by the block
  53673. */
  53674. operation: TrigonometryBlockOperations;
  53675. /**
  53676. * Creates a new TrigonometryBlock
  53677. * @param name defines the block name
  53678. */
  53679. constructor(name: string);
  53680. /**
  53681. * Gets the current class name
  53682. * @returns the class name
  53683. */
  53684. getClassName(): string;
  53685. /**
  53686. * Gets the input component
  53687. */
  53688. readonly input: NodeMaterialConnectionPoint;
  53689. /**
  53690. * Gets the output component
  53691. */
  53692. readonly output: NodeMaterialConnectionPoint;
  53693. protected _buildBlock(state: NodeMaterialBuildState): this;
  53694. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53695. }
  53696. }
  53697. declare module BABYLON {
  53698. /**
  53699. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53700. */
  53701. export class ColorMergerBlock extends NodeMaterialBlock {
  53702. /**
  53703. * Create a new ColorMergerBlock
  53704. * @param name defines the block name
  53705. */
  53706. constructor(name: string);
  53707. /**
  53708. * Gets the current class name
  53709. * @returns the class name
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Gets the r component (input)
  53714. */
  53715. readonly r: NodeMaterialConnectionPoint;
  53716. /**
  53717. * Gets the g component (input)
  53718. */
  53719. readonly g: NodeMaterialConnectionPoint;
  53720. /**
  53721. * Gets the b component (input)
  53722. */
  53723. readonly b: NodeMaterialConnectionPoint;
  53724. /**
  53725. * Gets the a component (input)
  53726. */
  53727. readonly a: NodeMaterialConnectionPoint;
  53728. /**
  53729. * Gets the rgba component (output)
  53730. */
  53731. readonly rgba: NodeMaterialConnectionPoint;
  53732. /**
  53733. * Gets the rgb component (output)
  53734. */
  53735. readonly rgb: NodeMaterialConnectionPoint;
  53736. protected _buildBlock(state: NodeMaterialBuildState): this;
  53737. }
  53738. }
  53739. declare module BABYLON {
  53740. /**
  53741. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53742. */
  53743. export class VectorMergerBlock extends NodeMaterialBlock {
  53744. /**
  53745. * Create a new VectorMergerBlock
  53746. * @param name defines the block name
  53747. */
  53748. constructor(name: string);
  53749. /**
  53750. * Gets the current class name
  53751. * @returns the class name
  53752. */
  53753. getClassName(): string;
  53754. /**
  53755. * Gets the x component (input)
  53756. */
  53757. readonly x: NodeMaterialConnectionPoint;
  53758. /**
  53759. * Gets the y component (input)
  53760. */
  53761. readonly y: NodeMaterialConnectionPoint;
  53762. /**
  53763. * Gets the z component (input)
  53764. */
  53765. readonly z: NodeMaterialConnectionPoint;
  53766. /**
  53767. * Gets the w component (input)
  53768. */
  53769. readonly w: NodeMaterialConnectionPoint;
  53770. /**
  53771. * Gets the xyzw component (output)
  53772. */
  53773. readonly xyzw: NodeMaterialConnectionPoint;
  53774. /**
  53775. * Gets the xyz component (output)
  53776. */
  53777. readonly xyz: NodeMaterialConnectionPoint;
  53778. /**
  53779. * Gets the xy component (output)
  53780. */
  53781. readonly xy: NodeMaterialConnectionPoint;
  53782. protected _buildBlock(state: NodeMaterialBuildState): this;
  53783. }
  53784. }
  53785. declare module BABYLON {
  53786. /**
  53787. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53788. */
  53789. export class ColorSplitterBlock extends NodeMaterialBlock {
  53790. /**
  53791. * Create a new ColorSplitterBlock
  53792. * @param name defines the block name
  53793. */
  53794. constructor(name: string);
  53795. /**
  53796. * Gets the current class name
  53797. * @returns the class name
  53798. */
  53799. getClassName(): string;
  53800. /**
  53801. * Gets the rgba component (input)
  53802. */
  53803. readonly rgba: NodeMaterialConnectionPoint;
  53804. /**
  53805. * Gets the rgb component (input)
  53806. */
  53807. readonly rgbIn: NodeMaterialConnectionPoint;
  53808. /**
  53809. * Gets the rgb component (output)
  53810. */
  53811. readonly rgbOut: NodeMaterialConnectionPoint;
  53812. /**
  53813. * Gets the r component (output)
  53814. */
  53815. readonly r: NodeMaterialConnectionPoint;
  53816. /**
  53817. * Gets the g component (output)
  53818. */
  53819. readonly g: NodeMaterialConnectionPoint;
  53820. /**
  53821. * Gets the b component (output)
  53822. */
  53823. readonly b: NodeMaterialConnectionPoint;
  53824. /**
  53825. * Gets the a component (output)
  53826. */
  53827. readonly a: NodeMaterialConnectionPoint;
  53828. protected _inputRename(name: string): string;
  53829. protected _outputRename(name: string): string;
  53830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53831. }
  53832. }
  53833. declare module BABYLON {
  53834. /**
  53835. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53836. */
  53837. export class VectorSplitterBlock extends NodeMaterialBlock {
  53838. /**
  53839. * Create a new VectorSplitterBlock
  53840. * @param name defines the block name
  53841. */
  53842. constructor(name: string);
  53843. /**
  53844. * Gets the current class name
  53845. * @returns the class name
  53846. */
  53847. getClassName(): string;
  53848. /**
  53849. * Gets the xyzw component (input)
  53850. */
  53851. readonly xyzw: NodeMaterialConnectionPoint;
  53852. /**
  53853. * Gets the xyz component (input)
  53854. */
  53855. readonly xyzIn: NodeMaterialConnectionPoint;
  53856. /**
  53857. * Gets the xy component (input)
  53858. */
  53859. readonly xyIn: NodeMaterialConnectionPoint;
  53860. /**
  53861. * Gets the xyz component (output)
  53862. */
  53863. readonly xyzOut: NodeMaterialConnectionPoint;
  53864. /**
  53865. * Gets the xy component (output)
  53866. */
  53867. readonly xyOut: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the x component (output)
  53870. */
  53871. readonly x: NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets the y component (output)
  53874. */
  53875. readonly y: NodeMaterialConnectionPoint;
  53876. /**
  53877. * Gets the z component (output)
  53878. */
  53879. readonly z: NodeMaterialConnectionPoint;
  53880. /**
  53881. * Gets the w component (output)
  53882. */
  53883. readonly w: NodeMaterialConnectionPoint;
  53884. protected _inputRename(name: string): string;
  53885. protected _outputRename(name: string): string;
  53886. protected _buildBlock(state: NodeMaterialBuildState): this;
  53887. }
  53888. }
  53889. declare module BABYLON {
  53890. /**
  53891. * Block used to lerp 2 values
  53892. */
  53893. export class LerpBlock extends NodeMaterialBlock {
  53894. /**
  53895. * Creates a new LerpBlock
  53896. * @param name defines the block name
  53897. */
  53898. constructor(name: string);
  53899. /**
  53900. * Gets the current class name
  53901. * @returns the class name
  53902. */
  53903. getClassName(): string;
  53904. /**
  53905. * Gets the left operand input component
  53906. */
  53907. readonly left: NodeMaterialConnectionPoint;
  53908. /**
  53909. * Gets the right operand input component
  53910. */
  53911. readonly right: NodeMaterialConnectionPoint;
  53912. /**
  53913. * Gets the gradient operand input component
  53914. */
  53915. readonly gradient: NodeMaterialConnectionPoint;
  53916. /**
  53917. * Gets the output component
  53918. */
  53919. readonly output: NodeMaterialConnectionPoint;
  53920. protected _buildBlock(state: NodeMaterialBuildState): this;
  53921. }
  53922. }
  53923. declare module BABYLON {
  53924. /**
  53925. * Block used to divide 2 vectors
  53926. */
  53927. export class DivideBlock extends NodeMaterialBlock {
  53928. /**
  53929. * Creates a new DivideBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the left operand input component
  53940. */
  53941. readonly left: NodeMaterialConnectionPoint;
  53942. /**
  53943. * Gets the right operand input component
  53944. */
  53945. readonly right: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the output component
  53948. */
  53949. readonly output: NodeMaterialConnectionPoint;
  53950. protected _buildBlock(state: NodeMaterialBuildState): this;
  53951. }
  53952. }
  53953. declare module BABYLON {
  53954. /**
  53955. * Block used to subtract 2 vectors
  53956. */
  53957. export class SubtractBlock extends NodeMaterialBlock {
  53958. /**
  53959. * Creates a new SubtractBlock
  53960. * @param name defines the block name
  53961. */
  53962. constructor(name: string);
  53963. /**
  53964. * Gets the current class name
  53965. * @returns the class name
  53966. */
  53967. getClassName(): string;
  53968. /**
  53969. * Gets the left operand input component
  53970. */
  53971. readonly left: NodeMaterialConnectionPoint;
  53972. /**
  53973. * Gets the right operand input component
  53974. */
  53975. readonly right: NodeMaterialConnectionPoint;
  53976. /**
  53977. * Gets the output component
  53978. */
  53979. readonly output: NodeMaterialConnectionPoint;
  53980. protected _buildBlock(state: NodeMaterialBuildState): this;
  53981. }
  53982. }
  53983. declare module BABYLON {
  53984. /**
  53985. * Block used to step a value
  53986. */
  53987. export class StepBlock extends NodeMaterialBlock {
  53988. /**
  53989. * Creates a new AddBlock
  53990. * @param name defines the block name
  53991. */
  53992. constructor(name: string);
  53993. /**
  53994. * Gets the current class name
  53995. * @returns the class name
  53996. */
  53997. getClassName(): string;
  53998. /**
  53999. * Gets the value operand input component
  54000. */
  54001. readonly value: NodeMaterialConnectionPoint;
  54002. /**
  54003. * Gets the edge operand input component
  54004. */
  54005. readonly edge: NodeMaterialConnectionPoint;
  54006. /**
  54007. * Gets the output component
  54008. */
  54009. readonly output: NodeMaterialConnectionPoint;
  54010. protected _buildBlock(state: NodeMaterialBuildState): this;
  54011. }
  54012. }
  54013. declare module BABYLON {
  54014. /**
  54015. * Block used to get the opposite (1 - x) of a value
  54016. */
  54017. export class OneMinusBlock extends NodeMaterialBlock {
  54018. /**
  54019. * Creates a new OneMinusBlock
  54020. * @param name defines the block name
  54021. */
  54022. constructor(name: string);
  54023. /**
  54024. * Gets the current class name
  54025. * @returns the class name
  54026. */
  54027. getClassName(): string;
  54028. /**
  54029. * Gets the input component
  54030. */
  54031. readonly input: NodeMaterialConnectionPoint;
  54032. /**
  54033. * Gets the output component
  54034. */
  54035. readonly output: NodeMaterialConnectionPoint;
  54036. protected _buildBlock(state: NodeMaterialBuildState): this;
  54037. }
  54038. }
  54039. declare module BABYLON {
  54040. /**
  54041. * Block used to get the view direction
  54042. */
  54043. export class ViewDirectionBlock extends NodeMaterialBlock {
  54044. /**
  54045. * Creates a new ViewDirectionBlock
  54046. * @param name defines the block name
  54047. */
  54048. constructor(name: string);
  54049. /**
  54050. * Gets the current class name
  54051. * @returns the class name
  54052. */
  54053. getClassName(): string;
  54054. /**
  54055. * Gets the world position component
  54056. */
  54057. readonly worldPosition: NodeMaterialConnectionPoint;
  54058. /**
  54059. * Gets the camera position component
  54060. */
  54061. readonly cameraPosition: NodeMaterialConnectionPoint;
  54062. /**
  54063. * Gets the output component
  54064. */
  54065. readonly output: NodeMaterialConnectionPoint;
  54066. autoConfigure(material: NodeMaterial): void;
  54067. protected _buildBlock(state: NodeMaterialBuildState): this;
  54068. }
  54069. }
  54070. declare module BABYLON {
  54071. /**
  54072. * Block used to compute fresnel value
  54073. */
  54074. export class FresnelBlock extends NodeMaterialBlock {
  54075. /**
  54076. * Create a new FresnelBlock
  54077. * @param name defines the block name
  54078. */
  54079. constructor(name: string);
  54080. /**
  54081. * Gets the current class name
  54082. * @returns the class name
  54083. */
  54084. getClassName(): string;
  54085. /**
  54086. * Gets the world normal input component
  54087. */
  54088. readonly worldNormal: NodeMaterialConnectionPoint;
  54089. /**
  54090. * Gets the view direction input component
  54091. */
  54092. readonly viewDirection: NodeMaterialConnectionPoint;
  54093. /**
  54094. * Gets the bias input component
  54095. */
  54096. readonly bias: NodeMaterialConnectionPoint;
  54097. /**
  54098. * Gets the camera (or eye) position component
  54099. */
  54100. readonly power: NodeMaterialConnectionPoint;
  54101. /**
  54102. * Gets the fresnel output component
  54103. */
  54104. readonly fresnel: NodeMaterialConnectionPoint;
  54105. autoConfigure(material: NodeMaterial): void;
  54106. protected _buildBlock(state: NodeMaterialBuildState): this;
  54107. }
  54108. }
  54109. declare module BABYLON {
  54110. /**
  54111. * Block used to get the max of 2 values
  54112. */
  54113. export class MaxBlock extends NodeMaterialBlock {
  54114. /**
  54115. * Creates a new MaxBlock
  54116. * @param name defines the block name
  54117. */
  54118. constructor(name: string);
  54119. /**
  54120. * Gets the current class name
  54121. * @returns the class name
  54122. */
  54123. getClassName(): string;
  54124. /**
  54125. * Gets the left operand input component
  54126. */
  54127. readonly left: NodeMaterialConnectionPoint;
  54128. /**
  54129. * Gets the right operand input component
  54130. */
  54131. readonly right: NodeMaterialConnectionPoint;
  54132. /**
  54133. * Gets the output component
  54134. */
  54135. readonly output: NodeMaterialConnectionPoint;
  54136. protected _buildBlock(state: NodeMaterialBuildState): this;
  54137. }
  54138. }
  54139. declare module BABYLON {
  54140. /**
  54141. * Block used to get the min of 2 values
  54142. */
  54143. export class MinBlock extends NodeMaterialBlock {
  54144. /**
  54145. * Creates a new MinBlock
  54146. * @param name defines the block name
  54147. */
  54148. constructor(name: string);
  54149. /**
  54150. * Gets the current class name
  54151. * @returns the class name
  54152. */
  54153. getClassName(): string;
  54154. /**
  54155. * Gets the left operand input component
  54156. */
  54157. readonly left: NodeMaterialConnectionPoint;
  54158. /**
  54159. * Gets the right operand input component
  54160. */
  54161. readonly right: NodeMaterialConnectionPoint;
  54162. /**
  54163. * Gets the output component
  54164. */
  54165. readonly output: NodeMaterialConnectionPoint;
  54166. protected _buildBlock(state: NodeMaterialBuildState): this;
  54167. }
  54168. }
  54169. declare module BABYLON {
  54170. /**
  54171. * Block used to get the distance between 2 values
  54172. */
  54173. export class DistanceBlock extends NodeMaterialBlock {
  54174. /**
  54175. * Creates a new DistanceBlock
  54176. * @param name defines the block name
  54177. */
  54178. constructor(name: string);
  54179. /**
  54180. * Gets the current class name
  54181. * @returns the class name
  54182. */
  54183. getClassName(): string;
  54184. /**
  54185. * Gets the left operand input component
  54186. */
  54187. readonly left: NodeMaterialConnectionPoint;
  54188. /**
  54189. * Gets the right operand input component
  54190. */
  54191. readonly right: NodeMaterialConnectionPoint;
  54192. /**
  54193. * Gets the output component
  54194. */
  54195. readonly output: NodeMaterialConnectionPoint;
  54196. protected _buildBlock(state: NodeMaterialBuildState): this;
  54197. }
  54198. }
  54199. declare module BABYLON {
  54200. /**
  54201. * Block used to get the length of a vector
  54202. */
  54203. export class LengthBlock extends NodeMaterialBlock {
  54204. /**
  54205. * Creates a new LengthBlock
  54206. * @param name defines the block name
  54207. */
  54208. constructor(name: string);
  54209. /**
  54210. * Gets the current class name
  54211. * @returns the class name
  54212. */
  54213. getClassName(): string;
  54214. /**
  54215. * Gets the value input component
  54216. */
  54217. readonly value: NodeMaterialConnectionPoint;
  54218. /**
  54219. * Gets the output component
  54220. */
  54221. readonly output: NodeMaterialConnectionPoint;
  54222. protected _buildBlock(state: NodeMaterialBuildState): this;
  54223. }
  54224. }
  54225. declare module BABYLON {
  54226. /**
  54227. * Block used to get negative version of a value (i.e. x * -1)
  54228. */
  54229. export class NegateBlock extends NodeMaterialBlock {
  54230. /**
  54231. * Creates a new NegateBlock
  54232. * @param name defines the block name
  54233. */
  54234. constructor(name: string);
  54235. /**
  54236. * Gets the current class name
  54237. * @returns the class name
  54238. */
  54239. getClassName(): string;
  54240. /**
  54241. * Gets the value input component
  54242. */
  54243. readonly value: NodeMaterialConnectionPoint;
  54244. /**
  54245. * Gets the output component
  54246. */
  54247. readonly output: NodeMaterialConnectionPoint;
  54248. protected _buildBlock(state: NodeMaterialBuildState): this;
  54249. }
  54250. }
  54251. declare module BABYLON {
  54252. /**
  54253. * Block used to get the value of the first parameter raised to the power of the second
  54254. */
  54255. export class PowBlock extends NodeMaterialBlock {
  54256. /**
  54257. * Creates a new PowBlock
  54258. * @param name defines the block name
  54259. */
  54260. constructor(name: string);
  54261. /**
  54262. * Gets the current class name
  54263. * @returns the class name
  54264. */
  54265. getClassName(): string;
  54266. /**
  54267. * Gets the value operand input component
  54268. */
  54269. readonly value: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the power operand input component
  54272. */
  54273. readonly power: NodeMaterialConnectionPoint;
  54274. /**
  54275. * Gets the output component
  54276. */
  54277. readonly output: NodeMaterialConnectionPoint;
  54278. protected _buildBlock(state: NodeMaterialBuildState): this;
  54279. }
  54280. }
  54281. declare module BABYLON {
  54282. /**
  54283. * Block used to get a random number
  54284. */
  54285. export class RandomNumberBlock extends NodeMaterialBlock {
  54286. /**
  54287. * Creates a new RandomNumberBlock
  54288. * @param name defines the block name
  54289. */
  54290. constructor(name: string);
  54291. /**
  54292. * Gets the current class name
  54293. * @returns the class name
  54294. */
  54295. getClassName(): string;
  54296. /**
  54297. * Gets the seed input component
  54298. */
  54299. readonly seed: NodeMaterialConnectionPoint;
  54300. /**
  54301. * Gets the output component
  54302. */
  54303. readonly output: NodeMaterialConnectionPoint;
  54304. protected _buildBlock(state: NodeMaterialBuildState): this;
  54305. }
  54306. }
  54307. declare module BABYLON {
  54308. /**
  54309. * Effect Render Options
  54310. */
  54311. export interface IEffectRendererOptions {
  54312. /**
  54313. * Defines the vertices positions.
  54314. */
  54315. positions?: number[];
  54316. /**
  54317. * Defines the indices.
  54318. */
  54319. indices?: number[];
  54320. }
  54321. /**
  54322. * Helper class to render one or more effects
  54323. */
  54324. export class EffectRenderer {
  54325. private engine;
  54326. private static _DefaultOptions;
  54327. private _vertexBuffers;
  54328. private _indexBuffer;
  54329. private _ringBufferIndex;
  54330. private _ringScreenBuffer;
  54331. private _fullscreenViewport;
  54332. private _getNextFrameBuffer;
  54333. /**
  54334. * Creates an effect renderer
  54335. * @param engine the engine to use for rendering
  54336. * @param options defines the options of the effect renderer
  54337. */
  54338. constructor(engine: Engine, options?: IEffectRendererOptions);
  54339. /**
  54340. * Sets the current viewport in normalized coordinates 0-1
  54341. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54342. */
  54343. setViewport(viewport?: Viewport): void;
  54344. /**
  54345. * Binds the embedded attributes buffer to the effect.
  54346. * @param effect Defines the effect to bind the attributes for
  54347. */
  54348. bindBuffers(effect: Effect): void;
  54349. /**
  54350. * Sets the current effect wrapper to use during draw.
  54351. * The effect needs to be ready before calling this api.
  54352. * This also sets the default full screen position attribute.
  54353. * @param effectWrapper Defines the effect to draw with
  54354. */
  54355. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54356. /**
  54357. * Draws a full screen quad.
  54358. */
  54359. draw(): void;
  54360. /**
  54361. * renders one or more effects to a specified texture
  54362. * @param effectWrappers list of effects to renderer
  54363. * @param outputTexture texture to draw to, if null it will render to the screen
  54364. */
  54365. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54366. /**
  54367. * Disposes of the effect renderer
  54368. */
  54369. dispose(): void;
  54370. }
  54371. /**
  54372. * Options to create an EffectWrapper
  54373. */
  54374. interface EffectWrapperCreationOptions {
  54375. /**
  54376. * Engine to use to create the effect
  54377. */
  54378. engine: Engine;
  54379. /**
  54380. * Fragment shader for the effect
  54381. */
  54382. fragmentShader: string;
  54383. /**
  54384. * Vertex shader for the effect
  54385. */
  54386. vertexShader?: string;
  54387. /**
  54388. * Attributes to use in the shader
  54389. */
  54390. attributeNames?: Array<string>;
  54391. /**
  54392. * Uniforms to use in the shader
  54393. */
  54394. uniformNames?: Array<string>;
  54395. /**
  54396. * Texture sampler names to use in the shader
  54397. */
  54398. samplerNames?: Array<string>;
  54399. /**
  54400. * The friendly name of the effect displayed in Spector.
  54401. */
  54402. name?: string;
  54403. }
  54404. /**
  54405. * Wraps an effect to be used for rendering
  54406. */
  54407. export class EffectWrapper {
  54408. /**
  54409. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54410. */
  54411. onApplyObservable: Observable<{}>;
  54412. /**
  54413. * The underlying effect
  54414. */
  54415. effect: Effect;
  54416. /**
  54417. * Creates an effect to be renderer
  54418. * @param creationOptions options to create the effect
  54419. */
  54420. constructor(creationOptions: EffectWrapperCreationOptions);
  54421. /**
  54422. * Disposes of the effect wrapper
  54423. */
  54424. dispose(): void;
  54425. }
  54426. }
  54427. declare module BABYLON {
  54428. /**
  54429. * Helper class to push actions to a pool of workers.
  54430. */
  54431. export class WorkerPool implements IDisposable {
  54432. private _workerInfos;
  54433. private _pendingActions;
  54434. /**
  54435. * Constructor
  54436. * @param workers Array of workers to use for actions
  54437. */
  54438. constructor(workers: Array<Worker>);
  54439. /**
  54440. * Terminates all workers and clears any pending actions.
  54441. */
  54442. dispose(): void;
  54443. /**
  54444. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54445. * pended until a worker has completed its action.
  54446. * @param action The action to perform. Call onComplete when the action is complete.
  54447. */
  54448. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54449. private _execute;
  54450. }
  54451. }
  54452. declare module BABYLON {
  54453. /**
  54454. * Configuration for Draco compression
  54455. */
  54456. export interface IDracoCompressionConfiguration {
  54457. /**
  54458. * Configuration for the decoder.
  54459. */
  54460. decoder: {
  54461. /**
  54462. * The url to the WebAssembly module.
  54463. */
  54464. wasmUrl?: string;
  54465. /**
  54466. * The url to the WebAssembly binary.
  54467. */
  54468. wasmBinaryUrl?: string;
  54469. /**
  54470. * The url to the fallback JavaScript module.
  54471. */
  54472. fallbackUrl?: string;
  54473. };
  54474. }
  54475. /**
  54476. * Draco compression (https://google.github.io/draco/)
  54477. *
  54478. * This class wraps the Draco module.
  54479. *
  54480. * **Encoder**
  54481. *
  54482. * The encoder is not currently implemented.
  54483. *
  54484. * **Decoder**
  54485. *
  54486. * 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.
  54487. *
  54488. * To update the configuration, use the following code:
  54489. * ```javascript
  54490. * DracoCompression.Configuration = {
  54491. * decoder: {
  54492. * wasmUrl: "<url to the WebAssembly library>",
  54493. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54494. * fallbackUrl: "<url to the fallback JavaScript library>",
  54495. * }
  54496. * };
  54497. * ```
  54498. *
  54499. * 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.
  54500. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54501. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54502. *
  54503. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54504. * ```javascript
  54505. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54506. * ```
  54507. *
  54508. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54509. */
  54510. export class DracoCompression implements IDisposable {
  54511. private _workerPoolPromise?;
  54512. private _decoderModulePromise?;
  54513. /**
  54514. * The configuration. Defaults to the following urls:
  54515. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54516. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54517. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54518. */
  54519. static Configuration: IDracoCompressionConfiguration;
  54520. /**
  54521. * Returns true if the decoder configuration is available.
  54522. */
  54523. static readonly DecoderAvailable: boolean;
  54524. /**
  54525. * Default number of workers to create when creating the draco compression object.
  54526. */
  54527. static DefaultNumWorkers: number;
  54528. private static GetDefaultNumWorkers;
  54529. private static _Default;
  54530. /**
  54531. * Default instance for the draco compression object.
  54532. */
  54533. static readonly Default: DracoCompression;
  54534. /**
  54535. * Constructor
  54536. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54537. */
  54538. constructor(numWorkers?: number);
  54539. /**
  54540. * Stop all async operations and release resources.
  54541. */
  54542. dispose(): void;
  54543. /**
  54544. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54545. * @returns a promise that resolves when ready
  54546. */
  54547. whenReadyAsync(): Promise<void>;
  54548. /**
  54549. * Decode Draco compressed mesh data to vertex data.
  54550. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54551. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54552. * @returns A promise that resolves with the decoded vertex data
  54553. */
  54554. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54555. [kind: string]: number;
  54556. }): Promise<VertexData>;
  54557. }
  54558. }
  54559. declare module BABYLON {
  54560. /**
  54561. * Class for building Constructive Solid Geometry
  54562. */
  54563. export class CSG {
  54564. private polygons;
  54565. /**
  54566. * The world matrix
  54567. */
  54568. matrix: Matrix;
  54569. /**
  54570. * Stores the position
  54571. */
  54572. position: Vector3;
  54573. /**
  54574. * Stores the rotation
  54575. */
  54576. rotation: Vector3;
  54577. /**
  54578. * Stores the rotation quaternion
  54579. */
  54580. rotationQuaternion: Nullable<Quaternion>;
  54581. /**
  54582. * Stores the scaling vector
  54583. */
  54584. scaling: Vector3;
  54585. /**
  54586. * Convert the Mesh to CSG
  54587. * @param mesh The Mesh to convert to CSG
  54588. * @returns A new CSG from the Mesh
  54589. */
  54590. static FromMesh(mesh: Mesh): CSG;
  54591. /**
  54592. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54593. * @param polygons Polygons used to construct a CSG solid
  54594. */
  54595. private static FromPolygons;
  54596. /**
  54597. * Clones, or makes a deep copy, of the CSG
  54598. * @returns A new CSG
  54599. */
  54600. clone(): CSG;
  54601. /**
  54602. * Unions this CSG with another CSG
  54603. * @param csg The CSG to union against this CSG
  54604. * @returns The unioned CSG
  54605. */
  54606. union(csg: CSG): CSG;
  54607. /**
  54608. * Unions this CSG with another CSG in place
  54609. * @param csg The CSG to union against this CSG
  54610. */
  54611. unionInPlace(csg: CSG): void;
  54612. /**
  54613. * Subtracts this CSG with another CSG
  54614. * @param csg The CSG to subtract against this CSG
  54615. * @returns A new CSG
  54616. */
  54617. subtract(csg: CSG): CSG;
  54618. /**
  54619. * Subtracts this CSG with another CSG in place
  54620. * @param csg The CSG to subtact against this CSG
  54621. */
  54622. subtractInPlace(csg: CSG): void;
  54623. /**
  54624. * Intersect this CSG with another CSG
  54625. * @param csg The CSG to intersect against this CSG
  54626. * @returns A new CSG
  54627. */
  54628. intersect(csg: CSG): CSG;
  54629. /**
  54630. * Intersects this CSG with another CSG in place
  54631. * @param csg The CSG to intersect against this CSG
  54632. */
  54633. intersectInPlace(csg: CSG): void;
  54634. /**
  54635. * Return a new CSG solid with solid and empty space switched. This solid is
  54636. * not modified.
  54637. * @returns A new CSG solid with solid and empty space switched
  54638. */
  54639. inverse(): CSG;
  54640. /**
  54641. * Inverses the CSG in place
  54642. */
  54643. inverseInPlace(): void;
  54644. /**
  54645. * This is used to keep meshes transformations so they can be restored
  54646. * when we build back a Babylon Mesh
  54647. * NB : All CSG operations are performed in world coordinates
  54648. * @param csg The CSG to copy the transform attributes from
  54649. * @returns This CSG
  54650. */
  54651. copyTransformAttributes(csg: CSG): CSG;
  54652. /**
  54653. * Build Raw mesh from CSG
  54654. * Coordinates here are in world space
  54655. * @param name The name of the mesh geometry
  54656. * @param scene The Scene
  54657. * @param keepSubMeshes Specifies if the submeshes should be kept
  54658. * @returns A new Mesh
  54659. */
  54660. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54661. /**
  54662. * Build Mesh from CSG taking material and transforms into account
  54663. * @param name The name of the Mesh
  54664. * @param material The material of the Mesh
  54665. * @param scene The Scene
  54666. * @param keepSubMeshes Specifies if submeshes should be kept
  54667. * @returns The new Mesh
  54668. */
  54669. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54670. }
  54671. }
  54672. declare module BABYLON {
  54673. /**
  54674. * Class used to create a trail following a mesh
  54675. */
  54676. export class TrailMesh extends Mesh {
  54677. private _generator;
  54678. private _autoStart;
  54679. private _running;
  54680. private _diameter;
  54681. private _length;
  54682. private _sectionPolygonPointsCount;
  54683. private _sectionVectors;
  54684. private _sectionNormalVectors;
  54685. private _beforeRenderObserver;
  54686. /**
  54687. * @constructor
  54688. * @param name The value used by scene.getMeshByName() to do a lookup.
  54689. * @param generator The mesh to generate a trail.
  54690. * @param scene The scene to add this mesh to.
  54691. * @param diameter Diameter of trailing mesh. Default is 1.
  54692. * @param length Length of trailing mesh. Default is 60.
  54693. * @param autoStart Automatically start trailing mesh. Default true.
  54694. */
  54695. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54696. /**
  54697. * "TrailMesh"
  54698. * @returns "TrailMesh"
  54699. */
  54700. getClassName(): string;
  54701. private _createMesh;
  54702. /**
  54703. * Start trailing mesh.
  54704. */
  54705. start(): void;
  54706. /**
  54707. * Stop trailing mesh.
  54708. */
  54709. stop(): void;
  54710. /**
  54711. * Update trailing mesh geometry.
  54712. */
  54713. update(): void;
  54714. /**
  54715. * Returns a new TrailMesh object.
  54716. * @param name is a string, the name given to the new mesh
  54717. * @param newGenerator use new generator object for cloned trail mesh
  54718. * @returns a new mesh
  54719. */
  54720. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54721. /**
  54722. * Serializes this trail mesh
  54723. * @param serializationObject object to write serialization to
  54724. */
  54725. serialize(serializationObject: any): void;
  54726. /**
  54727. * Parses a serialized trail mesh
  54728. * @param parsedMesh the serialized mesh
  54729. * @param scene the scene to create the trail mesh in
  54730. * @returns the created trail mesh
  54731. */
  54732. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54733. }
  54734. }
  54735. declare module BABYLON {
  54736. /**
  54737. * Class containing static functions to help procedurally build meshes
  54738. */
  54739. export class TiledBoxBuilder {
  54740. /**
  54741. * Creates a box mesh
  54742. * 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)
  54743. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54745. * * 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
  54746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54747. * @param name defines the name of the mesh
  54748. * @param options defines the options used to create the mesh
  54749. * @param scene defines the hosting scene
  54750. * @returns the box mesh
  54751. */
  54752. static CreateTiledBox(name: string, options: {
  54753. pattern?: number;
  54754. width?: number;
  54755. height?: number;
  54756. depth?: number;
  54757. tileSize?: number;
  54758. tileWidth?: number;
  54759. tileHeight?: number;
  54760. alignHorizontal?: number;
  54761. alignVertical?: number;
  54762. faceUV?: Vector4[];
  54763. faceColors?: Color4[];
  54764. sideOrientation?: number;
  54765. updatable?: boolean;
  54766. }, scene?: Nullable<Scene>): Mesh;
  54767. }
  54768. }
  54769. declare module BABYLON {
  54770. /**
  54771. * Class containing static functions to help procedurally build meshes
  54772. */
  54773. export class TorusKnotBuilder {
  54774. /**
  54775. * Creates a torus knot mesh
  54776. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54777. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54778. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54779. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54781. * * 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
  54782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54783. * @param name defines the name of the mesh
  54784. * @param options defines the options used to create the mesh
  54785. * @param scene defines the hosting scene
  54786. * @returns the torus knot mesh
  54787. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54788. */
  54789. static CreateTorusKnot(name: string, options: {
  54790. radius?: number;
  54791. tube?: number;
  54792. radialSegments?: number;
  54793. tubularSegments?: number;
  54794. p?: number;
  54795. q?: number;
  54796. updatable?: boolean;
  54797. sideOrientation?: number;
  54798. frontUVs?: Vector4;
  54799. backUVs?: Vector4;
  54800. }, scene: any): Mesh;
  54801. }
  54802. }
  54803. declare module BABYLON {
  54804. /**
  54805. * Polygon
  54806. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54807. */
  54808. export class Polygon {
  54809. /**
  54810. * Creates a rectangle
  54811. * @param xmin bottom X coord
  54812. * @param ymin bottom Y coord
  54813. * @param xmax top X coord
  54814. * @param ymax top Y coord
  54815. * @returns points that make the resulting rectation
  54816. */
  54817. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54818. /**
  54819. * Creates a circle
  54820. * @param radius radius of circle
  54821. * @param cx scale in x
  54822. * @param cy scale in y
  54823. * @param numberOfSides number of sides that make up the circle
  54824. * @returns points that make the resulting circle
  54825. */
  54826. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54827. /**
  54828. * Creates a polygon from input string
  54829. * @param input Input polygon data
  54830. * @returns the parsed points
  54831. */
  54832. static Parse(input: string): Vector2[];
  54833. /**
  54834. * Starts building a polygon from x and y coordinates
  54835. * @param x x coordinate
  54836. * @param y y coordinate
  54837. * @returns the started path2
  54838. */
  54839. static StartingAt(x: number, y: number): Path2;
  54840. }
  54841. /**
  54842. * Builds a polygon
  54843. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54844. */
  54845. export class PolygonMeshBuilder {
  54846. private _points;
  54847. private _outlinepoints;
  54848. private _holes;
  54849. private _name;
  54850. private _scene;
  54851. private _epoints;
  54852. private _eholes;
  54853. private _addToepoint;
  54854. /**
  54855. * Babylon reference to the earcut plugin.
  54856. */
  54857. bjsEarcut: any;
  54858. /**
  54859. * Creates a PolygonMeshBuilder
  54860. * @param name name of the builder
  54861. * @param contours Path of the polygon
  54862. * @param scene scene to add to when creating the mesh
  54863. * @param earcutInjection can be used to inject your own earcut reference
  54864. */
  54865. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54866. /**
  54867. * Adds a whole within the polygon
  54868. * @param hole Array of points defining the hole
  54869. * @returns this
  54870. */
  54871. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54872. /**
  54873. * Creates the polygon
  54874. * @param updatable If the mesh should be updatable
  54875. * @param depth The depth of the mesh created
  54876. * @returns the created mesh
  54877. */
  54878. build(updatable?: boolean, depth?: number): Mesh;
  54879. /**
  54880. * Creates the polygon
  54881. * @param depth The depth of the mesh created
  54882. * @returns the created VertexData
  54883. */
  54884. buildVertexData(depth?: number): VertexData;
  54885. /**
  54886. * Adds a side to the polygon
  54887. * @param positions points that make the polygon
  54888. * @param normals normals of the polygon
  54889. * @param uvs uvs of the polygon
  54890. * @param indices indices of the polygon
  54891. * @param bounds bounds of the polygon
  54892. * @param points points of the polygon
  54893. * @param depth depth of the polygon
  54894. * @param flip flip of the polygon
  54895. */
  54896. private addSide;
  54897. }
  54898. }
  54899. declare module BABYLON {
  54900. /**
  54901. * Class containing static functions to help procedurally build meshes
  54902. */
  54903. export class PolygonBuilder {
  54904. /**
  54905. * Creates a polygon mesh
  54906. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54907. * * 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
  54908. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54910. * * 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)
  54911. * * Remember you can only change the shape positions, not their number when updating a polygon
  54912. * @param name defines the name of the mesh
  54913. * @param options defines the options used to create the mesh
  54914. * @param scene defines the hosting scene
  54915. * @param earcutInjection can be used to inject your own earcut reference
  54916. * @returns the polygon mesh
  54917. */
  54918. static CreatePolygon(name: string, options: {
  54919. shape: Vector3[];
  54920. holes?: Vector3[][];
  54921. depth?: number;
  54922. faceUV?: Vector4[];
  54923. faceColors?: Color4[];
  54924. updatable?: boolean;
  54925. sideOrientation?: number;
  54926. frontUVs?: Vector4;
  54927. backUVs?: Vector4;
  54928. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54929. /**
  54930. * Creates an extruded polygon mesh, with depth in the Y direction.
  54931. * * 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)
  54932. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54933. * @param name defines the name of the mesh
  54934. * @param options defines the options used to create the mesh
  54935. * @param scene defines the hosting scene
  54936. * @param earcutInjection can be used to inject your own earcut reference
  54937. * @returns the polygon mesh
  54938. */
  54939. static ExtrudePolygon(name: string, options: {
  54940. shape: Vector3[];
  54941. holes?: Vector3[][];
  54942. depth?: number;
  54943. faceUV?: Vector4[];
  54944. faceColors?: Color4[];
  54945. updatable?: boolean;
  54946. sideOrientation?: number;
  54947. frontUVs?: Vector4;
  54948. backUVs?: Vector4;
  54949. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54950. }
  54951. }
  54952. declare module BABYLON {
  54953. /**
  54954. * Class containing static functions to help procedurally build meshes
  54955. */
  54956. export class LatheBuilder {
  54957. /**
  54958. * Creates lathe mesh.
  54959. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54960. * * 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
  54961. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54962. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54963. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54964. * * 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
  54965. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54966. * * 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
  54967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54968. * * 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
  54969. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54971. * @param name defines the name of the mesh
  54972. * @param options defines the options used to create the mesh
  54973. * @param scene defines the hosting scene
  54974. * @returns the lathe mesh
  54975. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54976. */
  54977. static CreateLathe(name: string, options: {
  54978. shape: Vector3[];
  54979. radius?: number;
  54980. tessellation?: number;
  54981. clip?: number;
  54982. arc?: number;
  54983. closed?: boolean;
  54984. updatable?: boolean;
  54985. sideOrientation?: number;
  54986. frontUVs?: Vector4;
  54987. backUVs?: Vector4;
  54988. cap?: number;
  54989. invertUV?: boolean;
  54990. }, scene?: Nullable<Scene>): Mesh;
  54991. }
  54992. }
  54993. declare module BABYLON {
  54994. /**
  54995. * Class containing static functions to help procedurally build meshes
  54996. */
  54997. export class TiledPlaneBuilder {
  54998. /**
  54999. * Creates a tiled plane mesh
  55000. * * The parameter `pattern` will, depending on value, do nothing or
  55001. * * * flip (reflect about central vertical) alternate tiles across and up
  55002. * * * flip every tile on alternate rows
  55003. * * * rotate (180 degs) alternate tiles across and up
  55004. * * * rotate every tile on alternate rows
  55005. * * * flip and rotate alternate tiles across and up
  55006. * * * flip and rotate every tile on alternate rows
  55007. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55008. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55009. * * 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
  55010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55011. * * 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)
  55012. * * 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)
  55013. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55014. * @param name defines the name of the mesh
  55015. * @param options defines the options used to create the mesh
  55016. * @param scene defines the hosting scene
  55017. * @returns the box mesh
  55018. */
  55019. static CreateTiledPlane(name: string, options: {
  55020. pattern?: number;
  55021. tileSize?: number;
  55022. tileWidth?: number;
  55023. tileHeight?: number;
  55024. size?: number;
  55025. width?: number;
  55026. height?: number;
  55027. alignHorizontal?: number;
  55028. alignVertical?: number;
  55029. sideOrientation?: number;
  55030. frontUVs?: Vector4;
  55031. backUVs?: Vector4;
  55032. updatable?: boolean;
  55033. }, scene?: Nullable<Scene>): Mesh;
  55034. }
  55035. }
  55036. declare module BABYLON {
  55037. /**
  55038. * Class containing static functions to help procedurally build meshes
  55039. */
  55040. export class TubeBuilder {
  55041. /**
  55042. * Creates a tube mesh.
  55043. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55044. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55045. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55046. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55047. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55048. * * 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)
  55049. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55050. * * 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
  55051. * * 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
  55052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55053. * * 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
  55054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55056. * @param name defines the name of the mesh
  55057. * @param options defines the options used to create the mesh
  55058. * @param scene defines the hosting scene
  55059. * @returns the tube mesh
  55060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55061. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55062. */
  55063. static CreateTube(name: string, options: {
  55064. path: Vector3[];
  55065. radius?: number;
  55066. tessellation?: number;
  55067. radiusFunction?: {
  55068. (i: number, distance: number): number;
  55069. };
  55070. cap?: number;
  55071. arc?: number;
  55072. updatable?: boolean;
  55073. sideOrientation?: number;
  55074. frontUVs?: Vector4;
  55075. backUVs?: Vector4;
  55076. instance?: Mesh;
  55077. invertUV?: boolean;
  55078. }, scene?: Nullable<Scene>): Mesh;
  55079. }
  55080. }
  55081. declare module BABYLON {
  55082. /**
  55083. * Class containing static functions to help procedurally build meshes
  55084. */
  55085. export class IcoSphereBuilder {
  55086. /**
  55087. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55088. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55089. * * 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`)
  55090. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55091. * * 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
  55092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55093. * * 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
  55094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55095. * @param name defines the name of the mesh
  55096. * @param options defines the options used to create the mesh
  55097. * @param scene defines the hosting scene
  55098. * @returns the icosahedron mesh
  55099. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55100. */
  55101. static CreateIcoSphere(name: string, options: {
  55102. radius?: number;
  55103. radiusX?: number;
  55104. radiusY?: number;
  55105. radiusZ?: number;
  55106. flat?: boolean;
  55107. subdivisions?: number;
  55108. sideOrientation?: number;
  55109. frontUVs?: Vector4;
  55110. backUVs?: Vector4;
  55111. updatable?: boolean;
  55112. }, scene?: Nullable<Scene>): Mesh;
  55113. }
  55114. }
  55115. declare module BABYLON {
  55116. /**
  55117. * Class containing static functions to help procedurally build meshes
  55118. */
  55119. export class DecalBuilder {
  55120. /**
  55121. * Creates a decal mesh.
  55122. * 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
  55123. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55124. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55125. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55126. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55127. * @param name defines the name of the mesh
  55128. * @param sourceMesh defines the mesh where the decal must be applied
  55129. * @param options defines the options used to create the mesh
  55130. * @param scene defines the hosting scene
  55131. * @returns the decal mesh
  55132. * @see https://doc.babylonjs.com/how_to/decals
  55133. */
  55134. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55135. position?: Vector3;
  55136. normal?: Vector3;
  55137. size?: Vector3;
  55138. angle?: number;
  55139. }): Mesh;
  55140. }
  55141. }
  55142. declare module BABYLON {
  55143. /**
  55144. * Class containing static functions to help procedurally build meshes
  55145. */
  55146. export class MeshBuilder {
  55147. /**
  55148. * Creates a box mesh
  55149. * * The parameter `size` sets the size (float) of each box side (default 1)
  55150. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55151. * * 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)
  55152. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55154. * * 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
  55155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55156. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55157. * @param name defines the name of the mesh
  55158. * @param options defines the options used to create the mesh
  55159. * @param scene defines the hosting scene
  55160. * @returns the box mesh
  55161. */
  55162. static CreateBox(name: string, options: {
  55163. size?: number;
  55164. width?: number;
  55165. height?: number;
  55166. depth?: number;
  55167. faceUV?: Vector4[];
  55168. faceColors?: Color4[];
  55169. sideOrientation?: number;
  55170. frontUVs?: Vector4;
  55171. backUVs?: Vector4;
  55172. updatable?: boolean;
  55173. }, scene?: Nullable<Scene>): Mesh;
  55174. /**
  55175. * Creates a tiled box mesh
  55176. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55178. * @param name defines the name of the mesh
  55179. * @param options defines the options used to create the mesh
  55180. * @param scene defines the hosting scene
  55181. * @returns the tiled box mesh
  55182. */
  55183. static CreateTiledBox(name: string, options: {
  55184. pattern?: number;
  55185. size?: number;
  55186. width?: number;
  55187. height?: number;
  55188. depth: number;
  55189. tileSize?: number;
  55190. tileWidth?: number;
  55191. tileHeight?: number;
  55192. faceUV?: Vector4[];
  55193. faceColors?: Color4[];
  55194. alignHorizontal?: number;
  55195. alignVertical?: number;
  55196. sideOrientation?: number;
  55197. updatable?: boolean;
  55198. }, scene?: Nullable<Scene>): Mesh;
  55199. /**
  55200. * Creates a sphere mesh
  55201. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55202. * * 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`)
  55203. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55204. * * 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
  55205. * * 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)
  55206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55207. * * 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
  55208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55209. * @param name defines the name of the mesh
  55210. * @param options defines the options used to create the mesh
  55211. * @param scene defines the hosting scene
  55212. * @returns the sphere mesh
  55213. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55214. */
  55215. static CreateSphere(name: string, options: {
  55216. segments?: number;
  55217. diameter?: number;
  55218. diameterX?: number;
  55219. diameterY?: number;
  55220. diameterZ?: number;
  55221. arc?: number;
  55222. slice?: number;
  55223. sideOrientation?: number;
  55224. frontUVs?: Vector4;
  55225. backUVs?: Vector4;
  55226. updatable?: boolean;
  55227. }, scene?: Nullable<Scene>): Mesh;
  55228. /**
  55229. * Creates a plane polygonal mesh. By default, this is a disc
  55230. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55231. * * 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
  55232. * * 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
  55233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55234. * * 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
  55235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55236. * @param name defines the name of the mesh
  55237. * @param options defines the options used to create the mesh
  55238. * @param scene defines the hosting scene
  55239. * @returns the plane polygonal mesh
  55240. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55241. */
  55242. static CreateDisc(name: string, options: {
  55243. radius?: number;
  55244. tessellation?: number;
  55245. arc?: number;
  55246. updatable?: boolean;
  55247. sideOrientation?: number;
  55248. frontUVs?: Vector4;
  55249. backUVs?: Vector4;
  55250. }, scene?: Nullable<Scene>): Mesh;
  55251. /**
  55252. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55253. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55254. * * 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`)
  55255. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55256. * * 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
  55257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55258. * * 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
  55259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55260. * @param name defines the name of the mesh
  55261. * @param options defines the options used to create the mesh
  55262. * @param scene defines the hosting scene
  55263. * @returns the icosahedron mesh
  55264. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55265. */
  55266. static CreateIcoSphere(name: string, options: {
  55267. radius?: number;
  55268. radiusX?: number;
  55269. radiusY?: number;
  55270. radiusZ?: number;
  55271. flat?: boolean;
  55272. subdivisions?: number;
  55273. sideOrientation?: number;
  55274. frontUVs?: Vector4;
  55275. backUVs?: Vector4;
  55276. updatable?: boolean;
  55277. }, scene?: Nullable<Scene>): Mesh;
  55278. /**
  55279. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55280. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55281. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55282. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55283. * * 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
  55284. * * 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
  55285. * * 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
  55286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55287. * * 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
  55288. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55289. * * 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
  55290. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55291. * * 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
  55292. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55294. * @param name defines the name of the mesh
  55295. * @param options defines the options used to create the mesh
  55296. * @param scene defines the hosting scene
  55297. * @returns the ribbon mesh
  55298. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55299. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55300. */
  55301. static CreateRibbon(name: string, options: {
  55302. pathArray: Vector3[][];
  55303. closeArray?: boolean;
  55304. closePath?: boolean;
  55305. offset?: number;
  55306. updatable?: boolean;
  55307. sideOrientation?: number;
  55308. frontUVs?: Vector4;
  55309. backUVs?: Vector4;
  55310. instance?: Mesh;
  55311. invertUV?: boolean;
  55312. uvs?: Vector2[];
  55313. colors?: Color4[];
  55314. }, scene?: Nullable<Scene>): Mesh;
  55315. /**
  55316. * Creates a cylinder or a cone mesh
  55317. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55318. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55319. * * 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.
  55320. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55321. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55322. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55323. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55324. * * 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).
  55325. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55326. * * 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).
  55327. * * 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
  55328. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55329. * * 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
  55330. * * 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.
  55331. * * If `enclose` is false, a ring surface is one element.
  55332. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55333. * * 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
  55334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55335. * * 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
  55336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55337. * @param name defines the name of the mesh
  55338. * @param options defines the options used to create the mesh
  55339. * @param scene defines the hosting scene
  55340. * @returns the cylinder mesh
  55341. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55342. */
  55343. static CreateCylinder(name: string, options: {
  55344. height?: number;
  55345. diameterTop?: number;
  55346. diameterBottom?: number;
  55347. diameter?: number;
  55348. tessellation?: number;
  55349. subdivisions?: number;
  55350. arc?: number;
  55351. faceColors?: Color4[];
  55352. faceUV?: Vector4[];
  55353. updatable?: boolean;
  55354. hasRings?: boolean;
  55355. enclose?: boolean;
  55356. cap?: number;
  55357. sideOrientation?: number;
  55358. frontUVs?: Vector4;
  55359. backUVs?: Vector4;
  55360. }, scene?: Nullable<Scene>): Mesh;
  55361. /**
  55362. * Creates a torus mesh
  55363. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55364. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55365. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55367. * * 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
  55368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55369. * @param name defines the name of the mesh
  55370. * @param options defines the options used to create the mesh
  55371. * @param scene defines the hosting scene
  55372. * @returns the torus mesh
  55373. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55374. */
  55375. static CreateTorus(name: string, options: {
  55376. diameter?: number;
  55377. thickness?: number;
  55378. tessellation?: number;
  55379. updatable?: boolean;
  55380. sideOrientation?: number;
  55381. frontUVs?: Vector4;
  55382. backUVs?: Vector4;
  55383. }, scene?: Nullable<Scene>): Mesh;
  55384. /**
  55385. * Creates a torus knot mesh
  55386. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55387. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55388. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55389. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55391. * * 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
  55392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55393. * @param name defines the name of the mesh
  55394. * @param options defines the options used to create the mesh
  55395. * @param scene defines the hosting scene
  55396. * @returns the torus knot mesh
  55397. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55398. */
  55399. static CreateTorusKnot(name: string, options: {
  55400. radius?: number;
  55401. tube?: number;
  55402. radialSegments?: number;
  55403. tubularSegments?: number;
  55404. p?: number;
  55405. q?: number;
  55406. updatable?: boolean;
  55407. sideOrientation?: number;
  55408. frontUVs?: Vector4;
  55409. backUVs?: Vector4;
  55410. }, scene?: Nullable<Scene>): Mesh;
  55411. /**
  55412. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55413. * * 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
  55414. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55415. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55416. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55417. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55418. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55419. * * 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
  55420. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55423. * @param name defines the name of the new line system
  55424. * @param options defines the options used to create the line system
  55425. * @param scene defines the hosting scene
  55426. * @returns a new line system mesh
  55427. */
  55428. static CreateLineSystem(name: string, options: {
  55429. lines: Vector3[][];
  55430. updatable?: boolean;
  55431. instance?: Nullable<LinesMesh>;
  55432. colors?: Nullable<Color4[][]>;
  55433. useVertexAlpha?: boolean;
  55434. }, scene: Nullable<Scene>): LinesMesh;
  55435. /**
  55436. * Creates a line mesh
  55437. * 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
  55438. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55439. * * The parameter `points` is an array successive Vector3
  55440. * * 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
  55441. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55442. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55443. * * When updating an instance, remember that only point positions can change, not the number of points
  55444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55446. * @param name defines the name of the new line system
  55447. * @param options defines the options used to create the line system
  55448. * @param scene defines the hosting scene
  55449. * @returns a new line mesh
  55450. */
  55451. static CreateLines(name: string, options: {
  55452. points: Vector3[];
  55453. updatable?: boolean;
  55454. instance?: Nullable<LinesMesh>;
  55455. colors?: Color4[];
  55456. useVertexAlpha?: boolean;
  55457. }, scene?: Nullable<Scene>): LinesMesh;
  55458. /**
  55459. * Creates a dashed line mesh
  55460. * * 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
  55461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55462. * * The parameter `points` is an array successive Vector3
  55463. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55464. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55465. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55466. * * 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
  55467. * * When updating an instance, remember that only point positions can change, not the number of points
  55468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55469. * @param name defines the name of the mesh
  55470. * @param options defines the options used to create the mesh
  55471. * @param scene defines the hosting scene
  55472. * @returns the dashed line mesh
  55473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55474. */
  55475. static CreateDashedLines(name: string, options: {
  55476. points: Vector3[];
  55477. dashSize?: number;
  55478. gapSize?: number;
  55479. dashNb?: number;
  55480. updatable?: boolean;
  55481. instance?: LinesMesh;
  55482. }, scene?: Nullable<Scene>): LinesMesh;
  55483. /**
  55484. * 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.
  55485. * * 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.
  55486. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55487. * * 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.
  55488. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55489. * * 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
  55490. * * 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
  55491. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55493. * * 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
  55494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55496. * @param name defines the name of the mesh
  55497. * @param options defines the options used to create the mesh
  55498. * @param scene defines the hosting scene
  55499. * @returns the extruded shape mesh
  55500. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55502. */
  55503. static ExtrudeShape(name: string, options: {
  55504. shape: Vector3[];
  55505. path: Vector3[];
  55506. scale?: number;
  55507. rotation?: number;
  55508. cap?: number;
  55509. updatable?: boolean;
  55510. sideOrientation?: number;
  55511. frontUVs?: Vector4;
  55512. backUVs?: Vector4;
  55513. instance?: Mesh;
  55514. invertUV?: boolean;
  55515. }, scene?: Nullable<Scene>): Mesh;
  55516. /**
  55517. * Creates an custom extruded shape mesh.
  55518. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55519. * * 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.
  55520. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55521. * * 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
  55522. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55523. * * 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
  55524. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55525. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55526. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55527. * * 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
  55528. * * 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
  55529. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55531. * * 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
  55532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55534. * @param name defines the name of the mesh
  55535. * @param options defines the options used to create the mesh
  55536. * @param scene defines the hosting scene
  55537. * @returns the custom extruded shape mesh
  55538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55541. */
  55542. static ExtrudeShapeCustom(name: string, options: {
  55543. shape: Vector3[];
  55544. path: Vector3[];
  55545. scaleFunction?: any;
  55546. rotationFunction?: any;
  55547. ribbonCloseArray?: boolean;
  55548. ribbonClosePath?: boolean;
  55549. cap?: number;
  55550. updatable?: boolean;
  55551. sideOrientation?: number;
  55552. frontUVs?: Vector4;
  55553. backUVs?: Vector4;
  55554. instance?: Mesh;
  55555. invertUV?: boolean;
  55556. }, scene?: Nullable<Scene>): Mesh;
  55557. /**
  55558. * Creates lathe mesh.
  55559. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55560. * * 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
  55561. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55562. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55563. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55564. * * 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
  55565. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55566. * * 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
  55567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55568. * * 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
  55569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55571. * @param name defines the name of the mesh
  55572. * @param options defines the options used to create the mesh
  55573. * @param scene defines the hosting scene
  55574. * @returns the lathe mesh
  55575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55576. */
  55577. static CreateLathe(name: string, options: {
  55578. shape: Vector3[];
  55579. radius?: number;
  55580. tessellation?: number;
  55581. clip?: number;
  55582. arc?: number;
  55583. closed?: boolean;
  55584. updatable?: boolean;
  55585. sideOrientation?: number;
  55586. frontUVs?: Vector4;
  55587. backUVs?: Vector4;
  55588. cap?: number;
  55589. invertUV?: boolean;
  55590. }, scene?: Nullable<Scene>): Mesh;
  55591. /**
  55592. * Creates a tiled plane mesh
  55593. * * You can set a limited pattern arrangement with the tiles
  55594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55595. * * 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
  55596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55597. * @param name defines the name of the mesh
  55598. * @param options defines the options used to create the mesh
  55599. * @param scene defines the hosting scene
  55600. * @returns the plane mesh
  55601. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55602. */
  55603. static CreateTiledPlane(name: string, options: {
  55604. pattern?: number;
  55605. tileSize?: number;
  55606. tileWidth?: number;
  55607. tileHeight?: number;
  55608. size?: number;
  55609. width?: number;
  55610. height?: number;
  55611. alignHorizontal?: number;
  55612. alignVertical?: number;
  55613. sideOrientation?: number;
  55614. frontUVs?: Vector4;
  55615. backUVs?: Vector4;
  55616. updatable?: boolean;
  55617. }, scene?: Nullable<Scene>): Mesh;
  55618. /**
  55619. * Creates a plane mesh
  55620. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55621. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55622. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55624. * * 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
  55625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55626. * @param name defines the name of the mesh
  55627. * @param options defines the options used to create the mesh
  55628. * @param scene defines the hosting scene
  55629. * @returns the plane mesh
  55630. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55631. */
  55632. static CreatePlane(name: string, options: {
  55633. size?: number;
  55634. width?: number;
  55635. height?: number;
  55636. sideOrientation?: number;
  55637. frontUVs?: Vector4;
  55638. backUVs?: Vector4;
  55639. updatable?: boolean;
  55640. sourcePlane?: Plane;
  55641. }, scene?: Nullable<Scene>): Mesh;
  55642. /**
  55643. * Creates a ground mesh
  55644. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55645. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55647. * @param name defines the name of the mesh
  55648. * @param options defines the options used to create the mesh
  55649. * @param scene defines the hosting scene
  55650. * @returns the ground mesh
  55651. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55652. */
  55653. static CreateGround(name: string, options: {
  55654. width?: number;
  55655. height?: number;
  55656. subdivisions?: number;
  55657. subdivisionsX?: number;
  55658. subdivisionsY?: number;
  55659. updatable?: boolean;
  55660. }, scene?: Nullable<Scene>): Mesh;
  55661. /**
  55662. * Creates a tiled ground mesh
  55663. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55664. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55665. * * 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
  55666. * * 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
  55667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55668. * @param name defines the name of the mesh
  55669. * @param options defines the options used to create the mesh
  55670. * @param scene defines the hosting scene
  55671. * @returns the tiled ground mesh
  55672. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55673. */
  55674. static CreateTiledGround(name: string, options: {
  55675. xmin: number;
  55676. zmin: number;
  55677. xmax: number;
  55678. zmax: number;
  55679. subdivisions?: {
  55680. w: number;
  55681. h: number;
  55682. };
  55683. precision?: {
  55684. w: number;
  55685. h: number;
  55686. };
  55687. updatable?: boolean;
  55688. }, scene?: Nullable<Scene>): Mesh;
  55689. /**
  55690. * Creates a ground mesh from a height map
  55691. * * The parameter `url` sets the URL of the height map image resource.
  55692. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55693. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55694. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55695. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55696. * * 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.
  55697. * * 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).
  55698. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55700. * @param name defines the name of the mesh
  55701. * @param url defines the url to the height map
  55702. * @param options defines the options used to create the mesh
  55703. * @param scene defines the hosting scene
  55704. * @returns the ground mesh
  55705. * @see https://doc.babylonjs.com/babylon101/height_map
  55706. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55707. */
  55708. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55709. width?: number;
  55710. height?: number;
  55711. subdivisions?: number;
  55712. minHeight?: number;
  55713. maxHeight?: number;
  55714. colorFilter?: Color3;
  55715. alphaFilter?: number;
  55716. updatable?: boolean;
  55717. onReady?: (mesh: GroundMesh) => void;
  55718. }, scene?: Nullable<Scene>): GroundMesh;
  55719. /**
  55720. * Creates a polygon mesh
  55721. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55722. * * 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
  55723. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55725. * * 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)
  55726. * * Remember you can only change the shape positions, not their number when updating a polygon
  55727. * @param name defines the name of the mesh
  55728. * @param options defines the options used to create the mesh
  55729. * @param scene defines the hosting scene
  55730. * @param earcutInjection can be used to inject your own earcut reference
  55731. * @returns the polygon mesh
  55732. */
  55733. static CreatePolygon(name: string, options: {
  55734. shape: Vector3[];
  55735. holes?: Vector3[][];
  55736. depth?: number;
  55737. faceUV?: Vector4[];
  55738. faceColors?: Color4[];
  55739. updatable?: boolean;
  55740. sideOrientation?: number;
  55741. frontUVs?: Vector4;
  55742. backUVs?: Vector4;
  55743. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55744. /**
  55745. * Creates an extruded polygon mesh, with depth in the Y direction.
  55746. * * 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)
  55747. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55748. * @param name defines the name of the mesh
  55749. * @param options defines the options used to create the mesh
  55750. * @param scene defines the hosting scene
  55751. * @param earcutInjection can be used to inject your own earcut reference
  55752. * @returns the polygon mesh
  55753. */
  55754. static ExtrudePolygon(name: string, options: {
  55755. shape: Vector3[];
  55756. holes?: Vector3[][];
  55757. depth?: number;
  55758. faceUV?: Vector4[];
  55759. faceColors?: Color4[];
  55760. updatable?: boolean;
  55761. sideOrientation?: number;
  55762. frontUVs?: Vector4;
  55763. backUVs?: Vector4;
  55764. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55765. /**
  55766. * Creates a tube mesh.
  55767. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55768. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55769. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55770. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55771. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55772. * * 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)
  55773. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55774. * * 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
  55775. * * 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
  55776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55777. * * 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
  55778. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55780. * @param name defines the name of the mesh
  55781. * @param options defines the options used to create the mesh
  55782. * @param scene defines the hosting scene
  55783. * @returns the tube mesh
  55784. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55785. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55786. */
  55787. static CreateTube(name: string, options: {
  55788. path: Vector3[];
  55789. radius?: number;
  55790. tessellation?: number;
  55791. radiusFunction?: {
  55792. (i: number, distance: number): number;
  55793. };
  55794. cap?: number;
  55795. arc?: number;
  55796. updatable?: boolean;
  55797. sideOrientation?: number;
  55798. frontUVs?: Vector4;
  55799. backUVs?: Vector4;
  55800. instance?: Mesh;
  55801. invertUV?: boolean;
  55802. }, scene?: Nullable<Scene>): Mesh;
  55803. /**
  55804. * Creates a polyhedron mesh
  55805. * * 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
  55806. * * The parameter `size` (positive float, default 1) sets the polygon size
  55807. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55808. * * 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`
  55809. * * 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
  55810. * * 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)`)
  55811. * * 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
  55812. * * 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
  55813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55814. * * 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
  55815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55816. * @param name defines the name of the mesh
  55817. * @param options defines the options used to create the mesh
  55818. * @param scene defines the hosting scene
  55819. * @returns the polyhedron mesh
  55820. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55821. */
  55822. static CreatePolyhedron(name: string, options: {
  55823. type?: number;
  55824. size?: number;
  55825. sizeX?: number;
  55826. sizeY?: number;
  55827. sizeZ?: number;
  55828. custom?: any;
  55829. faceUV?: Vector4[];
  55830. faceColors?: Color4[];
  55831. flat?: boolean;
  55832. updatable?: boolean;
  55833. sideOrientation?: number;
  55834. frontUVs?: Vector4;
  55835. backUVs?: Vector4;
  55836. }, scene?: Nullable<Scene>): Mesh;
  55837. /**
  55838. * Creates a decal mesh.
  55839. * 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
  55840. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55841. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55842. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55843. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55844. * @param name defines the name of the mesh
  55845. * @param sourceMesh defines the mesh where the decal must be applied
  55846. * @param options defines the options used to create the mesh
  55847. * @param scene defines the hosting scene
  55848. * @returns the decal mesh
  55849. * @see https://doc.babylonjs.com/how_to/decals
  55850. */
  55851. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55852. position?: Vector3;
  55853. normal?: Vector3;
  55854. size?: Vector3;
  55855. angle?: number;
  55856. }): Mesh;
  55857. }
  55858. }
  55859. declare module BABYLON {
  55860. /**
  55861. * A simplifier interface for future simplification implementations
  55862. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55863. */
  55864. export interface ISimplifier {
  55865. /**
  55866. * Simplification of a given mesh according to the given settings.
  55867. * Since this requires computation, it is assumed that the function runs async.
  55868. * @param settings The settings of the simplification, including quality and distance
  55869. * @param successCallback A callback that will be called after the mesh was simplified.
  55870. * @param errorCallback in case of an error, this callback will be called. optional.
  55871. */
  55872. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55873. }
  55874. /**
  55875. * Expected simplification settings.
  55876. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55877. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55878. */
  55879. export interface ISimplificationSettings {
  55880. /**
  55881. * Gets or sets the expected quality
  55882. */
  55883. quality: number;
  55884. /**
  55885. * Gets or sets the distance when this optimized version should be used
  55886. */
  55887. distance: number;
  55888. /**
  55889. * Gets an already optimized mesh
  55890. */
  55891. optimizeMesh?: boolean;
  55892. }
  55893. /**
  55894. * Class used to specify simplification options
  55895. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55896. */
  55897. export class SimplificationSettings implements ISimplificationSettings {
  55898. /** expected quality */
  55899. quality: number;
  55900. /** distance when this optimized version should be used */
  55901. distance: number;
  55902. /** already optimized mesh */
  55903. optimizeMesh?: boolean | undefined;
  55904. /**
  55905. * Creates a SimplificationSettings
  55906. * @param quality expected quality
  55907. * @param distance distance when this optimized version should be used
  55908. * @param optimizeMesh already optimized mesh
  55909. */
  55910. constructor(
  55911. /** expected quality */
  55912. quality: number,
  55913. /** distance when this optimized version should be used */
  55914. distance: number,
  55915. /** already optimized mesh */
  55916. optimizeMesh?: boolean | undefined);
  55917. }
  55918. /**
  55919. * Interface used to define a simplification task
  55920. */
  55921. export interface ISimplificationTask {
  55922. /**
  55923. * Array of settings
  55924. */
  55925. settings: Array<ISimplificationSettings>;
  55926. /**
  55927. * Simplification type
  55928. */
  55929. simplificationType: SimplificationType;
  55930. /**
  55931. * Mesh to simplify
  55932. */
  55933. mesh: Mesh;
  55934. /**
  55935. * Callback called on success
  55936. */
  55937. successCallback?: () => void;
  55938. /**
  55939. * Defines if parallel processing can be used
  55940. */
  55941. parallelProcessing: boolean;
  55942. }
  55943. /**
  55944. * Queue used to order the simplification tasks
  55945. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55946. */
  55947. export class SimplificationQueue {
  55948. private _simplificationArray;
  55949. /**
  55950. * Gets a boolean indicating that the process is still running
  55951. */
  55952. running: boolean;
  55953. /**
  55954. * Creates a new queue
  55955. */
  55956. constructor();
  55957. /**
  55958. * Adds a new simplification task
  55959. * @param task defines a task to add
  55960. */
  55961. addTask(task: ISimplificationTask): void;
  55962. /**
  55963. * Execute next task
  55964. */
  55965. executeNext(): void;
  55966. /**
  55967. * Execute a simplification task
  55968. * @param task defines the task to run
  55969. */
  55970. runSimplification(task: ISimplificationTask): void;
  55971. private getSimplifier;
  55972. }
  55973. /**
  55974. * The implemented types of simplification
  55975. * At the moment only Quadratic Error Decimation is implemented
  55976. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55977. */
  55978. export enum SimplificationType {
  55979. /** Quadratic error decimation */
  55980. QUADRATIC = 0
  55981. }
  55982. }
  55983. declare module BABYLON {
  55984. interface Scene {
  55985. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  55986. /**
  55987. * Gets or sets the simplification queue attached to the scene
  55988. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55989. */
  55990. simplificationQueue: SimplificationQueue;
  55991. }
  55992. interface Mesh {
  55993. /**
  55994. * Simplify the mesh according to the given array of settings.
  55995. * Function will return immediately and will simplify async
  55996. * @param settings a collection of simplification settings
  55997. * @param parallelProcessing should all levels calculate parallel or one after the other
  55998. * @param simplificationType the type of simplification to run
  55999. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56000. * @returns the current mesh
  56001. */
  56002. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56003. }
  56004. /**
  56005. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56006. * created in a scene
  56007. */
  56008. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56009. /**
  56010. * The component name helpfull to identify the component in the list of scene components.
  56011. */
  56012. readonly name: string;
  56013. /**
  56014. * The scene the component belongs to.
  56015. */
  56016. scene: Scene;
  56017. /**
  56018. * Creates a new instance of the component for the given scene
  56019. * @param scene Defines the scene to register the component in
  56020. */
  56021. constructor(scene: Scene);
  56022. /**
  56023. * Registers the component in a given scene
  56024. */
  56025. register(): void;
  56026. /**
  56027. * Rebuilds the elements related to this component in case of
  56028. * context lost for instance.
  56029. */
  56030. rebuild(): void;
  56031. /**
  56032. * Disposes the component and the associated ressources
  56033. */
  56034. dispose(): void;
  56035. private _beforeCameraUpdate;
  56036. }
  56037. }
  56038. declare module BABYLON {
  56039. /**
  56040. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56041. */
  56042. export interface INavigationEnginePlugin {
  56043. /**
  56044. * plugin name
  56045. */
  56046. name: string;
  56047. /**
  56048. * Creates a navigation mesh
  56049. * @param meshes array of all the geometry used to compute the navigatio mesh
  56050. * @param parameters bunch of parameters used to filter geometry
  56051. */
  56052. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56053. /**
  56054. * Create a navigation mesh debug mesh
  56055. * @param scene is where the mesh will be added
  56056. * @returns debug display mesh
  56057. */
  56058. createDebugNavMesh(scene: Scene): Mesh;
  56059. /**
  56060. * Get a navigation mesh constrained position, closest to the parameter position
  56061. * @param position world position
  56062. * @returns the closest point to position constrained by the navigation mesh
  56063. */
  56064. getClosestPoint(position: Vector3): Vector3;
  56065. /**
  56066. * Get a navigation mesh constrained position, within a particular radius
  56067. * @param position world position
  56068. * @param maxRadius the maximum distance to the constrained world position
  56069. * @returns the closest point to position constrained by the navigation mesh
  56070. */
  56071. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56072. /**
  56073. * Compute the final position from a segment made of destination-position
  56074. * @param position world position
  56075. * @param destination world position
  56076. * @returns the resulting point along the navmesh
  56077. */
  56078. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56079. /**
  56080. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56081. * @param start world position
  56082. * @param end world position
  56083. * @returns array containing world position composing the path
  56084. */
  56085. computePath(start: Vector3, end: Vector3): Vector3[];
  56086. /**
  56087. * If this plugin is supported
  56088. * @returns true if plugin is supported
  56089. */
  56090. isSupported(): boolean;
  56091. /**
  56092. * Create a new Crowd so you can add agents
  56093. * @param maxAgents the maximum agent count in the crowd
  56094. * @param maxAgentRadius the maximum radius an agent can have
  56095. * @param scene to attach the crowd to
  56096. * @returns the crowd you can add agents to
  56097. */
  56098. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56099. /**
  56100. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56101. * The queries will try to find a solution within those bounds
  56102. * default is (1,1,1)
  56103. * @param extent x,y,z value that define the extent around the queries point of reference
  56104. */
  56105. setDefaultQueryExtent(extent: Vector3): void;
  56106. /**
  56107. * Get the Bounding box extent specified by setDefaultQueryExtent
  56108. * @returns the box extent values
  56109. */
  56110. getDefaultQueryExtent(): Vector3;
  56111. /**
  56112. * Release all resources
  56113. */
  56114. dispose(): void;
  56115. }
  56116. /**
  56117. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56118. */
  56119. export interface ICrowd {
  56120. /**
  56121. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56122. * You can attach anything to that node. The node position is updated in the scene update tick.
  56123. * @param pos world position that will be constrained by the navigation mesh
  56124. * @param parameters agent parameters
  56125. * @param transform hooked to the agent that will be update by the scene
  56126. * @returns agent index
  56127. */
  56128. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56129. /**
  56130. * Returns the agent position in world space
  56131. * @param index agent index returned by addAgent
  56132. * @returns world space position
  56133. */
  56134. getAgentPosition(index: number): Vector3;
  56135. /**
  56136. * Gets the agent velocity in world space
  56137. * @param index agent index returned by addAgent
  56138. * @returns world space velocity
  56139. */
  56140. getAgentVelocity(index: number): Vector3;
  56141. /**
  56142. * remove a particular agent previously created
  56143. * @param index agent index returned by addAgent
  56144. */
  56145. removeAgent(index: number): void;
  56146. /**
  56147. * get the list of all agents attached to this crowd
  56148. * @returns list of agent indices
  56149. */
  56150. getAgents(): number[];
  56151. /**
  56152. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56153. * @param deltaTime in seconds
  56154. */
  56155. update(deltaTime: number): void;
  56156. /**
  56157. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56158. * @param index agent index returned by addAgent
  56159. * @param destination targeted world position
  56160. */
  56161. agentGoto(index: number, destination: Vector3): void;
  56162. /**
  56163. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56164. * The queries will try to find a solution within those bounds
  56165. * default is (1,1,1)
  56166. * @param extent x,y,z value that define the extent around the queries point of reference
  56167. */
  56168. setDefaultQueryExtent(extent: Vector3): void;
  56169. /**
  56170. * Get the Bounding box extent specified by setDefaultQueryExtent
  56171. * @returns the box extent values
  56172. */
  56173. getDefaultQueryExtent(): Vector3;
  56174. /**
  56175. * Release all resources
  56176. */
  56177. dispose(): void;
  56178. }
  56179. /**
  56180. * Configures an agent
  56181. */
  56182. export interface IAgentParameters {
  56183. /**
  56184. * Agent radius. [Limit: >= 0]
  56185. */
  56186. radius: number;
  56187. /**
  56188. * Agent height. [Limit: > 0]
  56189. */
  56190. height: number;
  56191. /**
  56192. * Maximum allowed acceleration. [Limit: >= 0]
  56193. */
  56194. maxAcceleration: number;
  56195. /**
  56196. * Maximum allowed speed. [Limit: >= 0]
  56197. */
  56198. maxSpeed: number;
  56199. /**
  56200. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56201. */
  56202. collisionQueryRange: number;
  56203. /**
  56204. * The path visibility optimization range. [Limit: > 0]
  56205. */
  56206. pathOptimizationRange: number;
  56207. /**
  56208. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56209. */
  56210. separationWeight: number;
  56211. }
  56212. /**
  56213. * Configures the navigation mesh creation
  56214. */
  56215. export interface INavMeshParameters {
  56216. /**
  56217. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56218. */
  56219. cs: number;
  56220. /**
  56221. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56222. */
  56223. ch: number;
  56224. /**
  56225. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56226. */
  56227. walkableSlopeAngle: number;
  56228. /**
  56229. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56230. * be considered walkable. [Limit: >= 3] [Units: vx]
  56231. */
  56232. walkableHeight: number;
  56233. /**
  56234. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56235. */
  56236. walkableClimb: number;
  56237. /**
  56238. * The distance to erode/shrink the walkable area of the heightfield away from
  56239. * obstructions. [Limit: >=0] [Units: vx]
  56240. */
  56241. walkableRadius: number;
  56242. /**
  56243. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56244. */
  56245. maxEdgeLen: number;
  56246. /**
  56247. * The maximum distance a simplfied contour's border edges should deviate
  56248. * the original raw contour. [Limit: >=0] [Units: vx]
  56249. */
  56250. maxSimplificationError: number;
  56251. /**
  56252. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56253. */
  56254. minRegionArea: number;
  56255. /**
  56256. * Any regions with a span count smaller than this value will, if possible,
  56257. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56258. */
  56259. mergeRegionArea: number;
  56260. /**
  56261. * The maximum number of vertices allowed for polygons generated during the
  56262. * contour to polygon conversion process. [Limit: >= 3]
  56263. */
  56264. maxVertsPerPoly: number;
  56265. /**
  56266. * Sets the sampling distance to use when generating the detail mesh.
  56267. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56268. */
  56269. detailSampleDist: number;
  56270. /**
  56271. * The maximum distance the detail mesh surface should deviate from heightfield
  56272. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56273. */
  56274. detailSampleMaxError: number;
  56275. }
  56276. }
  56277. declare module BABYLON {
  56278. /**
  56279. * RecastJS navigation plugin
  56280. */
  56281. export class RecastJSPlugin implements INavigationEnginePlugin {
  56282. /**
  56283. * Reference to the Recast library
  56284. */
  56285. bjsRECAST: any;
  56286. /**
  56287. * plugin name
  56288. */
  56289. name: string;
  56290. /**
  56291. * the first navmesh created. We might extend this to support multiple navmeshes
  56292. */
  56293. navMesh: any;
  56294. /**
  56295. * Initializes the recastJS plugin
  56296. * @param recastInjection can be used to inject your own recast reference
  56297. */
  56298. constructor(recastInjection?: any);
  56299. /**
  56300. * Creates a navigation mesh
  56301. * @param meshes array of all the geometry used to compute the navigatio mesh
  56302. * @param parameters bunch of parameters used to filter geometry
  56303. */
  56304. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56305. /**
  56306. * Create a navigation mesh debug mesh
  56307. * @param scene is where the mesh will be added
  56308. * @returns debug display mesh
  56309. */
  56310. createDebugNavMesh(scene: Scene): Mesh;
  56311. /**
  56312. * Get a navigation mesh constrained position, closest to the parameter position
  56313. * @param position world position
  56314. * @returns the closest point to position constrained by the navigation mesh
  56315. */
  56316. getClosestPoint(position: Vector3): Vector3;
  56317. /**
  56318. * Get a navigation mesh constrained position, within a particular radius
  56319. * @param position world position
  56320. * @param maxRadius the maximum distance to the constrained world position
  56321. * @returns the closest point to position constrained by the navigation mesh
  56322. */
  56323. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56324. /**
  56325. * Compute the final position from a segment made of destination-position
  56326. * @param position world position
  56327. * @param destination world position
  56328. * @returns the resulting point along the navmesh
  56329. */
  56330. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56331. /**
  56332. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56333. * @param start world position
  56334. * @param end world position
  56335. * @returns array containing world position composing the path
  56336. */
  56337. computePath(start: Vector3, end: Vector3): Vector3[];
  56338. /**
  56339. * Create a new Crowd so you can add agents
  56340. * @param maxAgents the maximum agent count in the crowd
  56341. * @param maxAgentRadius the maximum radius an agent can have
  56342. * @param scene to attach the crowd to
  56343. * @returns the crowd you can add agents to
  56344. */
  56345. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56346. /**
  56347. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56348. * The queries will try to find a solution within those bounds
  56349. * default is (1,1,1)
  56350. * @param extent x,y,z value that define the extent around the queries point of reference
  56351. */
  56352. setDefaultQueryExtent(extent: Vector3): void;
  56353. /**
  56354. * Get the Bounding box extent specified by setDefaultQueryExtent
  56355. * @returns the box extent values
  56356. */
  56357. getDefaultQueryExtent(): Vector3;
  56358. /**
  56359. * Disposes
  56360. */
  56361. dispose(): void;
  56362. /**
  56363. * If this plugin is supported
  56364. * @returns true if plugin is supported
  56365. */
  56366. isSupported(): boolean;
  56367. }
  56368. /**
  56369. * Recast detour crowd implementation
  56370. */
  56371. export class RecastJSCrowd implements ICrowd {
  56372. /**
  56373. * Recast/detour plugin
  56374. */
  56375. bjsRECASTPlugin: RecastJSPlugin;
  56376. /**
  56377. * Link to the detour crowd
  56378. */
  56379. recastCrowd: any;
  56380. /**
  56381. * One transform per agent
  56382. */
  56383. transforms: TransformNode[];
  56384. /**
  56385. * All agents created
  56386. */
  56387. agents: number[];
  56388. /**
  56389. * Link to the scene is kept to unregister the crowd from the scene
  56390. */
  56391. private _scene;
  56392. /**
  56393. * Observer for crowd updates
  56394. */
  56395. private _onBeforeAnimationsObserver;
  56396. /**
  56397. * Constructor
  56398. * @param plugin recastJS plugin
  56399. * @param maxAgents the maximum agent count in the crowd
  56400. * @param maxAgentRadius the maximum radius an agent can have
  56401. * @param scene to attach the crowd to
  56402. * @returns the crowd you can add agents to
  56403. */
  56404. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56405. /**
  56406. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56407. * You can attach anything to that node. The node position is updated in the scene update tick.
  56408. * @param pos world position that will be constrained by the navigation mesh
  56409. * @param parameters agent parameters
  56410. * @param transform hooked to the agent that will be update by the scene
  56411. * @returns agent index
  56412. */
  56413. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56414. /**
  56415. * Returns the agent position in world space
  56416. * @param index agent index returned by addAgent
  56417. * @returns world space position
  56418. */
  56419. getAgentPosition(index: number): Vector3;
  56420. /**
  56421. * Returns the agent velocity in world space
  56422. * @param index agent index returned by addAgent
  56423. * @returns world space velocity
  56424. */
  56425. getAgentVelocity(index: number): Vector3;
  56426. /**
  56427. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56428. * @param index agent index returned by addAgent
  56429. * @param destination targeted world position
  56430. */
  56431. agentGoto(index: number, destination: Vector3): void;
  56432. /**
  56433. * remove a particular agent previously created
  56434. * @param index agent index returned by addAgent
  56435. */
  56436. removeAgent(index: number): void;
  56437. /**
  56438. * get the list of all agents attached to this crowd
  56439. * @returns list of agent indices
  56440. */
  56441. getAgents(): number[];
  56442. /**
  56443. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56444. * @param deltaTime in seconds
  56445. */
  56446. update(deltaTime: number): void;
  56447. /**
  56448. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56449. * The queries will try to find a solution within those bounds
  56450. * default is (1,1,1)
  56451. * @param extent x,y,z value that define the extent around the queries point of reference
  56452. */
  56453. setDefaultQueryExtent(extent: Vector3): void;
  56454. /**
  56455. * Get the Bounding box extent specified by setDefaultQueryExtent
  56456. * @returns the box extent values
  56457. */
  56458. getDefaultQueryExtent(): Vector3;
  56459. /**
  56460. * Release all resources
  56461. */
  56462. dispose(): void;
  56463. }
  56464. }
  56465. declare module BABYLON {
  56466. /**
  56467. * Class used to enable access to IndexedDB
  56468. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56469. */
  56470. export class Database implements IOfflineProvider {
  56471. private _callbackManifestChecked;
  56472. private _currentSceneUrl;
  56473. private _db;
  56474. private _enableSceneOffline;
  56475. private _enableTexturesOffline;
  56476. private _manifestVersionFound;
  56477. private _mustUpdateRessources;
  56478. private _hasReachedQuota;
  56479. private _isSupported;
  56480. private _idbFactory;
  56481. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56482. private static IsUASupportingBlobStorage;
  56483. /**
  56484. * Gets a boolean indicating if Database storate is enabled (off by default)
  56485. */
  56486. static IDBStorageEnabled: boolean;
  56487. /**
  56488. * Gets a boolean indicating if scene must be saved in the database
  56489. */
  56490. readonly enableSceneOffline: boolean;
  56491. /**
  56492. * Gets a boolean indicating if textures must be saved in the database
  56493. */
  56494. readonly enableTexturesOffline: boolean;
  56495. /**
  56496. * Creates a new Database
  56497. * @param urlToScene defines the url to load the scene
  56498. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56499. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56500. */
  56501. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56502. private static _ParseURL;
  56503. private static _ReturnFullUrlLocation;
  56504. private _checkManifestFile;
  56505. /**
  56506. * Open the database and make it available
  56507. * @param successCallback defines the callback to call on success
  56508. * @param errorCallback defines the callback to call on error
  56509. */
  56510. open(successCallback: () => void, errorCallback: () => void): void;
  56511. /**
  56512. * Loads an image from the database
  56513. * @param url defines the url to load from
  56514. * @param image defines the target DOM image
  56515. */
  56516. loadImage(url: string, image: HTMLImageElement): void;
  56517. private _loadImageFromDBAsync;
  56518. private _saveImageIntoDBAsync;
  56519. private _checkVersionFromDB;
  56520. private _loadVersionFromDBAsync;
  56521. private _saveVersionIntoDBAsync;
  56522. /**
  56523. * Loads a file from database
  56524. * @param url defines the URL to load from
  56525. * @param sceneLoaded defines a callback to call on success
  56526. * @param progressCallBack defines a callback to call when progress changed
  56527. * @param errorCallback defines a callback to call on error
  56528. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56529. */
  56530. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56531. private _loadFileAsync;
  56532. private _saveFileAsync;
  56533. /**
  56534. * Validates if xhr data is correct
  56535. * @param xhr defines the request to validate
  56536. * @param dataType defines the expected data type
  56537. * @returns true if data is correct
  56538. */
  56539. private static _ValidateXHRData;
  56540. }
  56541. }
  56542. declare module BABYLON {
  56543. /** @hidden */
  56544. export var gpuUpdateParticlesPixelShader: {
  56545. name: string;
  56546. shader: string;
  56547. };
  56548. }
  56549. declare module BABYLON {
  56550. /** @hidden */
  56551. export var gpuUpdateParticlesVertexShader: {
  56552. name: string;
  56553. shader: string;
  56554. };
  56555. }
  56556. declare module BABYLON {
  56557. /** @hidden */
  56558. export var clipPlaneFragmentDeclaration2: {
  56559. name: string;
  56560. shader: string;
  56561. };
  56562. }
  56563. declare module BABYLON {
  56564. /** @hidden */
  56565. export var gpuRenderParticlesPixelShader: {
  56566. name: string;
  56567. shader: string;
  56568. };
  56569. }
  56570. declare module BABYLON {
  56571. /** @hidden */
  56572. export var clipPlaneVertexDeclaration2: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module BABYLON {
  56578. /** @hidden */
  56579. export var gpuRenderParticlesVertexShader: {
  56580. name: string;
  56581. shader: string;
  56582. };
  56583. }
  56584. declare module BABYLON {
  56585. /**
  56586. * This represents a GPU particle system in Babylon
  56587. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56588. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56589. */
  56590. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56591. /**
  56592. * The layer mask we are rendering the particles through.
  56593. */
  56594. layerMask: number;
  56595. private _capacity;
  56596. private _activeCount;
  56597. private _currentActiveCount;
  56598. private _accumulatedCount;
  56599. private _renderEffect;
  56600. private _updateEffect;
  56601. private _buffer0;
  56602. private _buffer1;
  56603. private _spriteBuffer;
  56604. private _updateVAO;
  56605. private _renderVAO;
  56606. private _targetIndex;
  56607. private _sourceBuffer;
  56608. private _targetBuffer;
  56609. private _engine;
  56610. private _currentRenderId;
  56611. private _started;
  56612. private _stopped;
  56613. private _timeDelta;
  56614. private _randomTexture;
  56615. private _randomTexture2;
  56616. private _attributesStrideSize;
  56617. private _updateEffectOptions;
  56618. private _randomTextureSize;
  56619. private _actualFrame;
  56620. private readonly _rawTextureWidth;
  56621. /**
  56622. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56623. */
  56624. static readonly IsSupported: boolean;
  56625. /**
  56626. * An event triggered when the system is disposed.
  56627. */
  56628. onDisposeObservable: Observable<GPUParticleSystem>;
  56629. /**
  56630. * Gets the maximum number of particles active at the same time.
  56631. * @returns The max number of active particles.
  56632. */
  56633. getCapacity(): number;
  56634. /**
  56635. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56636. * to override the particles.
  56637. */
  56638. forceDepthWrite: boolean;
  56639. /**
  56640. * Gets or set the number of active particles
  56641. */
  56642. activeParticleCount: number;
  56643. private _preWarmDone;
  56644. /**
  56645. * Is this system ready to be used/rendered
  56646. * @return true if the system is ready
  56647. */
  56648. isReady(): boolean;
  56649. /**
  56650. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56651. * @returns True if it has been started, otherwise false.
  56652. */
  56653. isStarted(): boolean;
  56654. /**
  56655. * Starts the particle system and begins to emit
  56656. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56657. */
  56658. start(delay?: number): void;
  56659. /**
  56660. * Stops the particle system.
  56661. */
  56662. stop(): void;
  56663. /**
  56664. * Remove all active particles
  56665. */
  56666. reset(): void;
  56667. /**
  56668. * Returns the string "GPUParticleSystem"
  56669. * @returns a string containing the class name
  56670. */
  56671. getClassName(): string;
  56672. private _colorGradientsTexture;
  56673. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56674. /**
  56675. * Adds a new color gradient
  56676. * @param gradient defines the gradient to use (between 0 and 1)
  56677. * @param color1 defines the color to affect to the specified gradient
  56678. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56679. * @returns the current particle system
  56680. */
  56681. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56682. /**
  56683. * Remove a specific color gradient
  56684. * @param gradient defines the gradient to remove
  56685. * @returns the current particle system
  56686. */
  56687. removeColorGradient(gradient: number): GPUParticleSystem;
  56688. private _angularSpeedGradientsTexture;
  56689. private _sizeGradientsTexture;
  56690. private _velocityGradientsTexture;
  56691. private _limitVelocityGradientsTexture;
  56692. private _dragGradientsTexture;
  56693. private _addFactorGradient;
  56694. /**
  56695. * Adds a new size gradient
  56696. * @param gradient defines the gradient to use (between 0 and 1)
  56697. * @param factor defines the size factor to affect to the specified gradient
  56698. * @returns the current particle system
  56699. */
  56700. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56701. /**
  56702. * Remove a specific size gradient
  56703. * @param gradient defines the gradient to remove
  56704. * @returns the current particle system
  56705. */
  56706. removeSizeGradient(gradient: number): GPUParticleSystem;
  56707. /**
  56708. * Adds a new angular speed gradient
  56709. * @param gradient defines the gradient to use (between 0 and 1)
  56710. * @param factor defines the angular speed to affect to the specified gradient
  56711. * @returns the current particle system
  56712. */
  56713. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56714. /**
  56715. * Remove a specific angular speed gradient
  56716. * @param gradient defines the gradient to remove
  56717. * @returns the current particle system
  56718. */
  56719. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56720. /**
  56721. * Adds a new velocity gradient
  56722. * @param gradient defines the gradient to use (between 0 and 1)
  56723. * @param factor defines the velocity to affect to the specified gradient
  56724. * @returns the current particle system
  56725. */
  56726. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56727. /**
  56728. * Remove a specific velocity gradient
  56729. * @param gradient defines the gradient to remove
  56730. * @returns the current particle system
  56731. */
  56732. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56733. /**
  56734. * Adds a new limit velocity gradient
  56735. * @param gradient defines the gradient to use (between 0 and 1)
  56736. * @param factor defines the limit velocity value to affect to the specified gradient
  56737. * @returns the current particle system
  56738. */
  56739. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56740. /**
  56741. * Remove a specific limit velocity gradient
  56742. * @param gradient defines the gradient to remove
  56743. * @returns the current particle system
  56744. */
  56745. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56746. /**
  56747. * Adds a new drag gradient
  56748. * @param gradient defines the gradient to use (between 0 and 1)
  56749. * @param factor defines the drag value to affect to the specified gradient
  56750. * @returns the current particle system
  56751. */
  56752. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56753. /**
  56754. * Remove a specific drag gradient
  56755. * @param gradient defines the gradient to remove
  56756. * @returns the current particle system
  56757. */
  56758. removeDragGradient(gradient: number): GPUParticleSystem;
  56759. /**
  56760. * Not supported by GPUParticleSystem
  56761. * @param gradient defines the gradient to use (between 0 and 1)
  56762. * @param factor defines the emit rate value to affect to the specified gradient
  56763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56764. * @returns the current particle system
  56765. */
  56766. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56767. /**
  56768. * Not supported by GPUParticleSystem
  56769. * @param gradient defines the gradient to remove
  56770. * @returns the current particle system
  56771. */
  56772. removeEmitRateGradient(gradient: number): IParticleSystem;
  56773. /**
  56774. * Not supported by GPUParticleSystem
  56775. * @param gradient defines the gradient to use (between 0 and 1)
  56776. * @param factor defines the start size value to affect to the specified gradient
  56777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56778. * @returns the current particle system
  56779. */
  56780. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56781. /**
  56782. * Not supported by GPUParticleSystem
  56783. * @param gradient defines the gradient to remove
  56784. * @returns the current particle system
  56785. */
  56786. removeStartSizeGradient(gradient: number): IParticleSystem;
  56787. /**
  56788. * Not supported by GPUParticleSystem
  56789. * @param gradient defines the gradient to use (between 0 and 1)
  56790. * @param min defines the color remap minimal range
  56791. * @param max defines the color remap maximal range
  56792. * @returns the current particle system
  56793. */
  56794. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56795. /**
  56796. * Not supported by GPUParticleSystem
  56797. * @param gradient defines the gradient to remove
  56798. * @returns the current particle system
  56799. */
  56800. removeColorRemapGradient(): IParticleSystem;
  56801. /**
  56802. * Not supported by GPUParticleSystem
  56803. * @param gradient defines the gradient to use (between 0 and 1)
  56804. * @param min defines the alpha remap minimal range
  56805. * @param max defines the alpha remap maximal range
  56806. * @returns the current particle system
  56807. */
  56808. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56809. /**
  56810. * Not supported by GPUParticleSystem
  56811. * @param gradient defines the gradient to remove
  56812. * @returns the current particle system
  56813. */
  56814. removeAlphaRemapGradient(): IParticleSystem;
  56815. /**
  56816. * Not supported by GPUParticleSystem
  56817. * @param gradient defines the gradient to use (between 0 and 1)
  56818. * @param color defines the color to affect to the specified gradient
  56819. * @returns the current particle system
  56820. */
  56821. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56822. /**
  56823. * Not supported by GPUParticleSystem
  56824. * @param gradient defines the gradient to remove
  56825. * @returns the current particle system
  56826. */
  56827. removeRampGradient(): IParticleSystem;
  56828. /**
  56829. * Not supported by GPUParticleSystem
  56830. * @returns the list of ramp gradients
  56831. */
  56832. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56833. /**
  56834. * Not supported by GPUParticleSystem
  56835. * Gets or sets a boolean indicating that ramp gradients must be used
  56836. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56837. */
  56838. useRampGradients: boolean;
  56839. /**
  56840. * Not supported by GPUParticleSystem
  56841. * @param gradient defines the gradient to use (between 0 and 1)
  56842. * @param factor defines the life time factor to affect to the specified gradient
  56843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56844. * @returns the current particle system
  56845. */
  56846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56847. /**
  56848. * Not supported by GPUParticleSystem
  56849. * @param gradient defines the gradient to remove
  56850. * @returns the current particle system
  56851. */
  56852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56853. /**
  56854. * Instantiates a GPU particle system.
  56855. * 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.
  56856. * @param name The name of the particle system
  56857. * @param options The options used to create the system
  56858. * @param scene The scene the particle system belongs to
  56859. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56860. */
  56861. constructor(name: string, options: Partial<{
  56862. capacity: number;
  56863. randomTextureSize: number;
  56864. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56865. protected _reset(): void;
  56866. private _createUpdateVAO;
  56867. private _createRenderVAO;
  56868. private _initialize;
  56869. /** @hidden */ private _recreateUpdateEffect(): void;
  56870. /** @hidden */ private _recreateRenderEffect(): void;
  56871. /**
  56872. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56873. * @param preWarm defines if we are in the pre-warmimg phase
  56874. */
  56875. animate(preWarm?: boolean): void;
  56876. private _createFactorGradientTexture;
  56877. private _createSizeGradientTexture;
  56878. private _createAngularSpeedGradientTexture;
  56879. private _createVelocityGradientTexture;
  56880. private _createLimitVelocityGradientTexture;
  56881. private _createDragGradientTexture;
  56882. private _createColorGradientTexture;
  56883. /**
  56884. * Renders the particle system in its current state
  56885. * @param preWarm defines if the system should only update the particles but not render them
  56886. * @returns the current number of particles
  56887. */
  56888. render(preWarm?: boolean): number;
  56889. /**
  56890. * Rebuilds the particle system
  56891. */
  56892. rebuild(): void;
  56893. private _releaseBuffers;
  56894. private _releaseVAOs;
  56895. /**
  56896. * Disposes the particle system and free the associated resources
  56897. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56898. */
  56899. dispose(disposeTexture?: boolean): void;
  56900. /**
  56901. * Clones the particle system.
  56902. * @param name The name of the cloned object
  56903. * @param newEmitter The new emitter to use
  56904. * @returns the cloned particle system
  56905. */
  56906. clone(name: string, newEmitter: any): GPUParticleSystem;
  56907. /**
  56908. * Serializes the particle system to a JSON object.
  56909. * @returns the JSON object
  56910. */
  56911. serialize(): any;
  56912. /**
  56913. * Parses a JSON object to create a GPU particle system.
  56914. * @param parsedParticleSystem The JSON object to parse
  56915. * @param scene The scene to create the particle system in
  56916. * @param rootUrl The root url to use to load external dependencies like texture
  56917. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56918. * @returns the parsed GPU particle system
  56919. */
  56920. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56921. }
  56922. }
  56923. declare module BABYLON {
  56924. /**
  56925. * Represents a set of particle systems working together to create a specific effect
  56926. */
  56927. export class ParticleSystemSet implements IDisposable {
  56928. private _emitterCreationOptions;
  56929. private _emitterNode;
  56930. /**
  56931. * Gets the particle system list
  56932. */
  56933. systems: IParticleSystem[];
  56934. /**
  56935. * Gets the emitter node used with this set
  56936. */
  56937. readonly emitterNode: Nullable<TransformNode>;
  56938. /**
  56939. * Creates a new emitter mesh as a sphere
  56940. * @param options defines the options used to create the sphere
  56941. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56942. * @param scene defines the hosting scene
  56943. */
  56944. setEmitterAsSphere(options: {
  56945. diameter: number;
  56946. segments: number;
  56947. color: Color3;
  56948. }, renderingGroupId: number, scene: Scene): void;
  56949. /**
  56950. * Starts all particle systems of the set
  56951. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56952. */
  56953. start(emitter?: AbstractMesh): void;
  56954. /**
  56955. * Release all associated resources
  56956. */
  56957. dispose(): void;
  56958. /**
  56959. * Serialize the set into a JSON compatible object
  56960. * @returns a JSON compatible representation of the set
  56961. */
  56962. serialize(): any;
  56963. /**
  56964. * Parse a new ParticleSystemSet from a serialized source
  56965. * @param data defines a JSON compatible representation of the set
  56966. * @param scene defines the hosting scene
  56967. * @param gpu defines if we want GPU particles or CPU particles
  56968. * @returns a new ParticleSystemSet
  56969. */
  56970. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56971. }
  56972. }
  56973. declare module BABYLON {
  56974. /**
  56975. * This class is made for on one-liner static method to help creating particle system set.
  56976. */
  56977. export class ParticleHelper {
  56978. /**
  56979. * Gets or sets base Assets URL
  56980. */
  56981. static BaseAssetsUrl: string;
  56982. /**
  56983. * Create a default particle system that you can tweak
  56984. * @param emitter defines the emitter to use
  56985. * @param capacity defines the system capacity (default is 500 particles)
  56986. * @param scene defines the hosting scene
  56987. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56988. * @returns the new Particle system
  56989. */
  56990. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56991. /**
  56992. * This is the main static method (one-liner) of this helper to create different particle systems
  56993. * @param type This string represents the type to the particle system to create
  56994. * @param scene The scene where the particle system should live
  56995. * @param gpu If the system will use gpu
  56996. * @returns the ParticleSystemSet created
  56997. */
  56998. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56999. /**
  57000. * Static function used to export a particle system to a ParticleSystemSet variable.
  57001. * Please note that the emitter shape is not exported
  57002. * @param systems defines the particle systems to export
  57003. * @returns the created particle system set
  57004. */
  57005. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57006. }
  57007. }
  57008. declare module BABYLON {
  57009. interface Engine {
  57010. /**
  57011. * Create an effect to use with particle systems.
  57012. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57013. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57014. * @param uniformsNames defines a list of attribute names
  57015. * @param samplers defines an array of string used to represent textures
  57016. * @param defines defines the string containing the defines to use to compile the shaders
  57017. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57018. * @param onCompiled defines a function to call when the effect creation is successful
  57019. * @param onError defines a function to call when the effect creation has failed
  57020. * @returns the new Effect
  57021. */
  57022. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57023. }
  57024. interface Mesh {
  57025. /**
  57026. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57027. * @returns an array of IParticleSystem
  57028. */
  57029. getEmittedParticleSystems(): IParticleSystem[];
  57030. /**
  57031. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57032. * @returns an array of IParticleSystem
  57033. */
  57034. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57035. }
  57036. /**
  57037. * @hidden
  57038. */
  57039. export var _IDoNeedToBeInTheBuild: number;
  57040. }
  57041. declare module BABYLON {
  57042. interface Scene {
  57043. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  57044. /**
  57045. * Gets the current physics engine
  57046. * @returns a IPhysicsEngine or null if none attached
  57047. */
  57048. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57049. /**
  57050. * Enables physics to the current scene
  57051. * @param gravity defines the scene's gravity for the physics engine
  57052. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57053. * @return a boolean indicating if the physics engine was initialized
  57054. */
  57055. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57056. /**
  57057. * Disables and disposes the physics engine associated with the scene
  57058. */
  57059. disablePhysicsEngine(): void;
  57060. /**
  57061. * Gets a boolean indicating if there is an active physics engine
  57062. * @returns a boolean indicating if there is an active physics engine
  57063. */
  57064. isPhysicsEnabled(): boolean;
  57065. /**
  57066. * Deletes a physics compound impostor
  57067. * @param compound defines the compound to delete
  57068. */
  57069. deleteCompoundImpostor(compound: any): void;
  57070. /**
  57071. * An event triggered when physic simulation is about to be run
  57072. */
  57073. onBeforePhysicsObservable: Observable<Scene>;
  57074. /**
  57075. * An event triggered when physic simulation has been done
  57076. */
  57077. onAfterPhysicsObservable: Observable<Scene>;
  57078. }
  57079. interface AbstractMesh {
  57080. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  57081. /**
  57082. * Gets or sets impostor used for physic simulation
  57083. * @see http://doc.babylonjs.com/features/physics_engine
  57084. */
  57085. physicsImpostor: Nullable<PhysicsImpostor>;
  57086. /**
  57087. * Gets the current physics impostor
  57088. * @see http://doc.babylonjs.com/features/physics_engine
  57089. * @returns a physics impostor or null
  57090. */
  57091. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57092. /** Apply a physic impulse to the mesh
  57093. * @param force defines the force to apply
  57094. * @param contactPoint defines where to apply the force
  57095. * @returns the current mesh
  57096. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57097. */
  57098. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57099. /**
  57100. * Creates a physic joint between two meshes
  57101. * @param otherMesh defines the other mesh to use
  57102. * @param pivot1 defines the pivot to use on this mesh
  57103. * @param pivot2 defines the pivot to use on the other mesh
  57104. * @param options defines additional options (can be plugin dependent)
  57105. * @returns the current mesh
  57106. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57107. */
  57108. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57109. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  57110. }
  57111. /**
  57112. * Defines the physics engine scene component responsible to manage a physics engine
  57113. */
  57114. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57115. /**
  57116. * The component name helpful to identify the component in the list of scene components.
  57117. */
  57118. readonly name: string;
  57119. /**
  57120. * The scene the component belongs to.
  57121. */
  57122. scene: Scene;
  57123. /**
  57124. * Creates a new instance of the component for the given scene
  57125. * @param scene Defines the scene to register the component in
  57126. */
  57127. constructor(scene: Scene);
  57128. /**
  57129. * Registers the component in a given scene
  57130. */
  57131. register(): void;
  57132. /**
  57133. * Rebuilds the elements related to this component in case of
  57134. * context lost for instance.
  57135. */
  57136. rebuild(): void;
  57137. /**
  57138. * Disposes the component and the associated ressources
  57139. */
  57140. dispose(): void;
  57141. }
  57142. }
  57143. declare module BABYLON {
  57144. /**
  57145. * A helper for physics simulations
  57146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57147. */
  57148. export class PhysicsHelper {
  57149. private _scene;
  57150. private _physicsEngine;
  57151. /**
  57152. * Initializes the Physics helper
  57153. * @param scene Babylon.js scene
  57154. */
  57155. constructor(scene: Scene);
  57156. /**
  57157. * Applies a radial explosion impulse
  57158. * @param origin the origin of the explosion
  57159. * @param radiusOrEventOptions the radius or the options of radial explosion
  57160. * @param strength the explosion strength
  57161. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57162. * @returns A physics radial explosion event, or null
  57163. */
  57164. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57165. /**
  57166. * Applies a radial explosion force
  57167. * @param origin the origin of the explosion
  57168. * @param radiusOrEventOptions the radius or the options of radial explosion
  57169. * @param strength the explosion strength
  57170. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57171. * @returns A physics radial explosion event, or null
  57172. */
  57173. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57174. /**
  57175. * Creates a gravitational field
  57176. * @param origin the origin of the explosion
  57177. * @param radiusOrEventOptions the radius or the options of radial explosion
  57178. * @param strength the explosion strength
  57179. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57180. * @returns A physics gravitational field event, or null
  57181. */
  57182. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57183. /**
  57184. * Creates a physics updraft event
  57185. * @param origin the origin of the updraft
  57186. * @param radiusOrEventOptions the radius or the options of the updraft
  57187. * @param strength the strength of the updraft
  57188. * @param height the height of the updraft
  57189. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57190. * @returns A physics updraft event, or null
  57191. */
  57192. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57193. /**
  57194. * Creates a physics vortex event
  57195. * @param origin the of the vortex
  57196. * @param radiusOrEventOptions the radius or the options of the vortex
  57197. * @param strength the strength of the vortex
  57198. * @param height the height of the vortex
  57199. * @returns a Physics vortex event, or null
  57200. * A physics vortex event or null
  57201. */
  57202. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57203. }
  57204. /**
  57205. * Represents a physics radial explosion event
  57206. */
  57207. class PhysicsRadialExplosionEvent {
  57208. private _scene;
  57209. private _options;
  57210. private _sphere;
  57211. private _dataFetched;
  57212. /**
  57213. * Initializes a radial explosioin event
  57214. * @param _scene BabylonJS scene
  57215. * @param _options The options for the vortex event
  57216. */
  57217. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57218. /**
  57219. * Returns the data related to the radial explosion event (sphere).
  57220. * @returns The radial explosion event data
  57221. */
  57222. getData(): PhysicsRadialExplosionEventData;
  57223. /**
  57224. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57225. * @param impostor A physics imposter
  57226. * @param origin the origin of the explosion
  57227. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57228. */
  57229. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57230. /**
  57231. * Triggers affecterd impostors callbacks
  57232. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57233. */
  57234. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57235. /**
  57236. * Disposes the sphere.
  57237. * @param force Specifies if the sphere should be disposed by force
  57238. */
  57239. dispose(force?: boolean): void;
  57240. /*** Helpers ***/
  57241. private _prepareSphere;
  57242. private _intersectsWithSphere;
  57243. }
  57244. /**
  57245. * Represents a gravitational field event
  57246. */
  57247. class PhysicsGravitationalFieldEvent {
  57248. private _physicsHelper;
  57249. private _scene;
  57250. private _origin;
  57251. private _options;
  57252. private _tickCallback;
  57253. private _sphere;
  57254. private _dataFetched;
  57255. /**
  57256. * Initializes the physics gravitational field event
  57257. * @param _physicsHelper A physics helper
  57258. * @param _scene BabylonJS scene
  57259. * @param _origin The origin position of the gravitational field event
  57260. * @param _options The options for the vortex event
  57261. */
  57262. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57263. /**
  57264. * Returns the data related to the gravitational field event (sphere).
  57265. * @returns A gravitational field event
  57266. */
  57267. getData(): PhysicsGravitationalFieldEventData;
  57268. /**
  57269. * Enables the gravitational field.
  57270. */
  57271. enable(): void;
  57272. /**
  57273. * Disables the gravitational field.
  57274. */
  57275. disable(): void;
  57276. /**
  57277. * Disposes the sphere.
  57278. * @param force The force to dispose from the gravitational field event
  57279. */
  57280. dispose(force?: boolean): void;
  57281. private _tick;
  57282. }
  57283. /**
  57284. * Represents a physics updraft event
  57285. */
  57286. class PhysicsUpdraftEvent {
  57287. private _scene;
  57288. private _origin;
  57289. private _options;
  57290. private _physicsEngine;
  57291. private _originTop;
  57292. private _originDirection;
  57293. private _tickCallback;
  57294. private _cylinder;
  57295. private _cylinderPosition;
  57296. private _dataFetched;
  57297. /**
  57298. * Initializes the physics updraft event
  57299. * @param _scene BabylonJS scene
  57300. * @param _origin The origin position of the updraft
  57301. * @param _options The options for the updraft event
  57302. */
  57303. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57304. /**
  57305. * Returns the data related to the updraft event (cylinder).
  57306. * @returns A physics updraft event
  57307. */
  57308. getData(): PhysicsUpdraftEventData;
  57309. /**
  57310. * Enables the updraft.
  57311. */
  57312. enable(): void;
  57313. /**
  57314. * Disables the updraft.
  57315. */
  57316. disable(): void;
  57317. /**
  57318. * Disposes the cylinder.
  57319. * @param force Specifies if the updraft should be disposed by force
  57320. */
  57321. dispose(force?: boolean): void;
  57322. private getImpostorHitData;
  57323. private _tick;
  57324. /*** Helpers ***/
  57325. private _prepareCylinder;
  57326. private _intersectsWithCylinder;
  57327. }
  57328. /**
  57329. * Represents a physics vortex event
  57330. */
  57331. class PhysicsVortexEvent {
  57332. private _scene;
  57333. private _origin;
  57334. private _options;
  57335. private _physicsEngine;
  57336. private _originTop;
  57337. private _tickCallback;
  57338. private _cylinder;
  57339. private _cylinderPosition;
  57340. private _dataFetched;
  57341. /**
  57342. * Initializes the physics vortex event
  57343. * @param _scene The BabylonJS scene
  57344. * @param _origin The origin position of the vortex
  57345. * @param _options The options for the vortex event
  57346. */
  57347. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57348. /**
  57349. * Returns the data related to the vortex event (cylinder).
  57350. * @returns The physics vortex event data
  57351. */
  57352. getData(): PhysicsVortexEventData;
  57353. /**
  57354. * Enables the vortex.
  57355. */
  57356. enable(): void;
  57357. /**
  57358. * Disables the cortex.
  57359. */
  57360. disable(): void;
  57361. /**
  57362. * Disposes the sphere.
  57363. * @param force
  57364. */
  57365. dispose(force?: boolean): void;
  57366. private getImpostorHitData;
  57367. private _tick;
  57368. /*** Helpers ***/
  57369. private _prepareCylinder;
  57370. private _intersectsWithCylinder;
  57371. }
  57372. /**
  57373. * Options fot the radial explosion event
  57374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57375. */
  57376. export class PhysicsRadialExplosionEventOptions {
  57377. /**
  57378. * The radius of the sphere for the radial explosion.
  57379. */
  57380. radius: number;
  57381. /**
  57382. * The strenth of the explosion.
  57383. */
  57384. strength: number;
  57385. /**
  57386. * The strenght of the force in correspondence to the distance of the affected object
  57387. */
  57388. falloff: PhysicsRadialImpulseFalloff;
  57389. /**
  57390. * Sphere options for the radial explosion.
  57391. */
  57392. sphere: {
  57393. segments: number;
  57394. diameter: number;
  57395. };
  57396. /**
  57397. * Sphere options for the radial explosion.
  57398. */
  57399. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57400. }
  57401. /**
  57402. * Options fot the updraft event
  57403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57404. */
  57405. export class PhysicsUpdraftEventOptions {
  57406. /**
  57407. * The radius of the cylinder for the vortex
  57408. */
  57409. radius: number;
  57410. /**
  57411. * The strenth of the updraft.
  57412. */
  57413. strength: number;
  57414. /**
  57415. * The height of the cylinder for the updraft.
  57416. */
  57417. height: number;
  57418. /**
  57419. * The mode for the the updraft.
  57420. */
  57421. updraftMode: PhysicsUpdraftMode;
  57422. }
  57423. /**
  57424. * Options fot the vortex event
  57425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57426. */
  57427. export class PhysicsVortexEventOptions {
  57428. /**
  57429. * The radius of the cylinder for the vortex
  57430. */
  57431. radius: number;
  57432. /**
  57433. * The strenth of the vortex.
  57434. */
  57435. strength: number;
  57436. /**
  57437. * The height of the cylinder for the vortex.
  57438. */
  57439. height: number;
  57440. /**
  57441. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57442. */
  57443. centripetalForceThreshold: number;
  57444. /**
  57445. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57446. */
  57447. centripetalForceMultiplier: number;
  57448. /**
  57449. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57450. */
  57451. centrifugalForceMultiplier: number;
  57452. /**
  57453. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57454. */
  57455. updraftForceMultiplier: number;
  57456. }
  57457. /**
  57458. * The strenght of the force in correspondence to the distance of the affected object
  57459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57460. */
  57461. export enum PhysicsRadialImpulseFalloff {
  57462. /** Defines that impulse is constant in strength across it's whole radius */
  57463. Constant = 0,
  57464. /** Defines that impulse gets weaker if it's further from the origin */
  57465. Linear = 1
  57466. }
  57467. /**
  57468. * The strength of the force in correspondence to the distance of the affected object
  57469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57470. */
  57471. export enum PhysicsUpdraftMode {
  57472. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57473. Center = 0,
  57474. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57475. Perpendicular = 1
  57476. }
  57477. /**
  57478. * Interface for a physics hit data
  57479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57480. */
  57481. export interface PhysicsHitData {
  57482. /**
  57483. * The force applied at the contact point
  57484. */
  57485. force: Vector3;
  57486. /**
  57487. * The contact point
  57488. */
  57489. contactPoint: Vector3;
  57490. /**
  57491. * The distance from the origin to the contact point
  57492. */
  57493. distanceFromOrigin: number;
  57494. }
  57495. /**
  57496. * Interface for radial explosion event data
  57497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57498. */
  57499. export interface PhysicsRadialExplosionEventData {
  57500. /**
  57501. * A sphere used for the radial explosion event
  57502. */
  57503. sphere: Mesh;
  57504. }
  57505. /**
  57506. * Interface for gravitational field event data
  57507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57508. */
  57509. export interface PhysicsGravitationalFieldEventData {
  57510. /**
  57511. * A sphere mesh used for the gravitational field event
  57512. */
  57513. sphere: Mesh;
  57514. }
  57515. /**
  57516. * Interface for updraft event data
  57517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57518. */
  57519. export interface PhysicsUpdraftEventData {
  57520. /**
  57521. * A cylinder used for the updraft event
  57522. */
  57523. cylinder: Mesh;
  57524. }
  57525. /**
  57526. * Interface for vortex event data
  57527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57528. */
  57529. export interface PhysicsVortexEventData {
  57530. /**
  57531. * A cylinder used for the vortex event
  57532. */
  57533. cylinder: Mesh;
  57534. }
  57535. /**
  57536. * Interface for an affected physics impostor
  57537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57538. */
  57539. export interface PhysicsAffectedImpostorWithData {
  57540. /**
  57541. * The impostor affected by the effect
  57542. */
  57543. impostor: PhysicsImpostor;
  57544. /**
  57545. * The data about the hit/horce from the explosion
  57546. */
  57547. hitData: PhysicsHitData;
  57548. }
  57549. }
  57550. declare module BABYLON {
  57551. /** @hidden */
  57552. export var blackAndWhitePixelShader: {
  57553. name: string;
  57554. shader: string;
  57555. };
  57556. }
  57557. declare module BABYLON {
  57558. /**
  57559. * Post process used to render in black and white
  57560. */
  57561. export class BlackAndWhitePostProcess extends PostProcess {
  57562. /**
  57563. * Linear about to convert he result to black and white (default: 1)
  57564. */
  57565. degree: number;
  57566. /**
  57567. * Creates a black and white post process
  57568. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57569. * @param name The name of the effect.
  57570. * @param options The required width/height ratio to downsize to before computing the render pass.
  57571. * @param camera The camera to apply the render pass to.
  57572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57573. * @param engine The engine which the post process will be applied. (default: current engine)
  57574. * @param reusable If the post process can be reused on the same frame. (default: false)
  57575. */
  57576. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57577. }
  57578. }
  57579. declare module BABYLON {
  57580. /**
  57581. * This represents a set of one or more post processes in Babylon.
  57582. * A post process can be used to apply a shader to a texture after it is rendered.
  57583. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57584. */
  57585. export class PostProcessRenderEffect {
  57586. private _postProcesses;
  57587. private _getPostProcesses;
  57588. private _singleInstance;
  57589. private _cameras;
  57590. private _indicesForCamera;
  57591. /**
  57592. * Name of the effect
  57593. * @hidden
  57594. */ private _name: string;
  57595. /**
  57596. * Instantiates a post process render effect.
  57597. * A post process can be used to apply a shader to a texture after it is rendered.
  57598. * @param engine The engine the effect is tied to
  57599. * @param name The name of the effect
  57600. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57601. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57602. */
  57603. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57604. /**
  57605. * Checks if all the post processes in the effect are supported.
  57606. */
  57607. readonly isSupported: boolean;
  57608. /**
  57609. * Updates the current state of the effect
  57610. * @hidden
  57611. */ private _update(): void;
  57612. /**
  57613. * Attaches the effect on cameras
  57614. * @param cameras The camera to attach to.
  57615. * @hidden
  57616. */ private _attachCameras(cameras: Camera): void;
  57617. /**
  57618. * Attaches the effect on cameras
  57619. * @param cameras The camera to attach to.
  57620. * @hidden
  57621. */ private _attachCameras(cameras: Camera[]): void;
  57622. /**
  57623. * Detaches the effect on cameras
  57624. * @param cameras The camera to detatch from.
  57625. * @hidden
  57626. */ private _detachCameras(cameras: Camera): void;
  57627. /**
  57628. * Detatches the effect on cameras
  57629. * @param cameras The camera to detatch from.
  57630. * @hidden
  57631. */ private _detachCameras(cameras: Camera[]): void;
  57632. /**
  57633. * Enables the effect on given cameras
  57634. * @param cameras The camera to enable.
  57635. * @hidden
  57636. */ private _enable(cameras: Camera): void;
  57637. /**
  57638. * Enables the effect on given cameras
  57639. * @param cameras The camera to enable.
  57640. * @hidden
  57641. */ private _enable(cameras: Nullable<Camera[]>): void;
  57642. /**
  57643. * Disables the effect on the given cameras
  57644. * @param cameras The camera to disable.
  57645. * @hidden
  57646. */ private _disable(cameras: Camera): void;
  57647. /**
  57648. * Disables the effect on the given cameras
  57649. * @param cameras The camera to disable.
  57650. * @hidden
  57651. */ private _disable(cameras: Nullable<Camera[]>): void;
  57652. /**
  57653. * Gets a list of the post processes contained in the effect.
  57654. * @param camera The camera to get the post processes on.
  57655. * @returns The list of the post processes in the effect.
  57656. */
  57657. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. /** @hidden */
  57662. export var extractHighlightsPixelShader: {
  57663. name: string;
  57664. shader: string;
  57665. };
  57666. }
  57667. declare module BABYLON {
  57668. /**
  57669. * 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.
  57670. */
  57671. export class ExtractHighlightsPostProcess extends PostProcess {
  57672. /**
  57673. * The luminance threshold, pixels below this value will be set to black.
  57674. */
  57675. threshold: number;
  57676. /** @hidden */ private _exposure: number;
  57677. /**
  57678. * Post process which has the input texture to be used when performing highlight extraction
  57679. * @hidden
  57680. */ private _inputPostProcess: Nullable<PostProcess>;
  57681. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57682. }
  57683. }
  57684. declare module BABYLON {
  57685. /** @hidden */
  57686. export var bloomMergePixelShader: {
  57687. name: string;
  57688. shader: string;
  57689. };
  57690. }
  57691. declare module BABYLON {
  57692. /**
  57693. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57694. */
  57695. export class BloomMergePostProcess extends PostProcess {
  57696. /** Weight of the bloom to be added to the original input. */
  57697. weight: number;
  57698. /**
  57699. * Creates a new instance of @see BloomMergePostProcess
  57700. * @param name The name of the effect.
  57701. * @param originalFromInput Post process which's input will be used for the merge.
  57702. * @param blurred Blurred highlights post process which's output will be used.
  57703. * @param weight Weight of the bloom to be added to the original input.
  57704. * @param options The required width/height ratio to downsize to before computing the render pass.
  57705. * @param camera The camera to apply the render pass to.
  57706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57707. * @param engine The engine which the post process will be applied. (default: current engine)
  57708. * @param reusable If the post process can be reused on the same frame. (default: false)
  57709. * @param textureType Type of textures used when performing the post process. (default: 0)
  57710. * @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)
  57711. */
  57712. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57713. /** Weight of the bloom to be added to the original input. */
  57714. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57715. }
  57716. }
  57717. declare module BABYLON {
  57718. /**
  57719. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57720. */
  57721. export class BloomEffect extends PostProcessRenderEffect {
  57722. private bloomScale;
  57723. /**
  57724. * @hidden Internal
  57725. */ private _effects: Array<PostProcess>;
  57726. /**
  57727. * @hidden Internal
  57728. */ private _downscale: ExtractHighlightsPostProcess;
  57729. private _blurX;
  57730. private _blurY;
  57731. private _merge;
  57732. /**
  57733. * The luminance threshold to find bright areas of the image to bloom.
  57734. */
  57735. threshold: number;
  57736. /**
  57737. * The strength of the bloom.
  57738. */
  57739. weight: number;
  57740. /**
  57741. * Specifies the size of the bloom blur kernel, relative to the final output size
  57742. */
  57743. kernel: number;
  57744. /**
  57745. * Creates a new instance of @see BloomEffect
  57746. * @param scene The scene the effect belongs to.
  57747. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57748. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57749. * @param bloomWeight The the strength of bloom.
  57750. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57751. * @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)
  57752. */
  57753. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57754. /**
  57755. * Disposes each of the internal effects for a given camera.
  57756. * @param camera The camera to dispose the effect on.
  57757. */
  57758. disposeEffects(camera: Camera): void;
  57759. /**
  57760. * @hidden Internal
  57761. */ private _updateEffects(): void;
  57762. /**
  57763. * Internal
  57764. * @returns if all the contained post processes are ready.
  57765. * @hidden
  57766. */ private _isReady(): boolean;
  57767. }
  57768. }
  57769. declare module BABYLON {
  57770. /** @hidden */
  57771. export var chromaticAberrationPixelShader: {
  57772. name: string;
  57773. shader: string;
  57774. };
  57775. }
  57776. declare module BABYLON {
  57777. /**
  57778. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57779. */
  57780. export class ChromaticAberrationPostProcess extends PostProcess {
  57781. /**
  57782. * The amount of seperation of rgb channels (default: 30)
  57783. */
  57784. aberrationAmount: number;
  57785. /**
  57786. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57787. */
  57788. radialIntensity: number;
  57789. /**
  57790. * 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))
  57791. */
  57792. direction: Vector2;
  57793. /**
  57794. * 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))
  57795. */
  57796. centerPosition: Vector2;
  57797. /**
  57798. * Creates a new instance ChromaticAberrationPostProcess
  57799. * @param name The name of the effect.
  57800. * @param screenWidth The width of the screen to apply the effect on.
  57801. * @param screenHeight The height of the screen to apply the effect on.
  57802. * @param options The required width/height ratio to downsize to before computing the render pass.
  57803. * @param camera The camera to apply the render pass to.
  57804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57805. * @param engine The engine which the post process will be applied. (default: current engine)
  57806. * @param reusable If the post process can be reused on the same frame. (default: false)
  57807. * @param textureType Type of textures used when performing the post process. (default: 0)
  57808. * @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)
  57809. */
  57810. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57811. }
  57812. }
  57813. declare module BABYLON {
  57814. /** @hidden */
  57815. export var circleOfConfusionPixelShader: {
  57816. name: string;
  57817. shader: string;
  57818. };
  57819. }
  57820. declare module BABYLON {
  57821. /**
  57822. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57823. */
  57824. export class CircleOfConfusionPostProcess extends PostProcess {
  57825. /**
  57826. * 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.
  57827. */
  57828. lensSize: number;
  57829. /**
  57830. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57831. */
  57832. fStop: number;
  57833. /**
  57834. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57835. */
  57836. focusDistance: number;
  57837. /**
  57838. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57839. */
  57840. focalLength: number;
  57841. private _depthTexture;
  57842. /**
  57843. * Creates a new instance CircleOfConfusionPostProcess
  57844. * @param name The name of the effect.
  57845. * @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.
  57846. * @param options The required width/height ratio to downsize to before computing the render pass.
  57847. * @param camera The camera to apply the render pass to.
  57848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57849. * @param engine The engine which the post process will be applied. (default: current engine)
  57850. * @param reusable If the post process can be reused on the same frame. (default: false)
  57851. * @param textureType Type of textures used when performing the post process. (default: 0)
  57852. * @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)
  57853. */
  57854. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57855. /**
  57856. * 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.
  57857. */
  57858. depthTexture: RenderTargetTexture;
  57859. }
  57860. }
  57861. declare module BABYLON {
  57862. /** @hidden */
  57863. export var colorCorrectionPixelShader: {
  57864. name: string;
  57865. shader: string;
  57866. };
  57867. }
  57868. declare module BABYLON {
  57869. /**
  57870. *
  57871. * This post-process allows the modification of rendered colors by using
  57872. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57873. *
  57874. * The object needs to be provided an url to a texture containing the color
  57875. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57876. * Use an image editing software to tweak the LUT to match your needs.
  57877. *
  57878. * For an example of a color LUT, see here:
  57879. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57880. * For explanations on color grading, see here:
  57881. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57882. *
  57883. */
  57884. export class ColorCorrectionPostProcess extends PostProcess {
  57885. private _colorTableTexture;
  57886. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57887. }
  57888. }
  57889. declare module BABYLON {
  57890. /** @hidden */
  57891. export var convolutionPixelShader: {
  57892. name: string;
  57893. shader: string;
  57894. };
  57895. }
  57896. declare module BABYLON {
  57897. /**
  57898. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57899. * input texture to perform effects such as edge detection or sharpening
  57900. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57901. */
  57902. export class ConvolutionPostProcess extends PostProcess {
  57903. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57904. kernel: number[];
  57905. /**
  57906. * Creates a new instance ConvolutionPostProcess
  57907. * @param name The name of the effect.
  57908. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57909. * @param options The required width/height ratio to downsize to before computing the render pass.
  57910. * @param camera The camera to apply the render pass to.
  57911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57912. * @param engine The engine which the post process will be applied. (default: current engine)
  57913. * @param reusable If the post process can be reused on the same frame. (default: false)
  57914. * @param textureType Type of textures used when performing the post process. (default: 0)
  57915. */
  57916. constructor(name: string,
  57917. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57918. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57919. /**
  57920. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57921. */
  57922. static EdgeDetect0Kernel: number[];
  57923. /**
  57924. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57925. */
  57926. static EdgeDetect1Kernel: number[];
  57927. /**
  57928. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57929. */
  57930. static EdgeDetect2Kernel: number[];
  57931. /**
  57932. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57933. */
  57934. static SharpenKernel: number[];
  57935. /**
  57936. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57937. */
  57938. static EmbossKernel: number[];
  57939. /**
  57940. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57941. */
  57942. static GaussianKernel: number[];
  57943. }
  57944. }
  57945. declare module BABYLON {
  57946. /**
  57947. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57948. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57949. * based on samples that have a large difference in distance than the center pixel.
  57950. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57951. */
  57952. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57953. direction: Vector2;
  57954. /**
  57955. * Creates a new instance CircleOfConfusionPostProcess
  57956. * @param name The name of the effect.
  57957. * @param scene The scene the effect belongs to.
  57958. * @param direction The direction the blur should be applied.
  57959. * @param kernel The size of the kernel used to blur.
  57960. * @param options The required width/height ratio to downsize to before computing the render pass.
  57961. * @param camera The camera to apply the render pass to.
  57962. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57963. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57965. * @param engine The engine which the post process will be applied. (default: current engine)
  57966. * @param reusable If the post process can be reused on the same frame. (default: false)
  57967. * @param textureType Type of textures used when performing the post process. (default: 0)
  57968. * @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)
  57969. */
  57970. 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);
  57971. }
  57972. }
  57973. declare module BABYLON {
  57974. /** @hidden */
  57975. export var depthOfFieldMergePixelShader: {
  57976. name: string;
  57977. shader: string;
  57978. };
  57979. }
  57980. declare module BABYLON {
  57981. /**
  57982. * Options to be set when merging outputs from the default pipeline.
  57983. */
  57984. export class DepthOfFieldMergePostProcessOptions {
  57985. /**
  57986. * The original image to merge on top of
  57987. */
  57988. originalFromInput: PostProcess;
  57989. /**
  57990. * Parameters to perform the merge of the depth of field effect
  57991. */
  57992. depthOfField?: {
  57993. circleOfConfusion: PostProcess;
  57994. blurSteps: Array<PostProcess>;
  57995. };
  57996. /**
  57997. * Parameters to perform the merge of bloom effect
  57998. */
  57999. bloom?: {
  58000. blurred: PostProcess;
  58001. weight: number;
  58002. };
  58003. }
  58004. /**
  58005. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58006. */
  58007. export class DepthOfFieldMergePostProcess extends PostProcess {
  58008. private blurSteps;
  58009. /**
  58010. * Creates a new instance of DepthOfFieldMergePostProcess
  58011. * @param name The name of the effect.
  58012. * @param originalFromInput Post process which's input will be used for the merge.
  58013. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58014. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58015. * @param options The required width/height ratio to downsize to before computing the render pass.
  58016. * @param camera The camera to apply the render pass to.
  58017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58018. * @param engine The engine which the post process will be applied. (default: current engine)
  58019. * @param reusable If the post process can be reused on the same frame. (default: false)
  58020. * @param textureType Type of textures used when performing the post process. (default: 0)
  58021. * @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)
  58022. */
  58023. 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);
  58024. /**
  58025. * Updates the effect with the current post process compile time values and recompiles the shader.
  58026. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58027. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58028. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58029. * @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
  58030. * @param onCompiled Called when the shader has been compiled.
  58031. * @param onError Called if there is an error when compiling a shader.
  58032. */
  58033. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58034. }
  58035. }
  58036. declare module BABYLON {
  58037. /**
  58038. * Specifies the level of max blur that should be applied when using the depth of field effect
  58039. */
  58040. export enum DepthOfFieldEffectBlurLevel {
  58041. /**
  58042. * Subtle blur
  58043. */
  58044. Low = 0,
  58045. /**
  58046. * Medium blur
  58047. */
  58048. Medium = 1,
  58049. /**
  58050. * Large blur
  58051. */
  58052. High = 2
  58053. }
  58054. /**
  58055. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58056. */
  58057. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58058. private _circleOfConfusion;
  58059. /**
  58060. * @hidden Internal, blurs from high to low
  58061. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58062. private _depthOfFieldBlurY;
  58063. private _dofMerge;
  58064. /**
  58065. * @hidden Internal post processes in depth of field effect
  58066. */ private _effects: Array<PostProcess>;
  58067. /**
  58068. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58069. */
  58070. focalLength: number;
  58071. /**
  58072. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58073. */
  58074. fStop: number;
  58075. /**
  58076. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58077. */
  58078. focusDistance: number;
  58079. /**
  58080. * 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.
  58081. */
  58082. lensSize: number;
  58083. /**
  58084. * Creates a new instance DepthOfFieldEffect
  58085. * @param scene The scene the effect belongs to.
  58086. * @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.
  58087. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58088. * @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)
  58089. */
  58090. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58091. /**
  58092. * Get the current class name of the current effet
  58093. * @returns "DepthOfFieldEffect"
  58094. */
  58095. getClassName(): string;
  58096. /**
  58097. * 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.
  58098. */
  58099. depthTexture: RenderTargetTexture;
  58100. /**
  58101. * Disposes each of the internal effects for a given camera.
  58102. * @param camera The camera to dispose the effect on.
  58103. */
  58104. disposeEffects(camera: Camera): void;
  58105. /**
  58106. * @hidden Internal
  58107. */ private _updateEffects(): void;
  58108. /**
  58109. * Internal
  58110. * @returns if all the contained post processes are ready.
  58111. * @hidden
  58112. */ private _isReady(): boolean;
  58113. }
  58114. }
  58115. declare module BABYLON {
  58116. /** @hidden */
  58117. export var displayPassPixelShader: {
  58118. name: string;
  58119. shader: string;
  58120. };
  58121. }
  58122. declare module BABYLON {
  58123. /**
  58124. * DisplayPassPostProcess which produces an output the same as it's input
  58125. */
  58126. export class DisplayPassPostProcess extends PostProcess {
  58127. /**
  58128. * Creates the DisplayPassPostProcess
  58129. * @param name The name of the effect.
  58130. * @param options The required width/height ratio to downsize to before computing the render pass.
  58131. * @param camera The camera to apply the render pass to.
  58132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58133. * @param engine The engine which the post process will be applied. (default: current engine)
  58134. * @param reusable If the post process can be reused on the same frame. (default: false)
  58135. */
  58136. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58137. }
  58138. }
  58139. declare module BABYLON {
  58140. /** @hidden */
  58141. export var filterPixelShader: {
  58142. name: string;
  58143. shader: string;
  58144. };
  58145. }
  58146. declare module BABYLON {
  58147. /**
  58148. * Applies a kernel filter to the image
  58149. */
  58150. export class FilterPostProcess extends PostProcess {
  58151. /** The matrix to be applied to the image */
  58152. kernelMatrix: Matrix;
  58153. /**
  58154. *
  58155. * @param name The name of the effect.
  58156. * @param kernelMatrix The matrix to be applied to the image
  58157. * @param options The required width/height ratio to downsize to before computing the render pass.
  58158. * @param camera The camera to apply the render pass to.
  58159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58160. * @param engine The engine which the post process will be applied. (default: current engine)
  58161. * @param reusable If the post process can be reused on the same frame. (default: false)
  58162. */
  58163. constructor(name: string,
  58164. /** The matrix to be applied to the image */
  58165. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58166. }
  58167. }
  58168. declare module BABYLON {
  58169. /** @hidden */
  58170. export var fxaaPixelShader: {
  58171. name: string;
  58172. shader: string;
  58173. };
  58174. }
  58175. declare module BABYLON {
  58176. /** @hidden */
  58177. export var fxaaVertexShader: {
  58178. name: string;
  58179. shader: string;
  58180. };
  58181. }
  58182. declare module BABYLON {
  58183. /**
  58184. * Fxaa post process
  58185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58186. */
  58187. export class FxaaPostProcess extends PostProcess {
  58188. /** @hidden */
  58189. texelWidth: number;
  58190. /** @hidden */
  58191. texelHeight: number;
  58192. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58193. private _getDefines;
  58194. }
  58195. }
  58196. declare module BABYLON {
  58197. /** @hidden */
  58198. export var grainPixelShader: {
  58199. name: string;
  58200. shader: string;
  58201. };
  58202. }
  58203. declare module BABYLON {
  58204. /**
  58205. * The GrainPostProcess adds noise to the image at mid luminance levels
  58206. */
  58207. export class GrainPostProcess extends PostProcess {
  58208. /**
  58209. * The intensity of the grain added (default: 30)
  58210. */
  58211. intensity: number;
  58212. /**
  58213. * If the grain should be randomized on every frame
  58214. */
  58215. animated: boolean;
  58216. /**
  58217. * Creates a new instance of @see GrainPostProcess
  58218. * @param name The name of the effect.
  58219. * @param options The required width/height ratio to downsize to before computing the render pass.
  58220. * @param camera The camera to apply the render pass to.
  58221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58222. * @param engine The engine which the post process will be applied. (default: current engine)
  58223. * @param reusable If the post process can be reused on the same frame. (default: false)
  58224. * @param textureType Type of textures used when performing the post process. (default: 0)
  58225. * @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)
  58226. */
  58227. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58228. }
  58229. }
  58230. declare module BABYLON {
  58231. /** @hidden */
  58232. export var highlightsPixelShader: {
  58233. name: string;
  58234. shader: string;
  58235. };
  58236. }
  58237. declare module BABYLON {
  58238. /**
  58239. * Extracts highlights from the image
  58240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58241. */
  58242. export class HighlightsPostProcess extends PostProcess {
  58243. /**
  58244. * Extracts highlights from the image
  58245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58246. * @param name The name of the effect.
  58247. * @param options The required width/height ratio to downsize to before computing the render pass.
  58248. * @param camera The camera to apply the render pass to.
  58249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58250. * @param engine The engine which the post process will be applied. (default: current engine)
  58251. * @param reusable If the post process can be reused on the same frame. (default: false)
  58252. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58253. */
  58254. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58255. }
  58256. }
  58257. declare module BABYLON {
  58258. /** @hidden */
  58259. export var mrtFragmentDeclaration: {
  58260. name: string;
  58261. shader: string;
  58262. };
  58263. }
  58264. declare module BABYLON {
  58265. /** @hidden */
  58266. export var geometryPixelShader: {
  58267. name: string;
  58268. shader: string;
  58269. };
  58270. }
  58271. declare module BABYLON {
  58272. /** @hidden */
  58273. export var geometryVertexShader: {
  58274. name: string;
  58275. shader: string;
  58276. };
  58277. }
  58278. declare module BABYLON {
  58279. /** @hidden */
  58280. interface ISavedTransformationMatrix {
  58281. world: Matrix;
  58282. viewProjection: Matrix;
  58283. }
  58284. /**
  58285. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58286. */
  58287. export class GeometryBufferRenderer {
  58288. /**
  58289. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58290. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58291. */
  58292. static readonly POSITION_TEXTURE_TYPE: number;
  58293. /**
  58294. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58295. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58296. */
  58297. static readonly VELOCITY_TEXTURE_TYPE: number;
  58298. /**
  58299. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58300. * in order to compute objects velocities when enableVelocity is set to "true"
  58301. * @hidden
  58302. */ private _previousTransformationMatrices: {
  58303. [index: number]: ISavedTransformationMatrix;
  58304. };
  58305. /**
  58306. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58307. * in order to compute objects velocities when enableVelocity is set to "true"
  58308. * @hidden
  58309. */ private _previousBonesTransformationMatrices: {
  58310. [index: number]: Float32Array;
  58311. };
  58312. /**
  58313. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58314. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58315. */
  58316. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58317. private _scene;
  58318. private _multiRenderTarget;
  58319. private _ratio;
  58320. private _enablePosition;
  58321. private _enableVelocity;
  58322. private _positionIndex;
  58323. private _velocityIndex;
  58324. protected _effect: Effect;
  58325. protected _cachedDefines: string;
  58326. /**
  58327. * Set the render list (meshes to be rendered) used in the G buffer.
  58328. */
  58329. renderList: Mesh[];
  58330. /**
  58331. * Gets wether or not G buffer are supported by the running hardware.
  58332. * This requires draw buffer supports
  58333. */
  58334. readonly isSupported: boolean;
  58335. /**
  58336. * Returns the index of the given texture type in the G-Buffer textures array
  58337. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58338. * @returns the index of the given texture type in the G-Buffer textures array
  58339. */
  58340. getTextureIndex(textureType: number): number;
  58341. /**
  58342. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58343. */
  58344. /**
  58345. * Sets whether or not objects positions are enabled for the G buffer.
  58346. */
  58347. enablePosition: boolean;
  58348. /**
  58349. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58350. */
  58351. /**
  58352. * Sets wether or not objects velocities are enabled for the G buffer.
  58353. */
  58354. enableVelocity: boolean;
  58355. /**
  58356. * Gets the scene associated with the buffer.
  58357. */
  58358. readonly scene: Scene;
  58359. /**
  58360. * Gets the ratio used by the buffer during its creation.
  58361. * How big is the buffer related to the main canvas.
  58362. */
  58363. readonly ratio: number;
  58364. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  58365. /**
  58366. * Creates a new G Buffer for the scene
  58367. * @param scene The scene the buffer belongs to
  58368. * @param ratio How big is the buffer related to the main canvas.
  58369. */
  58370. constructor(scene: Scene, ratio?: number);
  58371. /**
  58372. * Checks wether everything is ready to render a submesh to the G buffer.
  58373. * @param subMesh the submesh to check readiness for
  58374. * @param useInstances is the mesh drawn using instance or not
  58375. * @returns true if ready otherwise false
  58376. */
  58377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58378. /**
  58379. * Gets the current underlying G Buffer.
  58380. * @returns the buffer
  58381. */
  58382. getGBuffer(): MultiRenderTarget;
  58383. /**
  58384. * Gets the number of samples used to render the buffer (anti aliasing).
  58385. */
  58386. /**
  58387. * Sets the number of samples used to render the buffer (anti aliasing).
  58388. */
  58389. samples: number;
  58390. /**
  58391. * Disposes the renderer and frees up associated resources.
  58392. */
  58393. dispose(): void;
  58394. protected _createRenderTargets(): void;
  58395. private _copyBonesTransformationMatrices;
  58396. }
  58397. }
  58398. declare module BABYLON {
  58399. interface Scene {
  58400. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58401. /**
  58402. * Gets or Sets the current geometry buffer associated to the scene.
  58403. */
  58404. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58405. /**
  58406. * Enables a GeometryBufferRender and associates it with the scene
  58407. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58408. * @returns the GeometryBufferRenderer
  58409. */
  58410. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58411. /**
  58412. * Disables the GeometryBufferRender associated with the scene
  58413. */
  58414. disableGeometryBufferRenderer(): void;
  58415. }
  58416. /**
  58417. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58418. * in several rendering techniques.
  58419. */
  58420. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58421. /**
  58422. * The component name helpful to identify the component in the list of scene components.
  58423. */
  58424. readonly name: string;
  58425. /**
  58426. * The scene the component belongs to.
  58427. */
  58428. scene: Scene;
  58429. /**
  58430. * Creates a new instance of the component for the given scene
  58431. * @param scene Defines the scene to register the component in
  58432. */
  58433. constructor(scene: Scene);
  58434. /**
  58435. * Registers the component in a given scene
  58436. */
  58437. register(): void;
  58438. /**
  58439. * Rebuilds the elements related to this component in case of
  58440. * context lost for instance.
  58441. */
  58442. rebuild(): void;
  58443. /**
  58444. * Disposes the component and the associated ressources
  58445. */
  58446. dispose(): void;
  58447. private _gatherRenderTargets;
  58448. }
  58449. }
  58450. declare module BABYLON {
  58451. /** @hidden */
  58452. export var motionBlurPixelShader: {
  58453. name: string;
  58454. shader: string;
  58455. };
  58456. }
  58457. declare module BABYLON {
  58458. /**
  58459. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58460. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58461. * As an example, all you have to do is to create the post-process:
  58462. * var mb = new BABYLON.MotionBlurPostProcess(
  58463. * 'mb', // The name of the effect.
  58464. * scene, // The scene containing the objects to blur according to their velocity.
  58465. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58466. * camera // The camera to apply the render pass to.
  58467. * );
  58468. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58469. */
  58470. export class MotionBlurPostProcess extends PostProcess {
  58471. /**
  58472. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58473. */
  58474. motionStrength: number;
  58475. /**
  58476. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58477. */
  58478. /**
  58479. * Sets the number of iterations to be used for motion blur quality
  58480. */
  58481. motionBlurSamples: number;
  58482. private _motionBlurSamples;
  58483. private _geometryBufferRenderer;
  58484. /**
  58485. * Creates a new instance MotionBlurPostProcess
  58486. * @param name The name of the effect.
  58487. * @param scene The scene containing the objects to blur according to their velocity.
  58488. * @param options The required width/height ratio to downsize to before computing the render pass.
  58489. * @param camera The camera to apply the render pass to.
  58490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58491. * @param engine The engine which the post process will be applied. (default: current engine)
  58492. * @param reusable If the post process can be reused on the same frame. (default: false)
  58493. * @param textureType Type of textures used when performing the post process. (default: 0)
  58494. * @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)
  58495. */
  58496. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58497. /**
  58498. * Excludes the given skinned mesh from computing bones velocities.
  58499. * 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.
  58500. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58501. */
  58502. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58503. /**
  58504. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58505. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58506. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58507. */
  58508. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58509. /**
  58510. * Disposes the post process.
  58511. * @param camera The camera to dispose the post process on.
  58512. */
  58513. dispose(camera?: Camera): void;
  58514. }
  58515. }
  58516. declare module BABYLON {
  58517. /** @hidden */
  58518. export var refractionPixelShader: {
  58519. name: string;
  58520. shader: string;
  58521. };
  58522. }
  58523. declare module BABYLON {
  58524. /**
  58525. * Post process which applies a refractin texture
  58526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58527. */
  58528. export class RefractionPostProcess extends PostProcess {
  58529. /** the base color of the refraction (used to taint the rendering) */
  58530. color: Color3;
  58531. /** simulated refraction depth */
  58532. depth: number;
  58533. /** the coefficient of the base color (0 to remove base color tainting) */
  58534. colorLevel: number;
  58535. private _refTexture;
  58536. private _ownRefractionTexture;
  58537. /**
  58538. * Gets or sets the refraction texture
  58539. * Please note that you are responsible for disposing the texture if you set it manually
  58540. */
  58541. refractionTexture: Texture;
  58542. /**
  58543. * Initializes the RefractionPostProcess
  58544. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58545. * @param name The name of the effect.
  58546. * @param refractionTextureUrl Url of the refraction texture to use
  58547. * @param color the base color of the refraction (used to taint the rendering)
  58548. * @param depth simulated refraction depth
  58549. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58550. * @param camera The camera to apply the render pass to.
  58551. * @param options The required width/height ratio to downsize to before computing the render pass.
  58552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58553. * @param engine The engine which the post process will be applied. (default: current engine)
  58554. * @param reusable If the post process can be reused on the same frame. (default: false)
  58555. */
  58556. constructor(name: string, refractionTextureUrl: string,
  58557. /** the base color of the refraction (used to taint the rendering) */
  58558. color: Color3,
  58559. /** simulated refraction depth */
  58560. depth: number,
  58561. /** the coefficient of the base color (0 to remove base color tainting) */
  58562. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58563. /**
  58564. * Disposes of the post process
  58565. * @param camera Camera to dispose post process on
  58566. */
  58567. dispose(camera: Camera): void;
  58568. }
  58569. }
  58570. declare module BABYLON {
  58571. /** @hidden */
  58572. export var sharpenPixelShader: {
  58573. name: string;
  58574. shader: string;
  58575. };
  58576. }
  58577. declare module BABYLON {
  58578. /**
  58579. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58580. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58581. */
  58582. export class SharpenPostProcess extends PostProcess {
  58583. /**
  58584. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58585. */
  58586. colorAmount: number;
  58587. /**
  58588. * How much sharpness should be applied (default: 0.3)
  58589. */
  58590. edgeAmount: number;
  58591. /**
  58592. * Creates a new instance ConvolutionPostProcess
  58593. * @param name The name of the effect.
  58594. * @param options The required width/height ratio to downsize to before computing the render pass.
  58595. * @param camera The camera to apply the render pass to.
  58596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58597. * @param engine The engine which the post process will be applied. (default: current engine)
  58598. * @param reusable If the post process can be reused on the same frame. (default: false)
  58599. * @param textureType Type of textures used when performing the post process. (default: 0)
  58600. * @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)
  58601. */
  58602. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58603. }
  58604. }
  58605. declare module BABYLON {
  58606. /**
  58607. * PostProcessRenderPipeline
  58608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58609. */
  58610. export class PostProcessRenderPipeline {
  58611. private engine;
  58612. private _renderEffects;
  58613. private _renderEffectsForIsolatedPass;
  58614. /**
  58615. * List of inspectable custom properties (used by the Inspector)
  58616. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58617. */
  58618. inspectableCustomProperties: IInspectable[];
  58619. /**
  58620. * @hidden
  58621. */
  58622. protected _cameras: Camera[];
  58623. /** @hidden */ private _name: string;
  58624. /**
  58625. * Gets pipeline name
  58626. */
  58627. readonly name: string;
  58628. /**
  58629. * Initializes a PostProcessRenderPipeline
  58630. * @param engine engine to add the pipeline to
  58631. * @param name name of the pipeline
  58632. */
  58633. constructor(engine: Engine, name: string);
  58634. /**
  58635. * Gets the class name
  58636. * @returns "PostProcessRenderPipeline"
  58637. */
  58638. getClassName(): string;
  58639. /**
  58640. * If all the render effects in the pipeline are supported
  58641. */
  58642. readonly isSupported: boolean;
  58643. /**
  58644. * Adds an effect to the pipeline
  58645. * @param renderEffect the effect to add
  58646. */
  58647. addEffect(renderEffect: PostProcessRenderEffect): void;
  58648. /** @hidden */ private _rebuild(): void;
  58649. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  58650. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58651. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58652. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58653. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  58654. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  58655. /** @hidden */ private _detachCameras(cameras: Camera): void;
  58656. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  58657. /** @hidden */ private _update(): void;
  58658. /** @hidden */ private _reset(): void;
  58659. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58660. /**
  58661. * Disposes of the pipeline
  58662. */
  58663. dispose(): void;
  58664. }
  58665. }
  58666. declare module BABYLON {
  58667. /**
  58668. * PostProcessRenderPipelineManager class
  58669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58670. */
  58671. export class PostProcessRenderPipelineManager {
  58672. private _renderPipelines;
  58673. /**
  58674. * Initializes a PostProcessRenderPipelineManager
  58675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58676. */
  58677. constructor();
  58678. /**
  58679. * Gets the list of supported render pipelines
  58680. */
  58681. readonly supportedPipelines: PostProcessRenderPipeline[];
  58682. /**
  58683. * Adds a pipeline to the manager
  58684. * @param renderPipeline The pipeline to add
  58685. */
  58686. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58687. /**
  58688. * Attaches a camera to the pipeline
  58689. * @param renderPipelineName The name of the pipeline to attach to
  58690. * @param cameras the camera to attach
  58691. * @param unique if the camera can be attached multiple times to the pipeline
  58692. */
  58693. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58694. /**
  58695. * Detaches a camera from the pipeline
  58696. * @param renderPipelineName The name of the pipeline to detach from
  58697. * @param cameras the camera to detach
  58698. */
  58699. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58700. /**
  58701. * Enables an effect by name on a pipeline
  58702. * @param renderPipelineName the name of the pipeline to enable the effect in
  58703. * @param renderEffectName the name of the effect to enable
  58704. * @param cameras the cameras that the effect should be enabled on
  58705. */
  58706. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58707. /**
  58708. * Disables an effect by name on a pipeline
  58709. * @param renderPipelineName the name of the pipeline to disable the effect in
  58710. * @param renderEffectName the name of the effect to disable
  58711. * @param cameras the cameras that the effect should be disabled on
  58712. */
  58713. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58714. /**
  58715. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58716. */
  58717. update(): void;
  58718. /** @hidden */ private _rebuild(): void;
  58719. /**
  58720. * Disposes of the manager and pipelines
  58721. */
  58722. dispose(): void;
  58723. }
  58724. }
  58725. declare module BABYLON {
  58726. interface Scene {
  58727. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58728. /**
  58729. * Gets the postprocess render pipeline manager
  58730. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58731. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58732. */
  58733. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58734. }
  58735. /**
  58736. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58737. */
  58738. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58739. /**
  58740. * The component name helpfull to identify the component in the list of scene components.
  58741. */
  58742. readonly name: string;
  58743. /**
  58744. * The scene the component belongs to.
  58745. */
  58746. scene: Scene;
  58747. /**
  58748. * Creates a new instance of the component for the given scene
  58749. * @param scene Defines the scene to register the component in
  58750. */
  58751. constructor(scene: Scene);
  58752. /**
  58753. * Registers the component in a given scene
  58754. */
  58755. register(): void;
  58756. /**
  58757. * Rebuilds the elements related to this component in case of
  58758. * context lost for instance.
  58759. */
  58760. rebuild(): void;
  58761. /**
  58762. * Disposes the component and the associated ressources
  58763. */
  58764. dispose(): void;
  58765. private _gatherRenderTargets;
  58766. }
  58767. }
  58768. declare module BABYLON {
  58769. /**
  58770. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58771. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58772. */
  58773. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58774. private _scene;
  58775. private _camerasToBeAttached;
  58776. /**
  58777. * ID of the sharpen post process,
  58778. */
  58779. private readonly SharpenPostProcessId;
  58780. /**
  58781. * @ignore
  58782. * ID of the image processing post process;
  58783. */
  58784. readonly ImageProcessingPostProcessId: string;
  58785. /**
  58786. * @ignore
  58787. * ID of the Fast Approximate Anti-Aliasing post process;
  58788. */
  58789. readonly FxaaPostProcessId: string;
  58790. /**
  58791. * ID of the chromatic aberration post process,
  58792. */
  58793. private readonly ChromaticAberrationPostProcessId;
  58794. /**
  58795. * ID of the grain post process
  58796. */
  58797. private readonly GrainPostProcessId;
  58798. /**
  58799. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58800. */
  58801. sharpen: SharpenPostProcess;
  58802. private _sharpenEffect;
  58803. private bloom;
  58804. /**
  58805. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58806. */
  58807. depthOfField: DepthOfFieldEffect;
  58808. /**
  58809. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58810. */
  58811. fxaa: FxaaPostProcess;
  58812. /**
  58813. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58814. */
  58815. imageProcessing: ImageProcessingPostProcess;
  58816. /**
  58817. * Chromatic aberration post process which will shift rgb colors in the image
  58818. */
  58819. chromaticAberration: ChromaticAberrationPostProcess;
  58820. private _chromaticAberrationEffect;
  58821. /**
  58822. * Grain post process which add noise to the image
  58823. */
  58824. grain: GrainPostProcess;
  58825. private _grainEffect;
  58826. /**
  58827. * Glow post process which adds a glow to emissive areas of the image
  58828. */
  58829. private _glowLayer;
  58830. /**
  58831. * Animations which can be used to tweak settings over a period of time
  58832. */
  58833. animations: Animation[];
  58834. private _imageProcessingConfigurationObserver;
  58835. private _sharpenEnabled;
  58836. private _bloomEnabled;
  58837. private _depthOfFieldEnabled;
  58838. private _depthOfFieldBlurLevel;
  58839. private _fxaaEnabled;
  58840. private _imageProcessingEnabled;
  58841. private _defaultPipelineTextureType;
  58842. private _bloomScale;
  58843. private _chromaticAberrationEnabled;
  58844. private _grainEnabled;
  58845. private _buildAllowed;
  58846. /**
  58847. * Gets active scene
  58848. */
  58849. readonly scene: Scene;
  58850. /**
  58851. * Enable or disable the sharpen process from the pipeline
  58852. */
  58853. sharpenEnabled: boolean;
  58854. private _resizeObserver;
  58855. private _hardwareScaleLevel;
  58856. private _bloomKernel;
  58857. /**
  58858. * Specifies the size of the bloom blur kernel, relative to the final output size
  58859. */
  58860. bloomKernel: number;
  58861. /**
  58862. * Specifies the weight of the bloom in the final rendering
  58863. */
  58864. private _bloomWeight;
  58865. /**
  58866. * Specifies the luma threshold for the area that will be blurred by the bloom
  58867. */
  58868. private _bloomThreshold;
  58869. private _hdr;
  58870. /**
  58871. * The strength of the bloom.
  58872. */
  58873. bloomWeight: number;
  58874. /**
  58875. * The strength of the bloom.
  58876. */
  58877. bloomThreshold: number;
  58878. /**
  58879. * The scale of the bloom, lower value will provide better performance.
  58880. */
  58881. bloomScale: number;
  58882. /**
  58883. * Enable or disable the bloom from the pipeline
  58884. */
  58885. bloomEnabled: boolean;
  58886. private _rebuildBloom;
  58887. /**
  58888. * If the depth of field is enabled.
  58889. */
  58890. depthOfFieldEnabled: boolean;
  58891. /**
  58892. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58893. */
  58894. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58895. /**
  58896. * If the anti aliasing is enabled.
  58897. */
  58898. fxaaEnabled: boolean;
  58899. private _samples;
  58900. /**
  58901. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58902. */
  58903. samples: number;
  58904. /**
  58905. * If image processing is enabled.
  58906. */
  58907. imageProcessingEnabled: boolean;
  58908. /**
  58909. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58910. */
  58911. glowLayerEnabled: boolean;
  58912. /**
  58913. * Gets the glow layer (or null if not defined)
  58914. */
  58915. readonly glowLayer: Nullable<GlowLayer>;
  58916. /**
  58917. * Enable or disable the chromaticAberration process from the pipeline
  58918. */
  58919. chromaticAberrationEnabled: boolean;
  58920. /**
  58921. * Enable or disable the grain process from the pipeline
  58922. */
  58923. grainEnabled: boolean;
  58924. /**
  58925. * @constructor
  58926. * @param name - The rendering pipeline name (default: "")
  58927. * @param hdr - If high dynamic range textures should be used (default: true)
  58928. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58929. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58930. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58931. */
  58932. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58933. /**
  58934. * Get the class name
  58935. * @returns "DefaultRenderingPipeline"
  58936. */
  58937. getClassName(): string;
  58938. /**
  58939. * Force the compilation of the entire pipeline.
  58940. */
  58941. prepare(): void;
  58942. private _hasCleared;
  58943. private _prevPostProcess;
  58944. private _prevPrevPostProcess;
  58945. private _setAutoClearAndTextureSharing;
  58946. private _depthOfFieldSceneObserver;
  58947. private _buildPipeline;
  58948. private _disposePostProcesses;
  58949. /**
  58950. * Adds a camera to the pipeline
  58951. * @param camera the camera to be added
  58952. */
  58953. addCamera(camera: Camera): void;
  58954. /**
  58955. * Removes a camera from the pipeline
  58956. * @param camera the camera to remove
  58957. */
  58958. removeCamera(camera: Camera): void;
  58959. /**
  58960. * Dispose of the pipeline and stop all post processes
  58961. */
  58962. dispose(): void;
  58963. /**
  58964. * Serialize the rendering pipeline (Used when exporting)
  58965. * @returns the serialized object
  58966. */
  58967. serialize(): any;
  58968. /**
  58969. * Parse the serialized pipeline
  58970. * @param source Source pipeline.
  58971. * @param scene The scene to load the pipeline to.
  58972. * @param rootUrl The URL of the serialized pipeline.
  58973. * @returns An instantiated pipeline from the serialized object.
  58974. */
  58975. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /** @hidden */
  58980. export var lensHighlightsPixelShader: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module BABYLON {
  58986. /** @hidden */
  58987. export var depthOfFieldPixelShader: {
  58988. name: string;
  58989. shader: string;
  58990. };
  58991. }
  58992. declare module BABYLON {
  58993. /**
  58994. * BABYLON.JS Chromatic Aberration GLSL Shader
  58995. * Author: Olivier Guyot
  58996. * Separates very slightly R, G and B colors on the edges of the screen
  58997. * Inspired by Francois Tarlier & Martins Upitis
  58998. */
  58999. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59000. /**
  59001. * @ignore
  59002. * The chromatic aberration PostProcess id in the pipeline
  59003. */
  59004. LensChromaticAberrationEffect: string;
  59005. /**
  59006. * @ignore
  59007. * The highlights enhancing PostProcess id in the pipeline
  59008. */
  59009. HighlightsEnhancingEffect: string;
  59010. /**
  59011. * @ignore
  59012. * The depth-of-field PostProcess id in the pipeline
  59013. */
  59014. LensDepthOfFieldEffect: string;
  59015. private _scene;
  59016. private _depthTexture;
  59017. private _grainTexture;
  59018. private _chromaticAberrationPostProcess;
  59019. private _highlightsPostProcess;
  59020. private _depthOfFieldPostProcess;
  59021. private _edgeBlur;
  59022. private _grainAmount;
  59023. private _chromaticAberration;
  59024. private _distortion;
  59025. private _highlightsGain;
  59026. private _highlightsThreshold;
  59027. private _dofDistance;
  59028. private _dofAperture;
  59029. private _dofDarken;
  59030. private _dofPentagon;
  59031. private _blurNoise;
  59032. /**
  59033. * @constructor
  59034. *
  59035. * Effect parameters are as follow:
  59036. * {
  59037. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59038. * edge_blur: number; // from 0 to x (1 for realism)
  59039. * distortion: number; // from 0 to x (1 for realism)
  59040. * grain_amount: number; // from 0 to 1
  59041. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59042. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59043. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59044. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59045. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59046. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59047. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59048. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59049. * }
  59050. * Note: if an effect parameter is unset, effect is disabled
  59051. *
  59052. * @param name The rendering pipeline name
  59053. * @param parameters - An object containing all parameters (see above)
  59054. * @param scene The scene linked to this pipeline
  59055. * @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)
  59056. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59057. */
  59058. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59059. /**
  59060. * Get the class name
  59061. * @returns "LensRenderingPipeline"
  59062. */
  59063. getClassName(): string;
  59064. /**
  59065. * Gets associated scene
  59066. */
  59067. readonly scene: Scene;
  59068. /**
  59069. * Gets or sets the edge blur
  59070. */
  59071. edgeBlur: number;
  59072. /**
  59073. * Gets or sets the grain amount
  59074. */
  59075. grainAmount: number;
  59076. /**
  59077. * Gets or sets the chromatic aberration amount
  59078. */
  59079. chromaticAberration: number;
  59080. /**
  59081. * Gets or sets the depth of field aperture
  59082. */
  59083. dofAperture: number;
  59084. /**
  59085. * Gets or sets the edge distortion
  59086. */
  59087. edgeDistortion: number;
  59088. /**
  59089. * Gets or sets the depth of field distortion
  59090. */
  59091. dofDistortion: number;
  59092. /**
  59093. * Gets or sets the darken out of focus amount
  59094. */
  59095. darkenOutOfFocus: number;
  59096. /**
  59097. * Gets or sets a boolean indicating if blur noise is enabled
  59098. */
  59099. blurNoise: boolean;
  59100. /**
  59101. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59102. */
  59103. pentagonBokeh: boolean;
  59104. /**
  59105. * Gets or sets the highlight grain amount
  59106. */
  59107. highlightsGain: number;
  59108. /**
  59109. * Gets or sets the highlight threshold
  59110. */
  59111. highlightsThreshold: number;
  59112. /**
  59113. * Sets the amount of blur at the edges
  59114. * @param amount blur amount
  59115. */
  59116. setEdgeBlur(amount: number): void;
  59117. /**
  59118. * Sets edge blur to 0
  59119. */
  59120. disableEdgeBlur(): void;
  59121. /**
  59122. * Sets the amout of grain
  59123. * @param amount Amount of grain
  59124. */
  59125. setGrainAmount(amount: number): void;
  59126. /**
  59127. * Set grain amount to 0
  59128. */
  59129. disableGrain(): void;
  59130. /**
  59131. * Sets the chromatic aberration amount
  59132. * @param amount amount of chromatic aberration
  59133. */
  59134. setChromaticAberration(amount: number): void;
  59135. /**
  59136. * Sets chromatic aberration amount to 0
  59137. */
  59138. disableChromaticAberration(): void;
  59139. /**
  59140. * Sets the EdgeDistortion amount
  59141. * @param amount amount of EdgeDistortion
  59142. */
  59143. setEdgeDistortion(amount: number): void;
  59144. /**
  59145. * Sets edge distortion to 0
  59146. */
  59147. disableEdgeDistortion(): void;
  59148. /**
  59149. * Sets the FocusDistance amount
  59150. * @param amount amount of FocusDistance
  59151. */
  59152. setFocusDistance(amount: number): void;
  59153. /**
  59154. * Disables depth of field
  59155. */
  59156. disableDepthOfField(): void;
  59157. /**
  59158. * Sets the Aperture amount
  59159. * @param amount amount of Aperture
  59160. */
  59161. setAperture(amount: number): void;
  59162. /**
  59163. * Sets the DarkenOutOfFocus amount
  59164. * @param amount amount of DarkenOutOfFocus
  59165. */
  59166. setDarkenOutOfFocus(amount: number): void;
  59167. private _pentagonBokehIsEnabled;
  59168. /**
  59169. * Creates a pentagon bokeh effect
  59170. */
  59171. enablePentagonBokeh(): void;
  59172. /**
  59173. * Disables the pentagon bokeh effect
  59174. */
  59175. disablePentagonBokeh(): void;
  59176. /**
  59177. * Enables noise blur
  59178. */
  59179. enableNoiseBlur(): void;
  59180. /**
  59181. * Disables noise blur
  59182. */
  59183. disableNoiseBlur(): void;
  59184. /**
  59185. * Sets the HighlightsGain amount
  59186. * @param amount amount of HighlightsGain
  59187. */
  59188. setHighlightsGain(amount: number): void;
  59189. /**
  59190. * Sets the HighlightsThreshold amount
  59191. * @param amount amount of HighlightsThreshold
  59192. */
  59193. setHighlightsThreshold(amount: number): void;
  59194. /**
  59195. * Disables highlights
  59196. */
  59197. disableHighlights(): void;
  59198. /**
  59199. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59200. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59201. */
  59202. dispose(disableDepthRender?: boolean): void;
  59203. private _createChromaticAberrationPostProcess;
  59204. private _createHighlightsPostProcess;
  59205. private _createDepthOfFieldPostProcess;
  59206. private _createGrainTexture;
  59207. }
  59208. }
  59209. declare module BABYLON {
  59210. /** @hidden */
  59211. export var ssao2PixelShader: {
  59212. name: string;
  59213. shader: string;
  59214. };
  59215. }
  59216. declare module BABYLON {
  59217. /** @hidden */
  59218. export var ssaoCombinePixelShader: {
  59219. name: string;
  59220. shader: string;
  59221. };
  59222. }
  59223. declare module BABYLON {
  59224. /**
  59225. * Render pipeline to produce ssao effect
  59226. */
  59227. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59228. /**
  59229. * @ignore
  59230. * The PassPostProcess id in the pipeline that contains the original scene color
  59231. */
  59232. SSAOOriginalSceneColorEffect: string;
  59233. /**
  59234. * @ignore
  59235. * The SSAO PostProcess id in the pipeline
  59236. */
  59237. SSAORenderEffect: string;
  59238. /**
  59239. * @ignore
  59240. * The horizontal blur PostProcess id in the pipeline
  59241. */
  59242. SSAOBlurHRenderEffect: string;
  59243. /**
  59244. * @ignore
  59245. * The vertical blur PostProcess id in the pipeline
  59246. */
  59247. SSAOBlurVRenderEffect: string;
  59248. /**
  59249. * @ignore
  59250. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59251. */
  59252. SSAOCombineRenderEffect: string;
  59253. /**
  59254. * The output strength of the SSAO post-process. Default value is 1.0.
  59255. */
  59256. totalStrength: number;
  59257. /**
  59258. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59259. */
  59260. maxZ: number;
  59261. /**
  59262. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59263. */
  59264. minZAspect: number;
  59265. private _samples;
  59266. /**
  59267. * Number of samples used for the SSAO calculations. Default value is 8
  59268. */
  59269. samples: number;
  59270. private _textureSamples;
  59271. /**
  59272. * Number of samples to use for antialiasing
  59273. */
  59274. textureSamples: number;
  59275. /**
  59276. * Ratio object used for SSAO ratio and blur ratio
  59277. */
  59278. private _ratio;
  59279. /**
  59280. * Dynamically generated sphere sampler.
  59281. */
  59282. private _sampleSphere;
  59283. /**
  59284. * Blur filter offsets
  59285. */
  59286. private _samplerOffsets;
  59287. private _expensiveBlur;
  59288. /**
  59289. * If bilateral blur should be used
  59290. */
  59291. expensiveBlur: boolean;
  59292. /**
  59293. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59294. */
  59295. radius: number;
  59296. /**
  59297. * The base color of the SSAO post-process
  59298. * The final result is "base + ssao" between [0, 1]
  59299. */
  59300. base: number;
  59301. /**
  59302. * Support test.
  59303. */
  59304. static readonly IsSupported: boolean;
  59305. private _scene;
  59306. private _depthTexture;
  59307. private _normalTexture;
  59308. private _randomTexture;
  59309. private _originalColorPostProcess;
  59310. private _ssaoPostProcess;
  59311. private _blurHPostProcess;
  59312. private _blurVPostProcess;
  59313. private _ssaoCombinePostProcess;
  59314. private _firstUpdate;
  59315. /**
  59316. * Gets active scene
  59317. */
  59318. readonly scene: Scene;
  59319. /**
  59320. * @constructor
  59321. * @param name The rendering pipeline name
  59322. * @param scene The scene linked to this pipeline
  59323. * @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 }
  59324. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59325. */
  59326. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59327. /**
  59328. * Get the class name
  59329. * @returns "SSAO2RenderingPipeline"
  59330. */
  59331. getClassName(): string;
  59332. /**
  59333. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59334. */
  59335. dispose(disableGeometryBufferRenderer?: boolean): void;
  59336. private _createBlurPostProcess;
  59337. /** @hidden */ private _rebuild(): void;
  59338. private _bits;
  59339. private _radicalInverse_VdC;
  59340. private _hammersley;
  59341. private _hemisphereSample_uniform;
  59342. private _generateHemisphere;
  59343. private _createSSAOPostProcess;
  59344. private _createSSAOCombinePostProcess;
  59345. private _createRandomTexture;
  59346. /**
  59347. * Serialize the rendering pipeline (Used when exporting)
  59348. * @returns the serialized object
  59349. */
  59350. serialize(): any;
  59351. /**
  59352. * Parse the serialized pipeline
  59353. * @param source Source pipeline.
  59354. * @param scene The scene to load the pipeline to.
  59355. * @param rootUrl The URL of the serialized pipeline.
  59356. * @returns An instantiated pipeline from the serialized object.
  59357. */
  59358. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59359. }
  59360. }
  59361. declare module BABYLON {
  59362. /** @hidden */
  59363. export var ssaoPixelShader: {
  59364. name: string;
  59365. shader: string;
  59366. };
  59367. }
  59368. declare module BABYLON {
  59369. /**
  59370. * Render pipeline to produce ssao effect
  59371. */
  59372. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59373. /**
  59374. * @ignore
  59375. * The PassPostProcess id in the pipeline that contains the original scene color
  59376. */
  59377. SSAOOriginalSceneColorEffect: string;
  59378. /**
  59379. * @ignore
  59380. * The SSAO PostProcess id in the pipeline
  59381. */
  59382. SSAORenderEffect: string;
  59383. /**
  59384. * @ignore
  59385. * The horizontal blur PostProcess id in the pipeline
  59386. */
  59387. SSAOBlurHRenderEffect: string;
  59388. /**
  59389. * @ignore
  59390. * The vertical blur PostProcess id in the pipeline
  59391. */
  59392. SSAOBlurVRenderEffect: string;
  59393. /**
  59394. * @ignore
  59395. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59396. */
  59397. SSAOCombineRenderEffect: string;
  59398. /**
  59399. * The output strength of the SSAO post-process. Default value is 1.0.
  59400. */
  59401. totalStrength: number;
  59402. /**
  59403. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59404. */
  59405. radius: number;
  59406. /**
  59407. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59408. * Must not be equal to fallOff and superior to fallOff.
  59409. * Default value is 0.0075
  59410. */
  59411. area: number;
  59412. /**
  59413. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59414. * Must not be equal to area and inferior to area.
  59415. * Default value is 0.000001
  59416. */
  59417. fallOff: number;
  59418. /**
  59419. * The base color of the SSAO post-process
  59420. * The final result is "base + ssao" between [0, 1]
  59421. */
  59422. base: number;
  59423. private _scene;
  59424. private _depthTexture;
  59425. private _randomTexture;
  59426. private _originalColorPostProcess;
  59427. private _ssaoPostProcess;
  59428. private _blurHPostProcess;
  59429. private _blurVPostProcess;
  59430. private _ssaoCombinePostProcess;
  59431. private _firstUpdate;
  59432. /**
  59433. * Gets active scene
  59434. */
  59435. readonly scene: Scene;
  59436. /**
  59437. * @constructor
  59438. * @param name - The rendering pipeline name
  59439. * @param scene - The scene linked to this pipeline
  59440. * @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 }
  59441. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59442. */
  59443. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59444. /**
  59445. * Get the class name
  59446. * @returns "SSAORenderingPipeline"
  59447. */
  59448. getClassName(): string;
  59449. /**
  59450. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59451. */
  59452. dispose(disableDepthRender?: boolean): void;
  59453. private _createBlurPostProcess;
  59454. /** @hidden */ private _rebuild(): void;
  59455. private _createSSAOPostProcess;
  59456. private _createSSAOCombinePostProcess;
  59457. private _createRandomTexture;
  59458. }
  59459. }
  59460. declare module BABYLON {
  59461. /** @hidden */
  59462. export var standardPixelShader: {
  59463. name: string;
  59464. shader: string;
  59465. };
  59466. }
  59467. declare module BABYLON {
  59468. /**
  59469. * Standard rendering pipeline
  59470. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59471. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59472. */
  59473. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59474. /**
  59475. * Public members
  59476. */
  59477. /**
  59478. * Post-process which contains the original scene color before the pipeline applies all the effects
  59479. */
  59480. originalPostProcess: Nullable<PostProcess>;
  59481. /**
  59482. * Post-process used to down scale an image x4
  59483. */
  59484. downSampleX4PostProcess: Nullable<PostProcess>;
  59485. /**
  59486. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59487. */
  59488. brightPassPostProcess: Nullable<PostProcess>;
  59489. /**
  59490. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59491. */
  59492. blurHPostProcesses: PostProcess[];
  59493. /**
  59494. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59495. */
  59496. blurVPostProcesses: PostProcess[];
  59497. /**
  59498. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59499. */
  59500. textureAdderPostProcess: Nullable<PostProcess>;
  59501. /**
  59502. * Post-process used to create volumetric lighting effect
  59503. */
  59504. volumetricLightPostProcess: Nullable<PostProcess>;
  59505. /**
  59506. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59507. */
  59508. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59509. /**
  59510. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59511. */
  59512. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59513. /**
  59514. * Post-process used to merge the volumetric light effect and the real scene color
  59515. */
  59516. volumetricLightMergePostProces: Nullable<PostProcess>;
  59517. /**
  59518. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59519. */
  59520. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59521. /**
  59522. * Base post-process used to calculate the average luminance of the final image for HDR
  59523. */
  59524. luminancePostProcess: Nullable<PostProcess>;
  59525. /**
  59526. * Post-processes used to create down sample post-processes in order to get
  59527. * the average luminance of the final image for HDR
  59528. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59529. */
  59530. luminanceDownSamplePostProcesses: PostProcess[];
  59531. /**
  59532. * Post-process used to create a HDR effect (light adaptation)
  59533. */
  59534. hdrPostProcess: Nullable<PostProcess>;
  59535. /**
  59536. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59537. */
  59538. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59539. /**
  59540. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59541. */
  59542. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59543. /**
  59544. * Post-process used to merge the final HDR post-process and the real scene color
  59545. */
  59546. hdrFinalPostProcess: Nullable<PostProcess>;
  59547. /**
  59548. * Post-process used to create a lens flare effect
  59549. */
  59550. lensFlarePostProcess: Nullable<PostProcess>;
  59551. /**
  59552. * Post-process that merges the result of the lens flare post-process and the real scene color
  59553. */
  59554. lensFlareComposePostProcess: Nullable<PostProcess>;
  59555. /**
  59556. * Post-process used to create a motion blur effect
  59557. */
  59558. motionBlurPostProcess: Nullable<PostProcess>;
  59559. /**
  59560. * Post-process used to create a depth of field effect
  59561. */
  59562. depthOfFieldPostProcess: Nullable<PostProcess>;
  59563. /**
  59564. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59565. */
  59566. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59567. /**
  59568. * Represents the brightness threshold in order to configure the illuminated surfaces
  59569. */
  59570. brightThreshold: number;
  59571. /**
  59572. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59573. */
  59574. blurWidth: number;
  59575. /**
  59576. * Sets if the blur for highlighted surfaces must be only horizontal
  59577. */
  59578. horizontalBlur: boolean;
  59579. /**
  59580. * Gets the overall exposure used by the pipeline
  59581. */
  59582. /**
  59583. * Sets the overall exposure used by the pipeline
  59584. */
  59585. exposure: number;
  59586. /**
  59587. * Texture used typically to simulate "dirty" on camera lens
  59588. */
  59589. lensTexture: Nullable<Texture>;
  59590. /**
  59591. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59592. */
  59593. volumetricLightCoefficient: number;
  59594. /**
  59595. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59596. */
  59597. volumetricLightPower: number;
  59598. /**
  59599. * Used the set the blur intensity to smooth the volumetric lights
  59600. */
  59601. volumetricLightBlurScale: number;
  59602. /**
  59603. * Light (spot or directional) used to generate the volumetric lights rays
  59604. * The source light must have a shadow generate so the pipeline can get its
  59605. * depth map
  59606. */
  59607. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59608. /**
  59609. * For eye adaptation, represents the minimum luminance the eye can see
  59610. */
  59611. hdrMinimumLuminance: number;
  59612. /**
  59613. * For eye adaptation, represents the decrease luminance speed
  59614. */
  59615. hdrDecreaseRate: number;
  59616. /**
  59617. * For eye adaptation, represents the increase luminance speed
  59618. */
  59619. hdrIncreaseRate: number;
  59620. /**
  59621. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59622. */
  59623. /**
  59624. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59625. */
  59626. hdrAutoExposure: boolean;
  59627. /**
  59628. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59629. */
  59630. lensColorTexture: Nullable<Texture>;
  59631. /**
  59632. * The overall strengh for the lens flare effect
  59633. */
  59634. lensFlareStrength: number;
  59635. /**
  59636. * Dispersion coefficient for lens flare ghosts
  59637. */
  59638. lensFlareGhostDispersal: number;
  59639. /**
  59640. * Main lens flare halo width
  59641. */
  59642. lensFlareHaloWidth: number;
  59643. /**
  59644. * Based on the lens distortion effect, defines how much the lens flare result
  59645. * is distorted
  59646. */
  59647. lensFlareDistortionStrength: number;
  59648. /**
  59649. * Configures the blur intensity used for for lens flare (halo)
  59650. */
  59651. lensFlareBlurWidth: number;
  59652. /**
  59653. * Lens star texture must be used to simulate rays on the flares and is available
  59654. * in the documentation
  59655. */
  59656. lensStarTexture: Nullable<Texture>;
  59657. /**
  59658. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59659. * flare effect by taking account of the dirt texture
  59660. */
  59661. lensFlareDirtTexture: Nullable<Texture>;
  59662. /**
  59663. * Represents the focal length for the depth of field effect
  59664. */
  59665. depthOfFieldDistance: number;
  59666. /**
  59667. * Represents the blur intensity for the blurred part of the depth of field effect
  59668. */
  59669. depthOfFieldBlurWidth: number;
  59670. /**
  59671. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59672. */
  59673. /**
  59674. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59675. */
  59676. motionStrength: number;
  59677. /**
  59678. * Gets wether or not the motion blur post-process is object based or screen based.
  59679. */
  59680. /**
  59681. * Sets wether or not the motion blur post-process should be object based or screen based
  59682. */
  59683. objectBasedMotionBlur: boolean;
  59684. /**
  59685. * List of animations for the pipeline (IAnimatable implementation)
  59686. */
  59687. animations: Animation[];
  59688. /**
  59689. * Private members
  59690. */
  59691. private _scene;
  59692. private _currentDepthOfFieldSource;
  59693. private _basePostProcess;
  59694. private _fixedExposure;
  59695. private _currentExposure;
  59696. private _hdrAutoExposure;
  59697. private _hdrCurrentLuminance;
  59698. private _motionStrength;
  59699. private _isObjectBasedMotionBlur;
  59700. private _floatTextureType;
  59701. private _camerasToBeAttached;
  59702. private _ratio;
  59703. private _bloomEnabled;
  59704. private _depthOfFieldEnabled;
  59705. private _vlsEnabled;
  59706. private _lensFlareEnabled;
  59707. private _hdrEnabled;
  59708. private _motionBlurEnabled;
  59709. private _fxaaEnabled;
  59710. private _motionBlurSamples;
  59711. private _volumetricLightStepsCount;
  59712. private _samples;
  59713. /**
  59714. * @ignore
  59715. * Specifies if the bloom pipeline is enabled
  59716. */
  59717. BloomEnabled: boolean;
  59718. /**
  59719. * @ignore
  59720. * Specifies if the depth of field pipeline is enabed
  59721. */
  59722. DepthOfFieldEnabled: boolean;
  59723. /**
  59724. * @ignore
  59725. * Specifies if the lens flare pipeline is enabed
  59726. */
  59727. LensFlareEnabled: boolean;
  59728. /**
  59729. * @ignore
  59730. * Specifies if the HDR pipeline is enabled
  59731. */
  59732. HDREnabled: boolean;
  59733. /**
  59734. * @ignore
  59735. * Specifies if the volumetric lights scattering effect is enabled
  59736. */
  59737. VLSEnabled: boolean;
  59738. /**
  59739. * @ignore
  59740. * Specifies if the motion blur effect is enabled
  59741. */
  59742. MotionBlurEnabled: boolean;
  59743. /**
  59744. * Specifies if anti-aliasing is enabled
  59745. */
  59746. fxaaEnabled: boolean;
  59747. /**
  59748. * Specifies the number of steps used to calculate the volumetric lights
  59749. * Typically in interval [50, 200]
  59750. */
  59751. volumetricLightStepsCount: number;
  59752. /**
  59753. * Specifies the number of samples used for the motion blur effect
  59754. * Typically in interval [16, 64]
  59755. */
  59756. motionBlurSamples: number;
  59757. /**
  59758. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59759. */
  59760. samples: number;
  59761. /**
  59762. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59763. * @constructor
  59764. * @param name The rendering pipeline name
  59765. * @param scene The scene linked to this pipeline
  59766. * @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)
  59767. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59768. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59769. */
  59770. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59771. private _buildPipeline;
  59772. private _createDownSampleX4PostProcess;
  59773. private _createBrightPassPostProcess;
  59774. private _createBlurPostProcesses;
  59775. private _createTextureAdderPostProcess;
  59776. private _createVolumetricLightPostProcess;
  59777. private _createLuminancePostProcesses;
  59778. private _createHdrPostProcess;
  59779. private _createLensFlarePostProcess;
  59780. private _createDepthOfFieldPostProcess;
  59781. private _createMotionBlurPostProcess;
  59782. private _getDepthTexture;
  59783. private _disposePostProcesses;
  59784. /**
  59785. * Dispose of the pipeline and stop all post processes
  59786. */
  59787. dispose(): void;
  59788. /**
  59789. * Serialize the rendering pipeline (Used when exporting)
  59790. * @returns the serialized object
  59791. */
  59792. serialize(): any;
  59793. /**
  59794. * Parse the serialized pipeline
  59795. * @param source Source pipeline.
  59796. * @param scene The scene to load the pipeline to.
  59797. * @param rootUrl The URL of the serialized pipeline.
  59798. * @returns An instantiated pipeline from the serialized object.
  59799. */
  59800. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59801. /**
  59802. * Luminance steps
  59803. */
  59804. static LuminanceSteps: number;
  59805. }
  59806. }
  59807. declare module BABYLON {
  59808. /** @hidden */
  59809. export var tonemapPixelShader: {
  59810. name: string;
  59811. shader: string;
  59812. };
  59813. }
  59814. declare module BABYLON {
  59815. /** Defines operator used for tonemapping */
  59816. export enum TonemappingOperator {
  59817. /** Hable */
  59818. Hable = 0,
  59819. /** Reinhard */
  59820. Reinhard = 1,
  59821. /** HejiDawson */
  59822. HejiDawson = 2,
  59823. /** Photographic */
  59824. Photographic = 3
  59825. }
  59826. /**
  59827. * Defines a post process to apply tone mapping
  59828. */
  59829. export class TonemapPostProcess extends PostProcess {
  59830. private _operator;
  59831. /** Defines the required exposure adjustement */
  59832. exposureAdjustment: number;
  59833. /**
  59834. * Creates a new TonemapPostProcess
  59835. * @param name defines the name of the postprocess
  59836. * @param _operator defines the operator to use
  59837. * @param exposureAdjustment defines the required exposure adjustement
  59838. * @param camera defines the camera to use (can be null)
  59839. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59840. * @param engine defines the hosting engine (can be ignore if camera is set)
  59841. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59842. */
  59843. constructor(name: string, _operator: TonemappingOperator,
  59844. /** Defines the required exposure adjustement */
  59845. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59846. }
  59847. }
  59848. declare module BABYLON {
  59849. /** @hidden */
  59850. export var depthVertexShader: {
  59851. name: string;
  59852. shader: string;
  59853. };
  59854. }
  59855. declare module BABYLON {
  59856. /** @hidden */
  59857. export var volumetricLightScatteringPixelShader: {
  59858. name: string;
  59859. shader: string;
  59860. };
  59861. }
  59862. declare module BABYLON {
  59863. /** @hidden */
  59864. export var volumetricLightScatteringPassVertexShader: {
  59865. name: string;
  59866. shader: string;
  59867. };
  59868. }
  59869. declare module BABYLON {
  59870. /** @hidden */
  59871. export var volumetricLightScatteringPassPixelShader: {
  59872. name: string;
  59873. shader: string;
  59874. };
  59875. }
  59876. declare module BABYLON {
  59877. /**
  59878. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59879. */
  59880. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59881. private _volumetricLightScatteringPass;
  59882. private _volumetricLightScatteringRTT;
  59883. private _viewPort;
  59884. private _screenCoordinates;
  59885. private _cachedDefines;
  59886. /**
  59887. * If not undefined, the mesh position is computed from the attached node position
  59888. */
  59889. attachedNode: {
  59890. position: Vector3;
  59891. };
  59892. /**
  59893. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59894. */
  59895. customMeshPosition: Vector3;
  59896. /**
  59897. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59898. */
  59899. useCustomMeshPosition: boolean;
  59900. /**
  59901. * If the post-process should inverse the light scattering direction
  59902. */
  59903. invert: boolean;
  59904. /**
  59905. * The internal mesh used by the post-process
  59906. */
  59907. mesh: Mesh;
  59908. /**
  59909. * @hidden
  59910. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59911. */
  59912. useDiffuseColor: boolean;
  59913. /**
  59914. * Array containing the excluded meshes not rendered in the internal pass
  59915. */
  59916. excludedMeshes: AbstractMesh[];
  59917. /**
  59918. * Controls the overall intensity of the post-process
  59919. */
  59920. exposure: number;
  59921. /**
  59922. * Dissipates each sample's contribution in range [0, 1]
  59923. */
  59924. decay: number;
  59925. /**
  59926. * Controls the overall intensity of each sample
  59927. */
  59928. weight: number;
  59929. /**
  59930. * Controls the density of each sample
  59931. */
  59932. density: number;
  59933. /**
  59934. * @constructor
  59935. * @param name The post-process name
  59936. * @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)
  59937. * @param camera The camera that the post-process will be attached to
  59938. * @param mesh The mesh used to create the light scattering
  59939. * @param samples The post-process quality, default 100
  59940. * @param samplingModeThe post-process filtering mode
  59941. * @param engine The babylon engine
  59942. * @param reusable If the post-process is reusable
  59943. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59944. */
  59945. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59946. /**
  59947. * Returns the string "VolumetricLightScatteringPostProcess"
  59948. * @returns "VolumetricLightScatteringPostProcess"
  59949. */
  59950. getClassName(): string;
  59951. private _isReady;
  59952. /**
  59953. * Sets the new light position for light scattering effect
  59954. * @param position The new custom light position
  59955. */
  59956. setCustomMeshPosition(position: Vector3): void;
  59957. /**
  59958. * Returns the light position for light scattering effect
  59959. * @return Vector3 The custom light position
  59960. */
  59961. getCustomMeshPosition(): Vector3;
  59962. /**
  59963. * Disposes the internal assets and detaches the post-process from the camera
  59964. */
  59965. dispose(camera: Camera): void;
  59966. /**
  59967. * Returns the render target texture used by the post-process
  59968. * @return the render target texture used by the post-process
  59969. */
  59970. getPass(): RenderTargetTexture;
  59971. private _meshExcluded;
  59972. private _createPass;
  59973. private _updateMeshScreenCoordinates;
  59974. /**
  59975. * Creates a default mesh for the Volumeric Light Scattering post-process
  59976. * @param name The mesh name
  59977. * @param scene The scene where to create the mesh
  59978. * @return the default mesh
  59979. */
  59980. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59981. }
  59982. }
  59983. declare module BABYLON {
  59984. interface Scene {
  59985. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  59986. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  59987. /**
  59988. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59989. */
  59990. forceShowBoundingBoxes: boolean;
  59991. /**
  59992. * Gets the bounding box renderer associated with the scene
  59993. * @returns a BoundingBoxRenderer
  59994. */
  59995. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59996. }
  59997. interface AbstractMesh {
  59998. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  59999. /**
  60000. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60001. */
  60002. showBoundingBox: boolean;
  60003. }
  60004. /**
  60005. * Component responsible of rendering the bounding box of the meshes in a scene.
  60006. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60007. */
  60008. export class BoundingBoxRenderer implements ISceneComponent {
  60009. /**
  60010. * The component name helpfull to identify the component in the list of scene components.
  60011. */
  60012. readonly name: string;
  60013. /**
  60014. * The scene the component belongs to.
  60015. */
  60016. scene: Scene;
  60017. /**
  60018. * Color of the bounding box lines placed in front of an object
  60019. */
  60020. frontColor: Color3;
  60021. /**
  60022. * Color of the bounding box lines placed behind an object
  60023. */
  60024. backColor: Color3;
  60025. /**
  60026. * Defines if the renderer should show the back lines or not
  60027. */
  60028. showBackLines: boolean;
  60029. /**
  60030. * @hidden
  60031. */
  60032. renderList: SmartArray<BoundingBox>;
  60033. private _colorShader;
  60034. private _vertexBuffers;
  60035. private _indexBuffer;
  60036. private _fillIndexBuffer;
  60037. private _fillIndexData;
  60038. /**
  60039. * Instantiates a new bounding box renderer in a scene.
  60040. * @param scene the scene the renderer renders in
  60041. */
  60042. constructor(scene: Scene);
  60043. /**
  60044. * Registers the component in a given scene
  60045. */
  60046. register(): void;
  60047. private _evaluateSubMesh;
  60048. private _activeMesh;
  60049. private _prepareRessources;
  60050. private _createIndexBuffer;
  60051. /**
  60052. * Rebuilds the elements related to this component in case of
  60053. * context lost for instance.
  60054. */
  60055. rebuild(): void;
  60056. /**
  60057. * @hidden
  60058. */
  60059. reset(): void;
  60060. /**
  60061. * Render the bounding boxes of a specific rendering group
  60062. * @param renderingGroupId defines the rendering group to render
  60063. */
  60064. render(renderingGroupId: number): void;
  60065. /**
  60066. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60067. * @param mesh Define the mesh to render the occlusion bounding box for
  60068. */
  60069. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60070. /**
  60071. * Dispose and release the resources attached to this renderer.
  60072. */
  60073. dispose(): void;
  60074. }
  60075. }
  60076. declare module BABYLON {
  60077. /** @hidden */
  60078. export var depthPixelShader: {
  60079. name: string;
  60080. shader: string;
  60081. };
  60082. }
  60083. declare module BABYLON {
  60084. /**
  60085. * This represents a depth renderer in Babylon.
  60086. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60087. */
  60088. export class DepthRenderer {
  60089. private _scene;
  60090. private _depthMap;
  60091. private _effect;
  60092. private readonly _storeNonLinearDepth;
  60093. private readonly _clearColor;
  60094. /** Get if the depth renderer is using packed depth or not */
  60095. readonly isPacked: boolean;
  60096. private _cachedDefines;
  60097. private _camera;
  60098. /**
  60099. * Specifiess that the depth renderer will only be used within
  60100. * the camera it is created for.
  60101. * This can help forcing its rendering during the camera processing.
  60102. */
  60103. useOnlyInActiveCamera: boolean;
  60104. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  60105. /**
  60106. * Instantiates a depth renderer
  60107. * @param scene The scene the renderer belongs to
  60108. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60109. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60110. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60111. */
  60112. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60113. /**
  60114. * Creates the depth rendering effect and checks if the effect is ready.
  60115. * @param subMesh The submesh to be used to render the depth map of
  60116. * @param useInstances If multiple world instances should be used
  60117. * @returns if the depth renderer is ready to render the depth map
  60118. */
  60119. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60120. /**
  60121. * Gets the texture which the depth map will be written to.
  60122. * @returns The depth map texture
  60123. */
  60124. getDepthMap(): RenderTargetTexture;
  60125. /**
  60126. * Disposes of the depth renderer.
  60127. */
  60128. dispose(): void;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. interface Scene {
  60133. /** @hidden (Backing field) */ private _depthRenderer: {
  60134. [id: string]: DepthRenderer;
  60135. };
  60136. /**
  60137. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60138. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60139. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60140. * @returns the created depth renderer
  60141. */
  60142. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60143. /**
  60144. * Disables a depth renderer for a given camera
  60145. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60146. */
  60147. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60148. }
  60149. /**
  60150. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60151. * in several rendering techniques.
  60152. */
  60153. export class DepthRendererSceneComponent implements ISceneComponent {
  60154. /**
  60155. * The component name helpfull to identify the component in the list of scene components.
  60156. */
  60157. readonly name: string;
  60158. /**
  60159. * The scene the component belongs to.
  60160. */
  60161. scene: Scene;
  60162. /**
  60163. * Creates a new instance of the component for the given scene
  60164. * @param scene Defines the scene to register the component in
  60165. */
  60166. constructor(scene: Scene);
  60167. /**
  60168. * Registers the component in a given scene
  60169. */
  60170. register(): void;
  60171. /**
  60172. * Rebuilds the elements related to this component in case of
  60173. * context lost for instance.
  60174. */
  60175. rebuild(): void;
  60176. /**
  60177. * Disposes the component and the associated ressources
  60178. */
  60179. dispose(): void;
  60180. private _gatherRenderTargets;
  60181. private _gatherActiveCameraRenderTargets;
  60182. }
  60183. }
  60184. declare module BABYLON {
  60185. /** @hidden */
  60186. export var outlinePixelShader: {
  60187. name: string;
  60188. shader: string;
  60189. };
  60190. }
  60191. declare module BABYLON {
  60192. /** @hidden */
  60193. export var outlineVertexShader: {
  60194. name: string;
  60195. shader: string;
  60196. };
  60197. }
  60198. declare module BABYLON {
  60199. interface Scene {
  60200. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  60201. /**
  60202. * Gets the outline renderer associated with the scene
  60203. * @returns a OutlineRenderer
  60204. */
  60205. getOutlineRenderer(): OutlineRenderer;
  60206. }
  60207. interface AbstractMesh {
  60208. /** @hidden (Backing field) */ private _renderOutline: boolean;
  60209. /**
  60210. * Gets or sets a boolean indicating if the outline must be rendered as well
  60211. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60212. */
  60213. renderOutline: boolean;
  60214. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  60215. /**
  60216. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60217. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60218. */
  60219. renderOverlay: boolean;
  60220. }
  60221. /**
  60222. * This class is responsible to draw bothe outline/overlay of meshes.
  60223. * It should not be used directly but through the available method on mesh.
  60224. */
  60225. export class OutlineRenderer implements ISceneComponent {
  60226. /**
  60227. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60228. */
  60229. private static _StencilReference;
  60230. /**
  60231. * The name of the component. Each component must have a unique name.
  60232. */
  60233. name: string;
  60234. /**
  60235. * The scene the component belongs to.
  60236. */
  60237. scene: Scene;
  60238. /**
  60239. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60240. */
  60241. zOffset: number;
  60242. private _engine;
  60243. private _effect;
  60244. private _cachedDefines;
  60245. private _savedDepthWrite;
  60246. /**
  60247. * Instantiates a new outline renderer. (There could be only one per scene).
  60248. * @param scene Defines the scene it belongs to
  60249. */
  60250. constructor(scene: Scene);
  60251. /**
  60252. * Register the component to one instance of a scene.
  60253. */
  60254. register(): void;
  60255. /**
  60256. * Rebuilds the elements related to this component in case of
  60257. * context lost for instance.
  60258. */
  60259. rebuild(): void;
  60260. /**
  60261. * Disposes the component and the associated ressources.
  60262. */
  60263. dispose(): void;
  60264. /**
  60265. * Renders the outline in the canvas.
  60266. * @param subMesh Defines the sumesh to render
  60267. * @param batch Defines the batch of meshes in case of instances
  60268. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60269. */
  60270. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60271. /**
  60272. * Returns whether or not the outline renderer is ready for a given submesh.
  60273. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60274. * @param subMesh Defines the submesh to check readyness for
  60275. * @param useInstances Defines wheter wee are trying to render instances or not
  60276. * @returns true if ready otherwise false
  60277. */
  60278. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60279. private _beforeRenderingMesh;
  60280. private _afterRenderingMesh;
  60281. }
  60282. }
  60283. declare module BABYLON {
  60284. /**
  60285. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60286. * @see http://doc.babylonjs.com/babylon101/sprites
  60287. */
  60288. export class SpritePackedManager extends SpriteManager {
  60289. /** defines the packed manager's name */
  60290. name: string;
  60291. /**
  60292. * Creates a new sprite manager from a packed sprite sheet
  60293. * @param name defines the manager's name
  60294. * @param imgUrl defines the sprite sheet url
  60295. * @param capacity defines the maximum allowed number of sprites
  60296. * @param scene defines the hosting scene
  60297. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60298. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60299. * @param samplingMode defines the smapling mode to use with spritesheet
  60300. * @param fromPacked set to true; do not alter
  60301. */
  60302. constructor(
  60303. /** defines the packed manager's name */
  60304. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60305. }
  60306. }
  60307. declare module BABYLON {
  60308. /**
  60309. * Defines the list of states available for a task inside a AssetsManager
  60310. */
  60311. export enum AssetTaskState {
  60312. /**
  60313. * Initialization
  60314. */
  60315. INIT = 0,
  60316. /**
  60317. * Running
  60318. */
  60319. RUNNING = 1,
  60320. /**
  60321. * Done
  60322. */
  60323. DONE = 2,
  60324. /**
  60325. * Error
  60326. */
  60327. ERROR = 3
  60328. }
  60329. /**
  60330. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60331. */
  60332. export abstract class AbstractAssetTask {
  60333. /**
  60334. * Task name
  60335. */ name: string;
  60336. /**
  60337. * Callback called when the task is successful
  60338. */
  60339. onSuccess: (task: any) => void;
  60340. /**
  60341. * Callback called when the task is not successful
  60342. */
  60343. onError: (task: any, message?: string, exception?: any) => void;
  60344. /**
  60345. * Creates a new AssetsManager
  60346. * @param name defines the name of the task
  60347. */
  60348. constructor(
  60349. /**
  60350. * Task name
  60351. */ name: string);
  60352. private _isCompleted;
  60353. private _taskState;
  60354. private _errorObject;
  60355. /**
  60356. * Get if the task is completed
  60357. */
  60358. readonly isCompleted: boolean;
  60359. /**
  60360. * Gets the current state of the task
  60361. */
  60362. readonly taskState: AssetTaskState;
  60363. /**
  60364. * Gets the current error object (if task is in error)
  60365. */
  60366. readonly errorObject: {
  60367. message?: string;
  60368. exception?: any;
  60369. };
  60370. /**
  60371. * Internal only
  60372. * @hidden
  60373. */ private _setErrorObject(message?: string, exception?: any): void;
  60374. /**
  60375. * Execute the current task
  60376. * @param scene defines the scene where you want your assets to be loaded
  60377. * @param onSuccess is a callback called when the task is successfully executed
  60378. * @param onError is a callback called if an error occurs
  60379. */
  60380. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60381. /**
  60382. * Execute the current task
  60383. * @param scene defines the scene where you want your assets to be loaded
  60384. * @param onSuccess is a callback called when the task is successfully executed
  60385. * @param onError is a callback called if an error occurs
  60386. */
  60387. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60388. /**
  60389. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60390. * This can be used with failed tasks that have the reason for failure fixed.
  60391. */
  60392. reset(): void;
  60393. private onErrorCallback;
  60394. private onDoneCallback;
  60395. }
  60396. /**
  60397. * Define the interface used by progress events raised during assets loading
  60398. */
  60399. export interface IAssetsProgressEvent {
  60400. /**
  60401. * Defines the number of remaining tasks to process
  60402. */
  60403. remainingCount: number;
  60404. /**
  60405. * Defines the total number of tasks
  60406. */
  60407. totalCount: number;
  60408. /**
  60409. * Defines the task that was just processed
  60410. */
  60411. task: AbstractAssetTask;
  60412. }
  60413. /**
  60414. * Class used to share progress information about assets loading
  60415. */
  60416. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60417. /**
  60418. * Defines the number of remaining tasks to process
  60419. */
  60420. remainingCount: number;
  60421. /**
  60422. * Defines the total number of tasks
  60423. */
  60424. totalCount: number;
  60425. /**
  60426. * Defines the task that was just processed
  60427. */
  60428. task: AbstractAssetTask;
  60429. /**
  60430. * Creates a AssetsProgressEvent
  60431. * @param remainingCount defines the number of remaining tasks to process
  60432. * @param totalCount defines the total number of tasks
  60433. * @param task defines the task that was just processed
  60434. */
  60435. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60436. }
  60437. /**
  60438. * Define a task used by AssetsManager to load meshes
  60439. */
  60440. export class MeshAssetTask extends AbstractAssetTask {
  60441. /**
  60442. * Defines the name of the task
  60443. */
  60444. name: string;
  60445. /**
  60446. * Defines the list of mesh's names you want to load
  60447. */
  60448. meshesNames: any;
  60449. /**
  60450. * Defines the root url to use as a base to load your meshes and associated resources
  60451. */
  60452. rootUrl: string;
  60453. /**
  60454. * Defines the filename of the scene to load from
  60455. */
  60456. sceneFilename: string;
  60457. /**
  60458. * Gets the list of loaded meshes
  60459. */
  60460. loadedMeshes: Array<AbstractMesh>;
  60461. /**
  60462. * Gets the list of loaded particle systems
  60463. */
  60464. loadedParticleSystems: Array<IParticleSystem>;
  60465. /**
  60466. * Gets the list of loaded skeletons
  60467. */
  60468. loadedSkeletons: Array<Skeleton>;
  60469. /**
  60470. * Gets the list of loaded animation groups
  60471. */
  60472. loadedAnimationGroups: Array<AnimationGroup>;
  60473. /**
  60474. * Callback called when the task is successful
  60475. */
  60476. onSuccess: (task: MeshAssetTask) => void;
  60477. /**
  60478. * Callback called when the task is successful
  60479. */
  60480. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60481. /**
  60482. * Creates a new MeshAssetTask
  60483. * @param name defines the name of the task
  60484. * @param meshesNames defines the list of mesh's names you want to load
  60485. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60486. * @param sceneFilename defines the filename of the scene to load from
  60487. */
  60488. constructor(
  60489. /**
  60490. * Defines the name of the task
  60491. */
  60492. name: string,
  60493. /**
  60494. * Defines the list of mesh's names you want to load
  60495. */
  60496. meshesNames: any,
  60497. /**
  60498. * Defines the root url to use as a base to load your meshes and associated resources
  60499. */
  60500. rootUrl: string,
  60501. /**
  60502. * Defines the filename of the scene to load from
  60503. */
  60504. sceneFilename: string);
  60505. /**
  60506. * Execute the current task
  60507. * @param scene defines the scene where you want your assets to be loaded
  60508. * @param onSuccess is a callback called when the task is successfully executed
  60509. * @param onError is a callback called if an error occurs
  60510. */
  60511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60512. }
  60513. /**
  60514. * Define a task used by AssetsManager to load text content
  60515. */
  60516. export class TextFileAssetTask extends AbstractAssetTask {
  60517. /**
  60518. * Defines the name of the task
  60519. */
  60520. name: string;
  60521. /**
  60522. * Defines the location of the file to load
  60523. */
  60524. url: string;
  60525. /**
  60526. * Gets the loaded text string
  60527. */
  60528. text: string;
  60529. /**
  60530. * Callback called when the task is successful
  60531. */
  60532. onSuccess: (task: TextFileAssetTask) => void;
  60533. /**
  60534. * Callback called when the task is successful
  60535. */
  60536. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60537. /**
  60538. * Creates a new TextFileAssetTask object
  60539. * @param name defines the name of the task
  60540. * @param url defines the location of the file to load
  60541. */
  60542. constructor(
  60543. /**
  60544. * Defines the name of the task
  60545. */
  60546. name: string,
  60547. /**
  60548. * Defines the location of the file to load
  60549. */
  60550. url: string);
  60551. /**
  60552. * Execute the current task
  60553. * @param scene defines the scene where you want your assets to be loaded
  60554. * @param onSuccess is a callback called when the task is successfully executed
  60555. * @param onError is a callback called if an error occurs
  60556. */
  60557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60558. }
  60559. /**
  60560. * Define a task used by AssetsManager to load binary data
  60561. */
  60562. export class BinaryFileAssetTask extends AbstractAssetTask {
  60563. /**
  60564. * Defines the name of the task
  60565. */
  60566. name: string;
  60567. /**
  60568. * Defines the location of the file to load
  60569. */
  60570. url: string;
  60571. /**
  60572. * Gets the lodaded data (as an array buffer)
  60573. */
  60574. data: ArrayBuffer;
  60575. /**
  60576. * Callback called when the task is successful
  60577. */
  60578. onSuccess: (task: BinaryFileAssetTask) => void;
  60579. /**
  60580. * Callback called when the task is successful
  60581. */
  60582. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60583. /**
  60584. * Creates a new BinaryFileAssetTask object
  60585. * @param name defines the name of the new task
  60586. * @param url defines the location of the file to load
  60587. */
  60588. constructor(
  60589. /**
  60590. * Defines the name of the task
  60591. */
  60592. name: string,
  60593. /**
  60594. * Defines the location of the file to load
  60595. */
  60596. url: string);
  60597. /**
  60598. * Execute the current task
  60599. * @param scene defines the scene where you want your assets to be loaded
  60600. * @param onSuccess is a callback called when the task is successfully executed
  60601. * @param onError is a callback called if an error occurs
  60602. */
  60603. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60604. }
  60605. /**
  60606. * Define a task used by AssetsManager to load images
  60607. */
  60608. export class ImageAssetTask extends AbstractAssetTask {
  60609. /**
  60610. * Defines the name of the task
  60611. */
  60612. name: string;
  60613. /**
  60614. * Defines the location of the image to load
  60615. */
  60616. url: string;
  60617. /**
  60618. * Gets the loaded images
  60619. */
  60620. image: HTMLImageElement;
  60621. /**
  60622. * Callback called when the task is successful
  60623. */
  60624. onSuccess: (task: ImageAssetTask) => void;
  60625. /**
  60626. * Callback called when the task is successful
  60627. */
  60628. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60629. /**
  60630. * Creates a new ImageAssetTask
  60631. * @param name defines the name of the task
  60632. * @param url defines the location of the image to load
  60633. */
  60634. constructor(
  60635. /**
  60636. * Defines the name of the task
  60637. */
  60638. name: string,
  60639. /**
  60640. * Defines the location of the image to load
  60641. */
  60642. url: string);
  60643. /**
  60644. * Execute the current task
  60645. * @param scene defines the scene where you want your assets to be loaded
  60646. * @param onSuccess is a callback called when the task is successfully executed
  60647. * @param onError is a callback called if an error occurs
  60648. */
  60649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60650. }
  60651. /**
  60652. * Defines the interface used by texture loading tasks
  60653. */
  60654. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60655. /**
  60656. * Gets the loaded texture
  60657. */
  60658. texture: TEX;
  60659. }
  60660. /**
  60661. * Define a task used by AssetsManager to load 2D textures
  60662. */
  60663. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60664. /**
  60665. * Defines the name of the task
  60666. */
  60667. name: string;
  60668. /**
  60669. * Defines the location of the file to load
  60670. */
  60671. url: string;
  60672. /**
  60673. * Defines if mipmap should not be generated (default is false)
  60674. */
  60675. noMipmap?: boolean | undefined;
  60676. /**
  60677. * Defines if texture must be inverted on Y axis (default is false)
  60678. */
  60679. invertY?: boolean | undefined;
  60680. /**
  60681. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60682. */
  60683. samplingMode: number;
  60684. /**
  60685. * Gets the loaded texture
  60686. */
  60687. texture: Texture;
  60688. /**
  60689. * Callback called when the task is successful
  60690. */
  60691. onSuccess: (task: TextureAssetTask) => void;
  60692. /**
  60693. * Callback called when the task is successful
  60694. */
  60695. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60696. /**
  60697. * Creates a new TextureAssetTask object
  60698. * @param name defines the name of the task
  60699. * @param url defines the location of the file to load
  60700. * @param noMipmap defines if mipmap should not be generated (default is false)
  60701. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60702. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60703. */
  60704. constructor(
  60705. /**
  60706. * Defines the name of the task
  60707. */
  60708. name: string,
  60709. /**
  60710. * Defines the location of the file to load
  60711. */
  60712. url: string,
  60713. /**
  60714. * Defines if mipmap should not be generated (default is false)
  60715. */
  60716. noMipmap?: boolean | undefined,
  60717. /**
  60718. * Defines if texture must be inverted on Y axis (default is false)
  60719. */
  60720. invertY?: boolean | undefined,
  60721. /**
  60722. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60723. */
  60724. samplingMode?: number);
  60725. /**
  60726. * Execute the current task
  60727. * @param scene defines the scene where you want your assets to be loaded
  60728. * @param onSuccess is a callback called when the task is successfully executed
  60729. * @param onError is a callback called if an error occurs
  60730. */
  60731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60732. }
  60733. /**
  60734. * Define a task used by AssetsManager to load cube textures
  60735. */
  60736. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60737. /**
  60738. * Defines the name of the task
  60739. */
  60740. name: string;
  60741. /**
  60742. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60743. */
  60744. url: string;
  60745. /**
  60746. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60747. */
  60748. extensions?: string[] | undefined;
  60749. /**
  60750. * Defines if mipmaps should not be generated (default is false)
  60751. */
  60752. noMipmap?: boolean | undefined;
  60753. /**
  60754. * Defines the explicit list of files (undefined by default)
  60755. */
  60756. files?: string[] | undefined;
  60757. /**
  60758. * Gets the loaded texture
  60759. */
  60760. texture: CubeTexture;
  60761. /**
  60762. * Callback called when the task is successful
  60763. */
  60764. onSuccess: (task: CubeTextureAssetTask) => void;
  60765. /**
  60766. * Callback called when the task is successful
  60767. */
  60768. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60769. /**
  60770. * Creates a new CubeTextureAssetTask
  60771. * @param name defines the name of the task
  60772. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60773. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60774. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60775. * @param files defines the explicit list of files (undefined by default)
  60776. */
  60777. constructor(
  60778. /**
  60779. * Defines the name of the task
  60780. */
  60781. name: string,
  60782. /**
  60783. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60784. */
  60785. url: string,
  60786. /**
  60787. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60788. */
  60789. extensions?: string[] | undefined,
  60790. /**
  60791. * Defines if mipmaps should not be generated (default is false)
  60792. */
  60793. noMipmap?: boolean | undefined,
  60794. /**
  60795. * Defines the explicit list of files (undefined by default)
  60796. */
  60797. files?: string[] | undefined);
  60798. /**
  60799. * Execute the current task
  60800. * @param scene defines the scene where you want your assets to be loaded
  60801. * @param onSuccess is a callback called when the task is successfully executed
  60802. * @param onError is a callback called if an error occurs
  60803. */
  60804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60805. }
  60806. /**
  60807. * Define a task used by AssetsManager to load HDR cube textures
  60808. */
  60809. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60810. /**
  60811. * Defines the name of the task
  60812. */
  60813. name: string;
  60814. /**
  60815. * Defines the location of the file to load
  60816. */
  60817. url: string;
  60818. /**
  60819. * Defines the desired size (the more it increases the longer the generation will be)
  60820. */
  60821. size: number;
  60822. /**
  60823. * Defines if mipmaps should not be generated (default is false)
  60824. */
  60825. noMipmap: boolean;
  60826. /**
  60827. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60828. */
  60829. generateHarmonics: boolean;
  60830. /**
  60831. * 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)
  60832. */
  60833. gammaSpace: boolean;
  60834. /**
  60835. * Internal Use Only
  60836. */
  60837. reserved: boolean;
  60838. /**
  60839. * Gets the loaded texture
  60840. */
  60841. texture: HDRCubeTexture;
  60842. /**
  60843. * Callback called when the task is successful
  60844. */
  60845. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60846. /**
  60847. * Callback called when the task is successful
  60848. */
  60849. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60850. /**
  60851. * Creates a new HDRCubeTextureAssetTask object
  60852. * @param name defines the name of the task
  60853. * @param url defines the location of the file to load
  60854. * @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.
  60855. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60856. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60857. * @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)
  60858. * @param reserved Internal use only
  60859. */
  60860. constructor(
  60861. /**
  60862. * Defines the name of the task
  60863. */
  60864. name: string,
  60865. /**
  60866. * Defines the location of the file to load
  60867. */
  60868. url: string,
  60869. /**
  60870. * Defines the desired size (the more it increases the longer the generation will be)
  60871. */
  60872. size: number,
  60873. /**
  60874. * Defines if mipmaps should not be generated (default is false)
  60875. */
  60876. noMipmap?: boolean,
  60877. /**
  60878. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60879. */
  60880. generateHarmonics?: boolean,
  60881. /**
  60882. * 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)
  60883. */
  60884. gammaSpace?: boolean,
  60885. /**
  60886. * Internal Use Only
  60887. */
  60888. reserved?: boolean);
  60889. /**
  60890. * Execute the current task
  60891. * @param scene defines the scene where you want your assets to be loaded
  60892. * @param onSuccess is a callback called when the task is successfully executed
  60893. * @param onError is a callback called if an error occurs
  60894. */
  60895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60896. }
  60897. /**
  60898. * Define a task used by AssetsManager to load Equirectangular cube textures
  60899. */
  60900. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60901. /**
  60902. * Defines the name of the task
  60903. */
  60904. name: string;
  60905. /**
  60906. * Defines the location of the file to load
  60907. */
  60908. url: string;
  60909. /**
  60910. * Defines the desired size (the more it increases the longer the generation will be)
  60911. */
  60912. size: number;
  60913. /**
  60914. * Defines if mipmaps should not be generated (default is false)
  60915. */
  60916. noMipmap: boolean;
  60917. /**
  60918. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60919. * but the standard material would require them in Gamma space) (default is true)
  60920. */
  60921. gammaSpace: boolean;
  60922. /**
  60923. * Gets the loaded texture
  60924. */
  60925. texture: EquiRectangularCubeTexture;
  60926. /**
  60927. * Callback called when the task is successful
  60928. */
  60929. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60930. /**
  60931. * Callback called when the task is successful
  60932. */
  60933. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60934. /**
  60935. * Creates a new EquiRectangularCubeTextureAssetTask object
  60936. * @param name defines the name of the task
  60937. * @param url defines the location of the file to load
  60938. * @param size defines the desired size (the more it increases the longer the generation will be)
  60939. * If the size is omitted this implies you are using a preprocessed cubemap.
  60940. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60941. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60942. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60943. * (default is true)
  60944. */
  60945. constructor(
  60946. /**
  60947. * Defines the name of the task
  60948. */
  60949. name: string,
  60950. /**
  60951. * Defines the location of the file to load
  60952. */
  60953. url: string,
  60954. /**
  60955. * Defines the desired size (the more it increases the longer the generation will be)
  60956. */
  60957. size: number,
  60958. /**
  60959. * Defines if mipmaps should not be generated (default is false)
  60960. */
  60961. noMipmap?: boolean,
  60962. /**
  60963. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60964. * but the standard material would require them in Gamma space) (default is true)
  60965. */
  60966. gammaSpace?: boolean);
  60967. /**
  60968. * Execute the current task
  60969. * @param scene defines the scene where you want your assets to be loaded
  60970. * @param onSuccess is a callback called when the task is successfully executed
  60971. * @param onError is a callback called if an error occurs
  60972. */
  60973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60974. }
  60975. /**
  60976. * This class can be used to easily import assets into a scene
  60977. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60978. */
  60979. export class AssetsManager {
  60980. private _scene;
  60981. private _isLoading;
  60982. protected _tasks: AbstractAssetTask[];
  60983. protected _waitingTasksCount: number;
  60984. protected _totalTasksCount: number;
  60985. /**
  60986. * Callback called when all tasks are processed
  60987. */
  60988. onFinish: (tasks: AbstractAssetTask[]) => void;
  60989. /**
  60990. * Callback called when a task is successful
  60991. */
  60992. onTaskSuccess: (task: AbstractAssetTask) => void;
  60993. /**
  60994. * Callback called when a task had an error
  60995. */
  60996. onTaskError: (task: AbstractAssetTask) => void;
  60997. /**
  60998. * Callback called when a task is done (whatever the result is)
  60999. */
  61000. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61001. /**
  61002. * Observable called when all tasks are processed
  61003. */
  61004. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61005. /**
  61006. * Observable called when a task had an error
  61007. */
  61008. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61009. /**
  61010. * Observable called when all tasks were executed
  61011. */
  61012. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61013. /**
  61014. * Observable called when a task is done (whatever the result is)
  61015. */
  61016. onProgressObservable: Observable<IAssetsProgressEvent>;
  61017. /**
  61018. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61020. */
  61021. useDefaultLoadingScreen: boolean;
  61022. /**
  61023. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61024. * when all assets have been downloaded.
  61025. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61026. */
  61027. autoHideLoadingUI: boolean;
  61028. /**
  61029. * Creates a new AssetsManager
  61030. * @param scene defines the scene to work on
  61031. */
  61032. constructor(scene: Scene);
  61033. /**
  61034. * Add a MeshAssetTask to the list of active tasks
  61035. * @param taskName defines the name of the new task
  61036. * @param meshesNames defines the name of meshes to load
  61037. * @param rootUrl defines the root url to use to locate files
  61038. * @param sceneFilename defines the filename of the scene file
  61039. * @returns a new MeshAssetTask object
  61040. */
  61041. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61042. /**
  61043. * Add a TextFileAssetTask to the list of active tasks
  61044. * @param taskName defines the name of the new task
  61045. * @param url defines the url of the file to load
  61046. * @returns a new TextFileAssetTask object
  61047. */
  61048. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61049. /**
  61050. * Add a BinaryFileAssetTask to the list of active tasks
  61051. * @param taskName defines the name of the new task
  61052. * @param url defines the url of the file to load
  61053. * @returns a new BinaryFileAssetTask object
  61054. */
  61055. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61056. /**
  61057. * Add a ImageAssetTask to the list of active tasks
  61058. * @param taskName defines the name of the new task
  61059. * @param url defines the url of the file to load
  61060. * @returns a new ImageAssetTask object
  61061. */
  61062. addImageTask(taskName: string, url: string): ImageAssetTask;
  61063. /**
  61064. * Add a TextureAssetTask to the list of active tasks
  61065. * @param taskName defines the name of the new task
  61066. * @param url defines the url of the file to load
  61067. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61068. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61069. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61070. * @returns a new TextureAssetTask object
  61071. */
  61072. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61073. /**
  61074. * Add a CubeTextureAssetTask to the list of active tasks
  61075. * @param taskName defines the name of the new task
  61076. * @param url defines the url of the file to load
  61077. * @param extensions defines the extension to use to load the cube map (can be null)
  61078. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61079. * @param files defines the list of files to load (can be null)
  61080. * @returns a new CubeTextureAssetTask object
  61081. */
  61082. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61083. /**
  61084. *
  61085. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61086. * @param taskName defines the name of the new task
  61087. * @param url defines the url of the file to load
  61088. * @param size defines the size you want for the cubemap (can be null)
  61089. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61090. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61091. * @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)
  61092. * @param reserved Internal use only
  61093. * @returns a new HDRCubeTextureAssetTask object
  61094. */
  61095. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61096. /**
  61097. *
  61098. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61099. * @param taskName defines the name of the new task
  61100. * @param url defines the url of the file to load
  61101. * @param size defines the size you want for the cubemap (can be null)
  61102. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61103. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61104. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61105. * @returns a new EquiRectangularCubeTextureAssetTask object
  61106. */
  61107. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61108. /**
  61109. * Remove a task from the assets manager.
  61110. * @param task the task to remove
  61111. */
  61112. removeTask(task: AbstractAssetTask): void;
  61113. private _decreaseWaitingTasksCount;
  61114. private _runTask;
  61115. /**
  61116. * Reset the AssetsManager and remove all tasks
  61117. * @return the current instance of the AssetsManager
  61118. */
  61119. reset(): AssetsManager;
  61120. /**
  61121. * Start the loading process
  61122. * @return the current instance of the AssetsManager
  61123. */
  61124. load(): AssetsManager;
  61125. /**
  61126. * Start the loading process as an async operation
  61127. * @return a promise returning the list of failed tasks
  61128. */
  61129. loadAsync(): Promise<void>;
  61130. }
  61131. }
  61132. declare module BABYLON {
  61133. /**
  61134. * Wrapper class for promise with external resolve and reject.
  61135. */
  61136. export class Deferred<T> {
  61137. /**
  61138. * The promise associated with this deferred object.
  61139. */
  61140. readonly promise: Promise<T>;
  61141. private _resolve;
  61142. private _reject;
  61143. /**
  61144. * The resolve method of the promise associated with this deferred object.
  61145. */
  61146. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61147. /**
  61148. * The reject method of the promise associated with this deferred object.
  61149. */
  61150. readonly reject: (reason?: any) => void;
  61151. /**
  61152. * Constructor for this deferred object.
  61153. */
  61154. constructor();
  61155. }
  61156. }
  61157. declare module BABYLON {
  61158. /**
  61159. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61160. */
  61161. export class MeshExploder {
  61162. private _centerMesh;
  61163. private _meshes;
  61164. private _meshesOrigins;
  61165. private _toCenterVectors;
  61166. private _scaledDirection;
  61167. private _newPosition;
  61168. private _centerPosition;
  61169. /**
  61170. * Explodes meshes from a center mesh.
  61171. * @param meshes The meshes to explode.
  61172. * @param centerMesh The mesh to be center of explosion.
  61173. */
  61174. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61175. private _setCenterMesh;
  61176. /**
  61177. * Get class name
  61178. * @returns "MeshExploder"
  61179. */
  61180. getClassName(): string;
  61181. /**
  61182. * "Exploded meshes"
  61183. * @returns Array of meshes with the centerMesh at index 0.
  61184. */
  61185. getMeshes(): Array<Mesh>;
  61186. /**
  61187. * Explodes meshes giving a specific direction
  61188. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61189. */
  61190. explode(direction?: number): void;
  61191. }
  61192. }
  61193. declare module BABYLON {
  61194. /**
  61195. * Class used to help managing file picking and drag'n'drop
  61196. */
  61197. export class FilesInput {
  61198. /**
  61199. * List of files ready to be loaded
  61200. */
  61201. static readonly FilesToLoad: {
  61202. [key: string]: File;
  61203. };
  61204. /**
  61205. * Callback called when a file is processed
  61206. */
  61207. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61208. private _engine;
  61209. private _currentScene;
  61210. private _sceneLoadedCallback;
  61211. private _progressCallback;
  61212. private _additionalRenderLoopLogicCallback;
  61213. private _textureLoadingCallback;
  61214. private _startingProcessingFilesCallback;
  61215. private _onReloadCallback;
  61216. private _errorCallback;
  61217. private _elementToMonitor;
  61218. private _sceneFileToLoad;
  61219. private _filesToLoad;
  61220. /**
  61221. * Creates a new FilesInput
  61222. * @param engine defines the rendering engine
  61223. * @param scene defines the hosting scene
  61224. * @param sceneLoadedCallback callback called when scene is loaded
  61225. * @param progressCallback callback called to track progress
  61226. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61227. * @param textureLoadingCallback callback called when a texture is loading
  61228. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61229. * @param onReloadCallback callback called when a reload is requested
  61230. * @param errorCallback callback call if an error occurs
  61231. */
  61232. 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);
  61233. private _dragEnterHandler;
  61234. private _dragOverHandler;
  61235. private _dropHandler;
  61236. /**
  61237. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61238. * @param elementToMonitor defines the DOM element to track
  61239. */
  61240. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61241. /**
  61242. * Release all associated resources
  61243. */
  61244. dispose(): void;
  61245. private renderFunction;
  61246. private drag;
  61247. private drop;
  61248. private _traverseFolder;
  61249. private _processFiles;
  61250. /**
  61251. * Load files from a drop event
  61252. * @param event defines the drop event to use as source
  61253. */
  61254. loadFiles(event: any): void;
  61255. private _processReload;
  61256. /**
  61257. * Reload the current scene from the loaded files
  61258. */
  61259. reload(): void;
  61260. }
  61261. }
  61262. declare module BABYLON {
  61263. /**
  61264. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61266. */
  61267. export class SceneOptimization {
  61268. /**
  61269. * Defines the priority of this optimization (0 by default which means first in the list)
  61270. */
  61271. priority: number;
  61272. /**
  61273. * Gets a string describing the action executed by the current optimization
  61274. * @returns description string
  61275. */
  61276. getDescription(): string;
  61277. /**
  61278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61279. * @param scene defines the current scene where to apply this optimization
  61280. * @param optimizer defines the current optimizer
  61281. * @returns true if everything that can be done was applied
  61282. */
  61283. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61284. /**
  61285. * Creates the SceneOptimization object
  61286. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61287. * @param desc defines the description associated with the optimization
  61288. */
  61289. constructor(
  61290. /**
  61291. * Defines the priority of this optimization (0 by default which means first in the list)
  61292. */
  61293. priority?: number);
  61294. }
  61295. /**
  61296. * Defines an optimization used to reduce the size of render target textures
  61297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61298. */
  61299. export class TextureOptimization extends SceneOptimization {
  61300. /**
  61301. * Defines the priority of this optimization (0 by default which means first in the list)
  61302. */
  61303. priority: number;
  61304. /**
  61305. * 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
  61306. */
  61307. maximumSize: number;
  61308. /**
  61309. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61310. */
  61311. step: number;
  61312. /**
  61313. * Gets a string describing the action executed by the current optimization
  61314. * @returns description string
  61315. */
  61316. getDescription(): string;
  61317. /**
  61318. * Creates the TextureOptimization object
  61319. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61320. * @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
  61321. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61322. */
  61323. constructor(
  61324. /**
  61325. * Defines the priority of this optimization (0 by default which means first in the list)
  61326. */
  61327. priority?: number,
  61328. /**
  61329. * 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
  61330. */
  61331. maximumSize?: number,
  61332. /**
  61333. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61334. */
  61335. step?: number);
  61336. /**
  61337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61338. * @param scene defines the current scene where to apply this optimization
  61339. * @param optimizer defines the current optimizer
  61340. * @returns true if everything that can be done was applied
  61341. */
  61342. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61343. }
  61344. /**
  61345. * Defines an optimization used to increase or decrease the rendering resolution
  61346. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61347. */
  61348. export class HardwareScalingOptimization extends SceneOptimization {
  61349. /**
  61350. * Defines the priority of this optimization (0 by default which means first in the list)
  61351. */
  61352. priority: number;
  61353. /**
  61354. * Defines the maximum scale to use (2 by default)
  61355. */
  61356. maximumScale: number;
  61357. /**
  61358. * Defines the step to use between two passes (0.5 by default)
  61359. */
  61360. step: number;
  61361. private _currentScale;
  61362. private _directionOffset;
  61363. /**
  61364. * Gets a string describing the action executed by the current optimization
  61365. * @return description string
  61366. */
  61367. getDescription(): string;
  61368. /**
  61369. * Creates the HardwareScalingOptimization object
  61370. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61371. * @param maximumScale defines the maximum scale to use (2 by default)
  61372. * @param step defines the step to use between two passes (0.5 by default)
  61373. */
  61374. constructor(
  61375. /**
  61376. * Defines the priority of this optimization (0 by default which means first in the list)
  61377. */
  61378. priority?: number,
  61379. /**
  61380. * Defines the maximum scale to use (2 by default)
  61381. */
  61382. maximumScale?: number,
  61383. /**
  61384. * Defines the step to use between two passes (0.5 by default)
  61385. */
  61386. step?: number);
  61387. /**
  61388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61389. * @param scene defines the current scene where to apply this optimization
  61390. * @param optimizer defines the current optimizer
  61391. * @returns true if everything that can be done was applied
  61392. */
  61393. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61394. }
  61395. /**
  61396. * Defines an optimization used to remove shadows
  61397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61398. */
  61399. export class ShadowsOptimization extends SceneOptimization {
  61400. /**
  61401. * Gets a string describing the action executed by the current optimization
  61402. * @return description string
  61403. */
  61404. getDescription(): string;
  61405. /**
  61406. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61407. * @param scene defines the current scene where to apply this optimization
  61408. * @param optimizer defines the current optimizer
  61409. * @returns true if everything that can be done was applied
  61410. */
  61411. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61412. }
  61413. /**
  61414. * Defines an optimization used to turn post-processes off
  61415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61416. */
  61417. export class PostProcessesOptimization extends SceneOptimization {
  61418. /**
  61419. * Gets a string describing the action executed by the current optimization
  61420. * @return description string
  61421. */
  61422. getDescription(): string;
  61423. /**
  61424. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61425. * @param scene defines the current scene where to apply this optimization
  61426. * @param optimizer defines the current optimizer
  61427. * @returns true if everything that can be done was applied
  61428. */
  61429. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61430. }
  61431. /**
  61432. * Defines an optimization used to turn lens flares off
  61433. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61434. */
  61435. export class LensFlaresOptimization extends SceneOptimization {
  61436. /**
  61437. * Gets a string describing the action executed by the current optimization
  61438. * @return description string
  61439. */
  61440. getDescription(): string;
  61441. /**
  61442. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61443. * @param scene defines the current scene where to apply this optimization
  61444. * @param optimizer defines the current optimizer
  61445. * @returns true if everything that can be done was applied
  61446. */
  61447. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61448. }
  61449. /**
  61450. * Defines an optimization based on user defined callback.
  61451. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61452. */
  61453. export class CustomOptimization extends SceneOptimization {
  61454. /**
  61455. * Callback called to apply the custom optimization.
  61456. */
  61457. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61458. /**
  61459. * Callback called to get custom description
  61460. */
  61461. onGetDescription: () => string;
  61462. /**
  61463. * Gets a string describing the action executed by the current optimization
  61464. * @returns description string
  61465. */
  61466. getDescription(): string;
  61467. /**
  61468. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61469. * @param scene defines the current scene where to apply this optimization
  61470. * @param optimizer defines the current optimizer
  61471. * @returns true if everything that can be done was applied
  61472. */
  61473. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61474. }
  61475. /**
  61476. * Defines an optimization used to turn particles off
  61477. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61478. */
  61479. export class ParticlesOptimization extends SceneOptimization {
  61480. /**
  61481. * Gets a string describing the action executed by the current optimization
  61482. * @return description string
  61483. */
  61484. getDescription(): string;
  61485. /**
  61486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61487. * @param scene defines the current scene where to apply this optimization
  61488. * @param optimizer defines the current optimizer
  61489. * @returns true if everything that can be done was applied
  61490. */
  61491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61492. }
  61493. /**
  61494. * Defines an optimization used to turn render targets off
  61495. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61496. */
  61497. export class RenderTargetsOptimization extends SceneOptimization {
  61498. /**
  61499. * Gets a string describing the action executed by the current optimization
  61500. * @return description string
  61501. */
  61502. getDescription(): string;
  61503. /**
  61504. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61505. * @param scene defines the current scene where to apply this optimization
  61506. * @param optimizer defines the current optimizer
  61507. * @returns true if everything that can be done was applied
  61508. */
  61509. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61510. }
  61511. /**
  61512. * Defines an optimization used to merge meshes with compatible materials
  61513. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61514. */
  61515. export class MergeMeshesOptimization extends SceneOptimization {
  61516. private static _UpdateSelectionTree;
  61517. /**
  61518. * Gets or sets a boolean which defines if optimization octree has to be updated
  61519. */
  61520. /**
  61521. * Gets or sets a boolean which defines if optimization octree has to be updated
  61522. */
  61523. static UpdateSelectionTree: boolean;
  61524. /**
  61525. * Gets a string describing the action executed by the current optimization
  61526. * @return description string
  61527. */
  61528. getDescription(): string;
  61529. private _canBeMerged;
  61530. /**
  61531. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61532. * @param scene defines the current scene where to apply this optimization
  61533. * @param optimizer defines the current optimizer
  61534. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61535. * @returns true if everything that can be done was applied
  61536. */
  61537. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61538. }
  61539. /**
  61540. * Defines a list of options used by SceneOptimizer
  61541. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61542. */
  61543. export class SceneOptimizerOptions {
  61544. /**
  61545. * Defines the target frame rate to reach (60 by default)
  61546. */
  61547. targetFrameRate: number;
  61548. /**
  61549. * Defines the interval between two checkes (2000ms by default)
  61550. */
  61551. trackerDuration: number;
  61552. /**
  61553. * Gets the list of optimizations to apply
  61554. */
  61555. optimizations: SceneOptimization[];
  61556. /**
  61557. * Creates a new list of options used by SceneOptimizer
  61558. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61559. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61560. */
  61561. constructor(
  61562. /**
  61563. * Defines the target frame rate to reach (60 by default)
  61564. */
  61565. targetFrameRate?: number,
  61566. /**
  61567. * Defines the interval between two checkes (2000ms by default)
  61568. */
  61569. trackerDuration?: number);
  61570. /**
  61571. * Add a new optimization
  61572. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61573. * @returns the current SceneOptimizerOptions
  61574. */
  61575. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61576. /**
  61577. * Add a new custom optimization
  61578. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61579. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61580. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61581. * @returns the current SceneOptimizerOptions
  61582. */
  61583. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61584. /**
  61585. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61586. * @param targetFrameRate defines the target frame rate (60 by default)
  61587. * @returns a SceneOptimizerOptions object
  61588. */
  61589. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61590. /**
  61591. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61592. * @param targetFrameRate defines the target frame rate (60 by default)
  61593. * @returns a SceneOptimizerOptions object
  61594. */
  61595. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61596. /**
  61597. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61598. * @param targetFrameRate defines the target frame rate (60 by default)
  61599. * @returns a SceneOptimizerOptions object
  61600. */
  61601. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61602. }
  61603. /**
  61604. * Class used to run optimizations in order to reach a target frame rate
  61605. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61606. */
  61607. export class SceneOptimizer implements IDisposable {
  61608. private _isRunning;
  61609. private _options;
  61610. private _scene;
  61611. private _currentPriorityLevel;
  61612. private _targetFrameRate;
  61613. private _trackerDuration;
  61614. private _currentFrameRate;
  61615. private _sceneDisposeObserver;
  61616. private _improvementMode;
  61617. /**
  61618. * Defines an observable called when the optimizer reaches the target frame rate
  61619. */
  61620. onSuccessObservable: Observable<SceneOptimizer>;
  61621. /**
  61622. * Defines an observable called when the optimizer enables an optimization
  61623. */
  61624. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61625. /**
  61626. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61627. */
  61628. onFailureObservable: Observable<SceneOptimizer>;
  61629. /**
  61630. * Gets a boolean indicating if the optimizer is in improvement mode
  61631. */
  61632. readonly isInImprovementMode: boolean;
  61633. /**
  61634. * Gets the current priority level (0 at start)
  61635. */
  61636. readonly currentPriorityLevel: number;
  61637. /**
  61638. * Gets the current frame rate checked by the SceneOptimizer
  61639. */
  61640. readonly currentFrameRate: number;
  61641. /**
  61642. * Gets or sets the current target frame rate (60 by default)
  61643. */
  61644. /**
  61645. * Gets or sets the current target frame rate (60 by default)
  61646. */
  61647. targetFrameRate: number;
  61648. /**
  61649. * Gets or sets the current interval between two checks (every 2000ms by default)
  61650. */
  61651. /**
  61652. * Gets or sets the current interval between two checks (every 2000ms by default)
  61653. */
  61654. trackerDuration: number;
  61655. /**
  61656. * Gets the list of active optimizations
  61657. */
  61658. readonly optimizations: SceneOptimization[];
  61659. /**
  61660. * Creates a new SceneOptimizer
  61661. * @param scene defines the scene to work on
  61662. * @param options defines the options to use with the SceneOptimizer
  61663. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61664. * @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)
  61665. */
  61666. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61667. /**
  61668. * Stops the current optimizer
  61669. */
  61670. stop(): void;
  61671. /**
  61672. * Reset the optimizer to initial step (current priority level = 0)
  61673. */
  61674. reset(): void;
  61675. /**
  61676. * Start the optimizer. By default it will try to reach a specific framerate
  61677. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61678. */
  61679. start(): void;
  61680. private _checkCurrentState;
  61681. /**
  61682. * Release all resources
  61683. */
  61684. dispose(): void;
  61685. /**
  61686. * Helper function to create a SceneOptimizer with one single line of code
  61687. * @param scene defines the scene to work on
  61688. * @param options defines the options to use with the SceneOptimizer
  61689. * @param onSuccess defines a callback to call on success
  61690. * @param onFailure defines a callback to call on failure
  61691. * @returns the new SceneOptimizer object
  61692. */
  61693. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61694. }
  61695. }
  61696. declare module BABYLON {
  61697. /**
  61698. * Class used to serialize a scene into a string
  61699. */
  61700. export class SceneSerializer {
  61701. /**
  61702. * Clear cache used by a previous serialization
  61703. */
  61704. static ClearCache(): void;
  61705. /**
  61706. * Serialize a scene into a JSON compatible object
  61707. * @param scene defines the scene to serialize
  61708. * @returns a JSON compatible object
  61709. */
  61710. static Serialize(scene: Scene): any;
  61711. /**
  61712. * Serialize a mesh into a JSON compatible object
  61713. * @param toSerialize defines the mesh to serialize
  61714. * @param withParents defines if parents must be serialized as well
  61715. * @param withChildren defines if children must be serialized as well
  61716. * @returns a JSON compatible object
  61717. */
  61718. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61719. }
  61720. }
  61721. declare module BABYLON {
  61722. /**
  61723. * Class used to host texture specific utilities
  61724. */
  61725. export class TextureTools {
  61726. /**
  61727. * Uses the GPU to create a copy texture rescaled at a given size
  61728. * @param texture Texture to copy from
  61729. * @param width defines the desired width
  61730. * @param height defines the desired height
  61731. * @param useBilinearMode defines if bilinear mode has to be used
  61732. * @return the generated texture
  61733. */
  61734. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61735. }
  61736. }
  61737. declare module BABYLON {
  61738. /**
  61739. * This represents the different options available for the video capture.
  61740. */
  61741. export interface VideoRecorderOptions {
  61742. /** Defines the mime type of the video. */
  61743. mimeType: string;
  61744. /** Defines the FPS the video should be recorded at. */
  61745. fps: number;
  61746. /** Defines the chunk size for the recording data. */
  61747. recordChunckSize: number;
  61748. /** The audio tracks to attach to the recording. */
  61749. audioTracks?: MediaStreamTrack[];
  61750. }
  61751. /**
  61752. * This can help with recording videos from BabylonJS.
  61753. * This is based on the available WebRTC functionalities of the browser.
  61754. *
  61755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61756. */
  61757. export class VideoRecorder {
  61758. private static readonly _defaultOptions;
  61759. /**
  61760. * Returns whether or not the VideoRecorder is available in your browser.
  61761. * @param engine Defines the Babylon Engine.
  61762. * @returns true if supported otherwise false.
  61763. */
  61764. static IsSupported(engine: Engine): boolean;
  61765. private readonly _options;
  61766. private _canvas;
  61767. private _mediaRecorder;
  61768. private _recordedChunks;
  61769. private _fileName;
  61770. private _resolve;
  61771. private _reject;
  61772. /**
  61773. * True when a recording is already in progress.
  61774. */
  61775. readonly isRecording: boolean;
  61776. /**
  61777. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61778. * @param engine Defines the BabylonJS Engine you wish to record.
  61779. * @param options Defines options that can be used to customize the capture.
  61780. */
  61781. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61782. /**
  61783. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61784. */
  61785. stopRecording(): void;
  61786. /**
  61787. * Starts recording the canvas for a max duration specified in parameters.
  61788. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61789. * If null no automatic download will start and you can rely on the promise to get the data back.
  61790. * @param maxDuration Defines the maximum recording time in seconds.
  61791. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61792. * @return A promise callback at the end of the recording with the video data in Blob.
  61793. */
  61794. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61795. /**
  61796. * Releases internal resources used during the recording.
  61797. */
  61798. dispose(): void;
  61799. private _handleDataAvailable;
  61800. private _handleError;
  61801. private _handleStop;
  61802. }
  61803. }
  61804. declare module BABYLON {
  61805. /**
  61806. * Class containing a set of static utilities functions for screenshots
  61807. */
  61808. export class ScreenshotTools {
  61809. /**
  61810. * Captures a screenshot of the current rendering
  61811. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61812. * @param engine defines the rendering engine
  61813. * @param camera defines the source camera
  61814. * @param size This parameter can be set to a single number or to an object with the
  61815. * following (optional) properties: precision, width, height. If a single number is passed,
  61816. * it will be used for both width and height. If an object is passed, the screenshot size
  61817. * will be derived from the parameters. The precision property is a multiplier allowing
  61818. * rendering at a higher or lower resolution
  61819. * @param successCallback defines the callback receives a single parameter which contains the
  61820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61821. * src parameter of an <img> to display it
  61822. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61823. * Check your browser for supported MIME types
  61824. */
  61825. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61826. /**
  61827. * Captures a screenshot of the current rendering
  61828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61829. * @param engine defines the rendering engine
  61830. * @param camera defines the source camera
  61831. * @param size This parameter can be set to a single number or to an object with the
  61832. * following (optional) properties: precision, width, height. If a single number is passed,
  61833. * it will be used for both width and height. If an object is passed, the screenshot size
  61834. * will be derived from the parameters. The precision property is a multiplier allowing
  61835. * rendering at a higher or lower resolution
  61836. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61837. * Check your browser for supported MIME types
  61838. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61839. * to the src parameter of an <img> to display it
  61840. */
  61841. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61842. /**
  61843. * Generates an image screenshot from the specified camera.
  61844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61845. * @param engine The engine to use for rendering
  61846. * @param camera The camera to use for rendering
  61847. * @param size This parameter can be set to a single number or to an object with the
  61848. * following (optional) properties: precision, width, height. If a single number is passed,
  61849. * it will be used for both width and height. If an object is passed, the screenshot size
  61850. * will be derived from the parameters. The precision property is a multiplier allowing
  61851. * rendering at a higher or lower resolution
  61852. * @param successCallback The callback receives a single parameter which contains the
  61853. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61854. * src parameter of an <img> to display it
  61855. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61856. * Check your browser for supported MIME types
  61857. * @param samples Texture samples (default: 1)
  61858. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61859. * @param fileName A name for for the downloaded file.
  61860. */
  61861. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61862. /**
  61863. * Generates an image screenshot from the specified camera.
  61864. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61865. * @param engine The engine to use for rendering
  61866. * @param camera The camera to use for rendering
  61867. * @param size This parameter can be set to a single number or to an object with the
  61868. * following (optional) properties: precision, width, height. If a single number is passed,
  61869. * it will be used for both width and height. If an object is passed, the screenshot size
  61870. * will be derived from the parameters. The precision property is a multiplier allowing
  61871. * rendering at a higher or lower resolution
  61872. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61873. * Check your browser for supported MIME types
  61874. * @param samples Texture samples (default: 1)
  61875. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61876. * @param fileName A name for for the downloaded file.
  61877. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61878. * to the src parameter of an <img> to display it
  61879. */
  61880. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61881. /**
  61882. * Gets height and width for screenshot size
  61883. * @private
  61884. */
  61885. private static _getScreenshotSize;
  61886. }
  61887. }
  61888. declare module BABYLON {
  61889. /**
  61890. * A cursor which tracks a point on a path
  61891. */
  61892. export class PathCursor {
  61893. private path;
  61894. /**
  61895. * Stores path cursor callbacks for when an onchange event is triggered
  61896. */
  61897. private _onchange;
  61898. /**
  61899. * The value of the path cursor
  61900. */
  61901. value: number;
  61902. /**
  61903. * The animation array of the path cursor
  61904. */
  61905. animations: Animation[];
  61906. /**
  61907. * Initializes the path cursor
  61908. * @param path The path to track
  61909. */
  61910. constructor(path: Path2);
  61911. /**
  61912. * Gets the cursor point on the path
  61913. * @returns A point on the path cursor at the cursor location
  61914. */
  61915. getPoint(): Vector3;
  61916. /**
  61917. * Moves the cursor ahead by the step amount
  61918. * @param step The amount to move the cursor forward
  61919. * @returns This path cursor
  61920. */
  61921. moveAhead(step?: number): PathCursor;
  61922. /**
  61923. * Moves the cursor behind by the step amount
  61924. * @param step The amount to move the cursor back
  61925. * @returns This path cursor
  61926. */
  61927. moveBack(step?: number): PathCursor;
  61928. /**
  61929. * Moves the cursor by the step amount
  61930. * If the step amount is greater than one, an exception is thrown
  61931. * @param step The amount to move the cursor
  61932. * @returns This path cursor
  61933. */
  61934. move(step: number): PathCursor;
  61935. /**
  61936. * Ensures that the value is limited between zero and one
  61937. * @returns This path cursor
  61938. */
  61939. private ensureLimits;
  61940. /**
  61941. * Runs onchange callbacks on change (used by the animation engine)
  61942. * @returns This path cursor
  61943. */
  61944. private raiseOnChange;
  61945. /**
  61946. * Executes a function on change
  61947. * @param f A path cursor onchange callback
  61948. * @returns This path cursor
  61949. */
  61950. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61951. }
  61952. }
  61953. declare module BABYLON {
  61954. /** @hidden */
  61955. export var blurPixelShader: {
  61956. name: string;
  61957. shader: string;
  61958. };
  61959. }
  61960. declare module BABYLON {
  61961. /** @hidden */
  61962. export var pointCloudVertexDeclaration: {
  61963. name: string;
  61964. shader: string;
  61965. };
  61966. }
  61967. // Mixins
  61968. interface Window {
  61969. mozIndexedDB: IDBFactory;
  61970. webkitIndexedDB: IDBFactory;
  61971. msIndexedDB: IDBFactory;
  61972. webkitURL: typeof URL;
  61973. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61974. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61975. WebGLRenderingContext: WebGLRenderingContext;
  61976. MSGesture: MSGesture;
  61977. CANNON: any;
  61978. AudioContext: AudioContext;
  61979. webkitAudioContext: AudioContext;
  61980. PointerEvent: any;
  61981. Math: Math;
  61982. Uint8Array: Uint8ArrayConstructor;
  61983. Float32Array: Float32ArrayConstructor;
  61984. mozURL: typeof URL;
  61985. msURL: typeof URL;
  61986. VRFrameData: any; // WebVR, from specs 1.1
  61987. DracoDecoderModule: any;
  61988. setImmediate(handler: (...args: any[]) => void): number;
  61989. }
  61990. interface HTMLCanvasElement {
  61991. requestPointerLock(): void;
  61992. msRequestPointerLock?(): void;
  61993. mozRequestPointerLock?(): void;
  61994. webkitRequestPointerLock?(): void;
  61995. /** Track wether a record is in progress */
  61996. isRecording: boolean;
  61997. /** Capture Stream method defined by some browsers */
  61998. captureStream(fps?: number): MediaStream;
  61999. }
  62000. interface CanvasRenderingContext2D {
  62001. msImageSmoothingEnabled: boolean;
  62002. }
  62003. interface MouseEvent {
  62004. mozMovementX: number;
  62005. mozMovementY: number;
  62006. webkitMovementX: number;
  62007. webkitMovementY: number;
  62008. msMovementX: number;
  62009. msMovementY: number;
  62010. }
  62011. interface Navigator {
  62012. mozGetVRDevices: (any: any) => any;
  62013. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62014. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62015. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62016. webkitGetGamepads(): Gamepad[];
  62017. msGetGamepads(): Gamepad[];
  62018. webkitGamepads(): Gamepad[];
  62019. }
  62020. interface HTMLVideoElement {
  62021. mozSrcObject: any;
  62022. }
  62023. interface Math {
  62024. fround(x: number): number;
  62025. imul(a: number, b: number): number;
  62026. }
  62027. interface WebGLRenderingContext {
  62028. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62029. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62030. vertexAttribDivisor(index: number, divisor: number): void;
  62031. createVertexArray(): any;
  62032. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62033. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62034. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62035. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62036. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62037. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62038. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62039. // Queries
  62040. createQuery(): WebGLQuery;
  62041. deleteQuery(query: WebGLQuery): void;
  62042. beginQuery(target: number, query: WebGLQuery): void;
  62043. endQuery(target: number): void;
  62044. getQueryParameter(query: WebGLQuery, pname: number): any;
  62045. getQuery(target: number, pname: number): any;
  62046. MAX_SAMPLES: number;
  62047. RGBA8: number;
  62048. READ_FRAMEBUFFER: number;
  62049. DRAW_FRAMEBUFFER: number;
  62050. UNIFORM_BUFFER: number;
  62051. HALF_FLOAT_OES: number;
  62052. RGBA16F: number;
  62053. RGBA32F: number;
  62054. R32F: number;
  62055. RG32F: number;
  62056. RGB32F: number;
  62057. R16F: number;
  62058. RG16F: number;
  62059. RGB16F: number;
  62060. RED: number;
  62061. RG: number;
  62062. R8: number;
  62063. RG8: number;
  62064. UNSIGNED_INT_24_8: number;
  62065. DEPTH24_STENCIL8: number;
  62066. MIN: number;
  62067. MAX: number;
  62068. /* Multiple Render Targets */
  62069. drawBuffers(buffers: number[]): void;
  62070. readBuffer(src: number): void;
  62071. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62072. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62073. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62074. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62075. // Occlusion Query
  62076. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62077. ANY_SAMPLES_PASSED: number;
  62078. QUERY_RESULT_AVAILABLE: number;
  62079. QUERY_RESULT: number;
  62080. }
  62081. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62082. }
  62083. interface EXT_disjoint_timer_query {
  62084. QUERY_COUNTER_BITS_EXT: number;
  62085. TIME_ELAPSED_EXT: number;
  62086. TIMESTAMP_EXT: number;
  62087. GPU_DISJOINT_EXT: number;
  62088. QUERY_RESULT_EXT: number;
  62089. QUERY_RESULT_AVAILABLE_EXT: number;
  62090. queryCounterEXT(query: WebGLQuery, target: number): void;
  62091. createQueryEXT(): WebGLQuery;
  62092. beginQueryEXT(target: number, query: WebGLQuery): void;
  62093. endQueryEXT(target: number): void;
  62094. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62095. deleteQueryEXT(query: WebGLQuery): void;
  62096. }
  62097. interface WebGLUniformLocation { private _currentState: any;
  62098. }
  62099. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62100. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62101. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62102. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62103. interface WebGLRenderingContext {
  62104. readonly RASTERIZER_DISCARD: number;
  62105. readonly DEPTH_COMPONENT24: number;
  62106. readonly TEXTURE_3D: number;
  62107. readonly TEXTURE_2D_ARRAY: number;
  62108. readonly TEXTURE_COMPARE_FUNC: number;
  62109. readonly TEXTURE_COMPARE_MODE: number;
  62110. readonly COMPARE_REF_TO_TEXTURE: number;
  62111. readonly TEXTURE_WRAP_R: number;
  62112. readonly HALF_FLOAT: number;
  62113. readonly RGB8: number;
  62114. readonly RED_INTEGER: number;
  62115. readonly RG_INTEGER: number;
  62116. readonly RGB_INTEGER: number;
  62117. readonly RGBA_INTEGER: number;
  62118. readonly R8_SNORM: number;
  62119. readonly RG8_SNORM: number;
  62120. readonly RGB8_SNORM: number;
  62121. readonly RGBA8_SNORM: number;
  62122. readonly R8I: number;
  62123. readonly RG8I: number;
  62124. readonly RGB8I: number;
  62125. readonly RGBA8I: number;
  62126. readonly R8UI: number;
  62127. readonly RG8UI: number;
  62128. readonly RGB8UI: number;
  62129. readonly RGBA8UI: number;
  62130. readonly R16I: number;
  62131. readonly RG16I: number;
  62132. readonly RGB16I: number;
  62133. readonly RGBA16I: number;
  62134. readonly R16UI: number;
  62135. readonly RG16UI: number;
  62136. readonly RGB16UI: number;
  62137. readonly RGBA16UI: number;
  62138. readonly R32I: number;
  62139. readonly RG32I: number;
  62140. readonly RGB32I: number;
  62141. readonly RGBA32I: number;
  62142. readonly R32UI: number;
  62143. readonly RG32UI: number;
  62144. readonly RGB32UI: number;
  62145. readonly RGBA32UI: number;
  62146. readonly RGB10_A2UI: number;
  62147. readonly R11F_G11F_B10F: number;
  62148. readonly RGB9_E5: number;
  62149. readonly RGB10_A2: number;
  62150. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62151. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62152. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62153. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62154. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62155. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62156. 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;
  62157. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62158. readonly TRANSFORM_FEEDBACK: number;
  62159. readonly INTERLEAVED_ATTRIBS: number;
  62160. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62161. createTransformFeedback(): WebGLTransformFeedback;
  62162. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62163. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62164. beginTransformFeedback(primitiveMode: number): void;
  62165. endTransformFeedback(): void;
  62166. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62167. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62168. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62169. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62170. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62171. }
  62172. interface ImageBitmap {
  62173. readonly width: number;
  62174. readonly height: number;
  62175. close(): void;
  62176. }
  62177. interface WebGLQuery extends WebGLObject {
  62178. }
  62179. declare var WebGLQuery: {
  62180. prototype: WebGLQuery;
  62181. new(): WebGLQuery;
  62182. };
  62183. interface WebGLSampler extends WebGLObject {
  62184. }
  62185. declare var WebGLSampler: {
  62186. prototype: WebGLSampler;
  62187. new(): WebGLSampler;
  62188. };
  62189. interface WebGLSync extends WebGLObject {
  62190. }
  62191. declare var WebGLSync: {
  62192. prototype: WebGLSync;
  62193. new(): WebGLSync;
  62194. };
  62195. interface WebGLTransformFeedback extends WebGLObject {
  62196. }
  62197. declare var WebGLTransformFeedback: {
  62198. prototype: WebGLTransformFeedback;
  62199. new(): WebGLTransformFeedback;
  62200. };
  62201. interface WebGLVertexArrayObject extends WebGLObject {
  62202. }
  62203. declare var WebGLVertexArrayObject: {
  62204. prototype: WebGLVertexArrayObject;
  62205. new(): WebGLVertexArrayObject;
  62206. };
  62207. // Type definitions for WebVR API
  62208. // Project: https://w3c.github.io/webvr/
  62209. // Definitions by: six a <https://github.com/lostfictions>
  62210. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62211. interface VRDisplay extends EventTarget {
  62212. /**
  62213. * Dictionary of capabilities describing the VRDisplay.
  62214. */
  62215. readonly capabilities: VRDisplayCapabilities;
  62216. /**
  62217. * z-depth defining the far plane of the eye view frustum
  62218. * enables mapping of values in the render target depth
  62219. * attachment to scene coordinates. Initially set to 10000.0.
  62220. */
  62221. depthFar: number;
  62222. /**
  62223. * z-depth defining the near plane of the eye view frustum
  62224. * enables mapping of values in the render target depth
  62225. * attachment to scene coordinates. Initially set to 0.01.
  62226. */
  62227. depthNear: number;
  62228. /**
  62229. * An identifier for this distinct VRDisplay. Used as an
  62230. * association point in the Gamepad API.
  62231. */
  62232. readonly displayId: number;
  62233. /**
  62234. * A display name, a user-readable name identifying it.
  62235. */
  62236. readonly displayName: string;
  62237. readonly isConnected: boolean;
  62238. readonly isPresenting: boolean;
  62239. /**
  62240. * If this VRDisplay supports room-scale experiences, the optional
  62241. * stage attribute contains details on the room-scale parameters.
  62242. */
  62243. readonly stageParameters: VRStageParameters | null;
  62244. /**
  62245. * Passing the value returned by `requestAnimationFrame` to
  62246. * `cancelAnimationFrame` will unregister the callback.
  62247. * @param handle Define the hanle of the request to cancel
  62248. */
  62249. cancelAnimationFrame(handle: number): void;
  62250. /**
  62251. * Stops presenting to the VRDisplay.
  62252. * @returns a promise to know when it stopped
  62253. */
  62254. exitPresent(): Promise<void>;
  62255. /**
  62256. * Return the current VREyeParameters for the given eye.
  62257. * @param whichEye Define the eye we want the parameter for
  62258. * @returns the eye parameters
  62259. */
  62260. getEyeParameters(whichEye: string): VREyeParameters;
  62261. /**
  62262. * Populates the passed VRFrameData with the information required to render
  62263. * the current frame.
  62264. * @param frameData Define the data structure to populate
  62265. * @returns true if ok otherwise false
  62266. */
  62267. getFrameData(frameData: VRFrameData): boolean;
  62268. /**
  62269. * Get the layers currently being presented.
  62270. * @returns the list of VR layers
  62271. */
  62272. getLayers(): VRLayer[];
  62273. /**
  62274. * Return a VRPose containing the future predicted pose of the VRDisplay
  62275. * when the current frame will be presented. The value returned will not
  62276. * change until JavaScript has returned control to the browser.
  62277. *
  62278. * The VRPose will contain the position, orientation, velocity,
  62279. * and acceleration of each of these properties.
  62280. * @returns the pose object
  62281. */
  62282. getPose(): VRPose;
  62283. /**
  62284. * Return the current instantaneous pose of the VRDisplay, with no
  62285. * prediction applied.
  62286. * @returns the current instantaneous pose
  62287. */
  62288. getImmediatePose(): VRPose;
  62289. /**
  62290. * The callback passed to `requestAnimationFrame` will be called
  62291. * any time a new frame should be rendered. When the VRDisplay is
  62292. * presenting the callback will be called at the native refresh
  62293. * rate of the HMD. When not presenting this function acts
  62294. * identically to how window.requestAnimationFrame acts. Content should
  62295. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62296. * asynchronously from other displays and at differing refresh rates.
  62297. * @param callback Define the eaction to run next frame
  62298. * @returns the request handle it
  62299. */
  62300. requestAnimationFrame(callback: FrameRequestCallback): number;
  62301. /**
  62302. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62303. * Repeat calls while already presenting will update the VRLayers being displayed.
  62304. * @param layers Define the list of layer to present
  62305. * @returns a promise to know when the request has been fulfilled
  62306. */
  62307. requestPresent(layers: VRLayer[]): Promise<void>;
  62308. /**
  62309. * Reset the pose for this display, treating its current position and
  62310. * orientation as the "origin/zero" values. VRPose.position,
  62311. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62312. * updated when calling resetPose(). This should be called in only
  62313. * sitting-space experiences.
  62314. */
  62315. resetPose(): void;
  62316. /**
  62317. * The VRLayer provided to the VRDisplay will be captured and presented
  62318. * in the HMD. Calling this function has the same effect on the source
  62319. * canvas as any other operation that uses its source image, and canvases
  62320. * created without preserveDrawingBuffer set to true will be cleared.
  62321. * @param pose Define the pose to submit
  62322. */
  62323. submitFrame(pose?: VRPose): void;
  62324. }
  62325. declare var VRDisplay: {
  62326. prototype: VRDisplay;
  62327. new(): VRDisplay;
  62328. };
  62329. interface VRLayer {
  62330. leftBounds?: number[] | Float32Array | null;
  62331. rightBounds?: number[] | Float32Array | null;
  62332. source?: HTMLCanvasElement | null;
  62333. }
  62334. interface VRDisplayCapabilities {
  62335. readonly canPresent: boolean;
  62336. readonly hasExternalDisplay: boolean;
  62337. readonly hasOrientation: boolean;
  62338. readonly hasPosition: boolean;
  62339. readonly maxLayers: number;
  62340. }
  62341. interface VREyeParameters {
  62342. /** @deprecated */
  62343. readonly fieldOfView: VRFieldOfView;
  62344. readonly offset: Float32Array;
  62345. readonly renderHeight: number;
  62346. readonly renderWidth: number;
  62347. }
  62348. interface VRFieldOfView {
  62349. readonly downDegrees: number;
  62350. readonly leftDegrees: number;
  62351. readonly rightDegrees: number;
  62352. readonly upDegrees: number;
  62353. }
  62354. interface VRFrameData {
  62355. readonly leftProjectionMatrix: Float32Array;
  62356. readonly leftViewMatrix: Float32Array;
  62357. readonly pose: VRPose;
  62358. readonly rightProjectionMatrix: Float32Array;
  62359. readonly rightViewMatrix: Float32Array;
  62360. readonly timestamp: number;
  62361. }
  62362. interface VRPose {
  62363. readonly angularAcceleration: Float32Array | null;
  62364. readonly angularVelocity: Float32Array | null;
  62365. readonly linearAcceleration: Float32Array | null;
  62366. readonly linearVelocity: Float32Array | null;
  62367. readonly orientation: Float32Array | null;
  62368. readonly position: Float32Array | null;
  62369. readonly timestamp: number;
  62370. }
  62371. interface VRStageParameters {
  62372. sittingToStandingTransform?: Float32Array;
  62373. sizeX?: number;
  62374. sizeY?: number;
  62375. }
  62376. interface Navigator {
  62377. getVRDisplays(): Promise<VRDisplay[]>;
  62378. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62379. }
  62380. interface Window {
  62381. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62382. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62383. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62384. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62385. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62386. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62387. }
  62388. interface Gamepad {
  62389. readonly displayId: number;
  62390. }
  62391. type XRSessionMode =
  62392. | "inline"
  62393. | "immersive-vr"
  62394. | "immersive-ar";
  62395. type XRReferenceSpaceType =
  62396. | "viewer"
  62397. | "local"
  62398. | "local-floor"
  62399. | "bounded-floor"
  62400. | "unbounded";
  62401. type XREnvironmentBlendMode =
  62402. | "opaque"
  62403. | "additive"
  62404. | "alpha-blend";
  62405. type XRVisibilityState =
  62406. | "visible"
  62407. | "visible-blurred"
  62408. | "hidden";
  62409. type XRHandedness =
  62410. | "none"
  62411. | "left"
  62412. | "right";
  62413. type XRTargetRayMode =
  62414. | "gaze"
  62415. | "tracked-pointer"
  62416. | "screen";
  62417. type XREye =
  62418. | "none"
  62419. | "left"
  62420. | "right";
  62421. interface XRSpace extends EventTarget {
  62422. }
  62423. interface XRRenderState {
  62424. depthNear?: number;
  62425. depthFar?: number;
  62426. inlineVerticalFieldOfView?: number;
  62427. baseLayer?: XRWebGLLayer;
  62428. }
  62429. interface XRInputSource {
  62430. handedness: XRHandedness;
  62431. targetRayMode: XRTargetRayMode;
  62432. targetRaySpace: XRSpace;
  62433. gripSpace: XRSpace | undefined;
  62434. gamepad: Gamepad | undefined;
  62435. profiles: Array<string>;
  62436. }
  62437. interface XRSession {
  62438. addEventListener: Function;
  62439. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62440. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62441. requestAnimationFrame: Function;
  62442. end(): Promise<void>;
  62443. renderState: XRRenderState;
  62444. inputSources: Array<XRInputSource>;
  62445. }
  62446. interface XRReferenceSpace extends XRSpace {
  62447. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62448. onreset: any;
  62449. }
  62450. interface XRFrame {
  62451. session: XRSession;
  62452. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62453. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62454. }
  62455. interface XRViewerPose extends XRPose {
  62456. views: Array<XRView>;
  62457. }
  62458. interface XRPose {
  62459. transform: XRRigidTransform;
  62460. emulatedPosition: boolean;
  62461. }
  62462. declare var XRWebGLLayer: {
  62463. prototype: XRWebGLLayer;
  62464. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62465. };
  62466. interface XRWebGLLayer {
  62467. framebuffer: WebGLFramebuffer;
  62468. framebufferWidth: number;
  62469. framebufferHeight: number;
  62470. getViewport: Function;
  62471. }
  62472. interface XRRigidTransform {
  62473. position: DOMPointReadOnly;
  62474. orientation: DOMPointReadOnly;
  62475. matrix: Float32Array;
  62476. inverse: XRRigidTransform;
  62477. }
  62478. interface XRView {
  62479. eye: XREye;
  62480. projectionMatrix: Float32Array;
  62481. transform: XRRigidTransform;
  62482. }
  62483. interface XRInputSourceChangeEvent {
  62484. session: XRSession;
  62485. removed: Array<XRInputSource>;
  62486. added: Array<XRInputSource>;
  62487. }
  62488. /**
  62489. * @ignore
  62490. */
  62491. declare module BABYLON.GLTF2.Exporter {
  62492. }
  62493. /**
  62494. * @ignore
  62495. */
  62496. declare module BABYLON.GLTF1 {
  62497. }
  62498. declare module BABYLON.GUI {
  62499. /**
  62500. * Class used to specific a value and its associated unit
  62501. */
  62502. export class ValueAndUnit {
  62503. /** defines the unit to store */
  62504. unit: number;
  62505. /** defines a boolean indicating if the value can be negative */
  62506. negativeValueAllowed: boolean;
  62507. private _value;
  62508. private _originalUnit;
  62509. /**
  62510. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62511. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62512. */
  62513. ignoreAdaptiveScaling: boolean;
  62514. /**
  62515. * Creates a new ValueAndUnit
  62516. * @param value defines the value to store
  62517. * @param unit defines the unit to store
  62518. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62519. */
  62520. constructor(value: number,
  62521. /** defines the unit to store */
  62522. unit?: number,
  62523. /** defines a boolean indicating if the value can be negative */
  62524. negativeValueAllowed?: boolean);
  62525. /** Gets a boolean indicating if the value is a percentage */
  62526. readonly isPercentage: boolean;
  62527. /** Gets a boolean indicating if the value is store as pixel */
  62528. readonly isPixel: boolean;
  62529. /** Gets direct internal value */
  62530. readonly internalValue: number;
  62531. /**
  62532. * Gets value as pixel
  62533. * @param host defines the root host
  62534. * @param refValue defines the reference value for percentages
  62535. * @returns the value as pixel
  62536. */
  62537. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62538. /**
  62539. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62540. * @param value defines the value to store
  62541. * @param unit defines the unit to store
  62542. * @returns the current ValueAndUnit
  62543. */
  62544. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62545. /**
  62546. * Gets the value accordingly to its unit
  62547. * @param host defines the root host
  62548. * @returns the value
  62549. */
  62550. getValue(host: AdvancedDynamicTexture): number;
  62551. /**
  62552. * Gets a string representation of the value
  62553. * @param host defines the root host
  62554. * @param decimals defines an optional number of decimals to display
  62555. * @returns a string
  62556. */
  62557. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62558. /**
  62559. * Store a value parsed from a string
  62560. * @param source defines the source string
  62561. * @returns true if the value was successfully parsed
  62562. */
  62563. fromString(source: string | number): boolean;
  62564. private static _Regex;
  62565. private static _UNITMODE_PERCENTAGE;
  62566. private static _UNITMODE_PIXEL;
  62567. /** UNITMODE_PERCENTAGE */
  62568. static readonly UNITMODE_PERCENTAGE: number;
  62569. /** UNITMODE_PIXEL */
  62570. static readonly UNITMODE_PIXEL: number;
  62571. }
  62572. }
  62573. declare module BABYLON.GUI {
  62574. /**
  62575. * Define a style used by control to automatically setup properties based on a template.
  62576. * Only support font related properties so far
  62577. */
  62578. export class Style implements BABYLON.IDisposable {
  62579. private _fontFamily;
  62580. private _fontStyle;
  62581. private _fontWeight;
  62582. /** @hidden */ private _host: AdvancedDynamicTexture;
  62583. /** @hidden */ private _fontSize: ValueAndUnit;
  62584. /**
  62585. * BABYLON.Observable raised when the style values are changed
  62586. */
  62587. onChangedObservable: BABYLON.Observable<Style>;
  62588. /**
  62589. * Creates a new style object
  62590. * @param host defines the AdvancedDynamicTexture which hosts this style
  62591. */
  62592. constructor(host: AdvancedDynamicTexture);
  62593. /**
  62594. * Gets or sets the font size
  62595. */
  62596. fontSize: string | number;
  62597. /**
  62598. * Gets or sets the font family
  62599. */
  62600. fontFamily: string;
  62601. /**
  62602. * Gets or sets the font style
  62603. */
  62604. fontStyle: string;
  62605. /** Gets or sets font weight */
  62606. fontWeight: string;
  62607. /** Dispose all associated resources */
  62608. dispose(): void;
  62609. }
  62610. }
  62611. declare module BABYLON.GUI {
  62612. /**
  62613. * Class used to transport BABYLON.Vector2 information for pointer events
  62614. */
  62615. export class Vector2WithInfo extends BABYLON.Vector2 {
  62616. /** defines the current mouse button index */
  62617. buttonIndex: number;
  62618. /**
  62619. * Creates a new Vector2WithInfo
  62620. * @param source defines the vector2 data to transport
  62621. * @param buttonIndex defines the current mouse button index
  62622. */
  62623. constructor(source: BABYLON.Vector2,
  62624. /** defines the current mouse button index */
  62625. buttonIndex?: number);
  62626. }
  62627. /** Class used to provide 2D matrix features */
  62628. export class Matrix2D {
  62629. /** Gets the internal array of 6 floats used to store matrix data */
  62630. m: Float32Array;
  62631. /**
  62632. * Creates a new matrix
  62633. * @param m00 defines value for (0, 0)
  62634. * @param m01 defines value for (0, 1)
  62635. * @param m10 defines value for (1, 0)
  62636. * @param m11 defines value for (1, 1)
  62637. * @param m20 defines value for (2, 0)
  62638. * @param m21 defines value for (2, 1)
  62639. */
  62640. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62641. /**
  62642. * Fills the matrix from direct values
  62643. * @param m00 defines value for (0, 0)
  62644. * @param m01 defines value for (0, 1)
  62645. * @param m10 defines value for (1, 0)
  62646. * @param m11 defines value for (1, 1)
  62647. * @param m20 defines value for (2, 0)
  62648. * @param m21 defines value for (2, 1)
  62649. * @returns the current modified matrix
  62650. */
  62651. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62652. /**
  62653. * Gets matrix determinant
  62654. * @returns the determinant
  62655. */
  62656. determinant(): number;
  62657. /**
  62658. * Inverses the matrix and stores it in a target matrix
  62659. * @param result defines the target matrix
  62660. * @returns the current matrix
  62661. */
  62662. invertToRef(result: Matrix2D): Matrix2D;
  62663. /**
  62664. * Multiplies the current matrix with another one
  62665. * @param other defines the second operand
  62666. * @param result defines the target matrix
  62667. * @returns the current matrix
  62668. */
  62669. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62670. /**
  62671. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62672. * @param x defines the x coordinate to transform
  62673. * @param y defines the x coordinate to transform
  62674. * @param result defines the target vector2
  62675. * @returns the current matrix
  62676. */
  62677. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62678. /**
  62679. * Creates an identity matrix
  62680. * @returns a new matrix
  62681. */
  62682. static Identity(): Matrix2D;
  62683. /**
  62684. * Creates a translation matrix and stores it in a target matrix
  62685. * @param x defines the x coordinate of the translation
  62686. * @param y defines the y coordinate of the translation
  62687. * @param result defines the target matrix
  62688. */
  62689. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62690. /**
  62691. * Creates a scaling matrix and stores it in a target matrix
  62692. * @param x defines the x coordinate of the scaling
  62693. * @param y defines the y coordinate of the scaling
  62694. * @param result defines the target matrix
  62695. */
  62696. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62697. /**
  62698. * Creates a rotation matrix and stores it in a target matrix
  62699. * @param angle defines the rotation angle
  62700. * @param result defines the target matrix
  62701. */
  62702. static RotationToRef(angle: number, result: Matrix2D): void;
  62703. private static _TempPreTranslationMatrix;
  62704. private static _TempPostTranslationMatrix;
  62705. private static _TempRotationMatrix;
  62706. private static _TempScalingMatrix;
  62707. private static _TempCompose0;
  62708. private static _TempCompose1;
  62709. private static _TempCompose2;
  62710. /**
  62711. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62712. * @param tx defines the x coordinate of the translation
  62713. * @param ty defines the y coordinate of the translation
  62714. * @param angle defines the rotation angle
  62715. * @param scaleX defines the x coordinate of the scaling
  62716. * @param scaleY defines the y coordinate of the scaling
  62717. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62718. * @param result defines the target matrix
  62719. */
  62720. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62721. }
  62722. }
  62723. declare module BABYLON.GUI {
  62724. /**
  62725. * Class used to store 2D control sizes
  62726. */
  62727. export class Measure {
  62728. /** defines left coordinate */
  62729. left: number;
  62730. /** defines top coordinate */
  62731. top: number;
  62732. /** defines width dimension */
  62733. width: number;
  62734. /** defines height dimension */
  62735. height: number;
  62736. /**
  62737. * Creates a new measure
  62738. * @param left defines left coordinate
  62739. * @param top defines top coordinate
  62740. * @param width defines width dimension
  62741. * @param height defines height dimension
  62742. */
  62743. constructor(
  62744. /** defines left coordinate */
  62745. left: number,
  62746. /** defines top coordinate */
  62747. top: number,
  62748. /** defines width dimension */
  62749. width: number,
  62750. /** defines height dimension */
  62751. height: number);
  62752. /**
  62753. * Copy from another measure
  62754. * @param other defines the other measure to copy from
  62755. */
  62756. copyFrom(other: Measure): void;
  62757. /**
  62758. * Copy from a group of 4 floats
  62759. * @param left defines left coordinate
  62760. * @param top defines top coordinate
  62761. * @param width defines width dimension
  62762. * @param height defines height dimension
  62763. */
  62764. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62765. /**
  62766. * Computes the axis aligned bounding box measure for two given measures
  62767. * @param a Input measure
  62768. * @param b Input measure
  62769. * @param result the resulting bounding measure
  62770. */
  62771. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62772. /**
  62773. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62774. * @param transform the matrix to transform the measure before computing the AABB
  62775. * @param result the resulting AABB
  62776. */
  62777. transformToRef(transform: Matrix2D, result: Measure): void;
  62778. /**
  62779. * Check equality between this measure and another one
  62780. * @param other defines the other measures
  62781. * @returns true if both measures are equals
  62782. */
  62783. isEqualsTo(other: Measure): boolean;
  62784. /**
  62785. * Creates an empty measure
  62786. * @returns a new measure
  62787. */
  62788. static Empty(): Measure;
  62789. }
  62790. }
  62791. declare module BABYLON.GUI {
  62792. /**
  62793. * Interface used to define a control that can receive focus
  62794. */
  62795. export interface IFocusableControl {
  62796. /**
  62797. * Function called when the control receives the focus
  62798. */
  62799. onFocus(): void;
  62800. /**
  62801. * Function called when the control loses the focus
  62802. */
  62803. onBlur(): void;
  62804. /**
  62805. * Function called to let the control handle keyboard events
  62806. * @param evt defines the current keyboard event
  62807. */
  62808. processKeyboard(evt: KeyboardEvent): void;
  62809. /**
  62810. * Function called to get the list of controls that should not steal the focus from this control
  62811. * @returns an array of controls
  62812. */
  62813. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62814. }
  62815. /**
  62816. * Class used to create texture to support 2D GUI elements
  62817. * @see http://doc.babylonjs.com/how_to/gui
  62818. */
  62819. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62820. private _isDirty;
  62821. private _renderObserver;
  62822. private _resizeObserver;
  62823. private _preKeyboardObserver;
  62824. private _pointerMoveObserver;
  62825. private _pointerObserver;
  62826. private _canvasPointerOutObserver;
  62827. private _background;
  62828. /** @hidden */ private _rootContainer: Container;
  62829. /** @hidden */ private _lastPickedControl: Control;
  62830. /** @hidden */ private _lastControlOver: {
  62831. [pointerId: number]: Control;
  62832. };
  62833. /** @hidden */ private _lastControlDown: {
  62834. [pointerId: number]: Control;
  62835. };
  62836. /** @hidden */ private _capturingControl: {
  62837. [pointerId: number]: Control;
  62838. };
  62839. /** @hidden */ private _shouldBlockPointer: boolean;
  62840. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62841. /** @hidden */ private _linkedControls: Control[];
  62842. private _isFullscreen;
  62843. private _fullscreenViewport;
  62844. private _idealWidth;
  62845. private _idealHeight;
  62846. private _useSmallestIdeal;
  62847. private _renderAtIdealSize;
  62848. private _focusedControl;
  62849. private _blockNextFocusCheck;
  62850. private _renderScale;
  62851. private _rootCanvas;
  62852. private _cursorChanged;
  62853. /**
  62854. * Define type to string to ensure compatibility across browsers
  62855. * Safari doesn't support DataTransfer constructor
  62856. */
  62857. private _clipboardData;
  62858. /**
  62859. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62860. */
  62861. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62862. /**
  62863. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62864. */
  62865. onControlPickedObservable: BABYLON.Observable<Control>;
  62866. /**
  62867. * BABYLON.Observable event triggered before layout is evaluated
  62868. */
  62869. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62870. /**
  62871. * BABYLON.Observable event triggered after the layout was evaluated
  62872. */
  62873. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62874. /**
  62875. * BABYLON.Observable event triggered before the texture is rendered
  62876. */
  62877. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62878. /**
  62879. * BABYLON.Observable event triggered after the texture was rendered
  62880. */
  62881. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62882. /**
  62883. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62884. */
  62885. premulAlpha: boolean;
  62886. /**
  62887. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62888. * Useful when you want more antialiasing
  62889. */
  62890. renderScale: number;
  62891. /** Gets or sets the background color */
  62892. background: string;
  62893. /**
  62894. * Gets or sets the ideal width used to design controls.
  62895. * The GUI will then rescale everything accordingly
  62896. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62897. */
  62898. idealWidth: number;
  62899. /**
  62900. * Gets or sets the ideal height used to design controls.
  62901. * The GUI will then rescale everything accordingly
  62902. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62903. */
  62904. idealHeight: number;
  62905. /**
  62906. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62907. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62908. */
  62909. useSmallestIdeal: boolean;
  62910. /**
  62911. * Gets or sets a boolean indicating if adaptive scaling must be used
  62912. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62913. */
  62914. renderAtIdealSize: boolean;
  62915. /**
  62916. * Gets the underlying layer used to render the texture when in fullscreen mode
  62917. */
  62918. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62919. /**
  62920. * Gets the root container control
  62921. */
  62922. readonly rootContainer: Container;
  62923. /**
  62924. * Returns an array containing the root container.
  62925. * This is mostly used to let the Inspector introspects the ADT
  62926. * @returns an array containing the rootContainer
  62927. */
  62928. getChildren(): Array<Container>;
  62929. /**
  62930. * Will return all controls that are inside this texture
  62931. * @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
  62932. * @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
  62933. * @return all child controls
  62934. */
  62935. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62936. /**
  62937. * Gets or sets the current focused control
  62938. */
  62939. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62940. /**
  62941. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62942. */
  62943. isForeground: boolean;
  62944. /**
  62945. * Gets or set information about clipboardData
  62946. */
  62947. clipboardData: string;
  62948. /**
  62949. * Creates a new AdvancedDynamicTexture
  62950. * @param name defines the name of the texture
  62951. * @param width defines the width of the texture
  62952. * @param height defines the height of the texture
  62953. * @param scene defines the hosting scene
  62954. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62955. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62956. */
  62957. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62958. /**
  62959. * Get the current class name of the texture useful for serialization or dynamic coding.
  62960. * @returns "AdvancedDynamicTexture"
  62961. */
  62962. getClassName(): string;
  62963. /**
  62964. * Function used to execute a function on all controls
  62965. * @param func defines the function to execute
  62966. * @param container defines the container where controls belong. If null the root container will be used
  62967. */
  62968. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62969. private _useInvalidateRectOptimization;
  62970. /**
  62971. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62972. */
  62973. useInvalidateRectOptimization: boolean;
  62974. private _invalidatedRectangle;
  62975. /**
  62976. * Invalidates a rectangle area on the gui texture
  62977. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62978. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62979. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62980. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62981. */
  62982. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62983. /**
  62984. * Marks the texture as dirty forcing a complete update
  62985. */
  62986. markAsDirty(): void;
  62987. /**
  62988. * Helper function used to create a new style
  62989. * @returns a new style
  62990. * @see http://doc.babylonjs.com/how_to/gui#styles
  62991. */
  62992. createStyle(): Style;
  62993. /**
  62994. * Adds a new control to the root container
  62995. * @param control defines the control to add
  62996. * @returns the current texture
  62997. */
  62998. addControl(control: Control): AdvancedDynamicTexture;
  62999. /**
  63000. * Removes a control from the root container
  63001. * @param control defines the control to remove
  63002. * @returns the current texture
  63003. */
  63004. removeControl(control: Control): AdvancedDynamicTexture;
  63005. /**
  63006. * Release all resources
  63007. */
  63008. dispose(): void;
  63009. private _onResize;
  63010. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63011. /**
  63012. * Get screen coordinates for a vector3
  63013. * @param position defines the position to project
  63014. * @param worldMatrix defines the world matrix to use
  63015. * @returns the projected position
  63016. */
  63017. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63018. private _checkUpdate;
  63019. private _clearMeasure;
  63020. private _render;
  63021. /** @hidden */ private _changeCursor(cursor: string): void;
  63022. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  63023. private _doPicking;
  63024. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  63025. [pointerId: number]: Control;
  63026. }, control: Control): void;
  63027. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  63028. /** Attach to all scene events required to support pointer events */
  63029. attach(): void;
  63030. /** @hidden */
  63031. private onClipboardCopy;
  63032. /** @hidden */
  63033. private onClipboardCut;
  63034. /** @hidden */
  63035. private onClipboardPaste;
  63036. /**
  63037. * Register the clipboard Events onto the canvas
  63038. */
  63039. registerClipboardEvents(): void;
  63040. /**
  63041. * Unregister the clipboard Events from the canvas
  63042. */
  63043. unRegisterClipboardEvents(): void;
  63044. /**
  63045. * Connect the texture to a hosting mesh to enable interactions
  63046. * @param mesh defines the mesh to attach to
  63047. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63048. */
  63049. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63050. /**
  63051. * Move the focus to a specific control
  63052. * @param control defines the control which will receive the focus
  63053. */
  63054. moveFocusToControl(control: IFocusableControl): void;
  63055. private _manageFocus;
  63056. private _attachToOnPointerOut;
  63057. /**
  63058. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63059. * @param mesh defines the mesh which will receive the texture
  63060. * @param width defines the texture width (1024 by default)
  63061. * @param height defines the texture height (1024 by default)
  63062. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63063. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63064. * @returns a new AdvancedDynamicTexture
  63065. */
  63066. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63067. /**
  63068. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63069. * In this mode the texture will rely on a layer for its rendering.
  63070. * This allows it to be treated like any other layer.
  63071. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63072. * LayerMask is set through advancedTexture.layer.layerMask
  63073. * @param name defines name for the texture
  63074. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63075. * @param scene defines the hsoting scene
  63076. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63077. * @returns a new AdvancedDynamicTexture
  63078. */
  63079. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63080. }
  63081. }
  63082. declare module BABYLON.GUI {
  63083. /**
  63084. * Root class used for all 2D controls
  63085. * @see http://doc.babylonjs.com/how_to/gui#controls
  63086. */
  63087. export class Control {
  63088. /** defines the name of the control */
  63089. name?: string | undefined;
  63090. /**
  63091. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63092. */
  63093. static AllowAlphaInheritance: boolean;
  63094. private _alpha;
  63095. private _alphaSet;
  63096. private _zIndex;
  63097. /** @hidden */ private _host: AdvancedDynamicTexture;
  63098. /** Gets or sets the control parent */
  63099. parent: BABYLON.Nullable<Container>;
  63100. /** @hidden */ private _currentMeasure: Measure;
  63101. private _fontFamily;
  63102. private _fontStyle;
  63103. private _fontWeight;
  63104. private _fontSize;
  63105. private _font;
  63106. /** @hidden */ private _width: ValueAndUnit;
  63107. /** @hidden */ private _height: ValueAndUnit;
  63108. /** @hidden */
  63109. protected _fontOffset: {
  63110. ascent: number;
  63111. height: number;
  63112. descent: number;
  63113. };
  63114. private _color;
  63115. private _style;
  63116. private _styleObserver;
  63117. /** @hidden */
  63118. protected _horizontalAlignment: number;
  63119. /** @hidden */
  63120. protected _verticalAlignment: number;
  63121. /** @hidden */
  63122. protected _isDirty: boolean;
  63123. /** @hidden */
  63124. protected _wasDirty: boolean;
  63125. /** @hidden */ private _tempParentMeasure: Measure;
  63126. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63127. /** @hidden */
  63128. protected _cachedParentMeasure: Measure;
  63129. private _paddingLeft;
  63130. private _paddingRight;
  63131. private _paddingTop;
  63132. private _paddingBottom;
  63133. /** @hidden */ private _left: ValueAndUnit;
  63134. /** @hidden */ private _top: ValueAndUnit;
  63135. private _scaleX;
  63136. private _scaleY;
  63137. private _rotation;
  63138. private _transformCenterX;
  63139. private _transformCenterY;
  63140. /** @hidden */ private _transformMatrix: Matrix2D;
  63141. /** @hidden */
  63142. protected _invertTransformMatrix: Matrix2D;
  63143. /** @hidden */
  63144. protected _transformedPosition: BABYLON.Vector2;
  63145. private _isMatrixDirty;
  63146. private _cachedOffsetX;
  63147. private _cachedOffsetY;
  63148. private _isVisible;
  63149. private _isHighlighted;
  63150. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63151. private _fontSet;
  63152. private _dummyVector2;
  63153. private _downCount;
  63154. private _enterCount;
  63155. private _doNotRender;
  63156. private _downPointerIds;
  63157. protected _isEnabled: boolean;
  63158. protected _disabledColor: string;
  63159. /** @hidden */
  63160. protected _rebuildLayout: boolean;
  63161. /** @hidden */ private _isClipped: boolean;
  63162. /** @hidden */ private _tag: any;
  63163. /**
  63164. * 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
  63165. */
  63166. uniqueId: number;
  63167. /**
  63168. * Gets or sets an object used to store user defined information for the node
  63169. */
  63170. metadata: any;
  63171. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63172. isHitTestVisible: boolean;
  63173. /** Gets or sets a boolean indicating if the control can block pointer events */
  63174. isPointerBlocker: boolean;
  63175. /** Gets or sets a boolean indicating if the control can be focusable */
  63176. isFocusInvisible: boolean;
  63177. /**
  63178. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63179. * 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
  63180. */
  63181. clipChildren: boolean;
  63182. /**
  63183. * Gets or sets a boolean indicating that control content must be clipped
  63184. * 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
  63185. */
  63186. clipContent: boolean;
  63187. /**
  63188. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63189. */
  63190. useBitmapCache: boolean;
  63191. private _cacheData;
  63192. private _shadowOffsetX;
  63193. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63194. shadowOffsetX: number;
  63195. private _shadowOffsetY;
  63196. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63197. shadowOffsetY: number;
  63198. private _shadowBlur;
  63199. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63200. shadowBlur: number;
  63201. private _shadowColor;
  63202. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63203. shadowColor: string;
  63204. /** Gets or sets the cursor to use when the control is hovered */
  63205. hoverCursor: string;
  63206. /** @hidden */
  63207. protected _linkOffsetX: ValueAndUnit;
  63208. /** @hidden */
  63209. protected _linkOffsetY: ValueAndUnit;
  63210. /** Gets the control type name */
  63211. readonly typeName: string;
  63212. /**
  63213. * Get the current class name of the control.
  63214. * @returns current class name
  63215. */
  63216. getClassName(): string;
  63217. /**
  63218. * An event triggered when the pointer move over the control.
  63219. */
  63220. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63221. /**
  63222. * An event triggered when the pointer move out of the control.
  63223. */
  63224. onPointerOutObservable: BABYLON.Observable<Control>;
  63225. /**
  63226. * An event triggered when the pointer taps the control
  63227. */
  63228. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63229. /**
  63230. * An event triggered when pointer up
  63231. */
  63232. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63233. /**
  63234. * An event triggered when a control is clicked on
  63235. */
  63236. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63237. /**
  63238. * An event triggered when pointer enters the control
  63239. */
  63240. onPointerEnterObservable: BABYLON.Observable<Control>;
  63241. /**
  63242. * An event triggered when the control is marked as dirty
  63243. */
  63244. onDirtyObservable: BABYLON.Observable<Control>;
  63245. /**
  63246. * An event triggered before drawing the control
  63247. */
  63248. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63249. /**
  63250. * An event triggered after the control was drawn
  63251. */
  63252. onAfterDrawObservable: BABYLON.Observable<Control>;
  63253. /**
  63254. * Get the hosting AdvancedDynamicTexture
  63255. */
  63256. readonly host: AdvancedDynamicTexture;
  63257. /** Gets or set information about font offsets (used to render and align text) */
  63258. fontOffset: {
  63259. ascent: number;
  63260. height: number;
  63261. descent: number;
  63262. };
  63263. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63264. alpha: number;
  63265. /**
  63266. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63267. */
  63268. isHighlighted: boolean;
  63269. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63270. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63271. */
  63272. scaleX: number;
  63273. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63274. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63275. */
  63276. scaleY: number;
  63277. /** Gets or sets the rotation angle (0 by default)
  63278. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63279. */
  63280. rotation: number;
  63281. /** Gets or sets the transformation center on Y axis (0 by default)
  63282. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63283. */
  63284. transformCenterY: number;
  63285. /** Gets or sets the transformation center on X axis (0 by default)
  63286. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63287. */
  63288. transformCenterX: number;
  63289. /**
  63290. * Gets or sets the horizontal alignment
  63291. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63292. */
  63293. horizontalAlignment: number;
  63294. /**
  63295. * Gets or sets the vertical alignment
  63296. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63297. */
  63298. verticalAlignment: number;
  63299. /**
  63300. * Gets or sets control width
  63301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63302. */
  63303. width: string | number;
  63304. /**
  63305. * Gets or sets the control width in pixel
  63306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63307. */
  63308. widthInPixels: number;
  63309. /**
  63310. * Gets or sets control height
  63311. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63312. */
  63313. height: string | number;
  63314. /**
  63315. * Gets or sets control height in pixel
  63316. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63317. */
  63318. heightInPixels: number;
  63319. /** Gets or set font family */
  63320. fontFamily: string;
  63321. /** Gets or sets font style */
  63322. fontStyle: string;
  63323. /** Gets or sets font weight */
  63324. fontWeight: string;
  63325. /**
  63326. * Gets or sets style
  63327. * @see http://doc.babylonjs.com/how_to/gui#styles
  63328. */
  63329. style: BABYLON.Nullable<Style>;
  63330. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  63331. /** Gets or sets font size in pixels */
  63332. fontSizeInPixels: number;
  63333. /** Gets or sets font size */
  63334. fontSize: string | number;
  63335. /** Gets or sets foreground color */
  63336. color: string;
  63337. /** Gets or sets z index which is used to reorder controls on the z axis */
  63338. zIndex: number;
  63339. /** Gets or sets a boolean indicating if the control can be rendered */
  63340. notRenderable: boolean;
  63341. /** Gets or sets a boolean indicating if the control is visible */
  63342. isVisible: boolean;
  63343. /** Gets a boolean indicating that the control needs to update its rendering */
  63344. readonly isDirty: boolean;
  63345. /**
  63346. * Gets the current linked mesh (or null if none)
  63347. */
  63348. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63349. /**
  63350. * Gets or sets a value indicating the padding to use on the left of the control
  63351. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63352. */
  63353. paddingLeft: string | number;
  63354. /**
  63355. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63356. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63357. */
  63358. paddingLeftInPixels: number;
  63359. /**
  63360. * Gets or sets a value indicating the padding to use on the right of the control
  63361. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63362. */
  63363. paddingRight: string | number;
  63364. /**
  63365. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63366. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63367. */
  63368. paddingRightInPixels: number;
  63369. /**
  63370. * Gets or sets a value indicating the padding to use on the top of the control
  63371. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63372. */
  63373. paddingTop: string | number;
  63374. /**
  63375. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63376. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63377. */
  63378. paddingTopInPixels: number;
  63379. /**
  63380. * Gets or sets a value indicating the padding to use on the bottom of the control
  63381. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63382. */
  63383. paddingBottom: string | number;
  63384. /**
  63385. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63386. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63387. */
  63388. paddingBottomInPixels: number;
  63389. /**
  63390. * Gets or sets a value indicating the left coordinate of the control
  63391. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63392. */
  63393. left: string | number;
  63394. /**
  63395. * Gets or sets a value indicating the left coordinate in pixels of the control
  63396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63397. */
  63398. leftInPixels: number;
  63399. /**
  63400. * Gets or sets a value indicating the top coordinate of the control
  63401. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63402. */
  63403. top: string | number;
  63404. /**
  63405. * Gets or sets a value indicating the top coordinate in pixels of the control
  63406. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63407. */
  63408. topInPixels: number;
  63409. /**
  63410. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63411. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63412. */
  63413. linkOffsetX: string | number;
  63414. /**
  63415. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63416. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63417. */
  63418. linkOffsetXInPixels: number;
  63419. /**
  63420. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63421. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63422. */
  63423. linkOffsetY: string | number;
  63424. /**
  63425. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63426. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63427. */
  63428. linkOffsetYInPixels: number;
  63429. /** Gets the center coordinate on X axis */
  63430. readonly centerX: number;
  63431. /** Gets the center coordinate on Y axis */
  63432. readonly centerY: number;
  63433. /** Gets or sets if control is Enabled*/
  63434. isEnabled: boolean;
  63435. /** Gets or sets background color of control if it's disabled*/
  63436. disabledColor: string;
  63437. /**
  63438. * Creates a new control
  63439. * @param name defines the name of the control
  63440. */
  63441. constructor(
  63442. /** defines the name of the control */
  63443. name?: string | undefined);
  63444. /** @hidden */
  63445. protected _getTypeName(): string;
  63446. /**
  63447. * Gets the first ascendant in the hierarchy of the given type
  63448. * @param className defines the required type
  63449. * @returns the ascendant or null if not found
  63450. */
  63451. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63452. /** @hidden */ private _resetFontCache(): void;
  63453. /**
  63454. * Determines if a container is an ascendant of the current control
  63455. * @param container defines the container to look for
  63456. * @returns true if the container is one of the ascendant of the control
  63457. */
  63458. isAscendant(container: Control): boolean;
  63459. /**
  63460. * Gets coordinates in local control space
  63461. * @param globalCoordinates defines the coordinates to transform
  63462. * @returns the new coordinates in local space
  63463. */
  63464. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63465. /**
  63466. * Gets coordinates in local control space
  63467. * @param globalCoordinates defines the coordinates to transform
  63468. * @param result defines the target vector2 where to store the result
  63469. * @returns the current control
  63470. */
  63471. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63472. /**
  63473. * Gets coordinates in parent local control space
  63474. * @param globalCoordinates defines the coordinates to transform
  63475. * @returns the new coordinates in parent local space
  63476. */
  63477. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63478. /**
  63479. * Move the current control to a vector3 position projected onto the screen.
  63480. * @param position defines the target position
  63481. * @param scene defines the hosting scene
  63482. */
  63483. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63484. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63485. /**
  63486. * Will return all controls that have this control as ascendant
  63487. * @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
  63488. * @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
  63489. * @return all child controls
  63490. */
  63491. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63492. /**
  63493. * Link current control with a target mesh
  63494. * @param mesh defines the mesh to link with
  63495. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63496. */
  63497. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63498. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63499. /** @hidden */ private _offsetLeft(offset: number): void;
  63500. /** @hidden */ private _offsetTop(offset: number): void;
  63501. /** @hidden */ private _markMatrixAsDirty(): void;
  63502. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  63503. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  63504. /** @hidden */
  63505. protected invalidateRect(): void;
  63506. /** @hidden */ private _markAsDirty(force?: boolean): void;
  63507. /** @hidden */ private _markAllAsDirty(): void;
  63508. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63509. /** @hidden */
  63510. protected _transform(context?: CanvasRenderingContext2D): void;
  63511. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  63512. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63513. /** @hidden */
  63514. protected _applyStates(context: CanvasRenderingContext2D): void;
  63515. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63516. /** @hidden */
  63517. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63518. protected _evaluateClippingState(parentMeasure: Measure): void;
  63519. /** @hidden */ private _measure(): void;
  63520. /** @hidden */
  63521. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63522. /** @hidden */
  63523. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63524. /** @hidden */
  63525. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63526. /** @hidden */
  63527. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63528. private static _ClipMeasure;
  63529. private _tmpMeasureA;
  63530. private _clip;
  63531. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63532. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63533. /**
  63534. * Tests if a given coordinates belong to the current control
  63535. * @param x defines x coordinate to test
  63536. * @param y defines y coordinate to test
  63537. * @returns true if the coordinates are inside the control
  63538. */
  63539. contains(x: number, y: number): boolean;
  63540. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63541. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63542. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63543. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63544. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63545. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63546. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63547. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63548. private _prepareFont;
  63549. /** Releases associated resources */
  63550. dispose(): void;
  63551. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63552. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63553. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63554. private static _VERTICAL_ALIGNMENT_TOP;
  63555. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63556. private static _VERTICAL_ALIGNMENT_CENTER;
  63557. /** HORIZONTAL_ALIGNMENT_LEFT */
  63558. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63559. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63560. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63561. /** HORIZONTAL_ALIGNMENT_CENTER */
  63562. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63563. /** VERTICAL_ALIGNMENT_TOP */
  63564. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63565. /** VERTICAL_ALIGNMENT_BOTTOM */
  63566. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63567. /** VERTICAL_ALIGNMENT_CENTER */
  63568. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63569. private static _FontHeightSizes;
  63570. /** @hidden */ private static _GetFontOffset(font: string): {
  63571. ascent: number;
  63572. height: number;
  63573. descent: number;
  63574. };
  63575. /**
  63576. * Creates a stack panel that can be used to render headers
  63577. * @param control defines the control to associate with the header
  63578. * @param text defines the text of the header
  63579. * @param size defines the size of the header
  63580. * @param options defines options used to configure the header
  63581. * @returns a new StackPanel
  63582. * @ignore
  63583. * @hidden
  63584. */
  63585. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63586. isHorizontal: boolean;
  63587. controlFirst: boolean;
  63588. }) => any;
  63589. /** @hidden */
  63590. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63591. }
  63592. }
  63593. declare module BABYLON.GUI {
  63594. /**
  63595. * Root class for 2D containers
  63596. * @see http://doc.babylonjs.com/how_to/gui#containers
  63597. */
  63598. export class Container extends Control {
  63599. name?: string | undefined;
  63600. /** @hidden */
  63601. protected _children: Control[];
  63602. /** @hidden */
  63603. protected _measureForChildren: Measure;
  63604. /** @hidden */
  63605. protected _background: string;
  63606. /** @hidden */
  63607. protected _adaptWidthToChildren: boolean;
  63608. /** @hidden */
  63609. protected _adaptHeightToChildren: boolean;
  63610. /**
  63611. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63612. */
  63613. logLayoutCycleErrors: boolean;
  63614. /**
  63615. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63616. */
  63617. maxLayoutCycle: number;
  63618. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63619. adaptHeightToChildren: boolean;
  63620. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63621. adaptWidthToChildren: boolean;
  63622. /** Gets or sets background color */
  63623. background: string;
  63624. /** Gets the list of children */
  63625. readonly children: Control[];
  63626. /**
  63627. * Creates a new Container
  63628. * @param name defines the name of the container
  63629. */
  63630. constructor(name?: string | undefined);
  63631. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  63632. /**
  63633. * Gets a child using its name
  63634. * @param name defines the child name to look for
  63635. * @returns the child control if found
  63636. */
  63637. getChildByName(name: string): BABYLON.Nullable<Control>;
  63638. /**
  63639. * Gets a child using its type and its name
  63640. * @param name defines the child name to look for
  63641. * @param type defines the child type to look for
  63642. * @returns the child control if found
  63643. */
  63644. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63645. /**
  63646. * Search for a specific control in children
  63647. * @param control defines the control to look for
  63648. * @returns true if the control is in child list
  63649. */
  63650. containsControl(control: Control): boolean;
  63651. /**
  63652. * Adds a new control to the current container
  63653. * @param control defines the control to add
  63654. * @returns the current container
  63655. */
  63656. addControl(control: BABYLON.Nullable<Control>): Container;
  63657. /**
  63658. * Removes all controls from the current container
  63659. * @returns the current container
  63660. */
  63661. clearControls(): Container;
  63662. /**
  63663. * Removes a control from the current container
  63664. * @param control defines the control to remove
  63665. * @returns the current container
  63666. */
  63667. removeControl(control: Control): Container;
  63668. /** @hidden */ private _reOrderControl(control: Control): void;
  63669. /** @hidden */ private _offsetLeft(offset: number): void;
  63670. /** @hidden */ private _offsetTop(offset: number): void;
  63671. /** @hidden */ private _markAllAsDirty(): void;
  63672. /** @hidden */
  63673. protected _localDraw(context: CanvasRenderingContext2D): void;
  63674. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63675. /** @hidden */
  63676. protected _beforeLayout(): void;
  63677. /** @hidden */
  63678. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63679. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63680. protected _postMeasure(): void;
  63681. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63682. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63683. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63684. /** @hidden */
  63685. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63686. /** Releases associated resources */
  63687. dispose(): void;
  63688. }
  63689. }
  63690. declare module BABYLON.GUI {
  63691. /** Class used to create rectangle container */
  63692. export class Rectangle extends Container {
  63693. name?: string | undefined;
  63694. private _thickness;
  63695. private _cornerRadius;
  63696. /** Gets or sets border thickness */
  63697. thickness: number;
  63698. /** Gets or sets the corner radius angle */
  63699. cornerRadius: number;
  63700. /**
  63701. * Creates a new Rectangle
  63702. * @param name defines the control name
  63703. */
  63704. constructor(name?: string | undefined);
  63705. protected _getTypeName(): string;
  63706. protected _localDraw(context: CanvasRenderingContext2D): void;
  63707. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63708. private _drawRoundedRect;
  63709. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63710. }
  63711. }
  63712. declare module BABYLON.GUI {
  63713. /**
  63714. * Enum that determines the text-wrapping mode to use.
  63715. */
  63716. export enum TextWrapping {
  63717. /**
  63718. * Clip the text when it's larger than Control.width; this is the default mode.
  63719. */
  63720. Clip = 0,
  63721. /**
  63722. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63723. */
  63724. WordWrap = 1,
  63725. /**
  63726. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63727. */
  63728. Ellipsis = 2
  63729. }
  63730. /**
  63731. * Class used to create text block control
  63732. */
  63733. export class TextBlock extends Control {
  63734. /**
  63735. * Defines the name of the control
  63736. */
  63737. name?: string | undefined;
  63738. private _text;
  63739. private _textWrapping;
  63740. private _textHorizontalAlignment;
  63741. private _textVerticalAlignment;
  63742. private _lines;
  63743. private _resizeToFit;
  63744. private _lineSpacing;
  63745. private _outlineWidth;
  63746. private _outlineColor;
  63747. /**
  63748. * An event triggered after the text is changed
  63749. */
  63750. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63751. /**
  63752. * An event triggered after the text was broken up into lines
  63753. */
  63754. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63755. /**
  63756. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63757. */
  63758. readonly lines: any[];
  63759. /**
  63760. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63761. */
  63762. /**
  63763. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63764. */
  63765. resizeToFit: boolean;
  63766. /**
  63767. * Gets or sets a boolean indicating if text must be wrapped
  63768. */
  63769. /**
  63770. * Gets or sets a boolean indicating if text must be wrapped
  63771. */
  63772. textWrapping: TextWrapping | boolean;
  63773. /**
  63774. * Gets or sets text to display
  63775. */
  63776. /**
  63777. * Gets or sets text to display
  63778. */
  63779. text: string;
  63780. /**
  63781. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63782. */
  63783. /**
  63784. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63785. */
  63786. textHorizontalAlignment: number;
  63787. /**
  63788. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63789. */
  63790. /**
  63791. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63792. */
  63793. textVerticalAlignment: number;
  63794. /**
  63795. * Gets or sets line spacing value
  63796. */
  63797. /**
  63798. * Gets or sets line spacing value
  63799. */
  63800. lineSpacing: string | number;
  63801. /**
  63802. * Gets or sets outlineWidth of the text to display
  63803. */
  63804. /**
  63805. * Gets or sets outlineWidth of the text to display
  63806. */
  63807. outlineWidth: number;
  63808. /**
  63809. * Gets or sets outlineColor of the text to display
  63810. */
  63811. /**
  63812. * Gets or sets outlineColor of the text to display
  63813. */
  63814. outlineColor: string;
  63815. /**
  63816. * Creates a new TextBlock object
  63817. * @param name defines the name of the control
  63818. * @param text defines the text to display (emptry string by default)
  63819. */
  63820. constructor(
  63821. /**
  63822. * Defines the name of the control
  63823. */
  63824. name?: string | undefined, text?: string);
  63825. protected _getTypeName(): string;
  63826. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63827. private _drawText;
  63828. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63829. protected _applyStates(context: CanvasRenderingContext2D): void;
  63830. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63831. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63832. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63833. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63834. protected _renderLines(context: CanvasRenderingContext2D): void;
  63835. /**
  63836. * Given a width constraint applied on the text block, find the expected height
  63837. * @returns expected height
  63838. */
  63839. computeExpectedHeight(): number;
  63840. dispose(): void;
  63841. }
  63842. }
  63843. declare module BABYLON.GUI {
  63844. /**
  63845. * Class used to create 2D images
  63846. */
  63847. export class Image extends Control {
  63848. name?: string | undefined;
  63849. private static _WorkingCanvas;
  63850. private _domImage;
  63851. private _imageWidth;
  63852. private _imageHeight;
  63853. private _loaded;
  63854. private _stretch;
  63855. private _source;
  63856. private _autoScale;
  63857. private _sourceLeft;
  63858. private _sourceTop;
  63859. private _sourceWidth;
  63860. private _sourceHeight;
  63861. private _cellWidth;
  63862. private _cellHeight;
  63863. private _cellId;
  63864. private _populateNinePatchSlicesFromImage;
  63865. private _sliceLeft;
  63866. private _sliceRight;
  63867. private _sliceTop;
  63868. private _sliceBottom;
  63869. private _detectPointerOnOpaqueOnly;
  63870. /**
  63871. * BABYLON.Observable notified when the content is loaded
  63872. */
  63873. onImageLoadedObservable: BABYLON.Observable<Image>;
  63874. /**
  63875. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  63876. */
  63877. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  63878. /**
  63879. * Gets a boolean indicating that the content is loaded
  63880. */
  63881. readonly isLoaded: boolean;
  63882. /**
  63883. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63884. */
  63885. populateNinePatchSlicesFromImage: boolean;
  63886. /**
  63887. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63888. * Beware using this as this will comsume more memory as the image has to be stored twice
  63889. */
  63890. detectPointerOnOpaqueOnly: boolean;
  63891. /**
  63892. * Gets or sets the left value for slicing (9-patch)
  63893. */
  63894. sliceLeft: number;
  63895. /**
  63896. * Gets or sets the right value for slicing (9-patch)
  63897. */
  63898. sliceRight: number;
  63899. /**
  63900. * Gets or sets the top value for slicing (9-patch)
  63901. */
  63902. sliceTop: number;
  63903. /**
  63904. * Gets or sets the bottom value for slicing (9-patch)
  63905. */
  63906. sliceBottom: number;
  63907. /**
  63908. * Gets or sets the left coordinate in the source image
  63909. */
  63910. sourceLeft: number;
  63911. /**
  63912. * Gets or sets the top coordinate in the source image
  63913. */
  63914. sourceTop: number;
  63915. /**
  63916. * Gets or sets the width to capture in the source image
  63917. */
  63918. sourceWidth: number;
  63919. /**
  63920. * Gets or sets the height to capture in the source image
  63921. */
  63922. sourceHeight: number;
  63923. /**
  63924. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63925. * @see http://doc.babylonjs.com/how_to/gui#image
  63926. */
  63927. autoScale: boolean;
  63928. /** Gets or sets the streching mode used by the image */
  63929. stretch: number;
  63930. /**
  63931. * Gets or sets the internal DOM image used to render the control
  63932. */
  63933. domImage: HTMLImageElement;
  63934. private _onImageLoaded;
  63935. private _extractNinePatchSliceDataFromImage;
  63936. /**
  63937. * Gets or sets image source url
  63938. */
  63939. source: BABYLON.Nullable<string>;
  63940. /**
  63941. * Checks for svg document with icon id present
  63942. */
  63943. private _svgCheck;
  63944. /**
  63945. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  63946. * given external svg file and icon id
  63947. */
  63948. private _getSVGAttribs;
  63949. /**
  63950. * Gets or sets the cell width to use when animation sheet is enabled
  63951. * @see http://doc.babylonjs.com/how_to/gui#image
  63952. */
  63953. cellWidth: number;
  63954. /**
  63955. * Gets or sets the cell height to use when animation sheet is enabled
  63956. * @see http://doc.babylonjs.com/how_to/gui#image
  63957. */
  63958. cellHeight: number;
  63959. /**
  63960. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63961. * @see http://doc.babylonjs.com/how_to/gui#image
  63962. */
  63963. cellId: number;
  63964. /**
  63965. * Creates a new Image
  63966. * @param name defines the control name
  63967. * @param url defines the image url
  63968. */
  63969. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63970. /**
  63971. * Tests if a given coordinates belong to the current control
  63972. * @param x defines x coordinate to test
  63973. * @param y defines y coordinate to test
  63974. * @returns true if the coordinates are inside the control
  63975. */
  63976. contains(x: number, y: number): boolean;
  63977. protected _getTypeName(): string;
  63978. /** Force the control to synchronize with its content */
  63979. synchronizeSizeWithContent(): void;
  63980. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63981. private _prepareWorkingCanvasForOpaqueDetection;
  63982. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  63983. private _renderCornerPatch;
  63984. private _renderNinePatch;
  63985. dispose(): void;
  63986. /** STRETCH_NONE */
  63987. static readonly STRETCH_NONE: number;
  63988. /** STRETCH_FILL */
  63989. static readonly STRETCH_FILL: number;
  63990. /** STRETCH_UNIFORM */
  63991. static readonly STRETCH_UNIFORM: number;
  63992. /** STRETCH_EXTEND */
  63993. static readonly STRETCH_EXTEND: number;
  63994. /** NINE_PATCH */
  63995. static readonly STRETCH_NINE_PATCH: number;
  63996. }
  63997. }
  63998. declare module BABYLON.GUI {
  63999. /**
  64000. * Class used to create 2D buttons
  64001. */
  64002. export class Button extends Rectangle {
  64003. name?: string | undefined;
  64004. /**
  64005. * Function called to generate a pointer enter animation
  64006. */
  64007. pointerEnterAnimation: () => void;
  64008. /**
  64009. * Function called to generate a pointer out animation
  64010. */
  64011. pointerOutAnimation: () => void;
  64012. /**
  64013. * Function called to generate a pointer down animation
  64014. */
  64015. pointerDownAnimation: () => void;
  64016. /**
  64017. * Function called to generate a pointer up animation
  64018. */
  64019. pointerUpAnimation: () => void;
  64020. /**
  64021. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64022. */
  64023. delegatePickingToChildren: boolean;
  64024. private _image;
  64025. /**
  64026. * Returns the image part of the button (if any)
  64027. */
  64028. readonly image: BABYLON.Nullable<Image>;
  64029. private _textBlock;
  64030. /**
  64031. * Returns the image part of the button (if any)
  64032. */
  64033. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64034. /**
  64035. * Creates a new Button
  64036. * @param name defines the name of the button
  64037. */
  64038. constructor(name?: string | undefined);
  64039. protected _getTypeName(): string;
  64040. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64041. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64042. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64043. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64044. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64045. /**
  64046. * Creates a new button made with an image and a text
  64047. * @param name defines the name of the button
  64048. * @param text defines the text of the button
  64049. * @param imageUrl defines the url of the image
  64050. * @returns a new Button
  64051. */
  64052. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64053. /**
  64054. * Creates a new button made with an image
  64055. * @param name defines the name of the button
  64056. * @param imageUrl defines the url of the image
  64057. * @returns a new Button
  64058. */
  64059. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64060. /**
  64061. * Creates a new button made with a text
  64062. * @param name defines the name of the button
  64063. * @param text defines the text of the button
  64064. * @returns a new Button
  64065. */
  64066. static CreateSimpleButton(name: string, text: string): Button;
  64067. /**
  64068. * Creates a new button made with an image and a centered text
  64069. * @param name defines the name of the button
  64070. * @param text defines the text of the button
  64071. * @param imageUrl defines the url of the image
  64072. * @returns a new Button
  64073. */
  64074. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64075. }
  64076. }
  64077. declare module BABYLON.GUI {
  64078. /**
  64079. * Class used to create a 2D stack panel container
  64080. */
  64081. export class StackPanel extends Container {
  64082. name?: string | undefined;
  64083. private _isVertical;
  64084. private _manualWidth;
  64085. private _manualHeight;
  64086. private _doNotTrackManualChanges;
  64087. /**
  64088. * Gets or sets a boolean indicating that layou warnings should be ignored
  64089. */
  64090. ignoreLayoutWarnings: boolean;
  64091. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64092. isVertical: boolean;
  64093. /**
  64094. * Gets or sets panel width.
  64095. * This value should not be set when in horizontal mode as it will be computed automatically
  64096. */
  64097. width: string | number;
  64098. /**
  64099. * Gets or sets panel height.
  64100. * This value should not be set when in vertical mode as it will be computed automatically
  64101. */
  64102. height: string | number;
  64103. /**
  64104. * Creates a new StackPanel
  64105. * @param name defines control name
  64106. */
  64107. constructor(name?: string | undefined);
  64108. protected _getTypeName(): string;
  64109. /** @hidden */
  64110. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64111. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64112. protected _postMeasure(): void;
  64113. }
  64114. }
  64115. declare module BABYLON.GUI {
  64116. /**
  64117. * Class used to represent a 2D checkbox
  64118. */
  64119. export class Checkbox extends Control {
  64120. name?: string | undefined;
  64121. private _isChecked;
  64122. private _background;
  64123. private _checkSizeRatio;
  64124. private _thickness;
  64125. /** Gets or sets border thickness */
  64126. thickness: number;
  64127. /**
  64128. * BABYLON.Observable raised when isChecked property changes
  64129. */
  64130. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64131. /** Gets or sets a value indicating the ratio between overall size and check size */
  64132. checkSizeRatio: number;
  64133. /** Gets or sets background color */
  64134. background: string;
  64135. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64136. isChecked: boolean;
  64137. /**
  64138. * Creates a new CheckBox
  64139. * @param name defines the control name
  64140. */
  64141. constructor(name?: string | undefined);
  64142. protected _getTypeName(): string;
  64143. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64144. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64145. /**
  64146. * Utility function to easily create a checkbox with a header
  64147. * @param title defines the label to use for the header
  64148. * @param onValueChanged defines the callback to call when value changes
  64149. * @returns a StackPanel containing the checkbox and a textBlock
  64150. */
  64151. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64152. }
  64153. }
  64154. declare module BABYLON.GUI {
  64155. /**
  64156. * Class used to store key control properties
  64157. */
  64158. export class KeyPropertySet {
  64159. /** Width */
  64160. width?: string;
  64161. /** Height */
  64162. height?: string;
  64163. /** Left padding */
  64164. paddingLeft?: string;
  64165. /** Right padding */
  64166. paddingRight?: string;
  64167. /** Top padding */
  64168. paddingTop?: string;
  64169. /** Bottom padding */
  64170. paddingBottom?: string;
  64171. /** Foreground color */
  64172. color?: string;
  64173. /** Background color */
  64174. background?: string;
  64175. }
  64176. /**
  64177. * Class used to create virtual keyboard
  64178. */
  64179. export class VirtualKeyboard extends StackPanel {
  64180. /** BABYLON.Observable raised when a key is pressed */
  64181. onKeyPressObservable: BABYLON.Observable<string>;
  64182. /** Gets or sets default key button width */
  64183. defaultButtonWidth: string;
  64184. /** Gets or sets default key button height */
  64185. defaultButtonHeight: string;
  64186. /** Gets or sets default key button left padding */
  64187. defaultButtonPaddingLeft: string;
  64188. /** Gets or sets default key button right padding */
  64189. defaultButtonPaddingRight: string;
  64190. /** Gets or sets default key button top padding */
  64191. defaultButtonPaddingTop: string;
  64192. /** Gets or sets default key button bottom padding */
  64193. defaultButtonPaddingBottom: string;
  64194. /** Gets or sets default key button foreground color */
  64195. defaultButtonColor: string;
  64196. /** Gets or sets default key button background color */
  64197. defaultButtonBackground: string;
  64198. /** Gets or sets shift button foreground color */
  64199. shiftButtonColor: string;
  64200. /** Gets or sets shift button thickness*/
  64201. selectedShiftThickness: number;
  64202. /** Gets shift key state */
  64203. shiftState: number;
  64204. protected _getTypeName(): string;
  64205. private _createKey;
  64206. /**
  64207. * Adds a new row of keys
  64208. * @param keys defines the list of keys to add
  64209. * @param propertySets defines the associated property sets
  64210. */
  64211. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64212. /**
  64213. * Set the shift key to a specific state
  64214. * @param shiftState defines the new shift state
  64215. */
  64216. applyShiftState(shiftState: number): void;
  64217. private _currentlyConnectedInputText;
  64218. private _connectedInputTexts;
  64219. private _onKeyPressObserver;
  64220. /** Gets the input text control currently attached to the keyboard */
  64221. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64222. /**
  64223. * Connects the keyboard with an input text control
  64224. *
  64225. * @param input defines the target control
  64226. */
  64227. connect(input: InputText): void;
  64228. /**
  64229. * Disconnects the keyboard from connected InputText controls
  64230. *
  64231. * @param input optionally defines a target control, otherwise all are disconnected
  64232. */
  64233. disconnect(input?: InputText): void;
  64234. private _removeConnectedInputObservables;
  64235. /**
  64236. * Release all resources
  64237. */
  64238. dispose(): void;
  64239. /**
  64240. * Creates a new keyboard using a default layout
  64241. *
  64242. * @param name defines control name
  64243. * @returns a new VirtualKeyboard
  64244. */
  64245. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64246. }
  64247. }
  64248. declare module BABYLON.GUI {
  64249. /**
  64250. * Class used to create input text control
  64251. */
  64252. export class InputText extends Control implements IFocusableControl {
  64253. name?: string | undefined;
  64254. private _text;
  64255. private _placeholderText;
  64256. private _background;
  64257. private _focusedBackground;
  64258. private _focusedColor;
  64259. private _placeholderColor;
  64260. private _thickness;
  64261. private _margin;
  64262. private _autoStretchWidth;
  64263. private _maxWidth;
  64264. private _isFocused;
  64265. private _blinkTimeout;
  64266. private _blinkIsEven;
  64267. private _cursorOffset;
  64268. private _scrollLeft;
  64269. private _textWidth;
  64270. private _clickedCoordinate;
  64271. private _deadKey;
  64272. private _addKey;
  64273. private _currentKey;
  64274. private _isTextHighlightOn;
  64275. private _textHighlightColor;
  64276. private _highligherOpacity;
  64277. private _highlightedText;
  64278. private _startHighlightIndex;
  64279. private _endHighlightIndex;
  64280. private _cursorIndex;
  64281. private _onFocusSelectAll;
  64282. private _isPointerDown;
  64283. private _onClipboardObserver;
  64284. private _onPointerDblTapObserver;
  64285. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64286. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64287. promptMessage: string;
  64288. /** Force disable prompt on mobile device */
  64289. disableMobilePrompt: boolean;
  64290. /** BABYLON.Observable raised when the text changes */
  64291. onTextChangedObservable: BABYLON.Observable<InputText>;
  64292. /** BABYLON.Observable raised just before an entered character is to be added */
  64293. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64294. /** BABYLON.Observable raised when the control gets the focus */
  64295. onFocusObservable: BABYLON.Observable<InputText>;
  64296. /** BABYLON.Observable raised when the control loses the focus */
  64297. onBlurObservable: BABYLON.Observable<InputText>;
  64298. /**Observable raised when the text is highlighted */
  64299. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64300. /**Observable raised when copy event is triggered */
  64301. onTextCopyObservable: BABYLON.Observable<InputText>;
  64302. /** BABYLON.Observable raised when cut event is triggered */
  64303. onTextCutObservable: BABYLON.Observable<InputText>;
  64304. /** BABYLON.Observable raised when paste event is triggered */
  64305. onTextPasteObservable: BABYLON.Observable<InputText>;
  64306. /** BABYLON.Observable raised when a key event was processed */
  64307. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64308. /** Gets or sets the maximum width allowed by the control */
  64309. maxWidth: string | number;
  64310. /** Gets the maximum width allowed by the control in pixels */
  64311. readonly maxWidthInPixels: number;
  64312. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64313. highligherOpacity: number;
  64314. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64315. onFocusSelectAll: boolean;
  64316. /** Gets or sets the text hightlight color */
  64317. textHighlightColor: string;
  64318. /** Gets or sets control margin */
  64319. margin: string;
  64320. /** Gets control margin in pixels */
  64321. readonly marginInPixels: number;
  64322. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64323. autoStretchWidth: boolean;
  64324. /** Gets or sets border thickness */
  64325. thickness: number;
  64326. /** Gets or sets the background color when focused */
  64327. focusedBackground: string;
  64328. /** Gets or sets the background color when focused */
  64329. focusedColor: string;
  64330. /** Gets or sets the background color */
  64331. background: string;
  64332. /** Gets or sets the placeholder color */
  64333. placeholderColor: string;
  64334. /** Gets or sets the text displayed when the control is empty */
  64335. placeholderText: string;
  64336. /** Gets or sets the dead key flag */
  64337. deadKey: boolean;
  64338. /** Gets or sets the highlight text */
  64339. highlightedText: string;
  64340. /** Gets or sets if the current key should be added */
  64341. addKey: boolean;
  64342. /** Gets or sets the value of the current key being entered */
  64343. currentKey: string;
  64344. /** Gets or sets the text displayed in the control */
  64345. text: string;
  64346. /** Gets or sets control width */
  64347. width: string | number;
  64348. /**
  64349. * Creates a new InputText
  64350. * @param name defines the control name
  64351. * @param text defines the text of the control
  64352. */
  64353. constructor(name?: string | undefined, text?: string);
  64354. /** @hidden */
  64355. onBlur(): void;
  64356. /** @hidden */
  64357. onFocus(): void;
  64358. protected _getTypeName(): string;
  64359. /**
  64360. * Function called to get the list of controls that should not steal the focus from this control
  64361. * @returns an array of controls
  64362. */
  64363. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64364. /** @hidden */
  64365. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64366. /** @hidden */
  64367. private _updateValueFromCursorIndex;
  64368. /** @hidden */
  64369. private _processDblClick;
  64370. /** @hidden */
  64371. private _selectAllText;
  64372. /**
  64373. * Handles the keyboard event
  64374. * @param evt Defines the KeyboardEvent
  64375. */
  64376. processKeyboard(evt: KeyboardEvent): void;
  64377. /** @hidden */
  64378. private _onCopyText;
  64379. /** @hidden */
  64380. private _onCutText;
  64381. /** @hidden */
  64382. 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;
  64383. protected _beforeRenderText(text: string): string;
  64384. dispose(): void;
  64385. }
  64386. }
  64387. declare module BABYLON.GUI {
  64388. /**
  64389. * Class used to create a 2D grid container
  64390. */
  64391. export class Grid extends Container {
  64392. name?: string | undefined;
  64393. private _rowDefinitions;
  64394. private _columnDefinitions;
  64395. private _cells;
  64396. private _childControls;
  64397. /**
  64398. * Gets the number of columns
  64399. */
  64400. readonly columnCount: number;
  64401. /**
  64402. * Gets the number of rows
  64403. */
  64404. readonly rowCount: number;
  64405. /** Gets the list of children */
  64406. readonly children: Control[];
  64407. /** Gets the list of cells (e.g. the containers) */
  64408. readonly cells: {
  64409. [key: string]: Container;
  64410. };
  64411. /**
  64412. * Gets the definition of a specific row
  64413. * @param index defines the index of the row
  64414. * @returns the row definition
  64415. */
  64416. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64417. /**
  64418. * Gets the definition of a specific column
  64419. * @param index defines the index of the column
  64420. * @returns the column definition
  64421. */
  64422. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64423. /**
  64424. * Adds a new row to the grid
  64425. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64426. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64427. * @returns the current grid
  64428. */
  64429. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64430. /**
  64431. * Adds a new column to the grid
  64432. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64433. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64434. * @returns the current grid
  64435. */
  64436. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64437. /**
  64438. * Update a row definition
  64439. * @param index defines the index of the row to update
  64440. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64441. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64442. * @returns the current grid
  64443. */
  64444. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64445. /**
  64446. * Update a column definition
  64447. * @param index defines the index of the column to update
  64448. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64449. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64450. * @returns the current grid
  64451. */
  64452. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64453. /**
  64454. * Gets the list of children stored in a specific cell
  64455. * @param row defines the row to check
  64456. * @param column defines the column to check
  64457. * @returns the list of controls
  64458. */
  64459. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64460. /**
  64461. * Gets a string representing the child cell info (row x column)
  64462. * @param child defines the control to get info from
  64463. * @returns a string containing the child cell info (row x column)
  64464. */
  64465. getChildCellInfo(child: Control): string;
  64466. private _removeCell;
  64467. private _offsetCell;
  64468. /**
  64469. * Remove a column definition at specified index
  64470. * @param index defines the index of the column to remove
  64471. * @returns the current grid
  64472. */
  64473. removeColumnDefinition(index: number): Grid;
  64474. /**
  64475. * Remove a row definition at specified index
  64476. * @param index defines the index of the row to remove
  64477. * @returns the current grid
  64478. */
  64479. removeRowDefinition(index: number): Grid;
  64480. /**
  64481. * Adds a new control to the current grid
  64482. * @param control defines the control to add
  64483. * @param row defines the row where to add the control (0 by default)
  64484. * @param column defines the column where to add the control (0 by default)
  64485. * @returns the current grid
  64486. */
  64487. addControl(control: Control, row?: number, column?: number): Grid;
  64488. /**
  64489. * Removes a control from the current container
  64490. * @param control defines the control to remove
  64491. * @returns the current container
  64492. */
  64493. removeControl(control: Control): Container;
  64494. /**
  64495. * Creates a new Grid
  64496. * @param name defines control name
  64497. */
  64498. constructor(name?: string | undefined);
  64499. protected _getTypeName(): string;
  64500. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64501. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64502. /** Releases associated resources */
  64503. dispose(): void;
  64504. }
  64505. }
  64506. declare module BABYLON.GUI {
  64507. /** Class used to create color pickers */
  64508. export class ColorPicker extends Control {
  64509. name?: string | undefined;
  64510. private static _Epsilon;
  64511. private _colorWheelCanvas;
  64512. private _value;
  64513. private _tmpColor;
  64514. private _pointerStartedOnSquare;
  64515. private _pointerStartedOnWheel;
  64516. private _squareLeft;
  64517. private _squareTop;
  64518. private _squareSize;
  64519. private _h;
  64520. private _s;
  64521. private _v;
  64522. private _lastPointerDownID;
  64523. /**
  64524. * BABYLON.Observable raised when the value changes
  64525. */
  64526. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64527. /** Gets or sets the color of the color picker */
  64528. value: BABYLON.Color3;
  64529. /**
  64530. * Gets or sets control width
  64531. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64532. */
  64533. width: string | number;
  64534. /**
  64535. * Gets or sets control height
  64536. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64537. */
  64538. /** Gets or sets control height */
  64539. height: string | number;
  64540. /** Gets or sets control size */
  64541. size: string | number;
  64542. /**
  64543. * Creates a new ColorPicker
  64544. * @param name defines the control name
  64545. */
  64546. constructor(name?: string | undefined);
  64547. protected _getTypeName(): string;
  64548. /** @hidden */
  64549. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64550. private _updateSquareProps;
  64551. private _drawGradientSquare;
  64552. private _drawCircle;
  64553. private _createColorWheelCanvas;
  64554. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64555. private _pointerIsDown;
  64556. private _updateValueFromPointer;
  64557. private _isPointOnSquare;
  64558. 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;
  64559. /**
  64560. * This function expands the color picker by creating a color picker dialog with manual
  64561. * color value input and the ability to save colors into an array to be used later in
  64562. * subsequent launches of the dialogue.
  64563. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64564. * @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.
  64565. * @returns picked color as a hex string and the saved colors array as hex strings.
  64566. */
  64567. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64568. pickerWidth?: string;
  64569. pickerHeight?: string;
  64570. headerHeight?: string;
  64571. lastColor?: string;
  64572. swatchLimit?: number;
  64573. numSwatchesPerLine?: number;
  64574. savedColors?: Array<string>;
  64575. }): Promise<{
  64576. savedColors?: string[];
  64577. pickedColor: string;
  64578. }>;
  64579. }
  64580. }
  64581. declare module BABYLON.GUI {
  64582. /** Class used to create 2D ellipse containers */
  64583. export class Ellipse extends Container {
  64584. name?: string | undefined;
  64585. private _thickness;
  64586. /** Gets or sets border thickness */
  64587. thickness: number;
  64588. /**
  64589. * Creates a new Ellipse
  64590. * @param name defines the control name
  64591. */
  64592. constructor(name?: string | undefined);
  64593. protected _getTypeName(): string;
  64594. protected _localDraw(context: CanvasRenderingContext2D): void;
  64595. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64596. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64597. }
  64598. }
  64599. declare module BABYLON.GUI {
  64600. /**
  64601. * Class used to create a password control
  64602. */
  64603. export class InputPassword extends InputText {
  64604. protected _beforeRenderText(text: string): string;
  64605. }
  64606. }
  64607. declare module BABYLON.GUI {
  64608. /** Class used to render 2D lines */
  64609. export class Line extends Control {
  64610. name?: string | undefined;
  64611. private _lineWidth;
  64612. private _x1;
  64613. private _y1;
  64614. private _x2;
  64615. private _y2;
  64616. private _dash;
  64617. private _connectedControl;
  64618. private _connectedControlDirtyObserver;
  64619. /** Gets or sets the dash pattern */
  64620. dash: Array<number>;
  64621. /** Gets or sets the control connected with the line end */
  64622. connectedControl: Control;
  64623. /** Gets or sets start coordinates on X axis */
  64624. x1: string | number;
  64625. /** Gets or sets start coordinates on Y axis */
  64626. y1: string | number;
  64627. /** Gets or sets end coordinates on X axis */
  64628. x2: string | number;
  64629. /** Gets or sets end coordinates on Y axis */
  64630. y2: string | number;
  64631. /** Gets or sets line width */
  64632. lineWidth: number;
  64633. /** Gets or sets horizontal alignment */
  64634. horizontalAlignment: number;
  64635. /** Gets or sets vertical alignment */
  64636. verticalAlignment: number;
  64637. private readonly _effectiveX2;
  64638. private readonly _effectiveY2;
  64639. /**
  64640. * Creates a new Line
  64641. * @param name defines the control name
  64642. */
  64643. constructor(name?: string | undefined);
  64644. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  64645. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64646. /**
  64647. * Move one end of the line given 3D cartesian coordinates.
  64648. * @param position Targeted world position
  64649. * @param scene BABYLON.Scene
  64650. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64651. */
  64652. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64653. /**
  64654. * Move one end of the line to a position in screen absolute space.
  64655. * @param projectedPosition Position in screen absolute space (X, Y)
  64656. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64657. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64658. }
  64659. }
  64660. declare module BABYLON.GUI {
  64661. /**
  64662. * Class used to store a point for a MultiLine object.
  64663. * The point can be pure 2D coordinates, a mesh or a control
  64664. */
  64665. export class MultiLinePoint {
  64666. private _multiLine;
  64667. private _x;
  64668. private _y;
  64669. private _control;
  64670. private _mesh;
  64671. private _controlObserver;
  64672. private _meshObserver;
  64673. /** @hidden */ private _point: BABYLON.Vector2;
  64674. /**
  64675. * Creates a new MultiLinePoint
  64676. * @param multiLine defines the source MultiLine object
  64677. */
  64678. constructor(multiLine: MultiLine);
  64679. /** Gets or sets x coordinate */
  64680. x: string | number;
  64681. /** Gets or sets y coordinate */
  64682. y: string | number;
  64683. /** Gets or sets the control associated with this point */
  64684. control: BABYLON.Nullable<Control>;
  64685. /** Gets or sets the mesh associated with this point */
  64686. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64687. /** Resets links */
  64688. resetLinks(): void;
  64689. /**
  64690. * Gets a translation vector
  64691. * @returns the translation vector
  64692. */
  64693. translate(): BABYLON.Vector2;
  64694. private _translatePoint;
  64695. /** Release associated resources */
  64696. dispose(): void;
  64697. }
  64698. }
  64699. declare module BABYLON.GUI {
  64700. /**
  64701. * Class used to create multi line control
  64702. */
  64703. export class MultiLine extends Control {
  64704. name?: string | undefined;
  64705. private _lineWidth;
  64706. private _dash;
  64707. private _points;
  64708. private _minX;
  64709. private _minY;
  64710. private _maxX;
  64711. private _maxY;
  64712. /**
  64713. * Creates a new MultiLine
  64714. * @param name defines the control name
  64715. */
  64716. constructor(name?: string | undefined);
  64717. /** Gets or sets dash pattern */
  64718. dash: Array<number>;
  64719. /**
  64720. * Gets point stored at specified index
  64721. * @param index defines the index to look for
  64722. * @returns the requested point if found
  64723. */
  64724. getAt(index: number): MultiLinePoint;
  64725. /** Function called when a point is updated */
  64726. onPointUpdate: () => void;
  64727. /**
  64728. * Adds new points to the point collection
  64729. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64730. * @returns the list of created MultiLinePoint
  64731. */
  64732. add(...items: (AbstractMesh | Control | {
  64733. x: string | number;
  64734. y: string | number;
  64735. })[]): MultiLinePoint[];
  64736. /**
  64737. * Adds a new point to the point collection
  64738. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64739. * @returns the created MultiLinePoint
  64740. */
  64741. push(item?: (AbstractMesh | Control | {
  64742. x: string | number;
  64743. y: string | number;
  64744. })): MultiLinePoint;
  64745. /**
  64746. * Remove a specific value or point from the active point collection
  64747. * @param value defines the value or point to remove
  64748. */
  64749. remove(value: number | MultiLinePoint): void;
  64750. /**
  64751. * Resets this object to initial state (no point)
  64752. */
  64753. reset(): void;
  64754. /**
  64755. * Resets all links
  64756. */
  64757. resetLinks(): void;
  64758. /** Gets or sets line width */
  64759. lineWidth: number;
  64760. horizontalAlignment: number;
  64761. verticalAlignment: number;
  64762. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64763. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  64764. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64765. dispose(): void;
  64766. }
  64767. }
  64768. declare module BABYLON.GUI {
  64769. /**
  64770. * Class used to create radio button controls
  64771. */
  64772. export class RadioButton extends Control {
  64773. name?: string | undefined;
  64774. private _isChecked;
  64775. private _background;
  64776. private _checkSizeRatio;
  64777. private _thickness;
  64778. /** Gets or sets border thickness */
  64779. thickness: number;
  64780. /** Gets or sets group name */
  64781. group: string;
  64782. /** BABYLON.Observable raised when isChecked is changed */
  64783. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64784. /** Gets or sets a value indicating the ratio between overall size and check size */
  64785. checkSizeRatio: number;
  64786. /** Gets or sets background color */
  64787. background: string;
  64788. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64789. isChecked: boolean;
  64790. /**
  64791. * Creates a new RadioButton
  64792. * @param name defines the control name
  64793. */
  64794. constructor(name?: string | undefined);
  64795. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64796. /**
  64797. * Utility function to easily create a radio button with a header
  64798. * @param title defines the label to use for the header
  64799. * @param group defines the group to use for the radio button
  64800. * @param isChecked defines the initial state of the radio button
  64801. * @param onValueChanged defines the callback to call when value changes
  64802. * @returns a StackPanel containing the radio button and a textBlock
  64803. */
  64804. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64805. }
  64806. }
  64807. declare module BABYLON.GUI {
  64808. /**
  64809. * Class used to create slider controls
  64810. */
  64811. export class BaseSlider extends Control {
  64812. name?: string | undefined;
  64813. protected _thumbWidth: ValueAndUnit;
  64814. private _minimum;
  64815. private _maximum;
  64816. private _value;
  64817. private _isVertical;
  64818. protected _barOffset: ValueAndUnit;
  64819. private _isThumbClamped;
  64820. protected _displayThumb: boolean;
  64821. private _step;
  64822. private _lastPointerDownID;
  64823. protected _effectiveBarOffset: number;
  64824. protected _renderLeft: number;
  64825. protected _renderTop: number;
  64826. protected _renderWidth: number;
  64827. protected _renderHeight: number;
  64828. protected _backgroundBoxLength: number;
  64829. protected _backgroundBoxThickness: number;
  64830. protected _effectiveThumbThickness: number;
  64831. /** BABYLON.Observable raised when the sldier value changes */
  64832. onValueChangedObservable: BABYLON.Observable<number>;
  64833. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64834. displayThumb: boolean;
  64835. /** Gets or sets a step to apply to values (0 by default) */
  64836. step: number;
  64837. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64838. barOffset: string | number;
  64839. /** Gets main bar offset in pixels*/
  64840. readonly barOffsetInPixels: number;
  64841. /** Gets or sets thumb width */
  64842. thumbWidth: string | number;
  64843. /** Gets thumb width in pixels */
  64844. readonly thumbWidthInPixels: number;
  64845. /** Gets or sets minimum value */
  64846. minimum: number;
  64847. /** Gets or sets maximum value */
  64848. maximum: number;
  64849. /** Gets or sets current value */
  64850. value: number;
  64851. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64852. isVertical: boolean;
  64853. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64854. isThumbClamped: boolean;
  64855. /**
  64856. * Creates a new BaseSlider
  64857. * @param name defines the control name
  64858. */
  64859. constructor(name?: string | undefined);
  64860. protected _getTypeName(): string;
  64861. protected _getThumbPosition(): number;
  64862. protected _getThumbThickness(type: string): number;
  64863. protected _prepareRenderingData(type: string): void;
  64864. private _pointerIsDown;
  64865. /** @hidden */
  64866. 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;
  64867. }
  64868. }
  64869. declare module BABYLON.GUI {
  64870. /**
  64871. * Class used to create slider controls
  64872. */
  64873. export class Slider extends BaseSlider {
  64874. name?: string | undefined;
  64875. private _background;
  64876. private _borderColor;
  64877. private _isThumbCircle;
  64878. protected _displayValueBar: boolean;
  64879. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64880. displayValueBar: boolean;
  64881. /** Gets or sets border color */
  64882. borderColor: string;
  64883. /** Gets or sets background color */
  64884. background: string;
  64885. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64886. isThumbCircle: boolean;
  64887. /**
  64888. * Creates a new Slider
  64889. * @param name defines the control name
  64890. */
  64891. constructor(name?: string | undefined);
  64892. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64893. }
  64894. }
  64895. declare module BABYLON.GUI {
  64896. /** Class used to create a RadioGroup
  64897. * which contains groups of radio buttons
  64898. */
  64899. export class SelectorGroup {
  64900. /** name of SelectorGroup */
  64901. name: string;
  64902. private _groupPanel;
  64903. private _selectors;
  64904. private _groupHeader;
  64905. /**
  64906. * Creates a new SelectorGroup
  64907. * @param name of group, used as a group heading
  64908. */
  64909. constructor(
  64910. /** name of SelectorGroup */
  64911. name: string);
  64912. /** Gets the groupPanel of the SelectorGroup */
  64913. readonly groupPanel: StackPanel;
  64914. /** Gets the selectors array */
  64915. readonly selectors: StackPanel[];
  64916. /** Gets and sets the group header */
  64917. header: string;
  64918. /** @hidden */
  64919. private _addGroupHeader;
  64920. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  64921. /** Removes the selector at the given position
  64922. * @param selectorNb the position of the selector within the group
  64923. */
  64924. removeSelector(selectorNb: number): void;
  64925. }
  64926. /** Class used to create a CheckboxGroup
  64927. * which contains groups of checkbox buttons
  64928. */
  64929. export class CheckboxGroup extends SelectorGroup {
  64930. /** Adds a checkbox as a control
  64931. * @param text is the label for the selector
  64932. * @param func is the function called when the Selector is checked
  64933. * @param checked is true when Selector is checked
  64934. */
  64935. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64936. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64937. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64938. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64939. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64940. }
  64941. /** Class used to create a RadioGroup
  64942. * which contains groups of radio buttons
  64943. */
  64944. export class RadioGroup extends SelectorGroup {
  64945. private _selectNb;
  64946. /** Adds a radio button as a control
  64947. * @param label is the label for the selector
  64948. * @param func is the function called when the Selector is checked
  64949. * @param checked is true when Selector is checked
  64950. */
  64951. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64952. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64953. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64954. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64955. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64956. }
  64957. /** Class used to create a SliderGroup
  64958. * which contains groups of slider buttons
  64959. */
  64960. export class SliderGroup extends SelectorGroup {
  64961. /**
  64962. * Adds a slider to the SelectorGroup
  64963. * @param label is the label for the SliderBar
  64964. * @param func is the function called when the Slider moves
  64965. * @param unit is a string describing the units used, eg degrees or metres
  64966. * @param min is the minimum value for the Slider
  64967. * @param max is the maximum value for the Slider
  64968. * @param value is the start value for the Slider between min and max
  64969. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64970. */
  64971. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64972. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64973. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64974. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64975. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64976. }
  64977. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64978. * @see http://doc.babylonjs.com/how_to/selector
  64979. */
  64980. export class SelectionPanel extends Rectangle {
  64981. /** name of SelectionPanel */
  64982. name: string;
  64983. /** an array of SelectionGroups */
  64984. groups: SelectorGroup[];
  64985. private _panel;
  64986. private _buttonColor;
  64987. private _buttonBackground;
  64988. private _headerColor;
  64989. private _barColor;
  64990. private _barHeight;
  64991. private _spacerHeight;
  64992. private _labelColor;
  64993. private _groups;
  64994. private _bars;
  64995. /**
  64996. * Creates a new SelectionPanel
  64997. * @param name of SelectionPanel
  64998. * @param groups is an array of SelectionGroups
  64999. */
  65000. constructor(
  65001. /** name of SelectionPanel */
  65002. name: string,
  65003. /** an array of SelectionGroups */
  65004. groups?: SelectorGroup[]);
  65005. protected _getTypeName(): string;
  65006. /** Gets or sets the headerColor */
  65007. headerColor: string;
  65008. private _setHeaderColor;
  65009. /** Gets or sets the button color */
  65010. buttonColor: string;
  65011. private _setbuttonColor;
  65012. /** Gets or sets the label color */
  65013. labelColor: string;
  65014. private _setLabelColor;
  65015. /** Gets or sets the button background */
  65016. buttonBackground: string;
  65017. private _setButtonBackground;
  65018. /** Gets or sets the color of separator bar */
  65019. barColor: string;
  65020. private _setBarColor;
  65021. /** Gets or sets the height of separator bar */
  65022. barHeight: string;
  65023. private _setBarHeight;
  65024. /** Gets or sets the height of spacers*/
  65025. spacerHeight: string;
  65026. private _setSpacerHeight;
  65027. /** Adds a bar between groups */
  65028. private _addSpacer;
  65029. /** Add a group to the selection panel
  65030. * @param group is the selector group to add
  65031. */
  65032. addGroup(group: SelectorGroup): void;
  65033. /** Remove the group from the given position
  65034. * @param groupNb is the position of the group in the list
  65035. */
  65036. removeGroup(groupNb: number): void;
  65037. /** Change a group header label
  65038. * @param label is the new group header label
  65039. * @param groupNb is the number of the group to relabel
  65040. * */
  65041. setHeaderName(label: string, groupNb: number): void;
  65042. /** Change selector label to the one given
  65043. * @param label is the new selector label
  65044. * @param groupNb is the number of the groupcontaining the selector
  65045. * @param selectorNb is the number of the selector within a group to relabel
  65046. * */
  65047. relabel(label: string, groupNb: number, selectorNb: number): void;
  65048. /** For a given group position remove the selector at the given position
  65049. * @param groupNb is the number of the group to remove the selector from
  65050. * @param selectorNb is the number of the selector within the group
  65051. */
  65052. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65053. /** For a given group position of correct type add a checkbox button
  65054. * @param groupNb is the number of the group to remove the selector from
  65055. * @param label is the label for the selector
  65056. * @param func is the function called when the Selector is checked
  65057. * @param checked is true when Selector is checked
  65058. */
  65059. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65060. /** For a given group position of correct type add a radio button
  65061. * @param groupNb is the number of the group to remove the selector from
  65062. * @param label is the label for the selector
  65063. * @param func is the function called when the Selector is checked
  65064. * @param checked is true when Selector is checked
  65065. */
  65066. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65067. /**
  65068. * For a given slider group add a slider
  65069. * @param groupNb is the number of the group to add the slider to
  65070. * @param label is the label for the Slider
  65071. * @param func is the function called when the Slider moves
  65072. * @param unit is a string describing the units used, eg degrees or metres
  65073. * @param min is the minimum value for the Slider
  65074. * @param max is the maximum value for the Slider
  65075. * @param value is the start value for the Slider between min and max
  65076. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65077. */
  65078. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65079. }
  65080. }
  65081. declare module BABYLON.GUI {
  65082. /**
  65083. * Class used to hold a the container for ScrollViewer
  65084. * @hidden
  65085. */
  65086. export class _ScrollViewerWindow extends Container {
  65087. parentClientWidth: number;
  65088. parentClientHeight: number;
  65089. /**
  65090. * Creates a new ScrollViewerWindow
  65091. * @param name of ScrollViewerWindow
  65092. */
  65093. constructor(name?: string);
  65094. protected _getTypeName(): string;
  65095. /** @hidden */
  65096. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65097. protected _postMeasure(): void;
  65098. }
  65099. }
  65100. declare module BABYLON.GUI {
  65101. /**
  65102. * Class used to create slider controls
  65103. */
  65104. export class ScrollBar extends BaseSlider {
  65105. name?: string | undefined;
  65106. private _background;
  65107. private _borderColor;
  65108. private _thumbMeasure;
  65109. /** Gets or sets border color */
  65110. borderColor: string;
  65111. /** Gets or sets background color */
  65112. background: string;
  65113. /**
  65114. * Creates a new Slider
  65115. * @param name defines the control name
  65116. */
  65117. constructor(name?: string | undefined);
  65118. protected _getTypeName(): string;
  65119. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  65120. private _first;
  65121. private _originX;
  65122. private _originY;
  65123. /** @hidden */
  65124. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65125. }
  65126. }
  65127. declare module BABYLON.GUI {
  65128. /**
  65129. * Class used to hold a viewer window and sliders in a grid
  65130. */
  65131. export class ScrollViewer extends Rectangle {
  65132. private _grid;
  65133. private _horizontalBarSpace;
  65134. private _verticalBarSpace;
  65135. private _dragSpace;
  65136. private _horizontalBar;
  65137. private _verticalBar;
  65138. private _barColor;
  65139. private _barBackground;
  65140. private _barSize;
  65141. private _endLeft;
  65142. private _endTop;
  65143. private _window;
  65144. private _pointerIsOver;
  65145. private _wheelPrecision;
  65146. private _onPointerObserver;
  65147. private _clientWidth;
  65148. private _clientHeight;
  65149. /**
  65150. * Gets the horizontal scrollbar
  65151. */
  65152. readonly horizontalBar: ScrollBar;
  65153. /**
  65154. * Gets the vertical scrollbar
  65155. */
  65156. readonly verticalBar: ScrollBar;
  65157. /**
  65158. * Adds a new control to the current container
  65159. * @param control defines the control to add
  65160. * @returns the current container
  65161. */
  65162. addControl(control: BABYLON.Nullable<Control>): Container;
  65163. /**
  65164. * Removes a control from the current container
  65165. * @param control defines the control to remove
  65166. * @returns the current container
  65167. */
  65168. removeControl(control: Control): Container;
  65169. /** Gets the list of children */
  65170. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  65171. /**
  65172. * Creates a new ScrollViewer
  65173. * @param name of ScrollViewer
  65174. */
  65175. constructor(name?: string);
  65176. /** Reset the scroll viewer window to initial size */
  65177. resetWindow(): void;
  65178. protected _getTypeName(): string;
  65179. private _buildClientSizes;
  65180. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65181. protected _postMeasure(): void;
  65182. /**
  65183. * Gets or sets the mouse wheel precision
  65184. * from 0 to 1 with a default value of 0.05
  65185. * */
  65186. wheelPrecision: number;
  65187. /** Gets or sets the bar color */
  65188. barColor: string;
  65189. /** Gets or sets the size of the bar */
  65190. barSize: number;
  65191. /** Gets or sets the bar background */
  65192. barBackground: string;
  65193. /** @hidden */
  65194. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  65195. /** @hidden */
  65196. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65197. /** Releases associated resources */
  65198. dispose(): void;
  65199. }
  65200. }
  65201. declare module BABYLON.GUI {
  65202. /** Class used to render a grid */
  65203. export class DisplayGrid extends Control {
  65204. name?: string | undefined;
  65205. private _cellWidth;
  65206. private _cellHeight;
  65207. private _minorLineTickness;
  65208. private _minorLineColor;
  65209. private _majorLineTickness;
  65210. private _majorLineColor;
  65211. private _majorLineFrequency;
  65212. private _background;
  65213. private _displayMajorLines;
  65214. private _displayMinorLines;
  65215. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65216. displayMinorLines: boolean;
  65217. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65218. displayMajorLines: boolean;
  65219. /** Gets or sets background color (Black by default) */
  65220. background: string;
  65221. /** Gets or sets the width of each cell (20 by default) */
  65222. cellWidth: number;
  65223. /** Gets or sets the height of each cell (20 by default) */
  65224. cellHeight: number;
  65225. /** Gets or sets the tickness of minor lines (1 by default) */
  65226. minorLineTickness: number;
  65227. /** Gets or sets the color of minor lines (DarkGray by default) */
  65228. minorLineColor: string;
  65229. /** Gets or sets the tickness of major lines (2 by default) */
  65230. majorLineTickness: number;
  65231. /** Gets or sets the color of major lines (White by default) */
  65232. majorLineColor: string;
  65233. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65234. majorLineFrequency: number;
  65235. /**
  65236. * Creates a new GridDisplayRectangle
  65237. * @param name defines the control name
  65238. */
  65239. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  65240. protected _getTypeName(): string;
  65241. }
  65242. }
  65243. declare module BABYLON.GUI {
  65244. /**
  65245. * Class used to create slider controls based on images
  65246. */
  65247. export class ImageBasedSlider extends BaseSlider {
  65248. name?: string | undefined;
  65249. private _backgroundImage;
  65250. private _thumbImage;
  65251. private _valueBarImage;
  65252. private _tempMeasure;
  65253. displayThumb: boolean;
  65254. /**
  65255. * Gets or sets the image used to render the background
  65256. */
  65257. backgroundImage: Image;
  65258. /**
  65259. * Gets or sets the image used to render the value bar
  65260. */
  65261. valueBarImage: Image;
  65262. /**
  65263. * Gets or sets the image used to render the thumb
  65264. */
  65265. thumbImage: Image;
  65266. /**
  65267. * Creates a new ImageBasedSlider
  65268. * @param name defines the control name
  65269. */
  65270. constructor(name?: string | undefined);
  65271. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65272. }
  65273. }
  65274. declare module BABYLON.GUI {
  65275. /**
  65276. * Forcing an export so that this code will execute
  65277. * @hidden
  65278. */
  65279. const name = "Statics";
  65280. }
  65281. declare module BABYLON.GUI {
  65282. /**
  65283. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65284. */
  65285. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65286. /**
  65287. * Define the instrumented AdvancedDynamicTexture.
  65288. */
  65289. texture: AdvancedDynamicTexture;
  65290. private _captureRenderTime;
  65291. private _renderTime;
  65292. private _captureLayoutTime;
  65293. private _layoutTime;
  65294. private _onBeginRenderObserver;
  65295. private _onEndRenderObserver;
  65296. private _onBeginLayoutObserver;
  65297. private _onEndLayoutObserver;
  65298. /**
  65299. * Gets the perf counter used to capture render time
  65300. */
  65301. readonly renderTimeCounter: BABYLON.PerfCounter;
  65302. /**
  65303. * Gets the perf counter used to capture layout time
  65304. */
  65305. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65306. /**
  65307. * Enable or disable the render time capture
  65308. */
  65309. captureRenderTime: boolean;
  65310. /**
  65311. * Enable or disable the layout time capture
  65312. */
  65313. captureLayoutTime: boolean;
  65314. /**
  65315. * Instantiates a new advanced dynamic texture instrumentation.
  65316. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65317. * @param texture Defines the AdvancedDynamicTexture to instrument
  65318. */
  65319. constructor(
  65320. /**
  65321. * Define the instrumented AdvancedDynamicTexture.
  65322. */
  65323. texture: AdvancedDynamicTexture);
  65324. /**
  65325. * Dispose and release associated resources.
  65326. */
  65327. dispose(): void;
  65328. }
  65329. }
  65330. declare module BABYLON.GUI {
  65331. /**
  65332. * Class used to load GUI via XML.
  65333. */
  65334. export class XmlLoader {
  65335. private _nodes;
  65336. private _nodeTypes;
  65337. private _isLoaded;
  65338. private _objectAttributes;
  65339. private _parentClass;
  65340. /**
  65341. * Create a new xml loader
  65342. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  65343. */
  65344. constructor(parentClass?: null);
  65345. private _getChainElement;
  65346. private _getClassAttribute;
  65347. private _createGuiElement;
  65348. private _parseGrid;
  65349. private _parseElement;
  65350. private _prepareSourceElement;
  65351. private _parseElementsFromSource;
  65352. private _parseXml;
  65353. /**
  65354. * Gets if the loading has finished.
  65355. * @returns whether the loading has finished or not
  65356. */
  65357. isLoaded(): boolean;
  65358. /**
  65359. * Gets a loaded node / control by id.
  65360. * @param id the Controls id set in the xml
  65361. * @returns element of type Control
  65362. */
  65363. getNodeById(id: string): any;
  65364. /**
  65365. * Gets all loaded nodes / controls
  65366. * @returns Array of controls
  65367. */
  65368. getNodes(): any;
  65369. /**
  65370. * Initiates the xml layout loading
  65371. * @param xmlFile defines the xml layout to load
  65372. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  65373. * @param callback defines the callback called on layout load.
  65374. */
  65375. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  65376. }
  65377. }
  65378. declare module BABYLON.GUI {
  65379. /**
  65380. * Class used to create containers for controls
  65381. */
  65382. export class Container3D extends Control3D {
  65383. private _blockLayout;
  65384. /**
  65385. * Gets the list of child controls
  65386. */
  65387. protected _children: Control3D[];
  65388. /**
  65389. * Gets the list of child controls
  65390. */
  65391. readonly children: Array<Control3D>;
  65392. /**
  65393. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65394. * This is helpful to optimize layout operation when adding multiple children in a row
  65395. */
  65396. blockLayout: boolean;
  65397. /**
  65398. * Creates a new container
  65399. * @param name defines the container name
  65400. */
  65401. constructor(name?: string);
  65402. /**
  65403. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65404. * @returns the current container
  65405. */
  65406. updateLayout(): Container3D;
  65407. /**
  65408. * Gets a boolean indicating if the given control is in the children of this control
  65409. * @param control defines the control to check
  65410. * @returns true if the control is in the child list
  65411. */
  65412. containsControl(control: Control3D): boolean;
  65413. /**
  65414. * Adds a control to the children of this control
  65415. * @param control defines the control to add
  65416. * @returns the current container
  65417. */
  65418. addControl(control: Control3D): Container3D;
  65419. /**
  65420. * This function will be called everytime a new control is added
  65421. */
  65422. protected _arrangeChildren(): void;
  65423. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65424. /**
  65425. * Removes a control from the children of this control
  65426. * @param control defines the control to remove
  65427. * @returns the current container
  65428. */
  65429. removeControl(control: Control3D): Container3D;
  65430. protected _getTypeName(): string;
  65431. /**
  65432. * Releases all associated resources
  65433. */
  65434. dispose(): void;
  65435. /** Control rotation will remain unchanged */
  65436. static readonly UNSET_ORIENTATION: number;
  65437. /** Control will rotate to make it look at sphere central axis */
  65438. static readonly FACEORIGIN_ORIENTATION: number;
  65439. /** Control will rotate to make it look back at sphere central axis */
  65440. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65441. /** Control will rotate to look at z axis (0, 0, 1) */
  65442. static readonly FACEFORWARD_ORIENTATION: number;
  65443. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65444. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65445. }
  65446. }
  65447. declare module BABYLON.GUI {
  65448. /**
  65449. * Class used to manage 3D user interface
  65450. * @see http://doc.babylonjs.com/how_to/gui3d
  65451. */
  65452. export class GUI3DManager implements BABYLON.IDisposable {
  65453. private _scene;
  65454. private _sceneDisposeObserver;
  65455. private _utilityLayer;
  65456. private _rootContainer;
  65457. private _pointerObserver;
  65458. private _pointerOutObserver;
  65459. /** @hidden */ private _lastPickedControl: Control3D;
  65460. /** @hidden */ private _lastControlOver: {
  65461. [pointerId: number]: Control3D;
  65462. };
  65463. /** @hidden */ private _lastControlDown: {
  65464. [pointerId: number]: Control3D;
  65465. };
  65466. /**
  65467. * BABYLON.Observable raised when the point picked by the pointer events changed
  65468. */
  65469. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65470. /** @hidden */ private _sharedMaterials: {
  65471. [key: string]: BABYLON.Material;
  65472. };
  65473. /** Gets the hosting scene */
  65474. readonly scene: BABYLON.Scene;
  65475. /** Gets associated utility layer */
  65476. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65477. /**
  65478. * Creates a new GUI3DManager
  65479. * @param scene
  65480. */
  65481. constructor(scene?: BABYLON.Scene);
  65482. private _handlePointerOut;
  65483. private _doPicking;
  65484. /**
  65485. * Gets the root container
  65486. */
  65487. readonly rootContainer: Container3D;
  65488. /**
  65489. * Gets a boolean indicating if the given control is in the root child list
  65490. * @param control defines the control to check
  65491. * @returns true if the control is in the root child list
  65492. */
  65493. containsControl(control: Control3D): boolean;
  65494. /**
  65495. * Adds a control to the root child list
  65496. * @param control defines the control to add
  65497. * @returns the current manager
  65498. */
  65499. addControl(control: Control3D): GUI3DManager;
  65500. /**
  65501. * Removes a control from the root child list
  65502. * @param control defines the control to remove
  65503. * @returns the current container
  65504. */
  65505. removeControl(control: Control3D): GUI3DManager;
  65506. /**
  65507. * Releases all associated resources
  65508. */
  65509. dispose(): void;
  65510. }
  65511. }
  65512. declare module BABYLON.GUI {
  65513. /**
  65514. * Class used to transport BABYLON.Vector3 information for pointer events
  65515. */
  65516. export class Vector3WithInfo extends BABYLON.Vector3 {
  65517. /** defines the current mouse button index */
  65518. buttonIndex: number;
  65519. /**
  65520. * Creates a new Vector3WithInfo
  65521. * @param source defines the vector3 data to transport
  65522. * @param buttonIndex defines the current mouse button index
  65523. */
  65524. constructor(source: BABYLON.Vector3,
  65525. /** defines the current mouse button index */
  65526. buttonIndex?: number);
  65527. }
  65528. }
  65529. declare module BABYLON.GUI {
  65530. /**
  65531. * Class used as base class for controls
  65532. */
  65533. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65534. /** Defines the control name */
  65535. name?: string | undefined;
  65536. /** @hidden */ private _host: GUI3DManager;
  65537. private _node;
  65538. private _downCount;
  65539. private _enterCount;
  65540. private _downPointerIds;
  65541. private _isVisible;
  65542. /** Gets or sets the control position in world space */
  65543. position: BABYLON.Vector3;
  65544. /** Gets or sets the control scaling in world space */
  65545. scaling: BABYLON.Vector3;
  65546. /** Callback used to start pointer enter animation */
  65547. pointerEnterAnimation: () => void;
  65548. /** Callback used to start pointer out animation */
  65549. pointerOutAnimation: () => void;
  65550. /** Callback used to start pointer down animation */
  65551. pointerDownAnimation: () => void;
  65552. /** Callback used to start pointer up animation */
  65553. pointerUpAnimation: () => void;
  65554. /**
  65555. * An event triggered when the pointer move over the control
  65556. */
  65557. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65558. /**
  65559. * An event triggered when the pointer move out of the control
  65560. */
  65561. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65562. /**
  65563. * An event triggered when the pointer taps the control
  65564. */
  65565. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65566. /**
  65567. * An event triggered when pointer is up
  65568. */
  65569. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65570. /**
  65571. * An event triggered when a control is clicked on (with a mouse)
  65572. */
  65573. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65574. /**
  65575. * An event triggered when pointer enters the control
  65576. */
  65577. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65578. /**
  65579. * Gets or sets the parent container
  65580. */
  65581. parent: BABYLON.Nullable<Container3D>;
  65582. private _behaviors;
  65583. /**
  65584. * Gets the list of attached behaviors
  65585. * @see http://doc.babylonjs.com/features/behaviour
  65586. */
  65587. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65588. /**
  65589. * Attach a behavior to the control
  65590. * @see http://doc.babylonjs.com/features/behaviour
  65591. * @param behavior defines the behavior to attach
  65592. * @returns the current control
  65593. */
  65594. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65595. /**
  65596. * Remove an attached behavior
  65597. * @see http://doc.babylonjs.com/features/behaviour
  65598. * @param behavior defines the behavior to attach
  65599. * @returns the current control
  65600. */
  65601. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65602. /**
  65603. * Gets an attached behavior by name
  65604. * @param name defines the name of the behavior to look for
  65605. * @see http://doc.babylonjs.com/features/behaviour
  65606. * @returns null if behavior was not found else the requested behavior
  65607. */
  65608. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65609. /** Gets or sets a boolean indicating if the control is visible */
  65610. isVisible: boolean;
  65611. /**
  65612. * Creates a new control
  65613. * @param name defines the control name
  65614. */
  65615. constructor(
  65616. /** Defines the control name */
  65617. name?: string | undefined);
  65618. /**
  65619. * Gets a string representing the class name
  65620. */
  65621. readonly typeName: string;
  65622. /**
  65623. * Get the current class name of the control.
  65624. * @returns current class name
  65625. */
  65626. getClassName(): string;
  65627. protected _getTypeName(): string;
  65628. /**
  65629. * Gets the transform node used by this control
  65630. */
  65631. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65632. /**
  65633. * Gets the mesh used to render this control
  65634. */
  65635. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65636. /**
  65637. * Link the control as child of the given node
  65638. * @param node defines the node to link to. Use null to unlink the control
  65639. * @returns the current control
  65640. */
  65641. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65642. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  65643. /**
  65644. * Node creation.
  65645. * Can be overriden by children
  65646. * @param scene defines the scene where the node must be attached
  65647. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65648. */
  65649. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65650. /**
  65651. * Affect a material to the given mesh
  65652. * @param mesh defines the mesh which will represent the control
  65653. */
  65654. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65655. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65656. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  65657. /** @hidden */ private _onPointerOut(target: Control3D): void;
  65658. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65659. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65660. /** @hidden */
  65661. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65662. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65663. /** @hidden */ private _disposeNode(): void;
  65664. /**
  65665. * Releases all associated resources
  65666. */
  65667. dispose(): void;
  65668. }
  65669. }
  65670. declare module BABYLON.GUI {
  65671. /**
  65672. * Class used as a root to all buttons
  65673. */
  65674. export class AbstractButton3D extends Control3D {
  65675. /**
  65676. * Creates a new button
  65677. * @param name defines the control name
  65678. */
  65679. constructor(name?: string);
  65680. protected _getTypeName(): string;
  65681. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65682. }
  65683. }
  65684. declare module BABYLON.GUI {
  65685. /**
  65686. * Class used to create a button in 3D
  65687. */
  65688. export class Button3D extends AbstractButton3D {
  65689. /** @hidden */
  65690. protected _currentMaterial: BABYLON.Material;
  65691. private _facadeTexture;
  65692. private _content;
  65693. private _contentResolution;
  65694. private _contentScaleRatio;
  65695. /**
  65696. * Gets or sets the texture resolution used to render content (512 by default)
  65697. */
  65698. contentResolution: BABYLON.int;
  65699. /**
  65700. * Gets or sets the texture scale ratio used to render content (2 by default)
  65701. */
  65702. contentScaleRatio: number;
  65703. protected _disposeFacadeTexture(): void;
  65704. protected _resetContent(): void;
  65705. /**
  65706. * Creates a new button
  65707. * @param name defines the control name
  65708. */
  65709. constructor(name?: string);
  65710. /**
  65711. * Gets or sets the GUI 2D content used to display the button's facade
  65712. */
  65713. content: Control;
  65714. /**
  65715. * Apply the facade texture (created from the content property).
  65716. * This function can be overloaded by child classes
  65717. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65718. */
  65719. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65720. protected _getTypeName(): string;
  65721. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65722. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65723. /**
  65724. * Releases all associated resources
  65725. */
  65726. dispose(): void;
  65727. }
  65728. }
  65729. declare module BABYLON.GUI {
  65730. /**
  65731. * Abstract class used to create a container panel deployed on the surface of a volume
  65732. */
  65733. export abstract class VolumeBasedPanel extends Container3D {
  65734. private _columns;
  65735. private _rows;
  65736. private _rowThenColum;
  65737. private _orientation;
  65738. protected _cellWidth: number;
  65739. protected _cellHeight: number;
  65740. /**
  65741. * Gets or sets the distance between elements
  65742. */
  65743. margin: number;
  65744. /**
  65745. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65746. * | Value | Type | Description |
  65747. * | ----- | ----------------------------------- | ----------- |
  65748. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65749. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65750. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65751. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65752. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65753. */
  65754. orientation: number;
  65755. /**
  65756. * Gets or sets the number of columns requested (10 by default).
  65757. * The panel will automatically compute the number of rows based on number of child controls.
  65758. */
  65759. columns: BABYLON.int;
  65760. /**
  65761. * Gets or sets a the number of rows requested.
  65762. * The panel will automatically compute the number of columns based on number of child controls.
  65763. */
  65764. rows: BABYLON.int;
  65765. /**
  65766. * Creates new VolumeBasedPanel
  65767. */
  65768. constructor();
  65769. protected _arrangeChildren(): void;
  65770. /** Child classes must implement this function to provide correct control positioning */
  65771. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65772. /** Child classes can implement this function to provide additional processing */
  65773. protected _finalProcessing(): void;
  65774. }
  65775. }
  65776. declare module BABYLON.GUI {
  65777. /**
  65778. * Class used to create a container panel deployed on the surface of a cylinder
  65779. */
  65780. export class CylinderPanel extends VolumeBasedPanel {
  65781. private _radius;
  65782. /**
  65783. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65784. */
  65785. radius: BABYLON.float;
  65786. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65787. private _cylindricalMapping;
  65788. }
  65789. }
  65790. declare module BABYLON.GUI {
  65791. /** @hidden */
  65792. export var fluentVertexShader: {
  65793. name: string;
  65794. shader: string;
  65795. };
  65796. }
  65797. declare module BABYLON.GUI {
  65798. /** @hidden */
  65799. export var fluentPixelShader: {
  65800. name: string;
  65801. shader: string;
  65802. };
  65803. }
  65804. declare module BABYLON.GUI {
  65805. /** @hidden */
  65806. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65807. INNERGLOW: boolean;
  65808. BORDER: boolean;
  65809. HOVERLIGHT: boolean;
  65810. TEXTURE: boolean;
  65811. constructor();
  65812. }
  65813. /**
  65814. * Class used to render controls with fluent desgin
  65815. */
  65816. export class FluentMaterial extends BABYLON.PushMaterial {
  65817. /**
  65818. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65819. */
  65820. innerGlowColorIntensity: number;
  65821. /**
  65822. * Gets or sets the inner glow color (white by default)
  65823. */
  65824. innerGlowColor: BABYLON.Color3;
  65825. /**
  65826. * Gets or sets alpha value (default is 1.0)
  65827. */
  65828. alpha: number;
  65829. /**
  65830. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65831. */
  65832. albedoColor: BABYLON.Color3;
  65833. /**
  65834. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65835. */
  65836. renderBorders: boolean;
  65837. /**
  65838. * Gets or sets border width (default is 0.5)
  65839. */
  65840. borderWidth: number;
  65841. /**
  65842. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65843. */
  65844. edgeSmoothingValue: number;
  65845. /**
  65846. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65847. */
  65848. borderMinValue: number;
  65849. /**
  65850. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65851. */
  65852. renderHoverLight: boolean;
  65853. /**
  65854. * Gets or sets the radius used to render the hover light (default is 1.0)
  65855. */
  65856. hoverRadius: number;
  65857. /**
  65858. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65859. */
  65860. hoverColor: BABYLON.Color4;
  65861. /**
  65862. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65863. */
  65864. hoverPosition: BABYLON.Vector3;
  65865. private _albedoTexture;
  65866. /** Gets or sets the texture to use for albedo color */
  65867. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65868. /**
  65869. * Creates a new Fluent material
  65870. * @param name defines the name of the material
  65871. * @param scene defines the hosting scene
  65872. */
  65873. constructor(name: string, scene: BABYLON.Scene);
  65874. needAlphaBlending(): boolean;
  65875. needAlphaTesting(): boolean;
  65876. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65877. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65878. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65879. getActiveTextures(): BABYLON.BaseTexture[];
  65880. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65881. dispose(forceDisposeEffect?: boolean): void;
  65882. clone(name: string): FluentMaterial;
  65883. serialize(): any;
  65884. getClassName(): string;
  65885. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65886. }
  65887. }
  65888. declare module BABYLON.GUI {
  65889. /**
  65890. * Class used to create a holographic button in 3D
  65891. */
  65892. export class HolographicButton extends Button3D {
  65893. private _backPlate;
  65894. private _textPlate;
  65895. private _frontPlate;
  65896. private _text;
  65897. private _imageUrl;
  65898. private _shareMaterials;
  65899. private _frontMaterial;
  65900. private _backMaterial;
  65901. private _plateMaterial;
  65902. private _pickedPointObserver;
  65903. private _tooltipFade;
  65904. private _tooltipTextBlock;
  65905. private _tooltipTexture;
  65906. private _tooltipMesh;
  65907. private _tooltipHoverObserver;
  65908. private _tooltipOutObserver;
  65909. private _disposeTooltip;
  65910. /**
  65911. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65912. */
  65913. tooltipText: BABYLON.Nullable<string>;
  65914. /**
  65915. * Gets or sets text for the button
  65916. */
  65917. text: string;
  65918. /**
  65919. * Gets or sets the image url for the button
  65920. */
  65921. imageUrl: string;
  65922. /**
  65923. * Gets the back material used by this button
  65924. */
  65925. readonly backMaterial: FluentMaterial;
  65926. /**
  65927. * Gets the front material used by this button
  65928. */
  65929. readonly frontMaterial: FluentMaterial;
  65930. /**
  65931. * Gets the plate material used by this button
  65932. */
  65933. readonly plateMaterial: BABYLON.StandardMaterial;
  65934. /**
  65935. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65936. */
  65937. readonly shareMaterials: boolean;
  65938. /**
  65939. * Creates a new button
  65940. * @param name defines the control name
  65941. */
  65942. constructor(name?: string, shareMaterials?: boolean);
  65943. protected _getTypeName(): string;
  65944. private _rebuildContent;
  65945. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65946. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65947. private _createBackMaterial;
  65948. private _createFrontMaterial;
  65949. private _createPlateMaterial;
  65950. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65951. /**
  65952. * Releases all associated resources
  65953. */
  65954. dispose(): void;
  65955. }
  65956. }
  65957. declare module BABYLON.GUI {
  65958. /**
  65959. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65960. */
  65961. export class MeshButton3D extends Button3D {
  65962. /** @hidden */
  65963. protected _currentMesh: BABYLON.Mesh;
  65964. /**
  65965. * Creates a new 3D button based on a mesh
  65966. * @param mesh mesh to become a 3D button
  65967. * @param name defines the control name
  65968. */
  65969. constructor(mesh: BABYLON.Mesh, name?: string);
  65970. protected _getTypeName(): string;
  65971. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65972. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65973. }
  65974. }
  65975. declare module BABYLON.GUI {
  65976. /**
  65977. * Class used to create a container panel deployed on the surface of a plane
  65978. */
  65979. export class PlanePanel extends VolumeBasedPanel {
  65980. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65981. }
  65982. }
  65983. declare module BABYLON.GUI {
  65984. /**
  65985. * Class used to create a container panel where items get randomized planar mapping
  65986. */
  65987. export class ScatterPanel extends VolumeBasedPanel {
  65988. private _iteration;
  65989. /**
  65990. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65991. */
  65992. iteration: BABYLON.float;
  65993. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65994. private _scatterMapping;
  65995. protected _finalProcessing(): void;
  65996. }
  65997. }
  65998. declare module BABYLON.GUI {
  65999. /**
  66000. * Class used to create a container panel deployed on the surface of a sphere
  66001. */
  66002. export class SpherePanel extends VolumeBasedPanel {
  66003. private _radius;
  66004. /**
  66005. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66006. */
  66007. radius: BABYLON.float;
  66008. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66009. private _sphericalMapping;
  66010. }
  66011. }
  66012. declare module BABYLON.GUI {
  66013. /**
  66014. * Class used to create a stack panel in 3D on XY plane
  66015. */
  66016. export class StackPanel3D extends Container3D {
  66017. private _isVertical;
  66018. /**
  66019. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66020. */
  66021. isVertical: boolean;
  66022. /**
  66023. * Gets or sets the distance between elements
  66024. */
  66025. margin: number;
  66026. /**
  66027. * Creates new StackPanel
  66028. * @param isVertical
  66029. */
  66030. constructor(isVertical?: boolean);
  66031. protected _arrangeChildren(): void;
  66032. }
  66033. }
  66034. declare module BABYLON {
  66035. /**
  66036. * Mode that determines the coordinate system to use.
  66037. */
  66038. export enum GLTFLoaderCoordinateSystemMode {
  66039. /**
  66040. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66041. */
  66042. AUTO = 0,
  66043. /**
  66044. * Sets the useRightHandedSystem flag on the scene.
  66045. */
  66046. FORCE_RIGHT_HANDED = 1
  66047. }
  66048. /**
  66049. * Mode that determines what animations will start.
  66050. */
  66051. export enum GLTFLoaderAnimationStartMode {
  66052. /**
  66053. * No animation will start.
  66054. */
  66055. NONE = 0,
  66056. /**
  66057. * The first animation will start.
  66058. */
  66059. FIRST = 1,
  66060. /**
  66061. * All animations will start.
  66062. */
  66063. ALL = 2
  66064. }
  66065. /**
  66066. * Interface that contains the data for the glTF asset.
  66067. */
  66068. export interface IGLTFLoaderData {
  66069. /**
  66070. * Object that represents the glTF JSON.
  66071. */
  66072. json: Object;
  66073. /**
  66074. * The BIN chunk of a binary glTF.
  66075. */
  66076. bin: Nullable<ArrayBufferView>;
  66077. }
  66078. /**
  66079. * Interface for extending the loader.
  66080. */
  66081. export interface IGLTFLoaderExtension {
  66082. /**
  66083. * The name of this extension.
  66084. */
  66085. readonly name: string;
  66086. /**
  66087. * Defines whether this extension is enabled.
  66088. */
  66089. enabled: boolean;
  66090. }
  66091. /**
  66092. * Loader state.
  66093. */
  66094. export enum GLTFLoaderState {
  66095. /**
  66096. * The asset is loading.
  66097. */
  66098. LOADING = 0,
  66099. /**
  66100. * The asset is ready for rendering.
  66101. */
  66102. READY = 1,
  66103. /**
  66104. * The asset is completely loaded.
  66105. */
  66106. COMPLETE = 2
  66107. }
  66108. /** @hidden */
  66109. export interface IGLTFLoader extends IDisposable {
  66110. readonly state: Nullable<GLTFLoaderState>;
  66111. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66112. meshes: AbstractMesh[];
  66113. particleSystems: IParticleSystem[];
  66114. skeletons: Skeleton[];
  66115. animationGroups: AnimationGroup[];
  66116. }>;
  66117. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66118. }
  66119. /**
  66120. * File loader for loading glTF files into a scene.
  66121. */
  66122. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66123. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66124. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66125. /**
  66126. * Raised when the asset has been parsed
  66127. */
  66128. onParsedObservable: Observable<IGLTFLoaderData>;
  66129. private _onParsedObserver;
  66130. /**
  66131. * Raised when the asset has been parsed
  66132. */
  66133. onParsed: (loaderData: IGLTFLoaderData) => void;
  66134. /**
  66135. * 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.
  66136. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66137. * Defaults to true.
  66138. * @hidden
  66139. */
  66140. static IncrementalLoading: boolean;
  66141. /**
  66142. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66143. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66144. * @hidden
  66145. */
  66146. static HomogeneousCoordinates: boolean;
  66147. /**
  66148. * The coordinate system mode. Defaults to AUTO.
  66149. */
  66150. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66151. /**
  66152. * The animation start mode. Defaults to FIRST.
  66153. */
  66154. animationStartMode: GLTFLoaderAnimationStartMode;
  66155. /**
  66156. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66157. */
  66158. compileMaterials: boolean;
  66159. /**
  66160. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66161. */
  66162. useClipPlane: boolean;
  66163. /**
  66164. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66165. */
  66166. compileShadowGenerators: boolean;
  66167. /**
  66168. * Defines if the Alpha blended materials are only applied as coverage.
  66169. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66170. * If true, no extra effects are applied to transparent pixels.
  66171. */
  66172. transparencyAsCoverage: boolean;
  66173. /**
  66174. * Function called before loading a url referenced by the asset.
  66175. */
  66176. preprocessUrlAsync: (url: string) => Promise<string>;
  66177. /**
  66178. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66179. */
  66180. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66181. private _onMeshLoadedObserver;
  66182. /**
  66183. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66184. */
  66185. onMeshLoaded: (mesh: AbstractMesh) => void;
  66186. /**
  66187. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66188. */
  66189. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66190. private _onTextureLoadedObserver;
  66191. /**
  66192. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66193. */
  66194. onTextureLoaded: (texture: BaseTexture) => void;
  66195. /**
  66196. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66197. */
  66198. readonly onMaterialLoadedObservable: Observable<Material>;
  66199. private _onMaterialLoadedObserver;
  66200. /**
  66201. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66202. */
  66203. onMaterialLoaded: (material: Material) => void;
  66204. /**
  66205. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66206. */
  66207. readonly onCameraLoadedObservable: Observable<Camera>;
  66208. private _onCameraLoadedObserver;
  66209. /**
  66210. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66211. */
  66212. onCameraLoaded: (camera: Camera) => void;
  66213. /**
  66214. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66215. * For assets with LODs, raised when all of the LODs are complete.
  66216. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66217. */
  66218. readonly onCompleteObservable: Observable<void>;
  66219. private _onCompleteObserver;
  66220. /**
  66221. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66222. * For assets with LODs, raised when all of the LODs are complete.
  66223. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66224. */
  66225. onComplete: () => void;
  66226. /**
  66227. * Observable raised when an error occurs.
  66228. */
  66229. readonly onErrorObservable: Observable<any>;
  66230. private _onErrorObserver;
  66231. /**
  66232. * Callback raised when an error occurs.
  66233. */
  66234. onError: (reason: any) => void;
  66235. /**
  66236. * Observable raised after the loader is disposed.
  66237. */
  66238. readonly onDisposeObservable: Observable<void>;
  66239. private _onDisposeObserver;
  66240. /**
  66241. * Callback raised after the loader is disposed.
  66242. */
  66243. onDispose: () => void;
  66244. /**
  66245. * Observable raised after a loader extension is created.
  66246. * Set additional options for a loader extension in this event.
  66247. */
  66248. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66249. private _onExtensionLoadedObserver;
  66250. /**
  66251. * Callback raised after a loader extension is created.
  66252. */
  66253. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66254. /**
  66255. * Defines if the loader logging is enabled.
  66256. */
  66257. loggingEnabled: boolean;
  66258. /**
  66259. * Defines if the loader should capture performance counters.
  66260. */
  66261. capturePerformanceCounters: boolean;
  66262. /**
  66263. * Defines if the loader should validate the asset.
  66264. */
  66265. validate: boolean;
  66266. /**
  66267. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66268. */
  66269. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66270. private _onValidatedObserver;
  66271. /**
  66272. * Callback raised after a loader extension is created.
  66273. */
  66274. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66275. private _loader;
  66276. /**
  66277. * Name of the loader ("gltf")
  66278. */
  66279. name: string;
  66280. /**
  66281. * Supported file extensions of the loader (.gltf, .glb)
  66282. */
  66283. extensions: ISceneLoaderPluginExtensions;
  66284. /**
  66285. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66286. */
  66287. dispose(): void;
  66288. /** @hidden */ private _clear(): void;
  66289. /**
  66290. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66291. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66292. * @param scene the scene the meshes should be added to
  66293. * @param data the glTF data to load
  66294. * @param rootUrl root url to load from
  66295. * @param onProgress event that fires when loading progress has occured
  66296. * @param fileName Defines the name of the file to load
  66297. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66298. */
  66299. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66300. meshes: AbstractMesh[];
  66301. particleSystems: IParticleSystem[];
  66302. skeletons: Skeleton[];
  66303. animationGroups: AnimationGroup[];
  66304. }>;
  66305. /**
  66306. * Imports all objects from the loaded glTF data and adds them to the scene
  66307. * @param scene the scene the objects should be added to
  66308. * @param data the glTF data to load
  66309. * @param rootUrl root url to load from
  66310. * @param onProgress event that fires when loading progress has occured
  66311. * @param fileName Defines the name of the file to load
  66312. * @returns a promise which completes when objects have been loaded to the scene
  66313. */
  66314. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66315. /**
  66316. * Load into an asset container.
  66317. * @param scene The scene to load into
  66318. * @param data The data to import
  66319. * @param rootUrl The root url for scene and resources
  66320. * @param onProgress The callback when the load progresses
  66321. * @param fileName Defines the name of the file to load
  66322. * @returns The loaded asset container
  66323. */
  66324. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66325. /**
  66326. * If the data string can be loaded directly.
  66327. * @param data string contianing the file data
  66328. * @returns if the data can be loaded directly
  66329. */
  66330. canDirectLoad(data: string): boolean;
  66331. /**
  66332. * Rewrites a url by combining a root url and response url.
  66333. */
  66334. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66335. /**
  66336. * Instantiates a glTF file loader plugin.
  66337. * @returns the created plugin
  66338. */
  66339. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66340. /**
  66341. * The loader state or null if the loader is not active.
  66342. */
  66343. readonly loaderState: Nullable<GLTFLoaderState>;
  66344. /**
  66345. * Returns a promise that resolves when the asset is completely loaded.
  66346. * @returns a promise that resolves when the asset is completely loaded.
  66347. */
  66348. whenCompleteAsync(): Promise<void>;
  66349. private _parseAsync;
  66350. private _validateAsync;
  66351. private _getLoader;
  66352. private _unpackBinary;
  66353. private _unpackBinaryV1;
  66354. private _unpackBinaryV2;
  66355. private static _parseVersion;
  66356. private static _compareVersion;
  66357. private static _decodeBufferToText;
  66358. private static readonly _logSpaces;
  66359. private _logIndentLevel;
  66360. private _loggingEnabled;
  66361. /** @hidden */ private _log: (message: string) => void;
  66362. /** @hidden */ private _logOpen(message: string): void;
  66363. /** @hidden */ private _logClose(): void;
  66364. private _logEnabled;
  66365. private _logDisabled;
  66366. private _capturePerformanceCounters;
  66367. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  66368. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  66369. private _startPerformanceCounterEnabled;
  66370. private _startPerformanceCounterDisabled;
  66371. private _endPerformanceCounterEnabled;
  66372. private _endPerformanceCounterDisabled;
  66373. }
  66374. }
  66375. declare module BABYLON.GLTF1 {
  66376. /**
  66377. * Enums
  66378. * @hidden
  66379. */
  66380. export enum EComponentType {
  66381. BYTE = 5120,
  66382. UNSIGNED_BYTE = 5121,
  66383. SHORT = 5122,
  66384. UNSIGNED_SHORT = 5123,
  66385. FLOAT = 5126
  66386. }
  66387. /** @hidden */
  66388. export enum EShaderType {
  66389. FRAGMENT = 35632,
  66390. VERTEX = 35633
  66391. }
  66392. /** @hidden */
  66393. export enum EParameterType {
  66394. BYTE = 5120,
  66395. UNSIGNED_BYTE = 5121,
  66396. SHORT = 5122,
  66397. UNSIGNED_SHORT = 5123,
  66398. INT = 5124,
  66399. UNSIGNED_INT = 5125,
  66400. FLOAT = 5126,
  66401. FLOAT_VEC2 = 35664,
  66402. FLOAT_VEC3 = 35665,
  66403. FLOAT_VEC4 = 35666,
  66404. INT_VEC2 = 35667,
  66405. INT_VEC3 = 35668,
  66406. INT_VEC4 = 35669,
  66407. BOOL = 35670,
  66408. BOOL_VEC2 = 35671,
  66409. BOOL_VEC3 = 35672,
  66410. BOOL_VEC4 = 35673,
  66411. FLOAT_MAT2 = 35674,
  66412. FLOAT_MAT3 = 35675,
  66413. FLOAT_MAT4 = 35676,
  66414. SAMPLER_2D = 35678
  66415. }
  66416. /** @hidden */
  66417. export enum ETextureWrapMode {
  66418. CLAMP_TO_EDGE = 33071,
  66419. MIRRORED_REPEAT = 33648,
  66420. REPEAT = 10497
  66421. }
  66422. /** @hidden */
  66423. export enum ETextureFilterType {
  66424. NEAREST = 9728,
  66425. LINEAR = 9728,
  66426. NEAREST_MIPMAP_NEAREST = 9984,
  66427. LINEAR_MIPMAP_NEAREST = 9985,
  66428. NEAREST_MIPMAP_LINEAR = 9986,
  66429. LINEAR_MIPMAP_LINEAR = 9987
  66430. }
  66431. /** @hidden */
  66432. export enum ETextureFormat {
  66433. ALPHA = 6406,
  66434. RGB = 6407,
  66435. RGBA = 6408,
  66436. LUMINANCE = 6409,
  66437. LUMINANCE_ALPHA = 6410
  66438. }
  66439. /** @hidden */
  66440. export enum ECullingType {
  66441. FRONT = 1028,
  66442. BACK = 1029,
  66443. FRONT_AND_BACK = 1032
  66444. }
  66445. /** @hidden */
  66446. export enum EBlendingFunction {
  66447. ZERO = 0,
  66448. ONE = 1,
  66449. SRC_COLOR = 768,
  66450. ONE_MINUS_SRC_COLOR = 769,
  66451. DST_COLOR = 774,
  66452. ONE_MINUS_DST_COLOR = 775,
  66453. SRC_ALPHA = 770,
  66454. ONE_MINUS_SRC_ALPHA = 771,
  66455. DST_ALPHA = 772,
  66456. ONE_MINUS_DST_ALPHA = 773,
  66457. CONSTANT_COLOR = 32769,
  66458. ONE_MINUS_CONSTANT_COLOR = 32770,
  66459. CONSTANT_ALPHA = 32771,
  66460. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66461. SRC_ALPHA_SATURATE = 776
  66462. }
  66463. /** @hidden */
  66464. export interface IGLTFProperty {
  66465. extensions?: {
  66466. [key: string]: any;
  66467. };
  66468. extras?: Object;
  66469. }
  66470. /** @hidden */
  66471. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66472. name?: string;
  66473. }
  66474. /** @hidden */
  66475. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66476. bufferView: string;
  66477. byteOffset: number;
  66478. byteStride: number;
  66479. count: number;
  66480. type: string;
  66481. componentType: EComponentType;
  66482. max?: number[];
  66483. min?: number[];
  66484. name?: string;
  66485. }
  66486. /** @hidden */
  66487. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66488. buffer: string;
  66489. byteOffset: number;
  66490. byteLength: number;
  66491. byteStride: number;
  66492. target?: number;
  66493. }
  66494. /** @hidden */
  66495. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66496. uri: string;
  66497. byteLength?: number;
  66498. type?: string;
  66499. }
  66500. /** @hidden */
  66501. export interface IGLTFShader extends IGLTFChildRootProperty {
  66502. uri: string;
  66503. type: EShaderType;
  66504. }
  66505. /** @hidden */
  66506. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66507. attributes: string[];
  66508. fragmentShader: string;
  66509. vertexShader: string;
  66510. }
  66511. /** @hidden */
  66512. export interface IGLTFTechniqueParameter {
  66513. type: number;
  66514. count?: number;
  66515. semantic?: string;
  66516. node?: string;
  66517. value?: number | boolean | string | Array<any>;
  66518. source?: string;
  66519. babylonValue?: any;
  66520. }
  66521. /** @hidden */
  66522. export interface IGLTFTechniqueCommonProfile {
  66523. lightingModel: string;
  66524. texcoordBindings: Object;
  66525. parameters?: Array<any>;
  66526. }
  66527. /** @hidden */
  66528. export interface IGLTFTechniqueStatesFunctions {
  66529. blendColor?: number[];
  66530. blendEquationSeparate?: number[];
  66531. blendFuncSeparate?: number[];
  66532. colorMask: boolean[];
  66533. cullFace: number[];
  66534. }
  66535. /** @hidden */
  66536. export interface IGLTFTechniqueStates {
  66537. enable: number[];
  66538. functions: IGLTFTechniqueStatesFunctions;
  66539. }
  66540. /** @hidden */
  66541. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66542. parameters: {
  66543. [key: string]: IGLTFTechniqueParameter;
  66544. };
  66545. program: string;
  66546. attributes: {
  66547. [key: string]: string;
  66548. };
  66549. uniforms: {
  66550. [key: string]: string;
  66551. };
  66552. states: IGLTFTechniqueStates;
  66553. }
  66554. /** @hidden */
  66555. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66556. technique?: string;
  66557. values: string[];
  66558. }
  66559. /** @hidden */
  66560. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66561. attributes: {
  66562. [key: string]: string;
  66563. };
  66564. indices: string;
  66565. material: string;
  66566. mode?: number;
  66567. }
  66568. /** @hidden */
  66569. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66570. primitives: IGLTFMeshPrimitive[];
  66571. }
  66572. /** @hidden */
  66573. export interface IGLTFImage extends IGLTFChildRootProperty {
  66574. uri: string;
  66575. }
  66576. /** @hidden */
  66577. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66578. magFilter?: number;
  66579. minFilter?: number;
  66580. wrapS?: number;
  66581. wrapT?: number;
  66582. }
  66583. /** @hidden */
  66584. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66585. sampler: string;
  66586. source: string;
  66587. format?: ETextureFormat;
  66588. internalFormat?: ETextureFormat;
  66589. target?: number;
  66590. type?: number;
  66591. babylonTexture?: Texture;
  66592. }
  66593. /** @hidden */
  66594. export interface IGLTFAmbienLight {
  66595. color?: number[];
  66596. }
  66597. /** @hidden */
  66598. export interface IGLTFDirectionalLight {
  66599. color?: number[];
  66600. }
  66601. /** @hidden */
  66602. export interface IGLTFPointLight {
  66603. color?: number[];
  66604. constantAttenuation?: number;
  66605. linearAttenuation?: number;
  66606. quadraticAttenuation?: number;
  66607. }
  66608. /** @hidden */
  66609. export interface IGLTFSpotLight {
  66610. color?: number[];
  66611. constantAttenuation?: number;
  66612. fallOfAngle?: number;
  66613. fallOffExponent?: number;
  66614. linearAttenuation?: number;
  66615. quadraticAttenuation?: number;
  66616. }
  66617. /** @hidden */
  66618. export interface IGLTFLight extends IGLTFChildRootProperty {
  66619. type: string;
  66620. }
  66621. /** @hidden */
  66622. export interface IGLTFCameraOrthographic {
  66623. xmag: number;
  66624. ymag: number;
  66625. zfar: number;
  66626. znear: number;
  66627. }
  66628. /** @hidden */
  66629. export interface IGLTFCameraPerspective {
  66630. aspectRatio: number;
  66631. yfov: number;
  66632. zfar: number;
  66633. znear: number;
  66634. }
  66635. /** @hidden */
  66636. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66637. type: string;
  66638. }
  66639. /** @hidden */
  66640. export interface IGLTFAnimationChannelTarget {
  66641. id: string;
  66642. path: string;
  66643. }
  66644. /** @hidden */
  66645. export interface IGLTFAnimationChannel {
  66646. sampler: string;
  66647. target: IGLTFAnimationChannelTarget;
  66648. }
  66649. /** @hidden */
  66650. export interface IGLTFAnimationSampler {
  66651. input: string;
  66652. output: string;
  66653. interpolation?: string;
  66654. }
  66655. /** @hidden */
  66656. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66657. channels?: IGLTFAnimationChannel[];
  66658. parameters?: {
  66659. [key: string]: string;
  66660. };
  66661. samplers?: {
  66662. [key: string]: IGLTFAnimationSampler;
  66663. };
  66664. }
  66665. /** @hidden */
  66666. export interface IGLTFNodeInstanceSkin {
  66667. skeletons: string[];
  66668. skin: string;
  66669. meshes: string[];
  66670. }
  66671. /** @hidden */
  66672. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66673. bindShapeMatrix: number[];
  66674. inverseBindMatrices: string;
  66675. jointNames: string[];
  66676. babylonSkeleton?: Skeleton;
  66677. }
  66678. /** @hidden */
  66679. export interface IGLTFNode extends IGLTFChildRootProperty {
  66680. camera?: string;
  66681. children: string[];
  66682. skin?: string;
  66683. jointName?: string;
  66684. light?: string;
  66685. matrix: number[];
  66686. mesh?: string;
  66687. meshes?: string[];
  66688. rotation?: number[];
  66689. scale?: number[];
  66690. translation?: number[];
  66691. babylonNode?: Node;
  66692. }
  66693. /** @hidden */
  66694. export interface IGLTFScene extends IGLTFChildRootProperty {
  66695. nodes: string[];
  66696. }
  66697. /** @hidden */
  66698. export interface IGLTFRuntime {
  66699. extensions: {
  66700. [key: string]: any;
  66701. };
  66702. accessors: {
  66703. [key: string]: IGLTFAccessor;
  66704. };
  66705. buffers: {
  66706. [key: string]: IGLTFBuffer;
  66707. };
  66708. bufferViews: {
  66709. [key: string]: IGLTFBufferView;
  66710. };
  66711. meshes: {
  66712. [key: string]: IGLTFMesh;
  66713. };
  66714. lights: {
  66715. [key: string]: IGLTFLight;
  66716. };
  66717. cameras: {
  66718. [key: string]: IGLTFCamera;
  66719. };
  66720. nodes: {
  66721. [key: string]: IGLTFNode;
  66722. };
  66723. images: {
  66724. [key: string]: IGLTFImage;
  66725. };
  66726. textures: {
  66727. [key: string]: IGLTFTexture;
  66728. };
  66729. shaders: {
  66730. [key: string]: IGLTFShader;
  66731. };
  66732. programs: {
  66733. [key: string]: IGLTFProgram;
  66734. };
  66735. samplers: {
  66736. [key: string]: IGLTFSampler;
  66737. };
  66738. techniques: {
  66739. [key: string]: IGLTFTechnique;
  66740. };
  66741. materials: {
  66742. [key: string]: IGLTFMaterial;
  66743. };
  66744. animations: {
  66745. [key: string]: IGLTFAnimation;
  66746. };
  66747. skins: {
  66748. [key: string]: IGLTFSkins;
  66749. };
  66750. currentScene?: Object;
  66751. scenes: {
  66752. [key: string]: IGLTFScene;
  66753. };
  66754. extensionsUsed: string[];
  66755. extensionsRequired?: string[];
  66756. buffersCount: number;
  66757. shaderscount: number;
  66758. scene: Scene;
  66759. rootUrl: string;
  66760. loadedBufferCount: number;
  66761. loadedBufferViews: {
  66762. [name: string]: ArrayBufferView;
  66763. };
  66764. loadedShaderCount: number;
  66765. importOnlyMeshes: boolean;
  66766. importMeshesNames?: string[];
  66767. dummyNodes: Node[];
  66768. }
  66769. /** @hidden */
  66770. export interface INodeToRoot {
  66771. bone: Bone;
  66772. node: IGLTFNode;
  66773. id: string;
  66774. }
  66775. /** @hidden */
  66776. export interface IJointNode {
  66777. node: IGLTFNode;
  66778. id: string;
  66779. }
  66780. }
  66781. declare module BABYLON.GLTF1 {
  66782. /**
  66783. * Utils functions for GLTF
  66784. * @hidden
  66785. */
  66786. export class GLTFUtils {
  66787. /**
  66788. * Sets the given "parameter" matrix
  66789. * @param scene: the Scene object
  66790. * @param source: the source node where to pick the matrix
  66791. * @param parameter: the GLTF technique parameter
  66792. * @param uniformName: the name of the shader's uniform
  66793. * @param shaderMaterial: the shader material
  66794. */
  66795. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66796. /**
  66797. * Sets the given "parameter" matrix
  66798. * @param shaderMaterial: the shader material
  66799. * @param uniform: the name of the shader's uniform
  66800. * @param value: the value of the uniform
  66801. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66802. */
  66803. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66804. /**
  66805. * Returns the wrap mode of the texture
  66806. * @param mode: the mode value
  66807. */
  66808. static GetWrapMode(mode: number): number;
  66809. /**
  66810. * Returns the byte stride giving an accessor
  66811. * @param accessor: the GLTF accessor objet
  66812. */
  66813. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66814. /**
  66815. * Returns the texture filter mode giving a mode value
  66816. * @param mode: the filter mode value
  66817. */
  66818. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66819. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66820. /**
  66821. * Returns a buffer from its accessor
  66822. * @param gltfRuntime: the GLTF runtime
  66823. * @param accessor: the GLTF accessor
  66824. */
  66825. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66826. /**
  66827. * Decodes a buffer view into a string
  66828. * @param view: the buffer view
  66829. */
  66830. static DecodeBufferToText(view: ArrayBufferView): string;
  66831. /**
  66832. * Returns the default material of gltf. Related to
  66833. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66834. * @param scene: the Babylon.js scene
  66835. */
  66836. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66837. private static _DefaultMaterial;
  66838. }
  66839. }
  66840. declare module BABYLON.GLTF1 {
  66841. /**
  66842. * Implementation of the base glTF spec
  66843. * @hidden
  66844. */
  66845. export class GLTFLoaderBase {
  66846. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66847. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66848. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66849. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66850. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66851. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66852. }
  66853. /**
  66854. * glTF V1 Loader
  66855. * @hidden
  66856. */
  66857. export class GLTFLoader implements IGLTFLoader {
  66858. static Extensions: {
  66859. [name: string]: GLTFLoaderExtension;
  66860. };
  66861. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66862. state: Nullable<GLTFLoaderState>;
  66863. dispose(): void;
  66864. private _importMeshAsync;
  66865. /**
  66866. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66867. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66868. * @param scene the scene the meshes should be added to
  66869. * @param data gltf data containing information of the meshes in a loaded file
  66870. * @param rootUrl root url to load from
  66871. * @param onProgress event that fires when loading progress has occured
  66872. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66873. */
  66874. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66875. meshes: AbstractMesh[];
  66876. particleSystems: IParticleSystem[];
  66877. skeletons: Skeleton[];
  66878. animationGroups: AnimationGroup[];
  66879. }>;
  66880. private _loadAsync;
  66881. /**
  66882. * Imports all objects from a loaded gltf file and adds them to the scene
  66883. * @param scene the scene the objects should be added to
  66884. * @param data gltf data containing information of the meshes in a loaded file
  66885. * @param rootUrl root url to load from
  66886. * @param onProgress event that fires when loading progress has occured
  66887. * @returns a promise which completes when objects have been loaded to the scene
  66888. */
  66889. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66890. private _loadShadersAsync;
  66891. private _loadBuffersAsync;
  66892. private _createNodes;
  66893. }
  66894. /** @hidden */
  66895. export abstract class GLTFLoaderExtension {
  66896. private _name;
  66897. constructor(name: string);
  66898. readonly name: string;
  66899. /**
  66900. * Defines an override for loading the runtime
  66901. * Return true to stop further extensions from loading the runtime
  66902. */
  66903. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66904. /**
  66905. * Defines an onverride for creating gltf runtime
  66906. * Return true to stop further extensions from creating the runtime
  66907. */
  66908. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66909. /**
  66910. * Defines an override for loading buffers
  66911. * Return true to stop further extensions from loading this buffer
  66912. */
  66913. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66914. /**
  66915. * Defines an override for loading texture buffers
  66916. * Return true to stop further extensions from loading this texture data
  66917. */
  66918. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66919. /**
  66920. * Defines an override for creating textures
  66921. * Return true to stop further extensions from loading this texture
  66922. */
  66923. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66924. /**
  66925. * Defines an override for loading shader strings
  66926. * Return true to stop further extensions from loading this shader data
  66927. */
  66928. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66929. /**
  66930. * Defines an override for loading materials
  66931. * Return true to stop further extensions from loading this material
  66932. */
  66933. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66934. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66935. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66936. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66937. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66938. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66939. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66940. private static LoadTextureBufferAsync;
  66941. private static CreateTextureAsync;
  66942. private static ApplyExtensions;
  66943. }
  66944. }
  66945. declare module BABYLON.GLTF1 {
  66946. /** @hidden */
  66947. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66948. private _bin;
  66949. constructor();
  66950. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66951. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66952. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66953. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66954. }
  66955. }
  66956. declare module BABYLON.GLTF1 {
  66957. /** @hidden */
  66958. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66959. constructor();
  66960. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66961. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66962. private _loadTexture;
  66963. }
  66964. }
  66965. declare module BABYLON.GLTF2.Loader {
  66966. /**
  66967. * Loader interface with an index field.
  66968. */
  66969. export interface IArrayItem {
  66970. /**
  66971. * The index of this item in the array.
  66972. */
  66973. index: number;
  66974. }
  66975. /**
  66976. * Loader interface with additional members.
  66977. */
  66978. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66979. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66980. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  66981. }
  66982. /**
  66983. * Loader interface with additional members.
  66984. */
  66985. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66986. }
  66987. /** @hidden */
  66988. export interface _IAnimationSamplerData {
  66989. input: Float32Array;
  66990. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66991. output: Float32Array;
  66992. }
  66993. /**
  66994. * Loader interface with additional members.
  66995. */
  66996. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66997. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  66998. }
  66999. /**
  67000. * Loader interface with additional members.
  67001. */
  67002. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67003. channels: IAnimationChannel[];
  67004. samplers: IAnimationSampler[];
  67005. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  67006. }
  67007. /**
  67008. * Loader interface with additional members.
  67009. */
  67010. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67011. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67012. }
  67013. /**
  67014. * Loader interface with additional members.
  67015. */
  67016. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67017. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67018. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  67019. }
  67020. /**
  67021. * Loader interface with additional members.
  67022. */
  67023. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67024. }
  67025. /**
  67026. * Loader interface with additional members.
  67027. */
  67028. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67029. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67030. }
  67031. /**
  67032. * Loader interface with additional members.
  67033. */
  67034. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67035. }
  67036. /**
  67037. * Loader interface with additional members.
  67038. */
  67039. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67040. }
  67041. /**
  67042. * Loader interface with additional members.
  67043. */
  67044. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67045. baseColorTexture?: ITextureInfo;
  67046. metallicRoughnessTexture?: ITextureInfo;
  67047. }
  67048. /**
  67049. * Loader interface with additional members.
  67050. */
  67051. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67052. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67053. normalTexture?: IMaterialNormalTextureInfo;
  67054. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67055. emissiveTexture?: ITextureInfo;
  67056. /** @hidden */ private _data?: {
  67057. [babylonDrawMode: number]: {
  67058. babylonMaterial: Material;
  67059. babylonMeshes: AbstractMesh[];
  67060. promise: Promise<void>;
  67061. };
  67062. };
  67063. }
  67064. /**
  67065. * Loader interface with additional members.
  67066. */
  67067. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67068. primitives: IMeshPrimitive[];
  67069. }
  67070. /**
  67071. * Loader interface with additional members.
  67072. */
  67073. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67074. /** @hidden */ private _instanceData?: {
  67075. babylonSourceMesh: Mesh;
  67076. promise: Promise<any>;
  67077. };
  67078. }
  67079. /**
  67080. * Loader interface with additional members.
  67081. */
  67082. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67083. /**
  67084. * The parent glTF node.
  67085. */
  67086. parent?: INode;
  67087. /** @hidden */ private _babylonTransformNode?: TransformNode;
  67088. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  67089. /** @hidden */ private _babylonBones?: Bone[];
  67090. /** @hidden */ private _numMorphTargets?: number;
  67091. }
  67092. /** @hidden */
  67093. export interface _ISamplerData {
  67094. noMipMaps: boolean;
  67095. samplingMode: number;
  67096. wrapU: number;
  67097. wrapV: number;
  67098. }
  67099. /**
  67100. * Loader interface with additional members.
  67101. */
  67102. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67103. /** @hidden */ private _data?: _ISamplerData;
  67104. }
  67105. /**
  67106. * Loader interface with additional members.
  67107. */
  67108. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67109. }
  67110. /**
  67111. * Loader interface with additional members.
  67112. */
  67113. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67114. /** @hidden */ private _data?: {
  67115. babylonSkeleton: Skeleton;
  67116. promise: Promise<void>;
  67117. };
  67118. }
  67119. /**
  67120. * Loader interface with additional members.
  67121. */
  67122. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67123. }
  67124. /**
  67125. * Loader interface with additional members.
  67126. */
  67127. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67128. }
  67129. /**
  67130. * Loader interface with additional members.
  67131. */
  67132. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67133. accessors?: IAccessor[];
  67134. animations?: IAnimation[];
  67135. buffers?: IBuffer[];
  67136. bufferViews?: IBufferView[];
  67137. cameras?: ICamera[];
  67138. images?: IImage[];
  67139. materials?: IMaterial[];
  67140. meshes?: IMesh[];
  67141. nodes?: INode[];
  67142. samplers?: ISampler[];
  67143. scenes?: IScene[];
  67144. skins?: ISkin[];
  67145. textures?: ITexture[];
  67146. }
  67147. }
  67148. declare module BABYLON.GLTF2 {
  67149. /**
  67150. * Interface for a glTF loader extension.
  67151. */
  67152. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67153. /**
  67154. * Called after the loader state changes to LOADING.
  67155. */
  67156. onLoading?(): void;
  67157. /**
  67158. * Called after the loader state changes to READY.
  67159. */
  67160. onReady?(): void;
  67161. /**
  67162. * Define this method to modify the default behavior when loading scenes.
  67163. * @param context The context when loading the asset
  67164. * @param scene The glTF scene property
  67165. * @returns A promise that resolves when the load is complete or null if not handled
  67166. */
  67167. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67168. /**
  67169. * Define this method to modify the default behavior when loading nodes.
  67170. * @param context The context when loading the asset
  67171. * @param node The glTF node property
  67172. * @param assign A function called synchronously after parsing the glTF properties
  67173. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67174. */
  67175. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67176. /**
  67177. * Define this method to modify the default behavior when loading cameras.
  67178. * @param context The context when loading the asset
  67179. * @param camera The glTF camera property
  67180. * @param assign A function called synchronously after parsing the glTF properties
  67181. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67182. */
  67183. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67184. /**
  67185. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67186. * @param context The context when loading the asset
  67187. * @param primitive The glTF mesh primitive property
  67188. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67189. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67190. /**
  67191. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67192. * @param context The context when loading the asset
  67193. * @param name The mesh name when loading the asset
  67194. * @param node The glTF node when loading the asset
  67195. * @param mesh The glTF mesh when loading the asset
  67196. * @param primitive The glTF mesh primitive property
  67197. * @param assign A function called synchronously after parsing the glTF properties
  67198. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67199. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67200. /**
  67201. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67202. * @param context The context when loading the asset
  67203. * @param material The glTF material property
  67204. * @param assign A function called synchronously after parsing the glTF properties
  67205. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67206. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67207. /**
  67208. * Define this method to modify the default behavior when creating materials.
  67209. * @param context The context when loading the asset
  67210. * @param material The glTF material property
  67211. * @param babylonDrawMode The draw mode for the Babylon material
  67212. * @returns The Babylon material or null if not handled
  67213. */
  67214. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67215. /**
  67216. * Define this method to modify the default behavior when loading material properties.
  67217. * @param context The context when loading the asset
  67218. * @param material The glTF material property
  67219. * @param babylonMaterial The Babylon material
  67220. * @returns A promise that resolves when the load is complete or null if not handled
  67221. */
  67222. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67223. /**
  67224. * Define this method to modify the default behavior when loading texture infos.
  67225. * @param context The context when loading the asset
  67226. * @param textureInfo The glTF texture info property
  67227. * @param assign A function called synchronously after parsing the glTF properties
  67228. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67229. */
  67230. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67231. /**
  67232. * Define this method to modify the default behavior when loading animations.
  67233. * @param context The context when loading the asset
  67234. * @param animation The glTF animation property
  67235. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67236. */
  67237. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67238. /**
  67239. * @hidden Define this method to modify the default behavior when loading skins.
  67240. * @param context The context when loading the asset
  67241. * @param node The glTF node property
  67242. * @param skin The glTF skin property
  67243. * @returns A promise that resolves when the load is complete or null if not handled
  67244. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67245. /**
  67246. * @hidden Define this method to modify the default behavior when loading uris.
  67247. * @param context The context when loading the asset
  67248. * @param property The glTF property associated with the uri
  67249. * @param uri The uri to load
  67250. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67251. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67252. }
  67253. }
  67254. declare module BABYLON.GLTF2 {
  67255. /**
  67256. * Helper class for working with arrays when loading the glTF asset
  67257. */
  67258. export class ArrayItem {
  67259. /**
  67260. * Gets an item from the given array.
  67261. * @param context The context when loading the asset
  67262. * @param array The array to get the item from
  67263. * @param index The index to the array
  67264. * @returns The array item
  67265. */
  67266. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67267. /**
  67268. * Assign an `index` field to each item of the given array.
  67269. * @param array The array of items
  67270. */
  67271. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67272. }
  67273. /**
  67274. * The glTF 2.0 loader
  67275. */
  67276. export class GLTFLoader implements IGLTFLoader {
  67277. /** @hidden */ private _completePromises: Promise<any>[];
  67278. private _disposed;
  67279. private _parent;
  67280. private _state;
  67281. private _extensions;
  67282. private _rootUrl;
  67283. private _fileName;
  67284. private _uniqueRootUrl;
  67285. private _gltf;
  67286. private _babylonScene;
  67287. private _rootBabylonMesh;
  67288. private _defaultBabylonMaterialData;
  67289. private _progressCallback?;
  67290. private _requests;
  67291. private static readonly _DefaultSampler;
  67292. private static _ExtensionNames;
  67293. private static _ExtensionFactories;
  67294. /**
  67295. * Registers a loader extension.
  67296. * @param name The name of the loader extension.
  67297. * @param factory The factory function that creates the loader extension.
  67298. */
  67299. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67300. /**
  67301. * Unregisters a loader extension.
  67302. * @param name The name of the loader extenion.
  67303. * @returns A boolean indicating whether the extension has been unregistered
  67304. */
  67305. static UnregisterExtension(name: string): boolean;
  67306. /**
  67307. * Gets the loader state.
  67308. */
  67309. readonly state: Nullable<GLTFLoaderState>;
  67310. /**
  67311. * The glTF object parsed from the JSON.
  67312. */
  67313. readonly gltf: IGLTF;
  67314. /**
  67315. * The Babylon scene when loading the asset.
  67316. */
  67317. readonly babylonScene: Scene;
  67318. /**
  67319. * The root Babylon mesh when loading the asset.
  67320. */
  67321. readonly rootBabylonMesh: Mesh;
  67322. /** @hidden */
  67323. constructor(parent: GLTFFileLoader);
  67324. /** @hidden */
  67325. dispose(): void;
  67326. /** @hidden */
  67327. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67328. meshes: AbstractMesh[];
  67329. particleSystems: IParticleSystem[];
  67330. skeletons: Skeleton[];
  67331. animationGroups: AnimationGroup[];
  67332. }>;
  67333. /** @hidden */
  67334. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67335. private _loadAsync;
  67336. private _loadData;
  67337. private _setupData;
  67338. private _loadExtensions;
  67339. private _checkExtensions;
  67340. private _setState;
  67341. private _createRootNode;
  67342. /**
  67343. * Loads a glTF scene.
  67344. * @param context The context when loading the asset
  67345. * @param scene The glTF scene property
  67346. * @returns A promise that resolves when the load is complete
  67347. */
  67348. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67349. private _forEachPrimitive;
  67350. private _getMeshes;
  67351. private _getSkeletons;
  67352. private _getAnimationGroups;
  67353. private _startAnimations;
  67354. /**
  67355. * Loads a glTF node.
  67356. * @param context The context when loading the asset
  67357. * @param node The glTF node property
  67358. * @param assign A function called synchronously after parsing the glTF properties
  67359. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67360. */
  67361. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67362. private _loadMeshAsync;
  67363. /**
  67364. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67365. * @param context The context when loading the asset
  67366. * @param name The mesh name when loading the asset
  67367. * @param node The glTF node when loading the asset
  67368. * @param mesh The glTF mesh when loading the asset
  67369. * @param primitive The glTF mesh primitive property
  67370. * @param assign A function called synchronously after parsing the glTF properties
  67371. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67372. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67373. private _loadVertexDataAsync;
  67374. private _createMorphTargets;
  67375. private _loadMorphTargetsAsync;
  67376. private _loadMorphTargetVertexDataAsync;
  67377. private static _LoadTransform;
  67378. private _loadSkinAsync;
  67379. private _loadBones;
  67380. private _loadBone;
  67381. private _loadSkinInverseBindMatricesDataAsync;
  67382. private _updateBoneMatrices;
  67383. private _getNodeMatrix;
  67384. /**
  67385. * Loads a glTF camera.
  67386. * @param context The context when loading the asset
  67387. * @param camera The glTF camera property
  67388. * @param assign A function called synchronously after parsing the glTF properties
  67389. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67390. */
  67391. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67392. private _loadAnimationsAsync;
  67393. /**
  67394. * Loads a glTF animation.
  67395. * @param context The context when loading the asset
  67396. * @param animation The glTF animation property
  67397. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67398. */
  67399. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67400. /**
  67401. * @hidden Loads a glTF animation channel.
  67402. * @param context The context when loading the asset
  67403. * @param animationContext The context of the animation when loading the asset
  67404. * @param animation The glTF animation property
  67405. * @param channel The glTF animation channel property
  67406. * @param babylonAnimationGroup The babylon animation group property
  67407. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67408. * @returns A void promise when the channel load is complete
  67409. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67410. private _loadAnimationSamplerAsync;
  67411. private _loadBufferAsync;
  67412. /**
  67413. * Loads a glTF buffer view.
  67414. * @param context The context when loading the asset
  67415. * @param bufferView The glTF buffer view property
  67416. * @returns A promise that resolves with the loaded data when the load is complete
  67417. */
  67418. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67419. private _loadAccessorAsync;
  67420. private _loadFloatAccessorAsync;
  67421. private _loadIndicesAccessorAsync;
  67422. private _loadVertexBufferViewAsync;
  67423. private _loadVertexAccessorAsync;
  67424. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67425. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67426. private _createDefaultMaterial;
  67427. /**
  67428. * Creates a Babylon material from a glTF material.
  67429. * @param context The context when loading the asset
  67430. * @param material The glTF material property
  67431. * @param babylonDrawMode The draw mode for the Babylon material
  67432. * @returns The Babylon material
  67433. */
  67434. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67435. /**
  67436. * Loads properties from a glTF material into a Babylon material.
  67437. * @param context The context when loading the asset
  67438. * @param material The glTF material property
  67439. * @param babylonMaterial The Babylon material
  67440. * @returns A promise that resolves when the load is complete
  67441. */
  67442. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67443. /**
  67444. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67445. * @param context The context when loading the asset
  67446. * @param material The glTF material property
  67447. * @param babylonMaterial The Babylon material
  67448. * @returns A promise that resolves when the load is complete
  67449. */
  67450. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67451. /**
  67452. * Loads the alpha properties from a glTF material into a Babylon material.
  67453. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67454. * @param context The context when loading the asset
  67455. * @param material The glTF material property
  67456. * @param babylonMaterial The Babylon material
  67457. */
  67458. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67459. /**
  67460. * Loads a glTF texture info.
  67461. * @param context The context when loading the asset
  67462. * @param textureInfo The glTF texture info property
  67463. * @param assign A function called synchronously after parsing the glTF properties
  67464. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67465. */
  67466. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67467. private _loadTextureAsync;
  67468. private _loadSampler;
  67469. /**
  67470. * Loads a glTF image.
  67471. * @param context The context when loading the asset
  67472. * @param image The glTF image property
  67473. * @returns A promise that resolves with the loaded data when the load is complete
  67474. */
  67475. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67476. /**
  67477. * Loads a glTF uri.
  67478. * @param context The context when loading the asset
  67479. * @param property The glTF property associated with the uri
  67480. * @param uri The base64 or relative uri
  67481. * @returns A promise that resolves with the loaded data when the load is complete
  67482. */
  67483. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67484. private _onProgress;
  67485. /**
  67486. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67487. * @param babylonObject the Babylon object with metadata
  67488. * @param pointer the JSON pointer
  67489. */
  67490. static AddPointerMetadata(babylonObject: {
  67491. metadata: any;
  67492. }, pointer: string): void;
  67493. private static _GetTextureWrapMode;
  67494. private static _GetTextureSamplingMode;
  67495. private static _GetTypedArrayConstructor;
  67496. private static _GetTypedArray;
  67497. private static _GetNumComponents;
  67498. private static _ValidateUri;
  67499. private static _GetDrawMode;
  67500. private _compileMaterialsAsync;
  67501. private _compileShadowGeneratorsAsync;
  67502. private _forEachExtensions;
  67503. private _applyExtensions;
  67504. private _extensionsOnLoading;
  67505. private _extensionsOnReady;
  67506. private _extensionsLoadSceneAsync;
  67507. private _extensionsLoadNodeAsync;
  67508. private _extensionsLoadCameraAsync;
  67509. private _extensionsLoadVertexDataAsync;
  67510. private _extensionsLoadMeshPrimitiveAsync;
  67511. private _extensionsLoadMaterialAsync;
  67512. private _extensionsCreateMaterial;
  67513. private _extensionsLoadMaterialPropertiesAsync;
  67514. private _extensionsLoadTextureInfoAsync;
  67515. private _extensionsLoadAnimationAsync;
  67516. private _extensionsLoadSkinAsync;
  67517. private _extensionsLoadUriAsync;
  67518. /**
  67519. * Helper method called by a loader extension to load an glTF extension.
  67520. * @param context The context when loading the asset
  67521. * @param property The glTF property to load the extension from
  67522. * @param extensionName The name of the extension to load
  67523. * @param actionAsync The action to run
  67524. * @returns The promise returned by actionAsync or null if the extension does not exist
  67525. */
  67526. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67527. /**
  67528. * Helper method called by a loader extension to load a glTF extra.
  67529. * @param context The context when loading the asset
  67530. * @param property The glTF property to load the extra from
  67531. * @param extensionName The name of the extension to load
  67532. * @param actionAsync The action to run
  67533. * @returns The promise returned by actionAsync or null if the extra does not exist
  67534. */
  67535. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67536. /**
  67537. * Increments the indentation level and logs a message.
  67538. * @param message The message to log
  67539. */
  67540. logOpen(message: string): void;
  67541. /**
  67542. * Decrements the indentation level.
  67543. */
  67544. logClose(): void;
  67545. /**
  67546. * Logs a message
  67547. * @param message The message to log
  67548. */
  67549. log(message: string): void;
  67550. /**
  67551. * Starts a performance counter.
  67552. * @param counterName The name of the performance counter
  67553. */
  67554. startPerformanceCounter(counterName: string): void;
  67555. /**
  67556. * Ends a performance counter.
  67557. * @param counterName The name of the performance counter
  67558. */
  67559. endPerformanceCounter(counterName: string): void;
  67560. }
  67561. }
  67562. declare module BABYLON.GLTF2.Loader.Extensions {
  67563. /**
  67564. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67565. */
  67566. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67567. /** The name of this extension. */
  67568. readonly name: string;
  67569. /** Defines whether this extension is enabled. */
  67570. enabled: boolean;
  67571. private _loader;
  67572. private _lights?;
  67573. /** @hidden */
  67574. constructor(loader: GLTFLoader);
  67575. /** @hidden */
  67576. dispose(): void;
  67577. /** @hidden */
  67578. onLoading(): void;
  67579. /** @hidden */
  67580. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67581. private _loadLightAsync;
  67582. }
  67583. }
  67584. declare module BABYLON.GLTF2.Loader.Extensions {
  67585. /**
  67586. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67587. */
  67588. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67589. /** The name of this extension. */
  67590. readonly name: string;
  67591. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67592. dracoCompression?: DracoCompression;
  67593. /** Defines whether this extension is enabled. */
  67594. enabled: boolean;
  67595. private _loader;
  67596. /** @hidden */
  67597. constructor(loader: GLTFLoader);
  67598. /** @hidden */
  67599. dispose(): void;
  67600. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67601. }
  67602. }
  67603. declare module BABYLON.GLTF2.Loader.Extensions {
  67604. /**
  67605. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67606. */
  67607. export class KHR_lights implements IGLTFLoaderExtension {
  67608. /** The name of this extension. */
  67609. readonly name: string;
  67610. /** Defines whether this extension is enabled. */
  67611. enabled: boolean;
  67612. private _loader;
  67613. private _lights?;
  67614. /** @hidden */
  67615. constructor(loader: GLTFLoader);
  67616. /** @hidden */
  67617. dispose(): void;
  67618. /** @hidden */
  67619. onLoading(): void;
  67620. /** @hidden */
  67621. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67622. }
  67623. }
  67624. declare module BABYLON.GLTF2.Loader.Extensions {
  67625. /**
  67626. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67627. */
  67628. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67629. /** The name of this extension. */
  67630. readonly name: string;
  67631. /** Defines whether this extension is enabled. */
  67632. enabled: boolean;
  67633. private _loader;
  67634. /** @hidden */
  67635. constructor(loader: GLTFLoader);
  67636. /** @hidden */
  67637. dispose(): void;
  67638. /** @hidden */
  67639. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67640. private _loadSpecularGlossinessPropertiesAsync;
  67641. }
  67642. }
  67643. declare module BABYLON.GLTF2.Loader.Extensions {
  67644. /**
  67645. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67646. */
  67647. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67648. /** The name of this extension. */
  67649. readonly name: string;
  67650. /** Defines whether this extension is enabled. */
  67651. enabled: boolean;
  67652. private _loader;
  67653. /** @hidden */
  67654. constructor(loader: GLTFLoader);
  67655. /** @hidden */
  67656. dispose(): void;
  67657. /** @hidden */
  67658. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67659. private _loadUnlitPropertiesAsync;
  67660. }
  67661. }
  67662. declare module BABYLON.GLTF2.Loader.Extensions {
  67663. /**
  67664. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67665. */
  67666. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67667. /** The name of this extension. */
  67668. readonly name: string;
  67669. /** Defines whether this extension is enabled. */
  67670. enabled: boolean;
  67671. private _loader;
  67672. /** @hidden */
  67673. constructor(loader: GLTFLoader);
  67674. /** @hidden */
  67675. dispose(): void;
  67676. /** @hidden */
  67677. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67678. }
  67679. }
  67680. declare module BABYLON.GLTF2.Loader.Extensions {
  67681. /**
  67682. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67683. */
  67684. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67685. /** The name of this extension. */
  67686. readonly name: string;
  67687. /** Defines whether this extension is enabled. */
  67688. enabled: boolean;
  67689. private _loader;
  67690. private _clips;
  67691. private _emitters;
  67692. /** @hidden */
  67693. constructor(loader: GLTFLoader);
  67694. /** @hidden */
  67695. dispose(): void;
  67696. /** @hidden */
  67697. onLoading(): void;
  67698. /** @hidden */
  67699. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67700. /** @hidden */
  67701. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67702. /** @hidden */
  67703. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67704. private _loadClipAsync;
  67705. private _loadEmitterAsync;
  67706. private _getEventAction;
  67707. private _loadAnimationEventAsync;
  67708. }
  67709. }
  67710. declare module BABYLON.GLTF2.Loader.Extensions {
  67711. /**
  67712. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67713. */
  67714. export class MSFT_lod implements IGLTFLoaderExtension {
  67715. /** The name of this extension. */
  67716. readonly name: string;
  67717. /** Defines whether this extension is enabled. */
  67718. enabled: boolean;
  67719. /**
  67720. * Maximum number of LODs to load, starting from the lowest LOD.
  67721. */
  67722. maxLODsToLoad: number;
  67723. /**
  67724. * Observable raised when all node LODs of one level are loaded.
  67725. * The event data is the index of the loaded LOD starting from zero.
  67726. * Dispose the loader to cancel the loading of the next level of LODs.
  67727. */
  67728. onNodeLODsLoadedObservable: Observable<number>;
  67729. /**
  67730. * Observable raised when all material LODs of one level are loaded.
  67731. * The event data is the index of the loaded LOD starting from zero.
  67732. * Dispose the loader to cancel the loading of the next level of LODs.
  67733. */
  67734. onMaterialLODsLoadedObservable: Observable<number>;
  67735. private _loader;
  67736. private _nodeIndexLOD;
  67737. private _nodeSignalLODs;
  67738. private _nodePromiseLODs;
  67739. private _materialIndexLOD;
  67740. private _materialSignalLODs;
  67741. private _materialPromiseLODs;
  67742. /** @hidden */
  67743. constructor(loader: GLTFLoader);
  67744. /** @hidden */
  67745. dispose(): void;
  67746. /** @hidden */
  67747. onReady(): void;
  67748. /** @hidden */
  67749. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67750. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67751. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67752. /**
  67753. * Gets an array of LOD properties from lowest to highest.
  67754. */
  67755. private _getLODs;
  67756. private _disposeUnusedMaterials;
  67757. }
  67758. }
  67759. declare module BABYLON.GLTF2.Loader.Extensions {
  67760. /** @hidden */
  67761. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67762. readonly name: string;
  67763. enabled: boolean;
  67764. private _loader;
  67765. constructor(loader: GLTFLoader);
  67766. dispose(): void;
  67767. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67768. }
  67769. }
  67770. declare module BABYLON.GLTF2.Loader.Extensions {
  67771. /** @hidden */
  67772. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67773. readonly name: string;
  67774. enabled: boolean;
  67775. private _loader;
  67776. constructor(loader: GLTFLoader);
  67777. dispose(): void;
  67778. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67779. }
  67780. }
  67781. declare module BABYLON.GLTF2.Loader.Extensions {
  67782. /**
  67783. * Store glTF extras (if present) in BJS objects' metadata
  67784. */
  67785. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67786. /** The name of this extension. */
  67787. readonly name: string;
  67788. /** Defines whether this extension is enabled. */
  67789. enabled: boolean;
  67790. private _loader;
  67791. private _assignExtras;
  67792. /** @hidden */
  67793. constructor(loader: GLTFLoader);
  67794. /** @hidden */
  67795. dispose(): void;
  67796. /** @hidden */
  67797. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67798. /** @hidden */
  67799. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67800. /** @hidden */
  67801. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67802. }
  67803. }
  67804. declare module BABYLON {
  67805. /**
  67806. * Class reading and parsing the MTL file bundled with the obj file.
  67807. */
  67808. export class MTLFileLoader {
  67809. /**
  67810. * All material loaded from the mtl will be set here
  67811. */
  67812. materials: StandardMaterial[];
  67813. /**
  67814. * This function will read the mtl file and create each material described inside
  67815. * This function could be improve by adding :
  67816. * -some component missing (Ni, Tf...)
  67817. * -including the specific options available
  67818. *
  67819. * @param scene defines the scene the material will be created in
  67820. * @param data defines the mtl data to parse
  67821. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67822. */
  67823. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67824. /**
  67825. * Gets the texture for the material.
  67826. *
  67827. * If the material is imported from input file,
  67828. * We sanitize the url to ensure it takes the textre from aside the material.
  67829. *
  67830. * @param rootUrl The root url to load from
  67831. * @param value The value stored in the mtl
  67832. * @return The Texture
  67833. */
  67834. private static _getTexture;
  67835. }
  67836. /**
  67837. * Options for loading OBJ/MTL files
  67838. */
  67839. type MeshLoadOptions = {
  67840. /**
  67841. * Defines if UVs are optimized by default during load.
  67842. */
  67843. OptimizeWithUV: boolean;
  67844. /**
  67845. * Defines custom scaling of UV coordinates of loaded meshes.
  67846. */
  67847. UVScaling: Vector2;
  67848. /**
  67849. * Invert model on y-axis (does a model scaling inversion)
  67850. */
  67851. InvertY: boolean;
  67852. /**
  67853. * Invert Y-Axis of referenced textures on load
  67854. */
  67855. InvertTextureY: boolean;
  67856. /**
  67857. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67858. */
  67859. ImportVertexColors: boolean;
  67860. /**
  67861. * Compute the normals for the model, even if normals are present in the file.
  67862. */
  67863. ComputeNormals: boolean;
  67864. /**
  67865. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67866. */
  67867. SkipMaterials: boolean;
  67868. /**
  67869. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67870. */
  67871. MaterialLoadingFailsSilently: boolean;
  67872. };
  67873. /**
  67874. * OBJ file type loader.
  67875. * This is a babylon scene loader plugin.
  67876. */
  67877. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67878. /**
  67879. * Defines if UVs are optimized by default during load.
  67880. */
  67881. static OPTIMIZE_WITH_UV: boolean;
  67882. /**
  67883. * Invert model on y-axis (does a model scaling inversion)
  67884. */
  67885. static INVERT_Y: boolean;
  67886. /**
  67887. * Invert Y-Axis of referenced textures on load
  67888. */
  67889. static INVERT_TEXTURE_Y: boolean;
  67890. /**
  67891. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67892. */
  67893. static IMPORT_VERTEX_COLORS: boolean;
  67894. /**
  67895. * Compute the normals for the model, even if normals are present in the file.
  67896. */
  67897. static COMPUTE_NORMALS: boolean;
  67898. /**
  67899. * Defines custom scaling of UV coordinates of loaded meshes.
  67900. */
  67901. static UV_SCALING: Vector2;
  67902. /**
  67903. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67904. */
  67905. static SKIP_MATERIALS: boolean;
  67906. /**
  67907. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67908. *
  67909. * Defaults to true for backwards compatibility.
  67910. */
  67911. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67912. /**
  67913. * Defines the name of the plugin.
  67914. */
  67915. name: string;
  67916. /**
  67917. * Defines the extension the plugin is able to load.
  67918. */
  67919. extensions: string;
  67920. /** @hidden */
  67921. obj: RegExp;
  67922. /** @hidden */
  67923. group: RegExp;
  67924. /** @hidden */
  67925. mtllib: RegExp;
  67926. /** @hidden */
  67927. usemtl: RegExp;
  67928. /** @hidden */
  67929. smooth: RegExp;
  67930. /** @hidden */
  67931. vertexPattern: RegExp;
  67932. /** @hidden */
  67933. normalPattern: RegExp;
  67934. /** @hidden */
  67935. uvPattern: RegExp;
  67936. /** @hidden */
  67937. facePattern1: RegExp;
  67938. /** @hidden */
  67939. facePattern2: RegExp;
  67940. /** @hidden */
  67941. facePattern3: RegExp;
  67942. /** @hidden */
  67943. facePattern4: RegExp;
  67944. /** @hidden */
  67945. facePattern5: RegExp;
  67946. private _meshLoadOptions;
  67947. /**
  67948. * Creates loader for .OBJ files
  67949. *
  67950. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67951. */
  67952. constructor(meshLoadOptions?: MeshLoadOptions);
  67953. private static readonly currentMeshLoadOptions;
  67954. /**
  67955. * Calls synchronously the MTL file attached to this obj.
  67956. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67957. * Without this function materials are not displayed in the first frame (but displayed after).
  67958. * In consequence it is impossible to get material information in your HTML file
  67959. *
  67960. * @param url The URL of the MTL file
  67961. * @param rootUrl
  67962. * @param onSuccess Callback function to be called when the MTL file is loaded
  67963. * @private
  67964. */
  67965. private _loadMTL;
  67966. /**
  67967. * Instantiates a OBJ file loader plugin.
  67968. * @returns the created plugin
  67969. */
  67970. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67971. /**
  67972. * If the data string can be loaded directly.
  67973. *
  67974. * @param data string containing the file data
  67975. * @returns if the data can be loaded directly
  67976. */
  67977. canDirectLoad(data: string): boolean;
  67978. /**
  67979. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67980. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67981. * @param scene the scene the meshes should be added to
  67982. * @param data the OBJ data to load
  67983. * @param rootUrl root url to load from
  67984. * @param onProgress event that fires when loading progress has occured
  67985. * @param fileName Defines the name of the file to load
  67986. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67987. */
  67988. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67989. meshes: AbstractMesh[];
  67990. particleSystems: IParticleSystem[];
  67991. skeletons: Skeleton[];
  67992. animationGroups: AnimationGroup[];
  67993. }>;
  67994. /**
  67995. * Imports all objects from the loaded OBJ data and adds them to the scene
  67996. * @param scene the scene the objects should be added to
  67997. * @param data the OBJ data to load
  67998. * @param rootUrl root url to load from
  67999. * @param onProgress event that fires when loading progress has occured
  68000. * @param fileName Defines the name of the file to load
  68001. * @returns a promise which completes when objects have been loaded to the scene
  68002. */
  68003. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68004. /**
  68005. * Load into an asset container.
  68006. * @param scene The scene to load into
  68007. * @param data The data to import
  68008. * @param rootUrl The root url for scene and resources
  68009. * @param onProgress The callback when the load progresses
  68010. * @param fileName Defines the name of the file to load
  68011. * @returns The loaded asset container
  68012. */
  68013. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68014. /**
  68015. * Read the OBJ file and create an Array of meshes.
  68016. * Each mesh contains all information given by the OBJ and the MTL file.
  68017. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68018. *
  68019. * @param meshesNames
  68020. * @param scene Scene The scene where are displayed the data
  68021. * @param data String The content of the obj file
  68022. * @param rootUrl String The path to the folder
  68023. * @returns Array<AbstractMesh>
  68024. * @private
  68025. */
  68026. private _parseSolid;
  68027. }
  68028. }
  68029. declare module BABYLON {
  68030. /**
  68031. * STL file type loader.
  68032. * This is a babylon scene loader plugin.
  68033. */
  68034. export class STLFileLoader implements ISceneLoaderPlugin {
  68035. /** @hidden */
  68036. solidPattern: RegExp;
  68037. /** @hidden */
  68038. facetsPattern: RegExp;
  68039. /** @hidden */
  68040. normalPattern: RegExp;
  68041. /** @hidden */
  68042. vertexPattern: RegExp;
  68043. /**
  68044. * Defines the name of the plugin.
  68045. */
  68046. name: string;
  68047. /**
  68048. * Defines the extensions the stl loader is able to load.
  68049. * force data to come in as an ArrayBuffer
  68050. * we'll convert to string if it looks like it's an ASCII .stl
  68051. */
  68052. extensions: ISceneLoaderPluginExtensions;
  68053. /**
  68054. * Import meshes into a scene.
  68055. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68056. * @param scene The scene to import into
  68057. * @param data The data to import
  68058. * @param rootUrl The root url for scene and resources
  68059. * @param meshes The meshes array to import into
  68060. * @param particleSystems The particle systems array to import into
  68061. * @param skeletons The skeletons array to import into
  68062. * @param onError The callback when import fails
  68063. * @returns True if successful or false otherwise
  68064. */
  68065. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68066. /**
  68067. * Load into a scene.
  68068. * @param scene The scene to load into
  68069. * @param data The data to import
  68070. * @param rootUrl The root url for scene and resources
  68071. * @param onError The callback when import fails
  68072. * @returns true if successful or false otherwise
  68073. */
  68074. load(scene: Scene, data: any, rootUrl: string): boolean;
  68075. /**
  68076. * Load into an asset container.
  68077. * @param scene The scene to load into
  68078. * @param data The data to import
  68079. * @param rootUrl The root url for scene and resources
  68080. * @param onError The callback when import fails
  68081. * @returns The loaded asset container
  68082. */
  68083. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68084. private _isBinary;
  68085. private _parseBinary;
  68086. private _parseASCII;
  68087. }
  68088. }
  68089. declare module BABYLON {
  68090. /**
  68091. * Class for generating OBJ data from a Babylon scene.
  68092. */
  68093. export class OBJExport {
  68094. /**
  68095. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68096. * @param mesh defines the list of meshes to serialize
  68097. * @param materials defines if materials should be exported
  68098. * @param matlibname defines the name of the associated mtl file
  68099. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68100. * @returns the OBJ content
  68101. */
  68102. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68103. /**
  68104. * Exports the material(s) of a mesh in .MTL file format (text)
  68105. * @param mesh defines the mesh to extract the material from
  68106. * @returns the mtl content
  68107. */
  68108. static MTL(mesh: Mesh): string;
  68109. }
  68110. }
  68111. declare module BABYLON {
  68112. /** @hidden */
  68113. export var __IGLTFExporterExtension: number;
  68114. /**
  68115. * Interface for extending the exporter
  68116. * @hidden
  68117. */
  68118. export interface IGLTFExporterExtension {
  68119. /**
  68120. * The name of this extension
  68121. */
  68122. readonly name: string;
  68123. /**
  68124. * Defines whether this extension is enabled
  68125. */
  68126. enabled: boolean;
  68127. /**
  68128. * Defines whether this extension is required
  68129. */
  68130. required: boolean;
  68131. }
  68132. }
  68133. declare module BABYLON.GLTF2.Exporter {
  68134. /** @hidden */
  68135. export var __IGLTFExporterExtensionV2: number;
  68136. /**
  68137. * Interface for a glTF exporter extension
  68138. * @hidden
  68139. */
  68140. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68141. /**
  68142. * Define this method to modify the default behavior before exporting a texture
  68143. * @param context The context when loading the asset
  68144. * @param babylonTexture The glTF texture info property
  68145. * @param mimeType The mime-type of the generated image
  68146. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68147. */
  68148. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68149. /**
  68150. * Define this method to modify the default behavior when exporting texture info
  68151. * @param context The context when loading the asset
  68152. * @param meshPrimitive glTF mesh primitive
  68153. * @param babylonSubMesh Babylon submesh
  68154. * @param binaryWriter glTF serializer binary writer instance
  68155. * @returns nullable IMeshPrimitive promise
  68156. */
  68157. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68158. /**
  68159. * Define this method to modify the default behavior when exporting a node
  68160. * @param context The context when exporting the node
  68161. * @param node glTF node
  68162. * @param babylonNode BabylonJS node
  68163. * @returns nullable INode promise
  68164. */
  68165. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68166. /**
  68167. * Called after the exporter state changes to EXPORTING
  68168. */
  68169. onExporting?(): void;
  68170. }
  68171. }
  68172. declare module BABYLON.GLTF2.Exporter {
  68173. /**
  68174. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68175. * @hidden
  68176. */
  68177. export class _GLTFMaterialExporter {
  68178. /**
  68179. * Represents the dielectric specular values for R, G and B
  68180. */
  68181. private static readonly _DielectricSpecular;
  68182. /**
  68183. * Allows the maximum specular power to be defined for material calculations
  68184. */
  68185. private static readonly _MaxSpecularPower;
  68186. /**
  68187. * Mapping to store textures
  68188. */
  68189. private _textureMap;
  68190. /**
  68191. * Numeric tolerance value
  68192. */
  68193. private static readonly _Epsilon;
  68194. /**
  68195. * Reference to the glTF Exporter
  68196. */
  68197. private _exporter;
  68198. constructor(exporter: _Exporter);
  68199. /**
  68200. * Specifies if two colors are approximately equal in value
  68201. * @param color1 first color to compare to
  68202. * @param color2 second color to compare to
  68203. * @param epsilon threshold value
  68204. */
  68205. private static FuzzyEquals;
  68206. /**
  68207. * Gets the materials from a Babylon scene and converts them to glTF materials
  68208. * @param scene babylonjs scene
  68209. * @param mimeType texture mime type
  68210. * @param images array of images
  68211. * @param textures array of textures
  68212. * @param materials array of materials
  68213. * @param imageData mapping of texture names to base64 textures
  68214. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68215. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68216. /**
  68217. * Makes a copy of the glTF material without the texture parameters
  68218. * @param originalMaterial original glTF material
  68219. * @returns glTF material without texture parameters
  68220. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68221. /**
  68222. * Specifies if the material has any texture parameters present
  68223. * @param material glTF Material
  68224. * @returns boolean specifying if texture parameters are present
  68225. */ private _hasTexturesPresent(material: IMaterial): boolean;
  68226. /**
  68227. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68228. * @param babylonStandardMaterial
  68229. * @returns glTF Metallic Roughness Material representation
  68230. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68231. /**
  68232. * Computes the metallic factor
  68233. * @param diffuse diffused value
  68234. * @param specular specular value
  68235. * @param oneMinusSpecularStrength one minus the specular strength
  68236. * @returns metallic value
  68237. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68238. /**
  68239. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68240. * @param glTFMaterial glTF material
  68241. * @param babylonMaterial Babylon material
  68242. */
  68243. private static _SetAlphaMode;
  68244. /**
  68245. * Converts a Babylon Standard Material to a glTF Material
  68246. * @param babylonStandardMaterial BJS Standard Material
  68247. * @param mimeType mime type to use for the textures
  68248. * @param images array of glTF image interfaces
  68249. * @param textures array of glTF texture interfaces
  68250. * @param materials array of glTF material interfaces
  68251. * @param imageData map of image file name to data
  68252. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68253. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68254. /**
  68255. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68256. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68257. * @param mimeType mime type to use for the textures
  68258. * @param images array of glTF image interfaces
  68259. * @param textures array of glTF texture interfaces
  68260. * @param materials array of glTF material interfaces
  68261. * @param imageData map of image file name to data
  68262. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68263. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68264. /**
  68265. * Converts an image typed array buffer to a base64 image
  68266. * @param buffer typed array buffer
  68267. * @param width width of the image
  68268. * @param height height of the image
  68269. * @param mimeType mimetype of the image
  68270. * @returns base64 image string
  68271. */
  68272. private _createBase64FromCanvasAsync;
  68273. /**
  68274. * Generates a white texture based on the specified width and height
  68275. * @param width width of the texture in pixels
  68276. * @param height height of the texture in pixels
  68277. * @param scene babylonjs scene
  68278. * @returns white texture
  68279. */
  68280. private _createWhiteTexture;
  68281. /**
  68282. * 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
  68283. * @param texture1 first texture to resize
  68284. * @param texture2 second texture to resize
  68285. * @param scene babylonjs scene
  68286. * @returns resized textures or null
  68287. */
  68288. private _resizeTexturesToSameDimensions;
  68289. /**
  68290. * Converts an array of pixels to a Float32Array
  68291. * Throws an error if the pixel format is not supported
  68292. * @param pixels - array buffer containing pixel values
  68293. * @returns Float32 of pixels
  68294. */
  68295. private _convertPixelArrayToFloat32;
  68296. /**
  68297. * Convert Specular Glossiness Textures to Metallic Roughness
  68298. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68299. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68300. * @param diffuseTexture texture used to store diffuse information
  68301. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68302. * @param factors specular glossiness material factors
  68303. * @param mimeType the mime type to use for the texture
  68304. * @returns pbr metallic roughness interface or null
  68305. */
  68306. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68307. /**
  68308. * Converts specular glossiness material properties to metallic roughness
  68309. * @param specularGlossiness interface with specular glossiness material properties
  68310. * @returns interface with metallic roughness material properties
  68311. */
  68312. private _convertSpecularGlossinessToMetallicRoughness;
  68313. /**
  68314. * Calculates the surface reflectance, independent of lighting conditions
  68315. * @param color Color source to calculate brightness from
  68316. * @returns number representing the perceived brightness, or zero if color is undefined
  68317. */
  68318. private _getPerceivedBrightness;
  68319. /**
  68320. * Returns the maximum color component value
  68321. * @param color
  68322. * @returns maximum color component value, or zero if color is null or undefined
  68323. */
  68324. private _getMaxComponent;
  68325. /**
  68326. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68327. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68328. * @param mimeType mime type to use for the textures
  68329. * @param images array of glTF image interfaces
  68330. * @param textures array of glTF texture interfaces
  68331. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68332. * @param imageData map of image file name to data
  68333. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68334. * @returns glTF PBR Metallic Roughness factors
  68335. */
  68336. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68337. private _getGLTFTextureSampler;
  68338. private _getGLTFTextureWrapMode;
  68339. private _getGLTFTextureWrapModesSampler;
  68340. /**
  68341. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68342. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68343. * @param mimeType mime type to use for the textures
  68344. * @param images array of glTF image interfaces
  68345. * @param textures array of glTF texture interfaces
  68346. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68347. * @param imageData map of image file name to data
  68348. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68349. * @returns glTF PBR Metallic Roughness factors
  68350. */
  68351. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68352. /**
  68353. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68354. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68355. * @param mimeType mime type to use for the textures
  68356. * @param images array of glTF image interfaces
  68357. * @param textures array of glTF texture interfaces
  68358. * @param materials array of glTF material interfaces
  68359. * @param imageData map of image file name to data
  68360. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68361. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68362. private setMetallicRoughnessPbrMaterial;
  68363. private getPixelsFromTexture;
  68364. /**
  68365. * Extracts a texture from a Babylon texture into file data and glTF data
  68366. * @param babylonTexture Babylon texture to extract
  68367. * @param mimeType Mime Type of the babylonTexture
  68368. * @return glTF texture info, or null if the texture format is not supported
  68369. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68370. /**
  68371. * Builds a texture from base64 string
  68372. * @param base64Texture base64 texture string
  68373. * @param baseTextureName Name to use for the texture
  68374. * @param mimeType image mime type for the texture
  68375. * @param images array of images
  68376. * @param textures array of textures
  68377. * @param imageData map of image data
  68378. * @returns glTF texture info, or null if the texture format is not supported
  68379. */
  68380. private _getTextureInfoFromBase64;
  68381. }
  68382. }
  68383. declare module BABYLON {
  68384. /**
  68385. * Class for holding and downloading glTF file data
  68386. */
  68387. export class GLTFData {
  68388. /**
  68389. * Object which contains the file name as the key and its data as the value
  68390. */
  68391. glTFFiles: {
  68392. [fileName: string]: string | Blob;
  68393. };
  68394. /**
  68395. * Initializes the glTF file object
  68396. */
  68397. constructor();
  68398. /**
  68399. * Downloads the glTF data as files based on their names and data
  68400. */
  68401. downloadFiles(): void;
  68402. }
  68403. }
  68404. declare module BABYLON {
  68405. /**
  68406. * Holds a collection of exporter options and parameters
  68407. */
  68408. export interface IExportOptions {
  68409. /**
  68410. * Function which indicates whether a babylon node should be exported or not
  68411. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68412. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68413. */
  68414. shouldExportNode?(node: Node): boolean;
  68415. /**
  68416. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68417. * @param metadata source metadata to read from
  68418. * @returns the data to store to glTF node extras
  68419. */
  68420. metadataSelector?(metadata: any): any;
  68421. /**
  68422. * The sample rate to bake animation curves
  68423. */
  68424. animationSampleRate?: number;
  68425. /**
  68426. * Begin serialization without waiting for the scene to be ready
  68427. */
  68428. exportWithoutWaitingForScene?: boolean;
  68429. }
  68430. /**
  68431. * Class for generating glTF data from a Babylon scene.
  68432. */
  68433. export class GLTF2Export {
  68434. /**
  68435. * Exports the geometry of the scene to .gltf file format asynchronously
  68436. * @param scene Babylon scene with scene hierarchy information
  68437. * @param filePrefix File prefix to use when generating the glTF file
  68438. * @param options Exporter options
  68439. * @returns Returns an object with a .gltf file and associates texture names
  68440. * as keys and their data and paths as values
  68441. */
  68442. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68443. private static _PreExportAsync;
  68444. private static _PostExportAsync;
  68445. /**
  68446. * Exports the geometry of the scene to .glb file format asychronously
  68447. * @param scene Babylon scene with scene hierarchy information
  68448. * @param filePrefix File prefix to use when generating glb file
  68449. * @param options Exporter options
  68450. * @returns Returns an object with a .glb filename as key and data as value
  68451. */
  68452. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68453. }
  68454. }
  68455. declare module BABYLON.GLTF2.Exporter {
  68456. /**
  68457. * @hidden
  68458. */
  68459. export class _GLTFUtilities {
  68460. /**
  68461. * Creates a buffer view based on the supplied arguments
  68462. * @param bufferIndex index value of the specified buffer
  68463. * @param byteOffset byte offset value
  68464. * @param byteLength byte length of the bufferView
  68465. * @param byteStride byte distance between conequential elements
  68466. * @param name name of the buffer view
  68467. * @returns bufferView for glTF
  68468. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68469. /**
  68470. * Creates an accessor based on the supplied arguments
  68471. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68472. * @param name The name of the accessor
  68473. * @param type The type of the accessor
  68474. * @param componentType The datatype of components in the attribute
  68475. * @param count The number of attributes referenced by this accessor
  68476. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68477. * @param min Minimum value of each component in this attribute
  68478. * @param max Maximum value of each component in this attribute
  68479. * @returns accessor for glTF
  68480. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68481. /**
  68482. * Calculates the minimum and maximum values of an array of position floats
  68483. * @param positions Positions array of a mesh
  68484. * @param vertexStart Starting vertex offset to calculate min and max values
  68485. * @param vertexCount Number of vertices to check for min and max values
  68486. * @returns min number array and max number array
  68487. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68488. min: number[];
  68489. max: number[];
  68490. };
  68491. /**
  68492. * Converts a new right-handed Vector3
  68493. * @param vector vector3 array
  68494. * @returns right-handed Vector3
  68495. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68496. /**
  68497. * Converts a Vector3 to right-handed
  68498. * @param vector Vector3 to convert to right-handed
  68499. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68500. /**
  68501. * Converts a three element number array to right-handed
  68502. * @param vector number array to convert to right-handed
  68503. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68504. /**
  68505. * Converts a new right-handed Vector3
  68506. * @param vector vector3 array
  68507. * @returns right-handed Vector3
  68508. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68509. /**
  68510. * Converts a Vector3 to right-handed
  68511. * @param vector Vector3 to convert to right-handed
  68512. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68513. /**
  68514. * Converts a three element number array to right-handed
  68515. * @param vector number array to convert to right-handed
  68516. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68517. /**
  68518. * Converts a Vector4 to right-handed
  68519. * @param vector Vector4 to convert to right-handed
  68520. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68521. /**
  68522. * Converts a Vector4 to right-handed
  68523. * @param vector Vector4 to convert to right-handed
  68524. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  68525. /**
  68526. * Converts a Quaternion to right-handed
  68527. * @param quaternion Source quaternion to convert to right-handed
  68528. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68529. /**
  68530. * Converts a Quaternion to right-handed
  68531. * @param quaternion Source quaternion to convert to right-handed
  68532. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  68533. }
  68534. }
  68535. declare module BABYLON.GLTF2.Exporter {
  68536. /**
  68537. * Converts Babylon Scene into glTF 2.0.
  68538. * @hidden
  68539. */
  68540. export class _Exporter {
  68541. /**
  68542. * Stores the glTF to export
  68543. */ private _glTF: IGLTF;
  68544. /**
  68545. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68546. */ private _bufferViews: IBufferView[];
  68547. /**
  68548. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68549. */ private _accessors: IAccessor[];
  68550. /**
  68551. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68552. */
  68553. private _nodes;
  68554. /**
  68555. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68556. */
  68557. private _scenes;
  68558. /**
  68559. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68560. */
  68561. private _meshes;
  68562. /**
  68563. * Stores all the generated material information, which represents the appearance of each primitive
  68564. */ private _materials: IMaterial[]; private _materialMap: {
  68565. [materialID: number]: number;
  68566. };
  68567. /**
  68568. * Stores all the generated texture information, which is referenced by glTF materials
  68569. */ private _textures: ITexture[];
  68570. /**
  68571. * Stores all the generated image information, which is referenced by glTF textures
  68572. */ private _images: IImage[];
  68573. /**
  68574. * Stores all the texture samplers
  68575. */ private _samplers: ISampler[];
  68576. /**
  68577. * Stores all the generated animation samplers, which is referenced by glTF animations
  68578. */
  68579. /**
  68580. * Stores the animations for glTF models
  68581. */
  68582. private _animations;
  68583. /**
  68584. * Stores the total amount of bytes stored in the glTF buffer
  68585. */
  68586. private _totalByteLength;
  68587. /**
  68588. * Stores a reference to the Babylon scene containing the source geometry and material information
  68589. */ private _babylonScene: Scene;
  68590. /**
  68591. * Stores a map of the image data, where the key is the file name and the value
  68592. * is the image data
  68593. */ private _imageData: {
  68594. [fileName: string]: {
  68595. data: Uint8Array;
  68596. mimeType: ImageMimeType;
  68597. };
  68598. };
  68599. /**
  68600. * Stores a map of the unique id of a node to its index in the node array
  68601. */
  68602. private _nodeMap;
  68603. /**
  68604. * Specifies if the Babylon scene should be converted to right-handed on export
  68605. */ private _convertToRightHandedSystem: boolean;
  68606. /**
  68607. * Baked animation sample rate
  68608. */
  68609. private _animationSampleRate;
  68610. private _options;
  68611. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  68612. private _extensions;
  68613. private static _ExtensionNames;
  68614. private static _ExtensionFactories;
  68615. 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>>;
  68616. private _forEachExtensions;
  68617. private _extensionsOnExporting;
  68618. /**
  68619. * Load glTF serializer extensions
  68620. */
  68621. private _loadExtensions;
  68622. /**
  68623. * Creates a glTF Exporter instance, which can accept optional exporter options
  68624. * @param babylonScene Babylon scene object
  68625. * @param options Options to modify the behavior of the exporter
  68626. */
  68627. constructor(babylonScene: Scene, options?: IExportOptions);
  68628. /**
  68629. * Registers a glTF exporter extension
  68630. * @param name Name of the extension to export
  68631. * @param factory The factory function that creates the exporter extension
  68632. */
  68633. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68634. /**
  68635. * Un-registers an exporter extension
  68636. * @param name The name fo the exporter extension
  68637. * @returns A boolean indicating whether the extension has been un-registered
  68638. */
  68639. static UnregisterExtension(name: string): boolean;
  68640. /**
  68641. * Lazy load a local engine with premultiplied alpha set to false
  68642. */ private _getLocalEngine(): Engine;
  68643. private reorderIndicesBasedOnPrimitiveMode;
  68644. /**
  68645. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68646. * clock-wise during export to glTF
  68647. * @param submesh BabylonJS submesh
  68648. * @param primitiveMode Primitive mode of the mesh
  68649. * @param sideOrientation the winding order of the submesh
  68650. * @param vertexBufferKind The type of vertex attribute
  68651. * @param meshAttributeArray The vertex attribute data
  68652. * @param byteOffset The offset to the binary data
  68653. * @param binaryWriter The binary data for the glTF file
  68654. */
  68655. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68656. /**
  68657. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68658. * clock-wise during export to glTF
  68659. * @param submesh BabylonJS submesh
  68660. * @param primitiveMode Primitive mode of the mesh
  68661. * @param sideOrientation the winding order of the submesh
  68662. * @param vertexBufferKind The type of vertex attribute
  68663. * @param meshAttributeArray The vertex attribute data
  68664. * @param byteOffset The offset to the binary data
  68665. * @param binaryWriter The binary data for the glTF file
  68666. */
  68667. private reorderTriangleFillMode;
  68668. /**
  68669. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68670. * clock-wise during export to glTF
  68671. * @param submesh BabylonJS submesh
  68672. * @param primitiveMode Primitive mode of the mesh
  68673. * @param sideOrientation the winding order of the submesh
  68674. * @param vertexBufferKind The type of vertex attribute
  68675. * @param meshAttributeArray The vertex attribute data
  68676. * @param byteOffset The offset to the binary data
  68677. * @param binaryWriter The binary data for the glTF file
  68678. */
  68679. private reorderTriangleStripDrawMode;
  68680. /**
  68681. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68682. * clock-wise during export to glTF
  68683. * @param submesh BabylonJS submesh
  68684. * @param primitiveMode Primitive mode of the mesh
  68685. * @param sideOrientation the winding order of the submesh
  68686. * @param vertexBufferKind The type of vertex attribute
  68687. * @param meshAttributeArray The vertex attribute data
  68688. * @param byteOffset The offset to the binary data
  68689. * @param binaryWriter The binary data for the glTF file
  68690. */
  68691. private reorderTriangleFanMode;
  68692. /**
  68693. * Writes the vertex attribute data to binary
  68694. * @param vertices The vertices to write to the binary writer
  68695. * @param byteOffset The offset into the binary writer to overwrite binary data
  68696. * @param vertexAttributeKind The vertex attribute type
  68697. * @param meshAttributeArray The vertex attribute data
  68698. * @param binaryWriter The writer containing the binary data
  68699. */
  68700. private writeVertexAttributeData;
  68701. /**
  68702. * Writes mesh attribute data to a data buffer
  68703. * Returns the bytelength of the data
  68704. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68705. * @param meshAttributeArray Array containing the attribute data
  68706. * @param binaryWriter The buffer to write the binary data to
  68707. * @param indices Used to specify the order of the vertex data
  68708. */
  68709. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68710. /**
  68711. * Generates glTF json data
  68712. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68713. * @param glTFPrefix Text to use when prefixing a glTF file
  68714. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68715. * @returns json data as string
  68716. */
  68717. private generateJSON;
  68718. /**
  68719. * Generates data for .gltf and .bin files based on the glTF prefix string
  68720. * @param glTFPrefix Text to use when prefixing a glTF file
  68721. * @returns GLTFData with glTF file data
  68722. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68723. /**
  68724. * Creates a binary buffer for glTF
  68725. * @returns array buffer for binary data
  68726. */
  68727. private _generateBinaryAsync;
  68728. /**
  68729. * Pads the number to a multiple of 4
  68730. * @param num number to pad
  68731. * @returns padded number
  68732. */
  68733. private _getPadding;
  68734. /**
  68735. * Generates a glb file from the json and binary data
  68736. * Returns an object with the glb file name as the key and data as the value
  68737. * @param glTFPrefix
  68738. * @returns object with glb filename as key and data as value
  68739. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68740. /**
  68741. * Sets the TRS for each node
  68742. * @param node glTF Node for storing the transformation data
  68743. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68744. */
  68745. private setNodeTransformation;
  68746. private getVertexBufferFromMesh;
  68747. /**
  68748. * Creates a bufferview based on the vertices type for the Babylon mesh
  68749. * @param kind Indicates the type of vertices data
  68750. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68751. * @param binaryWriter The buffer to write the bufferview data to
  68752. */
  68753. private createBufferViewKind;
  68754. /**
  68755. * The primitive mode of the Babylon mesh
  68756. * @param babylonMesh The BabylonJS mesh
  68757. */
  68758. private getMeshPrimitiveMode;
  68759. /**
  68760. * Sets the primitive mode of the glTF mesh primitive
  68761. * @param meshPrimitive glTF mesh primitive
  68762. * @param primitiveMode The primitive mode
  68763. */
  68764. private setPrimitiveMode;
  68765. /**
  68766. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68767. * @param meshPrimitive glTF mesh primitive
  68768. * @param attributeKind vertex attribute
  68769. * @returns boolean specifying if uv coordinates are present
  68770. */
  68771. private setAttributeKind;
  68772. /**
  68773. * Sets data for the primitive attributes of each submesh
  68774. * @param mesh glTF Mesh object to store the primitive attribute information
  68775. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68776. * @param binaryWriter Buffer to write the attribute data to
  68777. */
  68778. private setPrimitiveAttributesAsync;
  68779. /**
  68780. * Creates a glTF scene based on the array of meshes
  68781. * Returns the the total byte offset
  68782. * @param babylonScene Babylon scene to get the mesh data from
  68783. * @param binaryWriter Buffer to write binary data to
  68784. */
  68785. private createSceneAsync;
  68786. /**
  68787. * Creates a mapping of Node unique id to node index and handles animations
  68788. * @param babylonScene Babylon Scene
  68789. * @param nodes Babylon transform nodes
  68790. * @param binaryWriter Buffer to write binary data to
  68791. * @returns Node mapping of unique id to index
  68792. */
  68793. private createNodeMapAndAnimationsAsync;
  68794. /**
  68795. * Creates a glTF node from a Babylon mesh
  68796. * @param babylonMesh Source Babylon mesh
  68797. * @param binaryWriter Buffer for storing geometry data
  68798. * @returns glTF node
  68799. */
  68800. private createNodeAsync;
  68801. }
  68802. /**
  68803. * @hidden
  68804. *
  68805. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68806. */
  68807. export class _BinaryWriter {
  68808. /**
  68809. * Array buffer which stores all binary data
  68810. */
  68811. private _arrayBuffer;
  68812. /**
  68813. * View of the array buffer
  68814. */
  68815. private _dataView;
  68816. /**
  68817. * byte offset of data in array buffer
  68818. */
  68819. private _byteOffset;
  68820. /**
  68821. * Initialize binary writer with an initial byte length
  68822. * @param byteLength Initial byte length of the array buffer
  68823. */
  68824. constructor(byteLength: number);
  68825. /**
  68826. * Resize the array buffer to the specified byte length
  68827. * @param byteLength
  68828. */
  68829. private resizeBuffer;
  68830. /**
  68831. * Get an array buffer with the length of the byte offset
  68832. * @returns ArrayBuffer resized to the byte offset
  68833. */
  68834. getArrayBuffer(): ArrayBuffer;
  68835. /**
  68836. * Get the byte offset of the array buffer
  68837. * @returns byte offset
  68838. */
  68839. getByteOffset(): number;
  68840. /**
  68841. * Stores an UInt8 in the array buffer
  68842. * @param entry
  68843. * @param byteOffset If defined, specifies where to set the value as an offset.
  68844. */
  68845. setUInt8(entry: number, byteOffset?: number): void;
  68846. /**
  68847. * Gets an UInt32 in the array buffer
  68848. * @param entry
  68849. * @param byteOffset If defined, specifies where to set the value as an offset.
  68850. */
  68851. getUInt32(byteOffset: number): number;
  68852. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68853. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68854. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68855. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68856. /**
  68857. * Stores a Float32 in the array buffer
  68858. * @param entry
  68859. */
  68860. setFloat32(entry: number, byteOffset?: number): void;
  68861. /**
  68862. * Stores an UInt32 in the array buffer
  68863. * @param entry
  68864. * @param byteOffset If defined, specifies where to set the value as an offset.
  68865. */
  68866. setUInt32(entry: number, byteOffset?: number): void;
  68867. }
  68868. }
  68869. declare module BABYLON.GLTF2.Exporter {
  68870. /**
  68871. * @hidden
  68872. * Interface to store animation data.
  68873. */
  68874. export interface _IAnimationData {
  68875. /**
  68876. * Keyframe data.
  68877. */
  68878. inputs: number[];
  68879. /**
  68880. * Value data.
  68881. */
  68882. outputs: number[][];
  68883. /**
  68884. * Animation interpolation data.
  68885. */
  68886. samplerInterpolation: AnimationSamplerInterpolation;
  68887. /**
  68888. * Minimum keyframe value.
  68889. */
  68890. inputsMin: number;
  68891. /**
  68892. * Maximum keyframe value.
  68893. */
  68894. inputsMax: number;
  68895. }
  68896. /**
  68897. * @hidden
  68898. */
  68899. export interface _IAnimationInfo {
  68900. /**
  68901. * The target channel for the animation
  68902. */
  68903. animationChannelTargetPath: AnimationChannelTargetPath;
  68904. /**
  68905. * The glTF accessor type for the data.
  68906. */
  68907. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68908. /**
  68909. * Specifies if quaternions should be used.
  68910. */
  68911. useQuaternion: boolean;
  68912. }
  68913. /**
  68914. * @hidden
  68915. * Utility class for generating glTF animation data from BabylonJS.
  68916. */
  68917. export class _GLTFAnimation {
  68918. /**
  68919. * @ignore
  68920. *
  68921. * Creates glTF channel animation from BabylonJS animation.
  68922. * @param babylonTransformNode - BabylonJS mesh.
  68923. * @param animation - animation.
  68924. * @param animationChannelTargetPath - The target animation channel.
  68925. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68926. * @param useQuaternion - Specifies if quaternions are used.
  68927. * @returns nullable IAnimationData
  68928. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68929. private static _DeduceAnimationInfo;
  68930. /**
  68931. * @ignore
  68932. * Create node animations from the transform node animations
  68933. * @param babylonNode
  68934. * @param runtimeGLTFAnimation
  68935. * @param idleGLTFAnimations
  68936. * @param nodeMap
  68937. * @param nodes
  68938. * @param binaryWriter
  68939. * @param bufferViews
  68940. * @param accessors
  68941. * @param convertToRightHandedSystem
  68942. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68943. [key: number]: number;
  68944. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68945. /**
  68946. * @ignore
  68947. * Create node animations from the animation groups
  68948. * @param babylonScene
  68949. * @param glTFAnimations
  68950. * @param nodeMap
  68951. * @param nodes
  68952. * @param binaryWriter
  68953. * @param bufferViews
  68954. * @param accessors
  68955. * @param convertToRightHandedSystem
  68956. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68957. [key: number]: number;
  68958. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68959. private static AddAnimation;
  68960. /**
  68961. * Create a baked animation
  68962. * @param babylonTransformNode BabylonJS mesh
  68963. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68964. * @param animationChannelTargetPath animation target channel
  68965. * @param minFrame minimum animation frame
  68966. * @param maxFrame maximum animation frame
  68967. * @param fps frames per second of the animation
  68968. * @param inputs input key frames of the animation
  68969. * @param outputs output key frame data of the animation
  68970. * @param convertToRightHandedSystem converts the values to right-handed
  68971. * @param useQuaternion specifies if quaternions should be used
  68972. */
  68973. private static _CreateBakedAnimation;
  68974. private static _ConvertFactorToVector3OrQuaternion;
  68975. private static _SetInterpolatedValue;
  68976. /**
  68977. * Creates linear animation from the animation key frames
  68978. * @param babylonTransformNode BabylonJS mesh
  68979. * @param animation BabylonJS animation
  68980. * @param animationChannelTargetPath The target animation channel
  68981. * @param frameDelta The difference between the last and first frame of the animation
  68982. * @param inputs Array to store the key frame times
  68983. * @param outputs Array to store the key frame data
  68984. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68985. * @param useQuaternion Specifies if quaternions are used in the animation
  68986. */
  68987. private static _CreateLinearOrStepAnimation;
  68988. /**
  68989. * Creates cubic spline animation from the animation key frames
  68990. * @param babylonTransformNode BabylonJS mesh
  68991. * @param animation BabylonJS animation
  68992. * @param animationChannelTargetPath The target animation channel
  68993. * @param frameDelta The difference between the last and first frame of the animation
  68994. * @param inputs Array to store the key frame times
  68995. * @param outputs Array to store the key frame data
  68996. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68997. * @param useQuaternion Specifies if quaternions are used in the animation
  68998. */
  68999. private static _CreateCubicSplineAnimation;
  69000. private static _GetBasePositionRotationOrScale;
  69001. /**
  69002. * Adds a key frame value
  69003. * @param keyFrame
  69004. * @param animation
  69005. * @param outputs
  69006. * @param animationChannelTargetPath
  69007. * @param basePositionRotationOrScale
  69008. * @param convertToRightHandedSystem
  69009. * @param useQuaternion
  69010. */
  69011. private static _AddKeyframeValue;
  69012. /**
  69013. * Determine the interpolation based on the key frames
  69014. * @param keyFrames
  69015. * @param animationChannelTargetPath
  69016. * @param useQuaternion
  69017. */
  69018. private static _DeduceInterpolation;
  69019. /**
  69020. * Adds an input tangent or output tangent to the output data
  69021. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69022. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69023. * @param outputs The animation data by keyframe
  69024. * @param animationChannelTargetPath The target animation channel
  69025. * @param interpolation The interpolation type
  69026. * @param keyFrame The key frame with the animation data
  69027. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69028. * @param useQuaternion Specifies if quaternions are used
  69029. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69030. */
  69031. private static AddSplineTangent;
  69032. /**
  69033. * Get the minimum and maximum key frames' frame values
  69034. * @param keyFrames animation key frames
  69035. * @returns the minimum and maximum key frame value
  69036. */
  69037. private static calculateMinMaxKeyFrames;
  69038. }
  69039. }
  69040. declare module BABYLON.GLTF2.Exporter {
  69041. /** @hidden */
  69042. export var textureTransformPixelShader: {
  69043. name: string;
  69044. shader: string;
  69045. };
  69046. }
  69047. declare module BABYLON.GLTF2.Exporter.Extensions {
  69048. /**
  69049. * @hidden
  69050. */
  69051. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69052. /** Name of this extension */
  69053. readonly name: string;
  69054. /** Defines whether this extension is enabled */
  69055. enabled: boolean;
  69056. /** Defines whether this extension is required */
  69057. required: boolean;
  69058. /** Reference to the glTF exporter */
  69059. private _exporter;
  69060. constructor(exporter: _Exporter);
  69061. dispose(): void;
  69062. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69063. /**
  69064. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69065. * @param babylonTexture
  69066. * @param offset
  69067. * @param rotation
  69068. * @param scale
  69069. * @param scene
  69070. */
  69071. private _textureTransformTextureAsync;
  69072. }
  69073. }
  69074. declare module BABYLON.GLTF2.Exporter.Extensions {
  69075. /**
  69076. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69077. */
  69078. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69079. /** The name of this extension. */
  69080. readonly name: string;
  69081. /** Defines whether this extension is enabled. */
  69082. enabled: boolean;
  69083. /** Defines whether this extension is required */
  69084. required: boolean;
  69085. /** Reference to the glTF exporter */
  69086. private _exporter;
  69087. private _lights;
  69088. /** @hidden */
  69089. constructor(exporter: _Exporter);
  69090. /** @hidden */
  69091. dispose(): void;
  69092. /** @hidden */
  69093. onExporting(): void;
  69094. /**
  69095. * Define this method to modify the default behavior when exporting a node
  69096. * @param context The context when exporting the node
  69097. * @param node glTF node
  69098. * @param babylonNode BabylonJS node
  69099. * @returns nullable INode promise
  69100. */
  69101. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69102. }
  69103. }
  69104. declare module BABYLON {
  69105. /**
  69106. * Class for generating STL data from a Babylon scene.
  69107. */
  69108. export class STLExport {
  69109. /**
  69110. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69111. * @param meshes list defines the mesh to serialize
  69112. * @param download triggers the automatic download of the file.
  69113. * @param fileName changes the downloads fileName.
  69114. * @param binary changes the STL to a binary type.
  69115. * @param isLittleEndian toggle for binary type exporter.
  69116. * @returns the STL as UTF8 string
  69117. */
  69118. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69119. }
  69120. }
  69121. declare module "babylonjs-gltf2interface" {
  69122. export = BABYLON.GLTF2;
  69123. }
  69124. /**
  69125. * Module for glTF 2.0 Interface
  69126. */
  69127. declare module BABYLON.GLTF2 {
  69128. /**
  69129. * The datatype of the components in the attribute
  69130. */
  69131. const enum AccessorComponentType {
  69132. /**
  69133. * Byte
  69134. */
  69135. BYTE = 5120,
  69136. /**
  69137. * Unsigned Byte
  69138. */
  69139. UNSIGNED_BYTE = 5121,
  69140. /**
  69141. * Short
  69142. */
  69143. SHORT = 5122,
  69144. /**
  69145. * Unsigned Short
  69146. */
  69147. UNSIGNED_SHORT = 5123,
  69148. /**
  69149. * Unsigned Int
  69150. */
  69151. UNSIGNED_INT = 5125,
  69152. /**
  69153. * Float
  69154. */
  69155. FLOAT = 5126,
  69156. }
  69157. /**
  69158. * Specifies if the attirbute is a scalar, vector, or matrix
  69159. */
  69160. const enum AccessorType {
  69161. /**
  69162. * Scalar
  69163. */
  69164. SCALAR = "SCALAR",
  69165. /**
  69166. * Vector2
  69167. */
  69168. VEC2 = "VEC2",
  69169. /**
  69170. * Vector3
  69171. */
  69172. VEC3 = "VEC3",
  69173. /**
  69174. * Vector4
  69175. */
  69176. VEC4 = "VEC4",
  69177. /**
  69178. * Matrix2x2
  69179. */
  69180. MAT2 = "MAT2",
  69181. /**
  69182. * Matrix3x3
  69183. */
  69184. MAT3 = "MAT3",
  69185. /**
  69186. * Matrix4x4
  69187. */
  69188. MAT4 = "MAT4",
  69189. }
  69190. /**
  69191. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69192. */
  69193. const enum AnimationChannelTargetPath {
  69194. /**
  69195. * Translation
  69196. */
  69197. TRANSLATION = "translation",
  69198. /**
  69199. * Rotation
  69200. */
  69201. ROTATION = "rotation",
  69202. /**
  69203. * Scale
  69204. */
  69205. SCALE = "scale",
  69206. /**
  69207. * Weights
  69208. */
  69209. WEIGHTS = "weights",
  69210. }
  69211. /**
  69212. * Interpolation algorithm
  69213. */
  69214. const enum AnimationSamplerInterpolation {
  69215. /**
  69216. * The animated values are linearly interpolated between keyframes
  69217. */
  69218. LINEAR = "LINEAR",
  69219. /**
  69220. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69221. */
  69222. STEP = "STEP",
  69223. /**
  69224. * The animation's interpolation is computed using a cubic spline with specified tangents
  69225. */
  69226. CUBICSPLINE = "CUBICSPLINE",
  69227. }
  69228. /**
  69229. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69230. */
  69231. const enum CameraType {
  69232. /**
  69233. * A perspective camera containing properties to create a perspective projection matrix
  69234. */
  69235. PERSPECTIVE = "perspective",
  69236. /**
  69237. * An orthographic camera containing properties to create an orthographic projection matrix
  69238. */
  69239. ORTHOGRAPHIC = "orthographic",
  69240. }
  69241. /**
  69242. * The mime-type of the image
  69243. */
  69244. const enum ImageMimeType {
  69245. /**
  69246. * JPEG Mime-type
  69247. */
  69248. JPEG = "image/jpeg",
  69249. /**
  69250. * PNG Mime-type
  69251. */
  69252. PNG = "image/png",
  69253. }
  69254. /**
  69255. * The alpha rendering mode of the material
  69256. */
  69257. const enum MaterialAlphaMode {
  69258. /**
  69259. * The alpha value is ignored and the rendered output is fully opaque
  69260. */
  69261. OPAQUE = "OPAQUE",
  69262. /**
  69263. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69264. */
  69265. MASK = "MASK",
  69266. /**
  69267. * 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)
  69268. */
  69269. BLEND = "BLEND",
  69270. }
  69271. /**
  69272. * The type of the primitives to render
  69273. */
  69274. const enum MeshPrimitiveMode {
  69275. /**
  69276. * Points
  69277. */
  69278. POINTS = 0,
  69279. /**
  69280. * Lines
  69281. */
  69282. LINES = 1,
  69283. /**
  69284. * Line Loop
  69285. */
  69286. LINE_LOOP = 2,
  69287. /**
  69288. * Line Strip
  69289. */
  69290. LINE_STRIP = 3,
  69291. /**
  69292. * Triangles
  69293. */
  69294. TRIANGLES = 4,
  69295. /**
  69296. * Triangle Strip
  69297. */
  69298. TRIANGLE_STRIP = 5,
  69299. /**
  69300. * Triangle Fan
  69301. */
  69302. TRIANGLE_FAN = 6,
  69303. }
  69304. /**
  69305. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69306. */
  69307. const enum TextureMagFilter {
  69308. /**
  69309. * Nearest
  69310. */
  69311. NEAREST = 9728,
  69312. /**
  69313. * Linear
  69314. */
  69315. LINEAR = 9729,
  69316. }
  69317. /**
  69318. * Minification filter. All valid values correspond to WebGL enums
  69319. */
  69320. const enum TextureMinFilter {
  69321. /**
  69322. * Nearest
  69323. */
  69324. NEAREST = 9728,
  69325. /**
  69326. * Linear
  69327. */
  69328. LINEAR = 9729,
  69329. /**
  69330. * Nearest Mip-Map Nearest
  69331. */
  69332. NEAREST_MIPMAP_NEAREST = 9984,
  69333. /**
  69334. * Linear Mipmap Nearest
  69335. */
  69336. LINEAR_MIPMAP_NEAREST = 9985,
  69337. /**
  69338. * Nearest Mipmap Linear
  69339. */
  69340. NEAREST_MIPMAP_LINEAR = 9986,
  69341. /**
  69342. * Linear Mipmap Linear
  69343. */
  69344. LINEAR_MIPMAP_LINEAR = 9987,
  69345. }
  69346. /**
  69347. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69348. */
  69349. const enum TextureWrapMode {
  69350. /**
  69351. * Clamp to Edge
  69352. */
  69353. CLAMP_TO_EDGE = 33071,
  69354. /**
  69355. * Mirrored Repeat
  69356. */
  69357. MIRRORED_REPEAT = 33648,
  69358. /**
  69359. * Repeat
  69360. */
  69361. REPEAT = 10497,
  69362. }
  69363. /**
  69364. * glTF Property
  69365. */
  69366. interface IProperty {
  69367. /**
  69368. * Dictionary object with extension-specific objects
  69369. */
  69370. extensions?: {
  69371. [key: string]: any;
  69372. };
  69373. /**
  69374. * Application-Specific data
  69375. */
  69376. extras?: any;
  69377. }
  69378. /**
  69379. * glTF Child of Root Property
  69380. */
  69381. interface IChildRootProperty extends IProperty {
  69382. /**
  69383. * The user-defined name of this object
  69384. */
  69385. name?: string;
  69386. }
  69387. /**
  69388. * Indices of those attributes that deviate from their initialization value
  69389. */
  69390. interface IAccessorSparseIndices extends IProperty {
  69391. /**
  69392. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69393. */
  69394. bufferView: number;
  69395. /**
  69396. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69397. */
  69398. byteOffset?: number;
  69399. /**
  69400. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69401. */
  69402. componentType: AccessorComponentType;
  69403. }
  69404. /**
  69405. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69406. */
  69407. interface IAccessorSparseValues extends IProperty {
  69408. /**
  69409. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69410. */
  69411. bufferView: number;
  69412. /**
  69413. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69414. */
  69415. byteOffset?: number;
  69416. }
  69417. /**
  69418. * Sparse storage of attributes that deviate from their initialization value
  69419. */
  69420. interface IAccessorSparse extends IProperty {
  69421. /**
  69422. * The number of attributes encoded in this sparse accessor
  69423. */
  69424. count: number;
  69425. /**
  69426. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69427. */
  69428. indices: IAccessorSparseIndices;
  69429. /**
  69430. * 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
  69431. */
  69432. values: IAccessorSparseValues;
  69433. }
  69434. /**
  69435. * 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
  69436. */
  69437. interface IAccessor extends IChildRootProperty {
  69438. /**
  69439. * The index of the bufferview
  69440. */
  69441. bufferView?: number;
  69442. /**
  69443. * The offset relative to the start of the bufferView in bytes
  69444. */
  69445. byteOffset?: number;
  69446. /**
  69447. * The datatype of components in the attribute
  69448. */
  69449. componentType: AccessorComponentType;
  69450. /**
  69451. * Specifies whether integer data values should be normalized
  69452. */
  69453. normalized?: boolean;
  69454. /**
  69455. * The number of attributes referenced by this accessor
  69456. */
  69457. count: number;
  69458. /**
  69459. * Specifies if the attribute is a scalar, vector, or matrix
  69460. */
  69461. type: AccessorType;
  69462. /**
  69463. * Maximum value of each component in this attribute
  69464. */
  69465. max?: number[];
  69466. /**
  69467. * Minimum value of each component in this attribute
  69468. */
  69469. min?: number[];
  69470. /**
  69471. * Sparse storage of attributes that deviate from their initialization value
  69472. */
  69473. sparse?: IAccessorSparse;
  69474. }
  69475. /**
  69476. * Targets an animation's sampler at a node's property
  69477. */
  69478. interface IAnimationChannel extends IProperty {
  69479. /**
  69480. * The index of a sampler in this animation used to compute the value for the target
  69481. */
  69482. sampler: number;
  69483. /**
  69484. * The index of the node and TRS property to target
  69485. */
  69486. target: IAnimationChannelTarget;
  69487. }
  69488. /**
  69489. * The index of the node and TRS property that an animation channel targets
  69490. */
  69491. interface IAnimationChannelTarget extends IProperty {
  69492. /**
  69493. * The index of the node to target
  69494. */
  69495. node: number;
  69496. /**
  69497. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69498. */
  69499. path: AnimationChannelTargetPath;
  69500. }
  69501. /**
  69502. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69503. */
  69504. interface IAnimationSampler extends IProperty {
  69505. /**
  69506. * The index of an accessor containing keyframe input values, e.g., time
  69507. */
  69508. input: number;
  69509. /**
  69510. * Interpolation algorithm
  69511. */
  69512. interpolation?: AnimationSamplerInterpolation;
  69513. /**
  69514. * The index of an accessor, containing keyframe output values
  69515. */
  69516. output: number;
  69517. }
  69518. /**
  69519. * A keyframe animation
  69520. */
  69521. interface IAnimation extends IChildRootProperty {
  69522. /**
  69523. * An array of channels, each of which targets an animation's sampler at a node's property
  69524. */
  69525. channels: IAnimationChannel[];
  69526. /**
  69527. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69528. */
  69529. samplers: IAnimationSampler[];
  69530. }
  69531. /**
  69532. * Metadata about the glTF asset
  69533. */
  69534. interface IAsset extends IChildRootProperty {
  69535. /**
  69536. * A copyright message suitable for display to credit the content creator
  69537. */
  69538. copyright?: string;
  69539. /**
  69540. * Tool that generated this glTF model. Useful for debugging
  69541. */
  69542. generator?: string;
  69543. /**
  69544. * The glTF version that this asset targets
  69545. */
  69546. version: string;
  69547. /**
  69548. * The minimum glTF version that this asset targets
  69549. */
  69550. minVersion?: string;
  69551. }
  69552. /**
  69553. * A buffer points to binary geometry, animation, or skins
  69554. */
  69555. interface IBuffer extends IChildRootProperty {
  69556. /**
  69557. * 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
  69558. */
  69559. uri?: string;
  69560. /**
  69561. * The length of the buffer in bytes
  69562. */
  69563. byteLength: number;
  69564. }
  69565. /**
  69566. * A view into a buffer generally representing a subset of the buffer
  69567. */
  69568. interface IBufferView extends IChildRootProperty {
  69569. /**
  69570. * The index of the buffer
  69571. */
  69572. buffer: number;
  69573. /**
  69574. * The offset into the buffer in bytes
  69575. */
  69576. byteOffset?: number;
  69577. /**
  69578. * The lenth of the bufferView in bytes
  69579. */
  69580. byteLength: number;
  69581. /**
  69582. * The stride, in bytes
  69583. */
  69584. byteStride?: number;
  69585. }
  69586. /**
  69587. * An orthographic camera containing properties to create an orthographic projection matrix
  69588. */
  69589. interface ICameraOrthographic extends IProperty {
  69590. /**
  69591. * The floating-point horizontal magnification of the view. Must not be zero
  69592. */
  69593. xmag: number;
  69594. /**
  69595. * The floating-point vertical magnification of the view. Must not be zero
  69596. */
  69597. ymag: number;
  69598. /**
  69599. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69600. */
  69601. zfar: number;
  69602. /**
  69603. * The floating-point distance to the near clipping plane
  69604. */
  69605. znear: number;
  69606. }
  69607. /**
  69608. * A perspective camera containing properties to create a perspective projection matrix
  69609. */
  69610. interface ICameraPerspective extends IProperty {
  69611. /**
  69612. * The floating-point aspect ratio of the field of view
  69613. */
  69614. aspectRatio?: number;
  69615. /**
  69616. * The floating-point vertical field of view in radians
  69617. */
  69618. yfov: number;
  69619. /**
  69620. * The floating-point distance to the far clipping plane
  69621. */
  69622. zfar?: number;
  69623. /**
  69624. * The floating-point distance to the near clipping plane
  69625. */
  69626. znear: number;
  69627. }
  69628. /**
  69629. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69630. */
  69631. interface ICamera extends IChildRootProperty {
  69632. /**
  69633. * An orthographic camera containing properties to create an orthographic projection matrix
  69634. */
  69635. orthographic?: ICameraOrthographic;
  69636. /**
  69637. * A perspective camera containing properties to create a perspective projection matrix
  69638. */
  69639. perspective?: ICameraPerspective;
  69640. /**
  69641. * Specifies if the camera uses a perspective or orthographic projection
  69642. */
  69643. type: CameraType;
  69644. }
  69645. /**
  69646. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69647. */
  69648. interface IImage extends IChildRootProperty {
  69649. /**
  69650. * 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
  69651. */
  69652. uri?: string;
  69653. /**
  69654. * The image's MIME type
  69655. */
  69656. mimeType?: ImageMimeType;
  69657. /**
  69658. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69659. */
  69660. bufferView?: number;
  69661. }
  69662. /**
  69663. * Material Normal Texture Info
  69664. */
  69665. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69666. /**
  69667. * The scalar multiplier applied to each normal vector of the normal texture
  69668. */
  69669. scale?: number;
  69670. }
  69671. /**
  69672. * Material Occlusion Texture Info
  69673. */
  69674. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69675. /**
  69676. * A scalar multiplier controlling the amount of occlusion applied
  69677. */
  69678. strength?: number;
  69679. }
  69680. /**
  69681. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69682. */
  69683. interface IMaterialPbrMetallicRoughness {
  69684. /**
  69685. * The material's base color factor
  69686. */
  69687. baseColorFactor?: number[];
  69688. /**
  69689. * The base color texture
  69690. */
  69691. baseColorTexture?: ITextureInfo;
  69692. /**
  69693. * The metalness of the material
  69694. */
  69695. metallicFactor?: number;
  69696. /**
  69697. * The roughness of the material
  69698. */
  69699. roughnessFactor?: number;
  69700. /**
  69701. * The metallic-roughness texture
  69702. */
  69703. metallicRoughnessTexture?: ITextureInfo;
  69704. }
  69705. /**
  69706. * The material appearance of a primitive
  69707. */
  69708. interface IMaterial extends IChildRootProperty {
  69709. /**
  69710. * 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
  69711. */
  69712. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69713. /**
  69714. * The normal map texture
  69715. */
  69716. normalTexture?: IMaterialNormalTextureInfo;
  69717. /**
  69718. * The occlusion map texture
  69719. */
  69720. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69721. /**
  69722. * The emissive map texture
  69723. */
  69724. emissiveTexture?: ITextureInfo;
  69725. /**
  69726. * 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
  69727. */
  69728. emissiveFactor?: number[];
  69729. /**
  69730. * The alpha rendering mode of the material
  69731. */
  69732. alphaMode?: MaterialAlphaMode;
  69733. /**
  69734. * The alpha cutoff value of the material
  69735. */
  69736. alphaCutoff?: number;
  69737. /**
  69738. * Specifies whether the material is double sided
  69739. */
  69740. doubleSided?: boolean;
  69741. }
  69742. /**
  69743. * Geometry to be rendered with the given material
  69744. */
  69745. interface IMeshPrimitive extends IProperty {
  69746. /**
  69747. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69748. */
  69749. attributes: {
  69750. [name: string]: number;
  69751. };
  69752. /**
  69753. * The index of the accessor that contains the indices
  69754. */
  69755. indices?: number;
  69756. /**
  69757. * The index of the material to apply to this primitive when rendering
  69758. */
  69759. material?: number;
  69760. /**
  69761. * The type of primitives to render. All valid values correspond to WebGL enums
  69762. */
  69763. mode?: MeshPrimitiveMode;
  69764. /**
  69765. * 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
  69766. */
  69767. targets?: {
  69768. [name: string]: number;
  69769. }[];
  69770. }
  69771. /**
  69772. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69773. */
  69774. interface IMesh extends IChildRootProperty {
  69775. /**
  69776. * An array of primitives, each defining geometry to be rendered with a material
  69777. */
  69778. primitives: IMeshPrimitive[];
  69779. /**
  69780. * Array of weights to be applied to the Morph Targets
  69781. */
  69782. weights?: number[];
  69783. }
  69784. /**
  69785. * A node in the node hierarchy
  69786. */
  69787. interface INode extends IChildRootProperty {
  69788. /**
  69789. * The index of the camera referenced by this node
  69790. */
  69791. camera?: number;
  69792. /**
  69793. * The indices of this node's children
  69794. */
  69795. children?: number[];
  69796. /**
  69797. * The index of the skin referenced by this node
  69798. */
  69799. skin?: number;
  69800. /**
  69801. * A floating-point 4x4 transformation matrix stored in column-major order
  69802. */
  69803. matrix?: number[];
  69804. /**
  69805. * The index of the mesh in this node
  69806. */
  69807. mesh?: number;
  69808. /**
  69809. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69810. */
  69811. rotation?: number[];
  69812. /**
  69813. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69814. */
  69815. scale?: number[];
  69816. /**
  69817. * The node's translation along the x, y, and z axes
  69818. */
  69819. translation?: number[];
  69820. /**
  69821. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69822. */
  69823. weights?: number[];
  69824. }
  69825. /**
  69826. * Texture sampler properties for filtering and wrapping modes
  69827. */
  69828. interface ISampler extends IChildRootProperty {
  69829. /**
  69830. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69831. */
  69832. magFilter?: TextureMagFilter;
  69833. /**
  69834. * Minification filter. All valid values correspond to WebGL enums
  69835. */
  69836. minFilter?: TextureMinFilter;
  69837. /**
  69838. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69839. */
  69840. wrapS?: TextureWrapMode;
  69841. /**
  69842. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69843. */
  69844. wrapT?: TextureWrapMode;
  69845. }
  69846. /**
  69847. * The root nodes of a scene
  69848. */
  69849. interface IScene extends IChildRootProperty {
  69850. /**
  69851. * The indices of each root node
  69852. */
  69853. nodes: number[];
  69854. }
  69855. /**
  69856. * Joints and matrices defining a skin
  69857. */
  69858. interface ISkin extends IChildRootProperty {
  69859. /**
  69860. * 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
  69861. */
  69862. inverseBindMatrices?: number;
  69863. /**
  69864. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69865. */
  69866. skeleton?: number;
  69867. /**
  69868. * 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)
  69869. */
  69870. joints: number[];
  69871. }
  69872. /**
  69873. * A texture and its sampler
  69874. */
  69875. interface ITexture extends IChildRootProperty {
  69876. /**
  69877. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69878. */
  69879. sampler?: number;
  69880. /**
  69881. * The index of the image used by this texture
  69882. */
  69883. source: number;
  69884. }
  69885. /**
  69886. * Reference to a texture
  69887. */
  69888. interface ITextureInfo extends IProperty {
  69889. /**
  69890. * The index of the texture
  69891. */
  69892. index: number;
  69893. /**
  69894. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69895. */
  69896. texCoord?: number;
  69897. }
  69898. /**
  69899. * The root object for a glTF asset
  69900. */
  69901. interface IGLTF extends IProperty {
  69902. /**
  69903. * An array of accessors. An accessor is a typed view into a bufferView
  69904. */
  69905. accessors?: IAccessor[];
  69906. /**
  69907. * An array of keyframe animations
  69908. */
  69909. animations?: IAnimation[];
  69910. /**
  69911. * Metadata about the glTF asset
  69912. */
  69913. asset: IAsset;
  69914. /**
  69915. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69916. */
  69917. buffers?: IBuffer[];
  69918. /**
  69919. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69920. */
  69921. bufferViews?: IBufferView[];
  69922. /**
  69923. * An array of cameras
  69924. */
  69925. cameras?: ICamera[];
  69926. /**
  69927. * Names of glTF extensions used somewhere in this asset
  69928. */
  69929. extensionsUsed?: string[];
  69930. /**
  69931. * Names of glTF extensions required to properly load this asset
  69932. */
  69933. extensionsRequired?: string[];
  69934. /**
  69935. * An array of images. An image defines data used to create a texture
  69936. */
  69937. images?: IImage[];
  69938. /**
  69939. * An array of materials. A material defines the appearance of a primitive
  69940. */
  69941. materials?: IMaterial[];
  69942. /**
  69943. * An array of meshes. A mesh is a set of primitives to be rendered
  69944. */
  69945. meshes?: IMesh[];
  69946. /**
  69947. * An array of nodes
  69948. */
  69949. nodes?: INode[];
  69950. /**
  69951. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69952. */
  69953. samplers?: ISampler[];
  69954. /**
  69955. * The index of the default scene
  69956. */
  69957. scene?: number;
  69958. /**
  69959. * An array of scenes
  69960. */
  69961. scenes?: IScene[];
  69962. /**
  69963. * An array of skins. A skin is defined by joints and matrices
  69964. */
  69965. skins?: ISkin[];
  69966. /**
  69967. * An array of textures
  69968. */
  69969. textures?: ITexture[];
  69970. }
  69971. /**
  69972. * The glTF validation results
  69973. * @ignore
  69974. */
  69975. interface IGLTFValidationResults {
  69976. info: {
  69977. generator: string;
  69978. hasAnimations: boolean;
  69979. hasDefaultScene: boolean;
  69980. hasMaterials: boolean;
  69981. hasMorphTargets: boolean;
  69982. hasSkins: boolean;
  69983. hasTextures: boolean;
  69984. maxAttributesUsed: number;
  69985. primitivesCount: number
  69986. };
  69987. issues: {
  69988. messages: Array<string>;
  69989. numErrors: number;
  69990. numHints: number;
  69991. numInfos: number;
  69992. numWarnings: number;
  69993. truncated: boolean
  69994. };
  69995. mimeType: string;
  69996. uri: string;
  69997. validatedAt: string;
  69998. validatorVersion: string;
  69999. }
  70000. /**
  70001. * The glTF validation options
  70002. */
  70003. interface IGLTFValidationOptions {
  70004. /** Uri to use */
  70005. uri?: string;
  70006. /** Function used to load external resources */
  70007. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70008. /** Boolean indicating that we need to validate accessor data */
  70009. validateAccessorData?: boolean;
  70010. /** max number of issues allowed */
  70011. maxIssues?: number;
  70012. /** Ignored issues */
  70013. ignoredIssues?: Array<string>;
  70014. /** Value to override severy settings */
  70015. severityOverrides?: Object;
  70016. }
  70017. /**
  70018. * The glTF validator object
  70019. * @ignore
  70020. */
  70021. interface IGLTFValidator {
  70022. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70023. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /** @hidden */
  70028. export var cellPixelShader: {
  70029. name: string;
  70030. shader: string;
  70031. };
  70032. }
  70033. declare module BABYLON {
  70034. /** @hidden */
  70035. export var cellVertexShader: {
  70036. name: string;
  70037. shader: string;
  70038. };
  70039. }
  70040. declare module BABYLON {
  70041. export class CellMaterial extends BABYLON.PushMaterial {
  70042. private _diffuseTexture;
  70043. diffuseTexture: BABYLON.BaseTexture;
  70044. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  70045. computeHighLevel: boolean;
  70046. private _disableLighting;
  70047. disableLighting: boolean;
  70048. private _maxSimultaneousLights;
  70049. maxSimultaneousLights: number;
  70050. private _renderId;
  70051. constructor(name: string, scene: BABYLON.Scene);
  70052. needAlphaBlending(): boolean;
  70053. needAlphaTesting(): boolean;
  70054. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70055. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70056. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70057. getAnimatables(): BABYLON.IAnimatable[];
  70058. getActiveTextures(): BABYLON.BaseTexture[];
  70059. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70060. dispose(forceDisposeEffect?: boolean): void;
  70061. getClassName(): string;
  70062. clone(name: string): CellMaterial;
  70063. serialize(): any;
  70064. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. export class CustomShaderStructure {
  70069. FragmentStore: string;
  70070. VertexStore: string;
  70071. constructor();
  70072. }
  70073. export class ShaderSpecialParts {
  70074. constructor();
  70075. Fragment_Begin: string;
  70076. Fragment_Definitions: string;
  70077. Fragment_MainBegin: string;
  70078. Fragment_Custom_Diffuse: string;
  70079. Fragment_Before_Lights: string;
  70080. Fragment_Before_Fog: string;
  70081. Fragment_Custom_Alpha: string;
  70082. Fragment_Before_FragColor: string;
  70083. Vertex_Begin: string;
  70084. Vertex_Definitions: string;
  70085. Vertex_MainBegin: string;
  70086. Vertex_Before_PositionUpdated: string;
  70087. Vertex_Before_NormalUpdated: string;
  70088. Vertex_MainEnd: string;
  70089. }
  70090. export class CustomMaterial extends BABYLON.StandardMaterial {
  70091. static ShaderIndexer: number;
  70092. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  70093. FragmentShader: string;
  70094. VertexShader: string;
  70095. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70096. ReviewUniform(name: string, arr: string[]): string[];
  70097. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70098. constructor(name: string, scene: BABYLON.Scene);
  70099. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70100. Fragment_Begin(shaderPart: string): CustomMaterial;
  70101. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70102. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70103. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70104. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70105. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70106. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70107. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70108. Vertex_Begin(shaderPart: string): CustomMaterial;
  70109. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70110. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70111. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70112. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70113. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70114. }
  70115. }
  70116. declare module BABYLON {
  70117. export class ShaderAlebdoParts {
  70118. constructor();
  70119. Fragment_Begin: string;
  70120. Fragment_Definitions: string;
  70121. Fragment_MainBegin: string;
  70122. Fragment_Custom_Albedo: string;
  70123. Fragment_Before_Lights: string;
  70124. Fragment_Custom_MetallicRoughness: string;
  70125. Fragment_Custom_MicroSurface: string;
  70126. Fragment_Before_Fog: string;
  70127. Fragment_Custom_Alpha: string;
  70128. Fragment_Before_FragColor: string;
  70129. Vertex_Begin: string;
  70130. Vertex_Definitions: string;
  70131. Vertex_MainBegin: string;
  70132. Vertex_Before_PositionUpdated: string;
  70133. Vertex_Before_NormalUpdated: string;
  70134. Vertex_MainEnd: string;
  70135. }
  70136. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70137. static ShaderIndexer: number;
  70138. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  70139. FragmentShader: string;
  70140. VertexShader: string;
  70141. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70142. ReviewUniform(name: string, arr: string[]): string[];
  70143. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70144. constructor(name: string, scene: BABYLON.Scene);
  70145. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70146. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70147. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70148. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70149. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70150. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70151. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70152. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70153. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70154. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70155. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70156. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70157. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70158. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70159. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70160. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70161. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70162. }
  70163. }
  70164. declare module BABYLON {
  70165. /** @hidden */
  70166. export var firePixelShader: {
  70167. name: string;
  70168. shader: string;
  70169. };
  70170. }
  70171. declare module BABYLON {
  70172. /** @hidden */
  70173. export var fireVertexShader: {
  70174. name: string;
  70175. shader: string;
  70176. };
  70177. }
  70178. declare module BABYLON {
  70179. export class FireMaterial extends BABYLON.PushMaterial {
  70180. private _diffuseTexture;
  70181. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70182. private _distortionTexture;
  70183. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70184. private _opacityTexture;
  70185. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70186. diffuseColor: BABYLON.Color3;
  70187. speed: number;
  70188. private _scaledDiffuse;
  70189. private _renderId;
  70190. private _lastTime;
  70191. constructor(name: string, scene: BABYLON.Scene);
  70192. needAlphaBlending(): boolean;
  70193. needAlphaTesting(): boolean;
  70194. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70195. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70196. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70197. getAnimatables(): BABYLON.IAnimatable[];
  70198. getActiveTextures(): BABYLON.BaseTexture[];
  70199. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70200. getClassName(): string;
  70201. dispose(forceDisposeEffect?: boolean): void;
  70202. clone(name: string): FireMaterial;
  70203. serialize(): any;
  70204. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70205. }
  70206. }
  70207. declare module BABYLON {
  70208. /** @hidden */
  70209. export var furPixelShader: {
  70210. name: string;
  70211. shader: string;
  70212. };
  70213. }
  70214. declare module BABYLON {
  70215. /** @hidden */
  70216. export var furVertexShader: {
  70217. name: string;
  70218. shader: string;
  70219. };
  70220. }
  70221. declare module BABYLON {
  70222. export class FurMaterial extends BABYLON.PushMaterial {
  70223. private _diffuseTexture;
  70224. diffuseTexture: BABYLON.BaseTexture;
  70225. private _heightTexture;
  70226. heightTexture: BABYLON.BaseTexture;
  70227. diffuseColor: BABYLON.Color3;
  70228. furLength: number;
  70229. furAngle: number;
  70230. furColor: BABYLON.Color3;
  70231. furOffset: number;
  70232. furSpacing: number;
  70233. furGravity: BABYLON.Vector3;
  70234. furSpeed: number;
  70235. furDensity: number;
  70236. furOcclusion: number;
  70237. furTexture: BABYLON.DynamicTexture;
  70238. private _disableLighting;
  70239. disableLighting: boolean;
  70240. private _maxSimultaneousLights;
  70241. maxSimultaneousLights: number;
  70242. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  70243. private _renderId;
  70244. private _furTime;
  70245. constructor(name: string, scene: BABYLON.Scene);
  70246. furTime: number;
  70247. needAlphaBlending(): boolean;
  70248. needAlphaTesting(): boolean;
  70249. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70250. updateFur(): void;
  70251. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70252. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70253. getAnimatables(): BABYLON.IAnimatable[];
  70254. getActiveTextures(): BABYLON.BaseTexture[];
  70255. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70256. dispose(forceDisposeEffect?: boolean): void;
  70257. clone(name: string): FurMaterial;
  70258. serialize(): any;
  70259. getClassName(): string;
  70260. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70261. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70262. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70263. }
  70264. }
  70265. declare module BABYLON {
  70266. /** @hidden */
  70267. export var gradientPixelShader: {
  70268. name: string;
  70269. shader: string;
  70270. };
  70271. }
  70272. declare module BABYLON {
  70273. /** @hidden */
  70274. export var gradientVertexShader: {
  70275. name: string;
  70276. shader: string;
  70277. };
  70278. }
  70279. declare module BABYLON {
  70280. export class GradientMaterial extends BABYLON.PushMaterial {
  70281. private _maxSimultaneousLights;
  70282. maxSimultaneousLights: number;
  70283. topColor: BABYLON.Color3;
  70284. topColorAlpha: number;
  70285. bottomColor: BABYLON.Color3;
  70286. bottomColorAlpha: number;
  70287. offset: number;
  70288. scale: number;
  70289. smoothness: number;
  70290. private _disableLighting;
  70291. disableLighting: boolean;
  70292. private _renderId;
  70293. constructor(name: string, scene: BABYLON.Scene);
  70294. needAlphaBlending(): boolean;
  70295. needAlphaTesting(): boolean;
  70296. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70297. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70298. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70299. getAnimatables(): BABYLON.IAnimatable[];
  70300. dispose(forceDisposeEffect?: boolean): void;
  70301. clone(name: string): GradientMaterial;
  70302. serialize(): any;
  70303. getClassName(): string;
  70304. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70305. }
  70306. }
  70307. declare module BABYLON {
  70308. /** @hidden */
  70309. export var gridPixelShader: {
  70310. name: string;
  70311. shader: string;
  70312. };
  70313. }
  70314. declare module BABYLON {
  70315. /** @hidden */
  70316. export var gridVertexShader: {
  70317. name: string;
  70318. shader: string;
  70319. };
  70320. }
  70321. declare module BABYLON {
  70322. /**
  70323. * The grid materials allows you to wrap any shape with a grid.
  70324. * Colors are customizable.
  70325. */
  70326. export class GridMaterial extends BABYLON.PushMaterial {
  70327. /**
  70328. * Main color of the grid (e.g. between lines)
  70329. */
  70330. mainColor: BABYLON.Color3;
  70331. /**
  70332. * Color of the grid lines.
  70333. */
  70334. lineColor: BABYLON.Color3;
  70335. /**
  70336. * The scale of the grid compared to unit.
  70337. */
  70338. gridRatio: number;
  70339. /**
  70340. * Allows setting an offset for the grid lines.
  70341. */
  70342. gridOffset: BABYLON.Vector3;
  70343. /**
  70344. * The frequency of thicker lines.
  70345. */
  70346. majorUnitFrequency: number;
  70347. /**
  70348. * The visibility of minor units in the grid.
  70349. */
  70350. minorUnitVisibility: number;
  70351. /**
  70352. * The grid opacity outside of the lines.
  70353. */
  70354. opacity: number;
  70355. /**
  70356. * Determine RBG output is premultiplied by alpha value.
  70357. */
  70358. preMultiplyAlpha: boolean;
  70359. private _opacityTexture;
  70360. opacityTexture: BABYLON.BaseTexture;
  70361. private _gridControl;
  70362. private _renderId;
  70363. /**
  70364. * constructor
  70365. * @param name The name given to the material in order to identify it afterwards.
  70366. * @param scene The scene the material is used in.
  70367. */
  70368. constructor(name: string, scene: BABYLON.Scene);
  70369. /**
  70370. * Returns wehter or not the grid requires alpha blending.
  70371. */
  70372. needAlphaBlending(): boolean;
  70373. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70374. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70375. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70376. /**
  70377. * Dispose the material and its associated resources.
  70378. * @param forceDisposeEffect will also dispose the used effect when true
  70379. */
  70380. dispose(forceDisposeEffect?: boolean): void;
  70381. clone(name: string): GridMaterial;
  70382. serialize(): any;
  70383. getClassName(): string;
  70384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70385. }
  70386. }
  70387. declare module BABYLON {
  70388. /** @hidden */
  70389. export var lavaPixelShader: {
  70390. name: string;
  70391. shader: string;
  70392. };
  70393. }
  70394. declare module BABYLON {
  70395. /** @hidden */
  70396. export var lavaVertexShader: {
  70397. name: string;
  70398. shader: string;
  70399. };
  70400. }
  70401. declare module BABYLON {
  70402. export class LavaMaterial extends BABYLON.PushMaterial {
  70403. private _diffuseTexture;
  70404. diffuseTexture: BABYLON.BaseTexture;
  70405. noiseTexture: BABYLON.BaseTexture;
  70406. fogColor: BABYLON.Color3;
  70407. speed: number;
  70408. movingSpeed: number;
  70409. lowFrequencySpeed: number;
  70410. fogDensity: number;
  70411. private _lastTime;
  70412. diffuseColor: BABYLON.Color3;
  70413. private _disableLighting;
  70414. disableLighting: boolean;
  70415. private _unlit;
  70416. unlit: boolean;
  70417. private _maxSimultaneousLights;
  70418. maxSimultaneousLights: number;
  70419. private _scaledDiffuse;
  70420. private _renderId;
  70421. constructor(name: string, scene: BABYLON.Scene);
  70422. needAlphaBlending(): boolean;
  70423. needAlphaTesting(): boolean;
  70424. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70425. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70426. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70427. getAnimatables(): BABYLON.IAnimatable[];
  70428. getActiveTextures(): BABYLON.BaseTexture[];
  70429. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70430. dispose(forceDisposeEffect?: boolean): void;
  70431. clone(name: string): LavaMaterial;
  70432. serialize(): any;
  70433. getClassName(): string;
  70434. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70435. }
  70436. }
  70437. declare module BABYLON {
  70438. /** @hidden */
  70439. export var mixPixelShader: {
  70440. name: string;
  70441. shader: string;
  70442. };
  70443. }
  70444. declare module BABYLON {
  70445. /** @hidden */
  70446. export var mixVertexShader: {
  70447. name: string;
  70448. shader: string;
  70449. };
  70450. }
  70451. declare module BABYLON {
  70452. export class MixMaterial extends BABYLON.PushMaterial {
  70453. /**
  70454. * Mix textures
  70455. */
  70456. private _mixTexture1;
  70457. mixTexture1: BABYLON.BaseTexture;
  70458. private _mixTexture2;
  70459. mixTexture2: BABYLON.BaseTexture;
  70460. /**
  70461. * Diffuse textures
  70462. */
  70463. private _diffuseTexture1;
  70464. diffuseTexture1: BABYLON.Texture;
  70465. private _diffuseTexture2;
  70466. diffuseTexture2: BABYLON.Texture;
  70467. private _diffuseTexture3;
  70468. diffuseTexture3: BABYLON.Texture;
  70469. private _diffuseTexture4;
  70470. diffuseTexture4: BABYLON.Texture;
  70471. private _diffuseTexture5;
  70472. diffuseTexture5: BABYLON.Texture;
  70473. private _diffuseTexture6;
  70474. diffuseTexture6: BABYLON.Texture;
  70475. private _diffuseTexture7;
  70476. diffuseTexture7: BABYLON.Texture;
  70477. private _diffuseTexture8;
  70478. diffuseTexture8: BABYLON.Texture;
  70479. /**
  70480. * Uniforms
  70481. */
  70482. diffuseColor: BABYLON.Color3;
  70483. specularColor: BABYLON.Color3;
  70484. specularPower: number;
  70485. private _disableLighting;
  70486. disableLighting: boolean;
  70487. private _maxSimultaneousLights;
  70488. maxSimultaneousLights: number;
  70489. private _renderId;
  70490. constructor(name: string, scene: BABYLON.Scene);
  70491. needAlphaBlending(): boolean;
  70492. needAlphaTesting(): boolean;
  70493. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70494. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70495. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70496. getAnimatables(): BABYLON.IAnimatable[];
  70497. getActiveTextures(): BABYLON.BaseTexture[];
  70498. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70499. dispose(forceDisposeEffect?: boolean): void;
  70500. clone(name: string): MixMaterial;
  70501. serialize(): any;
  70502. getClassName(): string;
  70503. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70504. }
  70505. }
  70506. declare module BABYLON {
  70507. /** @hidden */
  70508. export var normalPixelShader: {
  70509. name: string;
  70510. shader: string;
  70511. };
  70512. }
  70513. declare module BABYLON {
  70514. /** @hidden */
  70515. export var normalVertexShader: {
  70516. name: string;
  70517. shader: string;
  70518. };
  70519. }
  70520. declare module BABYLON {
  70521. export class NormalMaterial extends BABYLON.PushMaterial {
  70522. private _diffuseTexture;
  70523. diffuseTexture: BABYLON.BaseTexture;
  70524. diffuseColor: BABYLON.Color3;
  70525. private _disableLighting;
  70526. disableLighting: boolean;
  70527. private _maxSimultaneousLights;
  70528. maxSimultaneousLights: number;
  70529. private _renderId;
  70530. constructor(name: string, scene: BABYLON.Scene);
  70531. needAlphaBlending(): boolean;
  70532. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70533. needAlphaTesting(): boolean;
  70534. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70535. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70536. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70537. getAnimatables(): BABYLON.IAnimatable[];
  70538. getActiveTextures(): BABYLON.BaseTexture[];
  70539. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70540. dispose(forceDisposeEffect?: boolean): void;
  70541. clone(name: string): NormalMaterial;
  70542. serialize(): any;
  70543. getClassName(): string;
  70544. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70545. }
  70546. }
  70547. declare module BABYLON {
  70548. /** @hidden */
  70549. export var shadowOnlyPixelShader: {
  70550. name: string;
  70551. shader: string;
  70552. };
  70553. }
  70554. declare module BABYLON {
  70555. /** @hidden */
  70556. export var shadowOnlyVertexShader: {
  70557. name: string;
  70558. shader: string;
  70559. };
  70560. }
  70561. declare module BABYLON {
  70562. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70563. private _renderId;
  70564. private _activeLight;
  70565. constructor(name: string, scene: BABYLON.Scene);
  70566. shadowColor: BABYLON.Color3;
  70567. needAlphaBlending(): boolean;
  70568. needAlphaTesting(): boolean;
  70569. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70570. activeLight: BABYLON.IShadowLight;
  70571. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70572. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70573. clone(name: string): ShadowOnlyMaterial;
  70574. serialize(): any;
  70575. getClassName(): string;
  70576. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70577. }
  70578. }
  70579. declare module BABYLON {
  70580. /** @hidden */
  70581. export var simplePixelShader: {
  70582. name: string;
  70583. shader: string;
  70584. };
  70585. }
  70586. declare module BABYLON {
  70587. /** @hidden */
  70588. export var simpleVertexShader: {
  70589. name: string;
  70590. shader: string;
  70591. };
  70592. }
  70593. declare module BABYLON {
  70594. export class SimpleMaterial extends BABYLON.PushMaterial {
  70595. private _diffuseTexture;
  70596. diffuseTexture: BABYLON.BaseTexture;
  70597. diffuseColor: BABYLON.Color3;
  70598. private _disableLighting;
  70599. disableLighting: boolean;
  70600. private _maxSimultaneousLights;
  70601. maxSimultaneousLights: number;
  70602. private _renderId;
  70603. constructor(name: string, scene: BABYLON.Scene);
  70604. needAlphaBlending(): boolean;
  70605. needAlphaTesting(): boolean;
  70606. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70607. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70608. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70609. getAnimatables(): BABYLON.IAnimatable[];
  70610. getActiveTextures(): BABYLON.BaseTexture[];
  70611. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70612. dispose(forceDisposeEffect?: boolean): void;
  70613. clone(name: string): SimpleMaterial;
  70614. serialize(): any;
  70615. getClassName(): string;
  70616. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70617. }
  70618. }
  70619. declare module BABYLON {
  70620. /** @hidden */
  70621. export var skyPixelShader: {
  70622. name: string;
  70623. shader: string;
  70624. };
  70625. }
  70626. declare module BABYLON {
  70627. /** @hidden */
  70628. export var skyVertexShader: {
  70629. name: string;
  70630. shader: string;
  70631. };
  70632. }
  70633. declare module BABYLON {
  70634. /**
  70635. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70636. * @see https://doc.babylonjs.com/extensions/sky
  70637. */
  70638. export class SkyMaterial extends BABYLON.PushMaterial {
  70639. /**
  70640. * Defines the overall luminance of sky in interval ]0, 1[.
  70641. */
  70642. luminance: number;
  70643. /**
  70644. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70645. */
  70646. turbidity: number;
  70647. /**
  70648. * Defines the sky appearance (light intensity).
  70649. */
  70650. rayleigh: number;
  70651. /**
  70652. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70653. */
  70654. mieCoefficient: number;
  70655. /**
  70656. * Defines the amount of haze particles following the Mie scattering theory.
  70657. */
  70658. mieDirectionalG: number;
  70659. /**
  70660. * Defines the distance of the sun according to the active scene camera.
  70661. */
  70662. distance: number;
  70663. /**
  70664. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70665. * "inclined".
  70666. */
  70667. inclination: number;
  70668. /**
  70669. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70670. * an object direction and a reference direction.
  70671. */
  70672. azimuth: number;
  70673. /**
  70674. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70675. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70676. */
  70677. sunPosition: BABYLON.Vector3;
  70678. /**
  70679. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70680. * .sunPosition property.
  70681. */
  70682. useSunPosition: boolean;
  70683. /**
  70684. * Defines an offset vector used to get a horizon offset.
  70685. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70686. */
  70687. cameraOffset: BABYLON.Vector3;
  70688. private _cameraPosition;
  70689. private _renderId;
  70690. /**
  70691. * Instantiates a new sky material.
  70692. * This material allows to create dynamic and texture free
  70693. * effects for skyboxes by taking care of the atmosphere state.
  70694. * @see https://doc.babylonjs.com/extensions/sky
  70695. * @param name Define the name of the material in the scene
  70696. * @param scene Define the scene the material belong to
  70697. */
  70698. constructor(name: string, scene: BABYLON.Scene);
  70699. /**
  70700. * Specifies if the material will require alpha blending
  70701. * @returns a boolean specifying if alpha blending is needed
  70702. */
  70703. needAlphaBlending(): boolean;
  70704. /**
  70705. * Specifies if this material should be rendered in alpha test mode
  70706. * @returns false as the sky material doesn't need alpha testing.
  70707. */
  70708. needAlphaTesting(): boolean;
  70709. /**
  70710. * Get the texture used for alpha test purpose.
  70711. * @returns null as the sky material has no texture.
  70712. */
  70713. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70714. /**
  70715. * Get if the submesh is ready to be used and all its information available.
  70716. * Child classes can use it to update shaders
  70717. * @param mesh defines the mesh to check
  70718. * @param subMesh defines which submesh to check
  70719. * @param useInstances specifies that instances should be used
  70720. * @returns a boolean indicating that the submesh is ready or not
  70721. */
  70722. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70723. /**
  70724. * Binds the submesh to this material by preparing the effect and shader to draw
  70725. * @param world defines the world transformation matrix
  70726. * @param mesh defines the mesh containing the submesh
  70727. * @param subMesh defines the submesh to bind the material to
  70728. */
  70729. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70730. /**
  70731. * Get the list of animatables in the material.
  70732. * @returns the list of animatables object used in the material
  70733. */
  70734. getAnimatables(): BABYLON.IAnimatable[];
  70735. /**
  70736. * Disposes the material
  70737. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70738. */
  70739. dispose(forceDisposeEffect?: boolean): void;
  70740. /**
  70741. * Makes a duplicate of the material, and gives it a new name
  70742. * @param name defines the new name for the duplicated material
  70743. * @returns the cloned material
  70744. */
  70745. clone(name: string): SkyMaterial;
  70746. /**
  70747. * Serializes this material in a JSON representation
  70748. * @returns the serialized material object
  70749. */
  70750. serialize(): any;
  70751. /**
  70752. * Gets the current class name of the material e.g. "SkyMaterial"
  70753. * Mainly use in serialization.
  70754. * @returns the class name
  70755. */
  70756. getClassName(): string;
  70757. /**
  70758. * Creates a sky material from parsed material data
  70759. * @param source defines the JSON representation of the material
  70760. * @param scene defines the hosting scene
  70761. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70762. * @returns a new sky material
  70763. */
  70764. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70765. }
  70766. }
  70767. declare module BABYLON {
  70768. /** @hidden */
  70769. export var terrainPixelShader: {
  70770. name: string;
  70771. shader: string;
  70772. };
  70773. }
  70774. declare module BABYLON {
  70775. /** @hidden */
  70776. export var terrainVertexShader: {
  70777. name: string;
  70778. shader: string;
  70779. };
  70780. }
  70781. declare module BABYLON {
  70782. export class TerrainMaterial extends BABYLON.PushMaterial {
  70783. private _mixTexture;
  70784. mixTexture: BABYLON.BaseTexture;
  70785. private _diffuseTexture1;
  70786. diffuseTexture1: BABYLON.Texture;
  70787. private _diffuseTexture2;
  70788. diffuseTexture2: BABYLON.Texture;
  70789. private _diffuseTexture3;
  70790. diffuseTexture3: BABYLON.Texture;
  70791. private _bumpTexture1;
  70792. bumpTexture1: BABYLON.Texture;
  70793. private _bumpTexture2;
  70794. bumpTexture2: BABYLON.Texture;
  70795. private _bumpTexture3;
  70796. bumpTexture3: BABYLON.Texture;
  70797. diffuseColor: BABYLON.Color3;
  70798. specularColor: BABYLON.Color3;
  70799. specularPower: number;
  70800. private _disableLighting;
  70801. disableLighting: boolean;
  70802. private _maxSimultaneousLights;
  70803. maxSimultaneousLights: number;
  70804. private _renderId;
  70805. constructor(name: string, scene: BABYLON.Scene);
  70806. needAlphaBlending(): boolean;
  70807. needAlphaTesting(): boolean;
  70808. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70809. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70811. getAnimatables(): BABYLON.IAnimatable[];
  70812. getActiveTextures(): BABYLON.BaseTexture[];
  70813. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70814. dispose(forceDisposeEffect?: boolean): void;
  70815. clone(name: string): TerrainMaterial;
  70816. serialize(): any;
  70817. getClassName(): string;
  70818. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70819. }
  70820. }
  70821. declare module BABYLON {
  70822. /** @hidden */
  70823. export var triplanarPixelShader: {
  70824. name: string;
  70825. shader: string;
  70826. };
  70827. }
  70828. declare module BABYLON {
  70829. /** @hidden */
  70830. export var triplanarVertexShader: {
  70831. name: string;
  70832. shader: string;
  70833. };
  70834. }
  70835. declare module BABYLON {
  70836. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70837. mixTexture: BABYLON.BaseTexture;
  70838. private _diffuseTextureX;
  70839. diffuseTextureX: BABYLON.BaseTexture;
  70840. private _diffuseTextureY;
  70841. diffuseTextureY: BABYLON.BaseTexture;
  70842. private _diffuseTextureZ;
  70843. diffuseTextureZ: BABYLON.BaseTexture;
  70844. private _normalTextureX;
  70845. normalTextureX: BABYLON.BaseTexture;
  70846. private _normalTextureY;
  70847. normalTextureY: BABYLON.BaseTexture;
  70848. private _normalTextureZ;
  70849. normalTextureZ: BABYLON.BaseTexture;
  70850. tileSize: number;
  70851. diffuseColor: BABYLON.Color3;
  70852. specularColor: BABYLON.Color3;
  70853. specularPower: number;
  70854. private _disableLighting;
  70855. disableLighting: boolean;
  70856. private _maxSimultaneousLights;
  70857. maxSimultaneousLights: number;
  70858. private _renderId;
  70859. constructor(name: string, scene: BABYLON.Scene);
  70860. needAlphaBlending(): boolean;
  70861. needAlphaTesting(): boolean;
  70862. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70863. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70864. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70865. getAnimatables(): BABYLON.IAnimatable[];
  70866. getActiveTextures(): BABYLON.BaseTexture[];
  70867. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70868. dispose(forceDisposeEffect?: boolean): void;
  70869. clone(name: string): TriPlanarMaterial;
  70870. serialize(): any;
  70871. getClassName(): string;
  70872. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70873. }
  70874. }
  70875. declare module BABYLON {
  70876. /** @hidden */
  70877. export var waterPixelShader: {
  70878. name: string;
  70879. shader: string;
  70880. };
  70881. }
  70882. declare module BABYLON {
  70883. /** @hidden */
  70884. export var waterVertexShader: {
  70885. name: string;
  70886. shader: string;
  70887. };
  70888. }
  70889. declare module BABYLON {
  70890. export class WaterMaterial extends BABYLON.PushMaterial {
  70891. renderTargetSize: BABYLON.Vector2;
  70892. private _bumpTexture;
  70893. bumpTexture: BABYLON.BaseTexture;
  70894. diffuseColor: BABYLON.Color3;
  70895. specularColor: BABYLON.Color3;
  70896. specularPower: number;
  70897. private _disableLighting;
  70898. disableLighting: boolean;
  70899. private _maxSimultaneousLights;
  70900. maxSimultaneousLights: number;
  70901. /**
  70902. * @param {number}: Represents the wind force
  70903. */
  70904. windForce: number;
  70905. /**
  70906. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70907. */
  70908. windDirection: BABYLON.Vector2;
  70909. /**
  70910. * @param {number}: Wave height, represents the height of the waves
  70911. */
  70912. waveHeight: number;
  70913. /**
  70914. * @param {number}: Bump height, represents the bump height related to the bump map
  70915. */
  70916. bumpHeight: number;
  70917. /**
  70918. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70919. */
  70920. private _bumpSuperimpose;
  70921. bumpSuperimpose: boolean;
  70922. /**
  70923. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70924. */
  70925. private _fresnelSeparate;
  70926. fresnelSeparate: boolean;
  70927. /**
  70928. * @param {boolean}: bump Waves modify the reflection.
  70929. */
  70930. private _bumpAffectsReflection;
  70931. bumpAffectsReflection: boolean;
  70932. /**
  70933. * @param {number}: The water color blended with the refraction (near)
  70934. */
  70935. waterColor: BABYLON.Color3;
  70936. /**
  70937. * @param {number}: The blend factor related to the water color
  70938. */
  70939. colorBlendFactor: number;
  70940. /**
  70941. * @param {number}: The water color blended with the reflection (far)
  70942. */
  70943. waterColor2: BABYLON.Color3;
  70944. /**
  70945. * @param {number}: The blend factor related to the water color (reflection, far)
  70946. */
  70947. colorBlendFactor2: number;
  70948. /**
  70949. * @param {number}: Represents the maximum length of a wave
  70950. */
  70951. waveLength: number;
  70952. /**
  70953. * @param {number}: Defines the waves speed
  70954. */
  70955. waveSpeed: number;
  70956. /**
  70957. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70958. * will avoid calculating useless pixels in the pixel shader of the water material.
  70959. */
  70960. disableClipPlane: boolean;
  70961. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70962. private _mesh;
  70963. private _refractionRTT;
  70964. private _reflectionRTT;
  70965. private _reflectionTransform;
  70966. private _lastTime;
  70967. private _lastDeltaTime;
  70968. private _renderId;
  70969. private _useLogarithmicDepth;
  70970. private _waitingRenderList;
  70971. private _imageProcessingConfiguration;
  70972. private _imageProcessingObserver;
  70973. /**
  70974. * Gets a boolean indicating that current material needs to register RTT
  70975. */
  70976. readonly hasRenderTargetTextures: boolean;
  70977. /**
  70978. * Constructor
  70979. */
  70980. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70981. useLogarithmicDepth: boolean;
  70982. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70983. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70984. addToRenderList(node: any): void;
  70985. enableRenderTargets(enable: boolean): void;
  70986. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70987. readonly renderTargetsEnabled: boolean;
  70988. needAlphaBlending(): boolean;
  70989. needAlphaTesting(): boolean;
  70990. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70993. private _createRenderTargets;
  70994. getAnimatables(): BABYLON.IAnimatable[];
  70995. getActiveTextures(): BABYLON.BaseTexture[];
  70996. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70997. dispose(forceDisposeEffect?: boolean): void;
  70998. clone(name: string): WaterMaterial;
  70999. serialize(): any;
  71000. getClassName(): string;
  71001. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71002. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71003. }
  71004. }
  71005. declare module BABYLON {
  71006. /** @hidden */
  71007. export var asciiartPixelShader: {
  71008. name: string;
  71009. shader: string;
  71010. };
  71011. }
  71012. declare module BABYLON {
  71013. /**
  71014. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71015. *
  71016. * It basically takes care rendering the font front the given font size to a texture.
  71017. * This is used later on in the postprocess.
  71018. */
  71019. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71020. private _font;
  71021. private _text;
  71022. private _charSize;
  71023. /**
  71024. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71025. */
  71026. readonly charSize: number;
  71027. /**
  71028. * Create a new instance of the Ascii Art FontTexture class
  71029. * @param name the name of the texture
  71030. * @param font the font to use, use the W3C CSS notation
  71031. * @param text the caracter set to use in the rendering.
  71032. * @param scene the scene that owns the texture
  71033. */
  71034. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71035. /**
  71036. * Gets the max char width of a font.
  71037. * @param font the font to use, use the W3C CSS notation
  71038. * @return the max char width
  71039. */
  71040. private getFontWidth;
  71041. /**
  71042. * Gets the max char height of a font.
  71043. * @param font the font to use, use the W3C CSS notation
  71044. * @return the max char height
  71045. */
  71046. private getFontHeight;
  71047. /**
  71048. * Clones the current AsciiArtTexture.
  71049. * @return the clone of the texture.
  71050. */
  71051. clone(): AsciiArtFontTexture;
  71052. /**
  71053. * Parses a json object representing the texture and returns an instance of it.
  71054. * @param source the source JSON representation
  71055. * @param scene the scene to create the texture for
  71056. * @return the parsed texture
  71057. */
  71058. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71059. }
  71060. /**
  71061. * Option available in the Ascii Art Post Process.
  71062. */
  71063. export interface IAsciiArtPostProcessOptions {
  71064. /**
  71065. * The font to use following the w3c font definition.
  71066. */
  71067. font?: string;
  71068. /**
  71069. * The character set to use in the postprocess.
  71070. */
  71071. characterSet?: string;
  71072. /**
  71073. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71074. * This number is defined between 0 and 1;
  71075. */
  71076. mixToTile?: number;
  71077. /**
  71078. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71079. * This number is defined between 0 and 1;
  71080. */
  71081. mixToNormal?: number;
  71082. }
  71083. /**
  71084. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71085. *
  71086. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71087. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71088. */
  71089. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71090. /**
  71091. * The font texture used to render the char in the post process.
  71092. */
  71093. private _asciiArtFontTexture;
  71094. /**
  71095. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71096. * This number is defined between 0 and 1;
  71097. */
  71098. mixToTile: number;
  71099. /**
  71100. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71101. * This number is defined between 0 and 1;
  71102. */
  71103. mixToNormal: number;
  71104. /**
  71105. * Instantiates a new Ascii Art Post Process.
  71106. * @param name the name to give to the postprocess
  71107. * @camera the camera to apply the post process to.
  71108. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71109. */
  71110. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71111. }
  71112. }
  71113. declare module BABYLON {
  71114. /** @hidden */
  71115. export var digitalrainPixelShader: {
  71116. name: string;
  71117. shader: string;
  71118. };
  71119. }
  71120. declare module BABYLON {
  71121. /**
  71122. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71123. *
  71124. * It basically takes care rendering the font front the given font size to a texture.
  71125. * This is used later on in the postprocess.
  71126. */
  71127. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71128. private _font;
  71129. private _text;
  71130. private _charSize;
  71131. /**
  71132. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71133. */
  71134. readonly charSize: number;
  71135. /**
  71136. * Create a new instance of the Digital Rain FontTexture class
  71137. * @param name the name of the texture
  71138. * @param font the font to use, use the W3C CSS notation
  71139. * @param text the caracter set to use in the rendering.
  71140. * @param scene the scene that owns the texture
  71141. */
  71142. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71143. /**
  71144. * Gets the max char width of a font.
  71145. * @param font the font to use, use the W3C CSS notation
  71146. * @return the max char width
  71147. */
  71148. private getFontWidth;
  71149. /**
  71150. * Gets the max char height of a font.
  71151. * @param font the font to use, use the W3C CSS notation
  71152. * @return the max char height
  71153. */
  71154. private getFontHeight;
  71155. /**
  71156. * Clones the current DigitalRainFontTexture.
  71157. * @return the clone of the texture.
  71158. */
  71159. clone(): DigitalRainFontTexture;
  71160. /**
  71161. * Parses a json object representing the texture and returns an instance of it.
  71162. * @param source the source JSON representation
  71163. * @param scene the scene to create the texture for
  71164. * @return the parsed texture
  71165. */
  71166. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71167. }
  71168. /**
  71169. * Option available in the Digital Rain Post Process.
  71170. */
  71171. export interface IDigitalRainPostProcessOptions {
  71172. /**
  71173. * The font to use following the w3c font definition.
  71174. */
  71175. font?: string;
  71176. /**
  71177. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71178. * This number is defined between 0 and 1;
  71179. */
  71180. mixToTile?: number;
  71181. /**
  71182. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71183. * This number is defined between 0 and 1;
  71184. */
  71185. mixToNormal?: number;
  71186. }
  71187. /**
  71188. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71189. *
  71190. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71191. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71192. */
  71193. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71194. /**
  71195. * The font texture used to render the char in the post process.
  71196. */
  71197. private _digitalRainFontTexture;
  71198. /**
  71199. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71200. * This number is defined between 0 and 1;
  71201. */
  71202. mixToTile: number;
  71203. /**
  71204. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71205. * This number is defined between 0 and 1;
  71206. */
  71207. mixToNormal: number;
  71208. /**
  71209. * Instantiates a new Digital Rain Post Process.
  71210. * @param name the name to give to the postprocess
  71211. * @camera the camera to apply the post process to.
  71212. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71213. */
  71214. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71215. }
  71216. }
  71217. declare module BABYLON {
  71218. /** @hidden */
  71219. export var oceanPostProcessPixelShader: {
  71220. name: string;
  71221. shader: string;
  71222. };
  71223. }
  71224. declare module BABYLON {
  71225. /**
  71226. * Option available in the Ocean Post Process.
  71227. */
  71228. export interface IOceanPostProcessOptions {
  71229. /**
  71230. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71231. */
  71232. reflectionSize?: number | {
  71233. width: number;
  71234. height: number;
  71235. } | {
  71236. ratio: number;
  71237. };
  71238. /**
  71239. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71240. */
  71241. refractionSize?: number | {
  71242. width: number;
  71243. height: number;
  71244. } | {
  71245. ratio: number;
  71246. };
  71247. }
  71248. /**
  71249. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71250. *
  71251. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71252. * Example usage:
  71253. * var pp = new OceanPostProcess("myOcean", camera);
  71254. * pp.reflectionEnabled = true;
  71255. * pp.refractionEnabled = true;
  71256. */
  71257. export class OceanPostProcess extends BABYLON.PostProcess {
  71258. /**
  71259. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71260. */
  71261. /**
  71262. * Sets weither or not the real-time reflection is enabled on the ocean.
  71263. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71264. */
  71265. reflectionEnabled: boolean;
  71266. /**
  71267. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71268. */
  71269. /**
  71270. * Sets weither or not the real-time refraction is enabled on the ocean.
  71271. * Is set to true, the refraction render target texture will be used as refraction texture.
  71272. */
  71273. refractionEnabled: boolean;
  71274. /**
  71275. * Gets wether or not the post-processes is supported by the running hardware.
  71276. * This requires draw buffer supports.
  71277. */
  71278. readonly isSupported: boolean;
  71279. /**
  71280. * This is the reflection mirror texture used to display reflections on the ocean.
  71281. * By default, render list is empty.
  71282. */
  71283. reflectionTexture: BABYLON.MirrorTexture;
  71284. /**
  71285. * This is the refraction render target texture used to display refraction on the ocean.
  71286. * By default, render list is empty.
  71287. */
  71288. refractionTexture: BABYLON.RenderTargetTexture;
  71289. private _time;
  71290. private _cameraRotation;
  71291. private _cameraViewMatrix;
  71292. private _reflectionEnabled;
  71293. private _refractionEnabled;
  71294. private _geometryRenderer;
  71295. /**
  71296. * Instantiates a new Ocean Post Process.
  71297. * @param name the name to give to the postprocess.
  71298. * @camera the camera to apply the post process to.
  71299. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71300. */
  71301. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71302. /**
  71303. * Returns the appropriate defines according to the current configuration.
  71304. */
  71305. private _getDefines;
  71306. /**
  71307. * Computes the current camera rotation as the shader requires a camera rotation.
  71308. */
  71309. private _computeCameraRotation;
  71310. }
  71311. }
  71312. declare module BABYLON {
  71313. /** @hidden */
  71314. export var brickProceduralTexturePixelShader: {
  71315. name: string;
  71316. shader: string;
  71317. };
  71318. }
  71319. declare module BABYLON {
  71320. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71321. private _numberOfBricksHeight;
  71322. private _numberOfBricksWidth;
  71323. private _jointColor;
  71324. private _brickColor;
  71325. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71326. updateShaderUniforms(): void;
  71327. numberOfBricksHeight: number;
  71328. numberOfBricksWidth: number;
  71329. jointColor: BABYLON.Color3;
  71330. brickColor: BABYLON.Color3;
  71331. /**
  71332. * Serializes this brick procedural texture
  71333. * @returns a serialized brick procedural texture object
  71334. */
  71335. serialize(): any;
  71336. /**
  71337. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71338. * @param parsedTexture defines parsed texture data
  71339. * @param scene defines the current scene
  71340. * @param rootUrl defines the root URL containing brick procedural texture information
  71341. * @returns a parsed Brick Procedural BABYLON.Texture
  71342. */
  71343. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /** @hidden */
  71348. export var cloudProceduralTexturePixelShader: {
  71349. name: string;
  71350. shader: string;
  71351. };
  71352. }
  71353. declare module BABYLON {
  71354. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71355. private _skyColor;
  71356. private _cloudColor;
  71357. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71358. updateShaderUniforms(): void;
  71359. skyColor: BABYLON.Color4;
  71360. cloudColor: BABYLON.Color4;
  71361. /**
  71362. * Serializes this cloud procedural texture
  71363. * @returns a serialized cloud procedural texture object
  71364. */
  71365. serialize(): any;
  71366. /**
  71367. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71368. * @param parsedTexture defines parsed texture data
  71369. * @param scene defines the current scene
  71370. * @param rootUrl defines the root URL containing cloud procedural texture information
  71371. * @returns a parsed Cloud Procedural BABYLON.Texture
  71372. */
  71373. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71374. }
  71375. }
  71376. declare module BABYLON {
  71377. /** @hidden */
  71378. export var fireProceduralTexturePixelShader: {
  71379. name: string;
  71380. shader: string;
  71381. };
  71382. }
  71383. declare module BABYLON {
  71384. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71385. private _time;
  71386. private _speed;
  71387. private _autoGenerateTime;
  71388. private _fireColors;
  71389. private _alphaThreshold;
  71390. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71391. updateShaderUniforms(): void;
  71392. render(useCameraPostProcess?: boolean): void;
  71393. static readonly PurpleFireColors: BABYLON.Color3[];
  71394. static readonly GreenFireColors: BABYLON.Color3[];
  71395. static readonly RedFireColors: BABYLON.Color3[];
  71396. static readonly BlueFireColors: BABYLON.Color3[];
  71397. autoGenerateTime: boolean;
  71398. fireColors: BABYLON.Color3[];
  71399. time: number;
  71400. speed: BABYLON.Vector2;
  71401. alphaThreshold: number;
  71402. /**
  71403. * Serializes this fire procedural texture
  71404. * @returns a serialized fire procedural texture object
  71405. */
  71406. serialize(): any;
  71407. /**
  71408. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71409. * @param parsedTexture defines parsed texture data
  71410. * @param scene defines the current scene
  71411. * @param rootUrl defines the root URL containing fire procedural texture information
  71412. * @returns a parsed Fire Procedural BABYLON.Texture
  71413. */
  71414. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71415. }
  71416. }
  71417. declare module BABYLON {
  71418. /** @hidden */
  71419. export var grassProceduralTexturePixelShader: {
  71420. name: string;
  71421. shader: string;
  71422. };
  71423. }
  71424. declare module BABYLON {
  71425. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71426. private _grassColors;
  71427. private _groundColor;
  71428. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71429. updateShaderUniforms(): void;
  71430. grassColors: BABYLON.Color3[];
  71431. groundColor: BABYLON.Color3;
  71432. /**
  71433. * Serializes this grass procedural texture
  71434. * @returns a serialized grass procedural texture object
  71435. */
  71436. serialize(): any;
  71437. /**
  71438. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71439. * @param parsedTexture defines parsed texture data
  71440. * @param scene defines the current scene
  71441. * @param rootUrl defines the root URL containing grass procedural texture information
  71442. * @returns a parsed Grass Procedural BABYLON.Texture
  71443. */
  71444. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71445. }
  71446. }
  71447. declare module BABYLON {
  71448. /** @hidden */
  71449. export var marbleProceduralTexturePixelShader: {
  71450. name: string;
  71451. shader: string;
  71452. };
  71453. }
  71454. declare module BABYLON {
  71455. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71456. private _numberOfTilesHeight;
  71457. private _numberOfTilesWidth;
  71458. private _amplitude;
  71459. private _jointColor;
  71460. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71461. updateShaderUniforms(): void;
  71462. numberOfTilesHeight: number;
  71463. amplitude: number;
  71464. numberOfTilesWidth: number;
  71465. jointColor: BABYLON.Color3;
  71466. /**
  71467. * Serializes this marble procedural texture
  71468. * @returns a serialized marble procedural texture object
  71469. */
  71470. serialize(): any;
  71471. /**
  71472. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71473. * @param parsedTexture defines parsed texture data
  71474. * @param scene defines the current scene
  71475. * @param rootUrl defines the root URL containing marble procedural texture information
  71476. * @returns a parsed Marble Procedural BABYLON.Texture
  71477. */
  71478. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71479. }
  71480. }
  71481. declare module BABYLON {
  71482. /** @hidden */
  71483. export var normalMapProceduralTexturePixelShader: {
  71484. name: string;
  71485. shader: string;
  71486. };
  71487. }
  71488. declare module BABYLON {
  71489. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71490. private _baseTexture;
  71491. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71492. updateShaderUniforms(): void;
  71493. render(useCameraPostProcess?: boolean): void;
  71494. resize(size: any, generateMipMaps: any): void;
  71495. baseTexture: BABYLON.Texture;
  71496. /**
  71497. * Serializes this normal map procedural texture
  71498. * @returns a serialized normal map procedural texture object
  71499. */
  71500. serialize(): any;
  71501. /**
  71502. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71503. * @param parsedTexture defines parsed texture data
  71504. * @param scene defines the current scene
  71505. * @param rootUrl defines the root URL containing normal map procedural texture information
  71506. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71507. */
  71508. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71509. }
  71510. }
  71511. declare module BABYLON {
  71512. /** @hidden */
  71513. export var perlinNoiseProceduralTexturePixelShader: {
  71514. name: string;
  71515. shader: string;
  71516. };
  71517. }
  71518. declare module BABYLON {
  71519. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71520. time: number;
  71521. timeScale: number;
  71522. translationSpeed: number;
  71523. private _currentTranslation;
  71524. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71525. updateShaderUniforms(): void;
  71526. render(useCameraPostProcess?: boolean): void;
  71527. resize(size: any, generateMipMaps: any): void;
  71528. /**
  71529. * Serializes this perlin noise procedural texture
  71530. * @returns a serialized perlin noise procedural texture object
  71531. */
  71532. serialize(): any;
  71533. /**
  71534. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71535. * @param parsedTexture defines parsed texture data
  71536. * @param scene defines the current scene
  71537. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71538. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71539. */
  71540. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71541. }
  71542. }
  71543. declare module BABYLON {
  71544. /** @hidden */
  71545. export var roadProceduralTexturePixelShader: {
  71546. name: string;
  71547. shader: string;
  71548. };
  71549. }
  71550. declare module BABYLON {
  71551. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71552. private _roadColor;
  71553. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71554. updateShaderUniforms(): void;
  71555. roadColor: BABYLON.Color3;
  71556. /**
  71557. * Serializes this road procedural texture
  71558. * @returns a serialized road procedural texture object
  71559. */
  71560. serialize(): any;
  71561. /**
  71562. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71563. * @param parsedTexture defines parsed texture data
  71564. * @param scene defines the current scene
  71565. * @param rootUrl defines the root URL containing road procedural texture information
  71566. * @returns a parsed Road Procedural BABYLON.Texture
  71567. */
  71568. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71569. }
  71570. }
  71571. declare module BABYLON {
  71572. /** @hidden */
  71573. export var starfieldProceduralTexturePixelShader: {
  71574. name: string;
  71575. shader: string;
  71576. };
  71577. }
  71578. declare module BABYLON {
  71579. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71580. private _time;
  71581. private _alpha;
  71582. private _beta;
  71583. private _zoom;
  71584. private _formuparam;
  71585. private _stepsize;
  71586. private _tile;
  71587. private _brightness;
  71588. private _darkmatter;
  71589. private _distfading;
  71590. private _saturation;
  71591. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71592. updateShaderUniforms(): void;
  71593. time: number;
  71594. alpha: number;
  71595. beta: number;
  71596. formuparam: number;
  71597. stepsize: number;
  71598. zoom: number;
  71599. tile: number;
  71600. brightness: number;
  71601. darkmatter: number;
  71602. distfading: number;
  71603. saturation: number;
  71604. /**
  71605. * Serializes this starfield procedural texture
  71606. * @returns a serialized starfield procedural texture object
  71607. */
  71608. serialize(): any;
  71609. /**
  71610. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71611. * @param parsedTexture defines parsed texture data
  71612. * @param scene defines the current scene
  71613. * @param rootUrl defines the root URL containing startfield procedural texture information
  71614. * @returns a parsed Starfield Procedural BABYLON.Texture
  71615. */
  71616. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71617. }
  71618. }
  71619. declare module BABYLON {
  71620. /** @hidden */
  71621. export var woodProceduralTexturePixelShader: {
  71622. name: string;
  71623. shader: string;
  71624. };
  71625. }
  71626. declare module BABYLON {
  71627. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71628. private _ampScale;
  71629. private _woodColor;
  71630. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71631. updateShaderUniforms(): void;
  71632. ampScale: number;
  71633. woodColor: BABYLON.Color3;
  71634. /**
  71635. * Serializes this wood procedural texture
  71636. * @returns a serialized wood procedural texture object
  71637. */
  71638. serialize(): any;
  71639. /**
  71640. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71641. * @param parsedTexture defines parsed texture data
  71642. * @param scene defines the current scene
  71643. * @param rootUrl defines the root URL containing wood procedural texture information
  71644. * @returns a parsed Wood Procedural BABYLON.Texture
  71645. */
  71646. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71647. }
  71648. }