babylon.d.txt 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * 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.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * 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).
  160. * 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.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @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.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Checks if the navigator object exists
  282. * @returns true if the navigator object exists
  283. */
  284. static IsNavigatorAvailable(): boolean;
  285. /**
  286. * Extracts text content from a DOM element hierarchy
  287. * @param element defines the root element
  288. * @returns a string
  289. */
  290. static GetDOMTextContent(element: HTMLElement): string;
  291. }
  292. }
  293. declare module BABYLON {
  294. /**
  295. * Logger used througouht the application to allow configuration of
  296. * the log level required for the messages.
  297. */
  298. export class Logger {
  299. /**
  300. * No log
  301. */
  302. static readonly NoneLogLevel: number;
  303. /**
  304. * Only message logs
  305. */
  306. static readonly MessageLogLevel: number;
  307. /**
  308. * Only warning logs
  309. */
  310. static readonly WarningLogLevel: number;
  311. /**
  312. * Only error logs
  313. */
  314. static readonly ErrorLogLevel: number;
  315. /**
  316. * All logs
  317. */
  318. static readonly AllLogLevel: number;
  319. private static _LogCache;
  320. /**
  321. * Gets a value indicating the number of loading errors
  322. * @ignorenaming
  323. */
  324. static errorsCount: number;
  325. /**
  326. * Callback called when a new log is added
  327. */
  328. static OnNewCacheEntry: (entry: string) => void;
  329. private static _AddLogEntry;
  330. private static _FormatMessage;
  331. private static _LogDisabled;
  332. private static _LogEnabled;
  333. private static _WarnDisabled;
  334. private static _WarnEnabled;
  335. private static _ErrorDisabled;
  336. private static _ErrorEnabled;
  337. /**
  338. * Log a message to the console
  339. */
  340. static Log: (message: string) => void;
  341. /**
  342. * Write a warning message to the console
  343. */
  344. static Warn: (message: string) => void;
  345. /**
  346. * Write an error message to the console
  347. */
  348. static Error: (message: string) => void;
  349. /**
  350. * Gets current log cache (list of logs)
  351. */
  352. static readonly LogCache: string;
  353. /**
  354. * Clears the log cache
  355. */
  356. static ClearLogCache(): void;
  357. /**
  358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  359. */
  360. static LogLevels: number;
  361. }
  362. }
  363. declare module BABYLON {
  364. /** @hidden */
  365. export class _TypeStore {
  366. /** @hidden */
  367. static RegisteredTypes: {
  368. [key: string]: Object;
  369. };
  370. /** @hidden */
  371. static GetClass(fqdn: string): any;
  372. }
  373. }
  374. declare module BABYLON {
  375. /**
  376. * Class containing a set of static utilities functions for deep copy.
  377. */
  378. export class DeepCopier {
  379. /**
  380. * Tries to copy an object by duplicating every property
  381. * @param source defines the source object
  382. * @param destination defines the target object
  383. * @param doNotCopyList defines a list of properties to avoid
  384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  385. */
  386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  387. }
  388. }
  389. declare module BABYLON {
  390. /**
  391. * Class containing a set of static utilities functions for precision date
  392. */
  393. export class PrecisionDate {
  394. /**
  395. * Gets either window.performance.now() if supported or Date.now() else
  396. */
  397. static readonly Now: number;
  398. }
  399. }
  400. declare module BABYLON {
  401. /** @hidden */
  402. export class _DevTools {
  403. static WarnImport(name: string): string;
  404. }
  405. }
  406. declare module BABYLON {
  407. /**
  408. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  409. */
  410. export class WebRequest {
  411. private _xhr;
  412. /**
  413. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  414. * i.e. when loading files, where the server/service expects an Authorization header
  415. */
  416. static CustomRequestHeaders: {
  417. [key: string]: string;
  418. };
  419. /**
  420. * Add callback functions in this array to update all the requests before they get sent to the network
  421. */
  422. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  423. private _injectCustomRequestHeaders;
  424. /**
  425. * Gets or sets a function to be called when loading progress changes
  426. */
  427. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  428. /**
  429. * Returns client's state
  430. */
  431. readonly readyState: number;
  432. /**
  433. * Returns client's status
  434. */
  435. readonly status: number;
  436. /**
  437. * Returns client's status as a text
  438. */
  439. readonly statusText: string;
  440. /**
  441. * Returns client's response
  442. */
  443. readonly response: any;
  444. /**
  445. * Returns client's response url
  446. */
  447. readonly responseURL: string;
  448. /**
  449. * Returns client's response as text
  450. */
  451. readonly responseText: string;
  452. /**
  453. * Gets or sets the expected response type
  454. */
  455. responseType: XMLHttpRequestResponseType;
  456. /** @hidden */
  457. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  458. /** @hidden */
  459. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  460. /**
  461. * Cancels any network activity
  462. */
  463. abort(): void;
  464. /**
  465. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  466. * @param body defines an optional request body
  467. */
  468. send(body?: Document | BodyInit | null): void;
  469. /**
  470. * Sets the request method, request URL
  471. * @param method defines the method to use (GET, POST, etc..)
  472. * @param url defines the url to connect with
  473. */
  474. open(method: string, url: string): void;
  475. }
  476. }
  477. declare module BABYLON {
  478. /**
  479. * File request interface
  480. */
  481. export interface IFileRequest {
  482. /**
  483. * Raised when the request is complete (success or error).
  484. */
  485. onCompleteObservable: Observable<IFileRequest>;
  486. /**
  487. * Aborts the request for a file.
  488. */
  489. abort: () => void;
  490. }
  491. }
  492. declare module BABYLON {
  493. /**
  494. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  495. */
  496. export class PerformanceMonitor {
  497. private _enabled;
  498. private _rollingFrameTime;
  499. private _lastFrameTimeMs;
  500. /**
  501. * constructor
  502. * @param frameSampleSize The number of samples required to saturate the sliding window
  503. */
  504. constructor(frameSampleSize?: number);
  505. /**
  506. * Samples current frame
  507. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  508. */
  509. sampleFrame(timeMs?: number): void;
  510. /**
  511. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTime: number;
  514. /**
  515. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  516. */
  517. readonly averageFrameTimeVariance: number;
  518. /**
  519. * Returns the frame time of the most recent frame
  520. */
  521. readonly instantaneousFrameTime: number;
  522. /**
  523. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  524. */
  525. readonly averageFPS: number;
  526. /**
  527. * Returns the average framerate in frames per second using the most recent frame time
  528. */
  529. readonly instantaneousFPS: number;
  530. /**
  531. * Returns true if enough samples have been taken to completely fill the sliding window
  532. */
  533. readonly isSaturated: boolean;
  534. /**
  535. * Enables contributions to the sliding window sample set
  536. */
  537. enable(): void;
  538. /**
  539. * Disables contributions to the sliding window sample set
  540. * Samples will not be interpolated over the disabled period
  541. */
  542. disable(): void;
  543. /**
  544. * Returns true if sampling is enabled
  545. */
  546. readonly isEnabled: boolean;
  547. /**
  548. * Resets performance monitor
  549. */
  550. reset(): void;
  551. }
  552. /**
  553. * RollingAverage
  554. *
  555. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  556. */
  557. export class RollingAverage {
  558. /**
  559. * Current average
  560. */
  561. average: number;
  562. /**
  563. * Current variance
  564. */
  565. variance: number;
  566. protected _samples: Array<number>;
  567. protected _sampleCount: number;
  568. protected _pos: number;
  569. protected _m2: number;
  570. /**
  571. * constructor
  572. * @param length The number of samples required to saturate the sliding window
  573. */
  574. constructor(length: number);
  575. /**
  576. * Adds a sample to the sample set
  577. * @param v The sample value
  578. */
  579. add(v: number): void;
  580. /**
  581. * Returns previously added values or null if outside of history or outside the sliding window domain
  582. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  583. * @return Value previously recorded with add() or null if outside of range
  584. */
  585. history(i: number): number;
  586. /**
  587. * Returns true if enough samples have been taken to completely fill the sliding window
  588. * @return true if sample-set saturated
  589. */
  590. isSaturated(): boolean;
  591. /**
  592. * Resets the rolling average (equivalent to 0 samples taken so far)
  593. */
  594. reset(): void;
  595. /**
  596. * Wraps a value around the sample range boundaries
  597. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  598. * @return Wrapped position in sample range
  599. */
  600. protected _wrapPosition(i: number): number;
  601. }
  602. }
  603. declare module BABYLON {
  604. /**
  605. * This class implement a typical dictionary using a string as key and the generic type T as value.
  606. * The underlying implementation relies on an associative array to ensure the best performances.
  607. * The value can be anything including 'null' but except 'undefined'
  608. */
  609. export class StringDictionary<T> {
  610. /**
  611. * This will clear this dictionary and copy the content from the 'source' one.
  612. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  613. * @param source the dictionary to take the content from and copy to this dictionary
  614. */
  615. copyFrom(source: StringDictionary<T>): void;
  616. /**
  617. * Get a value based from its key
  618. * @param key the given key to get the matching value from
  619. * @return the value if found, otherwise undefined is returned
  620. */
  621. get(key: string): T | undefined;
  622. /**
  623. * Get a value from its key or add it if it doesn't exist.
  624. * This method will ensure you that a given key/data will be present in the dictionary.
  625. * @param key the given key to get the matching value from
  626. * @param factory the factory that will create the value if the key is not present in the dictionary.
  627. * The factory will only be invoked if there's no data for the given key.
  628. * @return the value corresponding to the key.
  629. */
  630. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  631. /**
  632. * Get a value from its key if present in the dictionary otherwise add it
  633. * @param key the key to get the value from
  634. * @param val if there's no such key/value pair in the dictionary add it with this value
  635. * @return the value corresponding to the key
  636. */
  637. getOrAdd(key: string, val: T): T;
  638. /**
  639. * Check if there's a given key in the dictionary
  640. * @param key the key to check for
  641. * @return true if the key is present, false otherwise
  642. */
  643. contains(key: string): boolean;
  644. /**
  645. * Add a new key and its corresponding value
  646. * @param key the key to add
  647. * @param value the value corresponding to the key
  648. * @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
  649. */
  650. add(key: string, value: T): boolean;
  651. /**
  652. * Update a specific value associated to a key
  653. * @param key defines the key to use
  654. * @param value defines the value to store
  655. * @returns true if the value was updated (or false if the key was not found)
  656. */
  657. set(key: string, value: T): boolean;
  658. /**
  659. * Get the element of the given key and remove it from the dictionary
  660. * @param key defines the key to search
  661. * @returns the value associated with the key or null if not found
  662. */
  663. getAndRemove(key: string): Nullable<T>;
  664. /**
  665. * Remove a key/value from the dictionary.
  666. * @param key the key to remove
  667. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  668. */
  669. remove(key: string): boolean;
  670. /**
  671. * Clear the whole content of the dictionary
  672. */
  673. clear(): void;
  674. /**
  675. * Gets the current count
  676. */
  677. readonly count: number;
  678. /**
  679. * Execute a callback on each key/val of the dictionary.
  680. * Note that you can remove any element in this dictionary in the callback implementation
  681. * @param callback the callback to execute on a given key/value pair
  682. */
  683. forEach(callback: (key: string, val: T) => void): void;
  684. /**
  685. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  686. * If the callback returns null or undefined the method will iterate to the next key/value pair
  687. * Note that you can remove any element in this dictionary in the callback implementation
  688. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  689. * @returns the first item
  690. */
  691. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  692. private _count;
  693. private _data;
  694. }
  695. }
  696. declare module BABYLON {
  697. /**
  698. * Class used to store gfx data (like WebGLBuffer)
  699. */
  700. export class DataBuffer {
  701. /**
  702. * Gets or sets the number of objects referencing this buffer
  703. */
  704. references: number;
  705. /** Gets or sets the size of the underlying buffer */
  706. capacity: number;
  707. /**
  708. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  709. */
  710. is32Bits: boolean;
  711. /**
  712. * Gets the underlying buffer
  713. */
  714. readonly underlyingResource: any;
  715. }
  716. }
  717. declare module BABYLON {
  718. /**
  719. * Class used to store data that will be store in GPU memory
  720. */
  721. export class Buffer {
  722. private _engine;
  723. private _buffer;
  724. /** @hidden */ private _data: Nullable<DataArray>;
  725. private _updatable;
  726. private _instanced;
  727. /**
  728. * Gets the byte stride.
  729. */
  730. readonly byteStride: number;
  731. /**
  732. * Constructor
  733. * @param engine the engine
  734. * @param data the data to use for this buffer
  735. * @param updatable whether the data is updatable
  736. * @param stride the stride (optional)
  737. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  738. * @param instanced whether the buffer is instanced (optional)
  739. * @param useBytes set to true if the stride in in bytes (optional)
  740. */
  741. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  742. /**
  743. * Create a new VertexBuffer based on the current buffer
  744. * @param kind defines the vertex buffer kind (position, normal, etc.)
  745. * @param offset defines offset in the buffer (0 by default)
  746. * @param size defines the size in floats of attributes (position is 3 for instance)
  747. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  748. * @param instanced defines if the vertex buffer contains indexed data
  749. * @param useBytes defines if the offset and stride are in bytes
  750. * @returns the new vertex buffer
  751. */
  752. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  753. /**
  754. * Gets a boolean indicating if the Buffer is updatable?
  755. * @returns true if the buffer is updatable
  756. */
  757. isUpdatable(): boolean;
  758. /**
  759. * Gets current buffer's data
  760. * @returns a DataArray or null
  761. */
  762. getData(): Nullable<DataArray>;
  763. /**
  764. * Gets underlying native buffer
  765. * @returns underlying native buffer
  766. */
  767. getBuffer(): Nullable<DataBuffer>;
  768. /**
  769. * Gets the stride in float32 units (i.e. byte stride / 4).
  770. * May not be an integer if the byte stride is not divisible by 4.
  771. * DEPRECATED. Use byteStride instead.
  772. * @returns the stride in float32 units
  773. */
  774. getStrideSize(): number;
  775. /**
  776. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  777. * @param data defines the data to store
  778. */
  779. create(data?: Nullable<DataArray>): void;
  780. /** @hidden */ private _rebuild(): void;
  781. /**
  782. * Update current buffer data
  783. * @param data defines the data to store
  784. */
  785. update(data: DataArray): void;
  786. /**
  787. * Updates the data directly.
  788. * @param data the new data
  789. * @param offset the new offset
  790. * @param vertexCount the vertex count (optional)
  791. * @param useBytes set to true if the offset is in bytes
  792. */
  793. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  794. /**
  795. * Release all resources
  796. */
  797. dispose(): void;
  798. }
  799. /**
  800. * Specialized buffer used to store vertex data
  801. */
  802. export class VertexBuffer {
  803. /** @hidden */ private _buffer: Buffer;
  804. private _kind;
  805. private _size;
  806. private _ownsBuffer;
  807. private _instanced;
  808. private _instanceDivisor;
  809. /**
  810. * The byte type.
  811. */
  812. static readonly BYTE: number;
  813. /**
  814. * The unsigned byte type.
  815. */
  816. static readonly UNSIGNED_BYTE: number;
  817. /**
  818. * The short type.
  819. */
  820. static readonly SHORT: number;
  821. /**
  822. * The unsigned short type.
  823. */
  824. static readonly UNSIGNED_SHORT: number;
  825. /**
  826. * The integer type.
  827. */
  828. static readonly INT: number;
  829. /**
  830. * The unsigned integer type.
  831. */
  832. static readonly UNSIGNED_INT: number;
  833. /**
  834. * The float type.
  835. */
  836. static readonly FLOAT: number;
  837. /**
  838. * Gets or sets the instance divisor when in instanced mode
  839. */
  840. instanceDivisor: number;
  841. /**
  842. * Gets the byte stride.
  843. */
  844. readonly byteStride: number;
  845. /**
  846. * Gets the byte offset.
  847. */
  848. readonly byteOffset: number;
  849. /**
  850. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  851. */
  852. readonly normalized: boolean;
  853. /**
  854. * Gets the data type of each component in the array.
  855. */
  856. readonly type: number;
  857. /**
  858. * Constructor
  859. * @param engine the engine
  860. * @param data the data to use for this vertex buffer
  861. * @param kind the vertex buffer kind
  862. * @param updatable whether the data is updatable
  863. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  864. * @param stride the stride (optional)
  865. * @param instanced whether the buffer is instanced (optional)
  866. * @param offset the offset of the data (optional)
  867. * @param size the number of components (optional)
  868. * @param type the type of the component (optional)
  869. * @param normalized whether the data contains normalized data (optional)
  870. * @param useBytes set to true if stride and offset are in bytes (optional)
  871. */
  872. 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);
  873. /** @hidden */ private _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2379. /**
  2380. * Unproject from screen space to object space
  2381. * @param source defines the screen space Vector3 to use
  2382. * @param viewportWidth defines the current width of the viewport
  2383. * @param viewportHeight defines the current height of the viewport
  2384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2385. * @param transform defines the transform (view x projection) matrix to use
  2386. * @returns the new Vector3
  2387. */
  2388. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2389. /**
  2390. * Unproject from screen space to object space
  2391. * @param source defines the screen space Vector3 to use
  2392. * @param viewportWidth defines the current width of the viewport
  2393. * @param viewportHeight defines the current height of the viewport
  2394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2395. * @param view defines the view matrix to use
  2396. * @param projection defines the projection matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @param result defines the Vector3 where to store the result
  2409. */
  2410. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param sourceX defines the screen space x coordinate to use
  2414. * @param sourceY defines the screen space y coordinate to use
  2415. * @param sourceZ defines the screen space z coordinate to use
  2416. * @param viewportWidth defines the current width of the viewport
  2417. * @param viewportHeight defines the current height of the viewport
  2418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2419. * @param view defines the view matrix to use
  2420. * @param projection defines the projection matrix to use
  2421. * @param result defines the Vector3 where to store the result
  2422. */
  2423. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2424. /**
  2425. * Gets the minimal coordinate values between two Vector3
  2426. * @param left defines the first operand
  2427. * @param right defines the second operand
  2428. * @returns the new Vector3
  2429. */
  2430. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Gets the maximal coordinate values between two Vector3
  2433. * @param left defines the first operand
  2434. * @param right defines the second operand
  2435. * @returns the new Vector3
  2436. */
  2437. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2438. /**
  2439. * Returns the distance between the vectors "value1" and "value2"
  2440. * @param value1 defines the first operand
  2441. * @param value2 defines the second operand
  2442. * @returns the distance
  2443. */
  2444. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2445. /**
  2446. * Returns the squared distance between the vectors "value1" and "value2"
  2447. * @param value1 defines the first operand
  2448. * @param value2 defines the second operand
  2449. * @returns the squared distance
  2450. */
  2451. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2452. /**
  2453. * Returns a new Vector3 located at the center between "value1" and "value2"
  2454. * @param value1 defines the first operand
  2455. * @param value2 defines the second operand
  2456. * @returns the new Vector3
  2457. */
  2458. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2459. /**
  2460. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2461. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2462. * to something in order to rotate it from its local system to the given target system
  2463. * Note: axis1, axis2 and axis3 are normalized during this operation
  2464. * @param axis1 defines the first axis
  2465. * @param axis2 defines the second axis
  2466. * @param axis3 defines the third axis
  2467. * @returns a new Vector3
  2468. */
  2469. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2472. * @param axis1 defines the first axis
  2473. * @param axis2 defines the second axis
  2474. * @param axis3 defines the third axis
  2475. * @param ref defines the Vector3 where to store the result
  2476. */
  2477. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2478. }
  2479. /**
  2480. * Vector4 class created for EulerAngle class conversion to Quaternion
  2481. */
  2482. export class Vector4 {
  2483. /** x value of the vector */
  2484. x: number;
  2485. /** y value of the vector */
  2486. y: number;
  2487. /** z value of the vector */
  2488. z: number;
  2489. /** w value of the vector */
  2490. w: number;
  2491. /**
  2492. * Creates a Vector4 object from the given floats.
  2493. * @param x x value of the vector
  2494. * @param y y value of the vector
  2495. * @param z z value of the vector
  2496. * @param w w value of the vector
  2497. */
  2498. constructor(
  2499. /** x value of the vector */
  2500. x: number,
  2501. /** y value of the vector */
  2502. y: number,
  2503. /** z value of the vector */
  2504. z: number,
  2505. /** w value of the vector */
  2506. w: number);
  2507. /**
  2508. * Returns the string with the Vector4 coordinates.
  2509. * @returns a string containing all the vector values
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Returns the string "Vector4".
  2514. * @returns "Vector4"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Returns the Vector4 hash code.
  2519. * @returns a unique hash code
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2524. * @returns the resulting array
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array from the given index with the Vector4 coordinates.
  2529. * @param array array to populate
  2530. * @param index index of the array to start at (default: 0)
  2531. * @returns the Vector4.
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector4;
  2534. /**
  2535. * Adds the given vector to the current Vector4.
  2536. * @param otherVector the vector to add
  2537. * @returns the updated Vector4.
  2538. */
  2539. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2540. /**
  2541. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2542. * @param otherVector the vector to add
  2543. * @returns the resulting vector
  2544. */
  2545. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @param result the vector to store the result
  2550. * @returns the current Vector4.
  2551. */
  2552. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2553. /**
  2554. * Subtract in place the given vector from the current Vector4.
  2555. * @param otherVector the vector to subtract
  2556. * @returns the updated Vector4.
  2557. */
  2558. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2559. /**
  2560. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2561. * @param otherVector the vector to add
  2562. * @returns the new vector with the result
  2563. */
  2564. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to subtract
  2568. * @param result the vector to store the result
  2569. * @returns the current Vector4.
  2570. */
  2571. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2572. /**
  2573. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2574. */
  2575. /**
  2576. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2577. * @param x value to subtract
  2578. * @param y value to subtract
  2579. * @param z value to subtract
  2580. * @param w value to subtract
  2581. * @returns new vector containing the result
  2582. */
  2583. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2584. /**
  2585. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2586. * @param x value to subtract
  2587. * @param y value to subtract
  2588. * @param z value to subtract
  2589. * @param w value to subtract
  2590. * @param result the vector to store the result in
  2591. * @returns the current Vector4.
  2592. */
  2593. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2594. /**
  2595. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2596. * @returns a new vector with the negated values
  2597. */
  2598. negate(): Vector4;
  2599. /**
  2600. * Multiplies the current Vector4 coordinates by scale (float).
  2601. * @param scale the number to scale with
  2602. * @returns the updated Vector4.
  2603. */
  2604. scaleInPlace(scale: number): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns a new vector with the result
  2609. */
  2610. scale(scale: number): Vector4;
  2611. /**
  2612. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @param result a vector to store the result in
  2615. * @returns the current Vector4.
  2616. */
  2617. scaleToRef(scale: number, result: Vector4): Vector4;
  2618. /**
  2619. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2620. * @param scale defines the scale factor
  2621. * @param result defines the Vector4 object where to store the result
  2622. * @returns the unmodified current Vector4
  2623. */
  2624. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2625. /**
  2626. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2627. * @param otherVector the vector to compare against
  2628. * @returns true if they are equal
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2633. * @param otherVector vector to compare against
  2634. * @param epsilon (Default: very small number)
  2635. * @returns true if they are equal
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2638. /**
  2639. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2640. * @param x x value to compare against
  2641. * @param y y value to compare against
  2642. * @param z z value to compare against
  2643. * @param w w value to compare against
  2644. * @returns true if equal
  2645. */
  2646. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2647. /**
  2648. * Multiplies in place the current Vector4 by the given one.
  2649. * @param otherVector vector to multiple with
  2650. * @returns the updated Vector4.
  2651. */
  2652. multiplyInPlace(otherVector: Vector4): Vector4;
  2653. /**
  2654. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns resulting new vector
  2657. */
  2658. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2659. /**
  2660. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @param result vector to store the result
  2663. * @returns the current Vector4.
  2664. */
  2665. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2666. /**
  2667. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2668. * @param x x value multiply with
  2669. * @param y y value multiply with
  2670. * @param z z value multiply with
  2671. * @param w w value multiply with
  2672. * @returns resulting new vector
  2673. */
  2674. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2675. /**
  2676. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2677. * @param otherVector vector to devide with
  2678. * @returns resulting new vector
  2679. */
  2680. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2681. /**
  2682. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @param result vector to store the result
  2685. * @returns the current Vector4.
  2686. */
  2687. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones.
  2690. * @param otherVector vector to devide with
  2691. * @returns the updated Vector3.
  2692. */
  2693. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2694. /**
  2695. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2696. * @param other defines the second operand
  2697. * @returns the current updated Vector4
  2698. */
  2699. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Gets a new Vector4 from current Vector4 floored values
  2708. * @returns a new Vector4
  2709. */
  2710. floor(): Vector4;
  2711. /**
  2712. * Gets a new Vector4 from current Vector3 floored values
  2713. * @returns a new Vector4
  2714. */
  2715. fract(): Vector4;
  2716. /**
  2717. * Returns the Vector4 length (float).
  2718. * @returns the length
  2719. */
  2720. length(): number;
  2721. /**
  2722. * Returns the Vector4 squared length (float).
  2723. * @returns the length squared
  2724. */
  2725. lengthSquared(): number;
  2726. /**
  2727. * Normalizes in place the Vector4.
  2728. * @returns the updated Vector4.
  2729. */
  2730. normalize(): Vector4;
  2731. /**
  2732. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2733. * @returns this converted to a new vector3
  2734. */
  2735. toVector3(): Vector3;
  2736. /**
  2737. * Returns a new Vector4 copied from the current one.
  2738. * @returns the new cloned vector
  2739. */
  2740. clone(): Vector4;
  2741. /**
  2742. * Updates the current Vector4 with the given one coordinates.
  2743. * @param source the source vector to copy from
  2744. * @returns the updated Vector4.
  2745. */
  2746. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2747. /**
  2748. * Updates the current Vector4 coordinates with the given floats.
  2749. * @param x float to copy from
  2750. * @param y float to copy from
  2751. * @param z float to copy from
  2752. * @param w float to copy from
  2753. * @returns the updated Vector4.
  2754. */
  2755. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2756. /**
  2757. * Updates the current Vector4 coordinates with the given floats.
  2758. * @param x float to set from
  2759. * @param y float to set from
  2760. * @param z float to set from
  2761. * @param w float to set from
  2762. * @returns the updated Vector4.
  2763. */
  2764. set(x: number, y: number, z: number, w: number): Vector4;
  2765. /**
  2766. * Copies the given float to the current Vector3 coordinates
  2767. * @param v defines the x, y, z and w coordinates of the operand
  2768. * @returns the current updated Vector3
  2769. */
  2770. setAll(v: number): Vector4;
  2771. /**
  2772. * Returns a new Vector4 set from the starting index of the given array.
  2773. * @param array the array to pull values from
  2774. * @param offset the offset into the array to start at
  2775. * @returns the new vector
  2776. */
  2777. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2778. /**
  2779. * Updates the given vector "result" from the starting index of the given array.
  2780. * @param array the array to pull values from
  2781. * @param offset the offset into the array to start at
  2782. * @param result the vector to store the result in
  2783. */
  2784. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2785. /**
  2786. * Updates the given vector "result" from the starting index of the given Float32Array.
  2787. * @param array the array to pull values from
  2788. * @param offset the offset into the array to start at
  2789. * @param result the vector to store the result in
  2790. */
  2791. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2792. /**
  2793. * Updates the given vector "result" coordinates from the given floats.
  2794. * @param x float to set from
  2795. * @param y float to set from
  2796. * @param z float to set from
  2797. * @param w float to set from
  2798. * @param result the vector to the floats in
  2799. */
  2800. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2801. /**
  2802. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2803. * @returns the new vector
  2804. */
  2805. static Zero(): Vector4;
  2806. /**
  2807. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2808. * @returns the new vector
  2809. */
  2810. static One(): Vector4;
  2811. /**
  2812. * Returns a new normalized Vector4 from the given one.
  2813. * @param vector the vector to normalize
  2814. * @returns the vector
  2815. */
  2816. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2817. /**
  2818. * Updates the given vector "result" from the normalization of the given one.
  2819. * @param vector the vector to normalize
  2820. * @param result the vector to store the result in
  2821. */
  2822. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2823. /**
  2824. * Returns a vector with the minimum values from the left and right vectors
  2825. * @param left left vector to minimize
  2826. * @param right right vector to minimize
  2827. * @returns a new vector with the minimum of the left and right vector values
  2828. */
  2829. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2830. /**
  2831. * Returns a vector with the maximum values from the left and right vectors
  2832. * @param left left vector to maximize
  2833. * @param right right vector to maximize
  2834. * @returns a new vector with the maximum of the left and right vector values
  2835. */
  2836. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2837. /**
  2838. * Returns the distance (float) between the vectors "value1" and "value2".
  2839. * @param value1 value to calulate the distance between
  2840. * @param value2 value to calulate the distance between
  2841. * @return the distance between the two vectors
  2842. */
  2843. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2844. /**
  2845. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2846. * @param value1 value to calulate the distance between
  2847. * @param value2 value to calulate the distance between
  2848. * @return the distance between the two vectors squared
  2849. */
  2850. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2851. /**
  2852. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2853. * @param value1 value to calulate the center between
  2854. * @param value2 value to calulate the center between
  2855. * @return the center between the two vectors
  2856. */
  2857. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2858. /**
  2859. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2860. * This methods computes transformed normalized direction vectors only.
  2861. * @param vector the vector to transform
  2862. * @param transformation the transformation matrix to apply
  2863. * @returns the new vector
  2864. */
  2865. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2866. /**
  2867. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2868. * This methods computes transformed normalized direction vectors only.
  2869. * @param vector the vector to transform
  2870. * @param transformation the transformation matrix to apply
  2871. * @param result the vector to store the result in
  2872. */
  2873. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2874. /**
  2875. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param x value to transform
  2878. * @param y value to transform
  2879. * @param z value to transform
  2880. * @param w value to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the results in
  2883. */
  2884. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Creates a new Vector4 from a Vector3
  2887. * @param source defines the source data
  2888. * @param w defines the 4th component (default is 0)
  2889. * @returns a new Vector4
  2890. */
  2891. static FromVector3(source: Vector3, w?: number): Vector4;
  2892. }
  2893. /**
  2894. * Class used to store quaternion data
  2895. * @see https://en.wikipedia.org/wiki/Quaternion
  2896. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2897. */
  2898. export class Quaternion {
  2899. /** defines the first component (0 by default) */
  2900. x: number;
  2901. /** defines the second component (0 by default) */
  2902. y: number;
  2903. /** defines the third component (0 by default) */
  2904. z: number;
  2905. /** defines the fourth component (1.0 by default) */
  2906. w: number;
  2907. /**
  2908. * Creates a new Quaternion from the given floats
  2909. * @param x defines the first component (0 by default)
  2910. * @param y defines the second component (0 by default)
  2911. * @param z defines the third component (0 by default)
  2912. * @param w defines the fourth component (1.0 by default)
  2913. */
  2914. constructor(
  2915. /** defines the first component (0 by default) */
  2916. x?: number,
  2917. /** defines the second component (0 by default) */
  2918. y?: number,
  2919. /** defines the third component (0 by default) */
  2920. z?: number,
  2921. /** defines the fourth component (1.0 by default) */
  2922. w?: number);
  2923. /**
  2924. * Gets a string representation for the current quaternion
  2925. * @returns a string with the Quaternion coordinates
  2926. */
  2927. toString(): string;
  2928. /**
  2929. * Gets the class name of the quaternion
  2930. * @returns the string "Quaternion"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets a hash code for this quaternion
  2935. * @returns the quaternion hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Copy the quaternion to an array
  2940. * @returns a new array populated with 4 elements from the quaternion coordinates
  2941. */
  2942. asArray(): number[];
  2943. /**
  2944. * Check if two quaternions are equals
  2945. * @param otherQuaternion defines the second operand
  2946. * @return true if the current quaternion and the given one coordinates are strictly equals
  2947. */
  2948. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2949. /**
  2950. * Clone the current quaternion
  2951. * @returns a new quaternion copied from the current one
  2952. */
  2953. clone(): Quaternion;
  2954. /**
  2955. * Copy a quaternion to the current one
  2956. * @param other defines the other quaternion
  2957. * @returns the updated current quaternion
  2958. */
  2959. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2960. /**
  2961. * Updates the current quaternion with the given float coordinates
  2962. * @param x defines the x coordinate
  2963. * @param y defines the y coordinate
  2964. * @param z defines the z coordinate
  2965. * @param w defines the w coordinate
  2966. * @returns the updated current quaternion
  2967. */
  2968. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2969. /**
  2970. * Updates the current quaternion from the given float coordinates
  2971. * @param x defines the x coordinate
  2972. * @param y defines the y coordinate
  2973. * @param z defines the z coordinate
  2974. * @param w defines the w coordinate
  2975. * @returns the updated current quaternion
  2976. */
  2977. set(x: number, y: number, z: number, w: number): Quaternion;
  2978. /**
  2979. * Adds two quaternions
  2980. * @param other defines the second operand
  2981. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2982. */
  2983. add(other: DeepImmutable<Quaternion>): Quaternion;
  2984. /**
  2985. * Add a quaternion to the current one
  2986. * @param other defines the quaternion to add
  2987. * @returns the current quaternion
  2988. */
  2989. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Subtract two quaternions
  2992. * @param other defines the second operand
  2993. * @returns a new quaternion as the subtraction result of the given one from the current one
  2994. */
  2995. subtract(other: Quaternion): Quaternion;
  2996. /**
  2997. * Multiplies the current quaternion by a scale factor
  2998. * @param value defines the scale factor
  2999. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3000. */
  3001. scale(value: number): Quaternion;
  3002. /**
  3003. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3004. * @param scale defines the scale factor
  3005. * @param result defines the Quaternion object where to store the result
  3006. * @returns the unmodified current quaternion
  3007. */
  3008. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3009. /**
  3010. * Multiplies in place the current quaternion by a scale factor
  3011. * @param value defines the scale factor
  3012. * @returns the current modified quaternion
  3013. */
  3014. scaleInPlace(value: number): Quaternion;
  3015. /**
  3016. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3017. * @param scale defines the scale factor
  3018. * @param result defines the Quaternion object where to store the result
  3019. * @returns the unmodified current quaternion
  3020. */
  3021. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3022. /**
  3023. * Multiplies two quaternions
  3024. * @param q1 defines the second operand
  3025. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3026. */
  3027. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3028. /**
  3029. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3030. * @param q1 defines the second operand
  3031. * @param result defines the target quaternion
  3032. * @returns the current quaternion
  3033. */
  3034. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3035. /**
  3036. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3037. * @param q1 defines the second operand
  3038. * @returns the currentupdated quaternion
  3039. */
  3040. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3041. /**
  3042. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3043. * @param ref defines the target quaternion
  3044. * @returns the current quaternion
  3045. */
  3046. conjugateToRef(ref: Quaternion): Quaternion;
  3047. /**
  3048. * Conjugates in place (1-q) the current quaternion
  3049. * @returns the current updated quaternion
  3050. */
  3051. conjugateInPlace(): Quaternion;
  3052. /**
  3053. * Conjugates in place (1-q) the current quaternion
  3054. * @returns a new quaternion
  3055. */
  3056. conjugate(): Quaternion;
  3057. /**
  3058. * Gets length of current quaternion
  3059. * @returns the quaternion length (float)
  3060. */
  3061. length(): number;
  3062. /**
  3063. * Normalize in place the current quaternion
  3064. * @returns the current updated quaternion
  3065. */
  3066. normalize(): Quaternion;
  3067. /**
  3068. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3069. * @param order is a reserved parameter and is ignore for now
  3070. * @returns a new Vector3 containing the Euler angles
  3071. */
  3072. toEulerAngles(order?: string): Vector3;
  3073. /**
  3074. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3075. * @param result defines the vector which will be filled with the Euler angles
  3076. * @param order is a reserved parameter and is ignore for now
  3077. * @returns the current unchanged quaternion
  3078. */
  3079. toEulerAnglesToRef(result: Vector3): Quaternion;
  3080. /**
  3081. * Updates the given rotation matrix with the current quaternion values
  3082. * @param result defines the target matrix
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toRotationMatrix(result: Matrix): Quaternion;
  3086. /**
  3087. * Updates the current quaternion from the given rotation matrix values
  3088. * @param matrix defines the source matrix
  3089. * @returns the current updated quaternion
  3090. */
  3091. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3092. /**
  3093. * Creates a new quaternion from a rotation matrix
  3094. * @param matrix defines the source matrix
  3095. * @returns a new quaternion created from the given rotation matrix values
  3096. */
  3097. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Updates the given quaternion with the given rotation matrix values
  3100. * @param matrix defines the source matrix
  3101. * @param result defines the target quaternion
  3102. */
  3103. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3104. /**
  3105. * Returns the dot product (float) between the quaternions "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the dot product
  3109. */
  3110. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3111. /**
  3112. * Checks if the two quaternions are close to each other
  3113. * @param quat0 defines the first quaternion to check
  3114. * @param quat1 defines the second quaternion to check
  3115. * @returns true if the two quaternions are close to each other
  3116. */
  3117. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3118. /**
  3119. * Creates an empty quaternion
  3120. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3121. */
  3122. static Zero(): Quaternion;
  3123. /**
  3124. * Inverse a given quaternion
  3125. * @param q defines the source quaternion
  3126. * @returns a new quaternion as the inverted current quaternion
  3127. */
  3128. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @param result the quaternion the result will be stored in
  3133. * @returns the result quaternion
  3134. */
  3135. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3136. /**
  3137. * Creates an identity quaternion
  3138. * @returns the identity quaternion
  3139. */
  3140. static Identity(): Quaternion;
  3141. /**
  3142. * Gets a boolean indicating if the given quaternion is identity
  3143. * @param quaternion defines the quaternion to check
  3144. * @returns true if the quaternion is identity
  3145. */
  3146. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3147. /**
  3148. * Creates a quaternion from a rotation around an axis
  3149. * @param axis defines the axis to use
  3150. * @param angle defines the angle to use
  3151. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3152. */
  3153. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3154. /**
  3155. * Creates a rotation around an axis and stores it into the given quaternion
  3156. * @param axis defines the axis to use
  3157. * @param angle defines the angle to use
  3158. * @param result defines the target quaternion
  3159. * @returns the target quaternion
  3160. */
  3161. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3162. /**
  3163. * Creates a new quaternion from data stored into an array
  3164. * @param array defines the data source
  3165. * @param offset defines the offset in the source array where the data starts
  3166. * @returns a new quaternion
  3167. */
  3168. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3169. /**
  3170. * Create a quaternion from Euler rotation angles
  3171. * @param x Pitch
  3172. * @param y Yaw
  3173. * @param z Roll
  3174. * @returns the new Quaternion
  3175. */
  3176. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3177. /**
  3178. * Updates a quaternion from Euler rotation angles
  3179. * @param x Pitch
  3180. * @param y Yaw
  3181. * @param z Roll
  3182. * @param result the quaternion to store the result
  3183. * @returns the updated quaternion
  3184. */
  3185. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3186. /**
  3187. * Create a quaternion from Euler rotation vector
  3188. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3189. * @returns the new Quaternion
  3190. */
  3191. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3192. /**
  3193. * Updates a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @param result the quaternion to store the result
  3196. * @returns the updated quaternion
  3197. */
  3198. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3199. /**
  3200. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3201. * @param yaw defines the rotation around Y axis
  3202. * @param pitch defines the rotation around X axis
  3203. * @param roll defines the rotation around Z axis
  3204. * @returns the new quaternion
  3205. */
  3206. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3207. /**
  3208. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3209. * @param yaw defines the rotation around Y axis
  3210. * @param pitch defines the rotation around X axis
  3211. * @param roll defines the rotation around Z axis
  3212. * @param result defines the target quaternion
  3213. */
  3214. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3217. * @param alpha defines the rotation around first axis
  3218. * @param beta defines the rotation around second axis
  3219. * @param gamma defines the rotation around third axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3223. /**
  3224. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3225. * @param alpha defines the rotation around first axis
  3226. * @param beta defines the rotation around second axis
  3227. * @param gamma defines the rotation around third axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3231. /**
  3232. * 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)
  3233. * @param axis1 defines the first axis
  3234. * @param axis2 defines the second axis
  3235. * @param axis3 defines the third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3239. /**
  3240. * 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
  3241. * @param axis1 defines the first axis
  3242. * @param axis2 defines the second axis
  3243. * @param axis3 defines the third axis
  3244. * @param ref defines the target quaternion
  3245. */
  3246. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3247. /**
  3248. * Interpolates between two quaternions
  3249. * @param left defines first quaternion
  3250. * @param right defines second quaternion
  3251. * @param amount defines the gradient to use
  3252. * @returns the new interpolated quaternion
  3253. */
  3254. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3255. /**
  3256. * Interpolates between two quaternions and stores it into a target quaternion
  3257. * @param left defines first quaternion
  3258. * @param right defines second quaternion
  3259. * @param amount defines the gradient to use
  3260. * @param result defines the target quaternion
  3261. */
  3262. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3263. /**
  3264. * Interpolate between two quaternions using Hermite interpolation
  3265. * @param value1 defines first quaternion
  3266. * @param tangent1 defines the incoming tangent
  3267. * @param value2 defines second quaternion
  3268. * @param tangent2 defines the outgoing tangent
  3269. * @param amount defines the target quaternion
  3270. * @returns the new interpolated quaternion
  3271. */
  3272. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3273. }
  3274. /**
  3275. * Class used to store matrix data (4x4)
  3276. */
  3277. export class Matrix {
  3278. private static _updateFlagSeed;
  3279. private static _identityReadOnly;
  3280. private _isIdentity;
  3281. private _isIdentityDirty;
  3282. private _isIdentity3x2;
  3283. private _isIdentity3x2Dirty;
  3284. /**
  3285. * Gets the update flag of the matrix which is an unique number for the matrix.
  3286. * It will be incremented every time the matrix data change.
  3287. * You can use it to speed the comparison between two versions of the same matrix.
  3288. */
  3289. updateFlag: number;
  3290. private readonly _m;
  3291. /**
  3292. * Gets the internal data of the matrix
  3293. */
  3294. readonly m: DeepImmutable<Float32Array>;
  3295. /** @hidden */ private _markAsUpdated(): void;
  3296. /** @hidden */
  3297. private _updateIdentityStatus;
  3298. /**
  3299. * Creates an empty matrix (filled with zeros)
  3300. */
  3301. constructor();
  3302. /**
  3303. * Check if the current matrix is identity
  3304. * @returns true is the matrix is the identity matrix
  3305. */
  3306. isIdentity(): boolean;
  3307. /**
  3308. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3309. * @returns true is the matrix is the identity matrix
  3310. */
  3311. isIdentityAs3x2(): boolean;
  3312. /**
  3313. * Gets the determinant of the matrix
  3314. * @returns the matrix determinant
  3315. */
  3316. determinant(): number;
  3317. /**
  3318. * Returns the matrix as a Float32Array
  3319. * @returns the matrix underlying array
  3320. */
  3321. toArray(): DeepImmutable<Float32Array>;
  3322. /**
  3323. * Returns the matrix as a Float32Array
  3324. * @returns the matrix underlying array.
  3325. */
  3326. asArray(): DeepImmutable<Float32Array>;
  3327. /**
  3328. * Inverts the current matrix in place
  3329. * @returns the current inverted matrix
  3330. */
  3331. invert(): Matrix;
  3332. /**
  3333. * Sets all the matrix elements to zero
  3334. * @returns the current matrix
  3335. */
  3336. reset(): Matrix;
  3337. /**
  3338. * Adds the current matrix with a second one
  3339. * @param other defines the matrix to add
  3340. * @returns a new matrix as the addition of the current matrix and the given one
  3341. */
  3342. add(other: DeepImmutable<Matrix>): Matrix;
  3343. /**
  3344. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3345. * @param other defines the matrix to add
  3346. * @param result defines the target matrix
  3347. * @returns the current matrix
  3348. */
  3349. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3350. /**
  3351. * Adds in place the given matrix to the current matrix
  3352. * @param other defines the second operand
  3353. * @returns the current updated matrix
  3354. */
  3355. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3356. /**
  3357. * Sets the given matrix to the current inverted Matrix
  3358. * @param other defines the target matrix
  3359. * @returns the unmodified current matrix
  3360. */
  3361. invertToRef(other: Matrix): Matrix;
  3362. /**
  3363. * add a value at the specified position in the current Matrix
  3364. * @param index the index of the value within the matrix. between 0 and 15.
  3365. * @param value the value to be added
  3366. * @returns the current updated matrix
  3367. */
  3368. addAtIndex(index: number, value: number): Matrix;
  3369. /**
  3370. * mutiply the specified position in the current Matrix by a value
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. multiplyAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * Inserts the translation vector (using 3 floats) in the current matrix
  3378. * @param x defines the 1st component of the translation
  3379. * @param y defines the 2nd component of the translation
  3380. * @param z defines the 3rd component of the translation
  3381. * @returns the current updated matrix
  3382. */
  3383. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3384. /**
  3385. * Adds the translation vector (using 3 floats) in the current matrix
  3386. * @param x defines the 1st component of the translation
  3387. * @param y defines the 2nd component of the translation
  3388. * @param z defines the 3rd component of the translation
  3389. * @returns the current updated matrix
  3390. */
  3391. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3392. /**
  3393. * Inserts the translation vector in the current matrix
  3394. * @param vector3 defines the translation to insert
  3395. * @returns the current updated matrix
  3396. */
  3397. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3398. /**
  3399. * Gets the translation value of the current matrix
  3400. * @returns a new Vector3 as the extracted translation from the matrix
  3401. */
  3402. getTranslation(): Vector3;
  3403. /**
  3404. * Fill a Vector3 with the extracted translation from the matrix
  3405. * @param result defines the Vector3 where to store the translation
  3406. * @returns the current matrix
  3407. */
  3408. getTranslationToRef(result: Vector3): Matrix;
  3409. /**
  3410. * Remove rotation and scaling part from the matrix
  3411. * @returns the updated matrix
  3412. */
  3413. removeRotationAndScaling(): Matrix;
  3414. /**
  3415. * Multiply two matrices
  3416. * @param other defines the second operand
  3417. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3418. */
  3419. multiply(other: DeepImmutable<Matrix>): Matrix;
  3420. /**
  3421. * Copy the current matrix from the given one
  3422. * @param other defines the source matrix
  3423. * @returns the current updated matrix
  3424. */
  3425. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3426. /**
  3427. * Populates the given array from the starting index with the current matrix values
  3428. * @param array defines the target array
  3429. * @param offset defines the offset in the target array where to start storing values
  3430. * @returns the current matrix
  3431. */
  3432. copyToArray(array: Float32Array, offset?: number): Matrix;
  3433. /**
  3434. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3435. * @param other defines the second operand
  3436. * @param result defines the matrix where to store the multiplication
  3437. * @returns the current matrix
  3438. */
  3439. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3440. /**
  3441. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the array where to store the multiplication
  3444. * @param offset defines the offset in the target array where to start storing values
  3445. * @returns the current matrix
  3446. */
  3447. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3448. /**
  3449. * Check equality between this matrix and a second one
  3450. * @param value defines the second matrix to compare
  3451. * @returns true is the current matrix and the given one values are strictly equal
  3452. */
  3453. equals(value: DeepImmutable<Matrix>): boolean;
  3454. /**
  3455. * Clone the current matrix
  3456. * @returns a new matrix from the current matrix
  3457. */
  3458. clone(): Matrix;
  3459. /**
  3460. * Returns the name of the current matrix class
  3461. * @returns the string "Matrix"
  3462. */
  3463. getClassName(): string;
  3464. /**
  3465. * Gets the hash code of the current matrix
  3466. * @returns the hash code
  3467. */
  3468. getHashCode(): number;
  3469. /**
  3470. * Decomposes the current Matrix into a translation, rotation and scaling components
  3471. * @param scale defines the scale vector3 given as a reference to update
  3472. * @param rotation defines the rotation quaternion given as a reference to update
  3473. * @param translation defines the translation vector3 given as a reference to update
  3474. * @returns true if operation was successful
  3475. */
  3476. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3477. /**
  3478. * Gets specific row of the matrix
  3479. * @param index defines the number of the row to get
  3480. * @returns the index-th row of the current matrix as a new Vector4
  3481. */
  3482. getRow(index: number): Nullable<Vector4>;
  3483. /**
  3484. * Sets the index-th row of the current matrix to the vector4 values
  3485. * @param index defines the number of the row to set
  3486. * @param row defines the target vector4
  3487. * @returns the updated current matrix
  3488. */
  3489. setRow(index: number, row: Vector4): Matrix;
  3490. /**
  3491. * Compute the transpose of the matrix
  3492. * @returns the new transposed matrix
  3493. */
  3494. transpose(): Matrix;
  3495. /**
  3496. * Compute the transpose of the matrix and store it in a given matrix
  3497. * @param result defines the target matrix
  3498. * @returns the current matrix
  3499. */
  3500. transposeToRef(result: Matrix): Matrix;
  3501. /**
  3502. * Sets the index-th row of the current matrix with the given 4 x float values
  3503. * @param index defines the row index
  3504. * @param x defines the x component to set
  3505. * @param y defines the y component to set
  3506. * @param z defines the z component to set
  3507. * @param w defines the w component to set
  3508. * @returns the updated current matrix
  3509. */
  3510. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3511. /**
  3512. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3513. * @param scale defines the scale factor
  3514. * @returns a new matrix
  3515. */
  3516. scale(scale: number): Matrix;
  3517. /**
  3518. * Scale the current matrix values by a factor to a given result matrix
  3519. * @param scale defines the scale factor
  3520. * @param result defines the matrix to store the result
  3521. * @returns the current matrix
  3522. */
  3523. scaleToRef(scale: number, result: Matrix): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor and add the result to a given matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the Matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3533. * @param ref matrix to store the result
  3534. */
  3535. toNormalMatrix(ref: Matrix): void;
  3536. /**
  3537. * Gets only rotation part of the current matrix
  3538. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3539. */
  3540. getRotationMatrix(): Matrix;
  3541. /**
  3542. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3543. * @param result defines the target matrix to store data to
  3544. * @returns the current matrix
  3545. */
  3546. getRotationMatrixToRef(result: Matrix): Matrix;
  3547. /**
  3548. * Toggles model matrix from being right handed to left handed in place and vice versa
  3549. */
  3550. toggleModelMatrixHandInPlace(): void;
  3551. /**
  3552. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3553. */
  3554. toggleProjectionMatrixHandInPlace(): void;
  3555. /**
  3556. * Creates a matrix from an array
  3557. * @param array defines the source array
  3558. * @param offset defines an offset in the source array
  3559. * @returns a new Matrix set from the starting index of the given array
  3560. */
  3561. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3562. /**
  3563. * Copy the content of an array into a given matrix
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @param result defines the target matrix
  3567. */
  3568. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3569. /**
  3570. * Stores an array into a matrix after having multiplied each component by a given factor
  3571. * @param array defines the source array
  3572. * @param offset defines the offset in the source array
  3573. * @param scale defines the scaling factor
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3577. /**
  3578. * Gets an identity matrix that must not be updated
  3579. */
  3580. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3581. /**
  3582. * Stores a list of values (16) inside a given matrix
  3583. * @param initialM11 defines 1st value of 1st row
  3584. * @param initialM12 defines 2nd value of 1st row
  3585. * @param initialM13 defines 3rd value of 1st row
  3586. * @param initialM14 defines 4th value of 1st row
  3587. * @param initialM21 defines 1st value of 2nd row
  3588. * @param initialM22 defines 2nd value of 2nd row
  3589. * @param initialM23 defines 3rd value of 2nd row
  3590. * @param initialM24 defines 4th value of 2nd row
  3591. * @param initialM31 defines 1st value of 3rd row
  3592. * @param initialM32 defines 2nd value of 3rd row
  3593. * @param initialM33 defines 3rd value of 3rd row
  3594. * @param initialM34 defines 4th value of 3rd row
  3595. * @param initialM41 defines 1st value of 4th row
  3596. * @param initialM42 defines 2nd value of 4th row
  3597. * @param initialM43 defines 3rd value of 4th row
  3598. * @param initialM44 defines 4th value of 4th row
  3599. * @param result defines the target matrix
  3600. */
  3601. 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;
  3602. /**
  3603. * Creates new matrix from a list of values (16)
  3604. * @param initialM11 defines 1st value of 1st row
  3605. * @param initialM12 defines 2nd value of 1st row
  3606. * @param initialM13 defines 3rd value of 1st row
  3607. * @param initialM14 defines 4th value of 1st row
  3608. * @param initialM21 defines 1st value of 2nd row
  3609. * @param initialM22 defines 2nd value of 2nd row
  3610. * @param initialM23 defines 3rd value of 2nd row
  3611. * @param initialM24 defines 4th value of 2nd row
  3612. * @param initialM31 defines 1st value of 3rd row
  3613. * @param initialM32 defines 2nd value of 3rd row
  3614. * @param initialM33 defines 3rd value of 3rd row
  3615. * @param initialM34 defines 4th value of 3rd row
  3616. * @param initialM41 defines 1st value of 4th row
  3617. * @param initialM42 defines 2nd value of 4th row
  3618. * @param initialM43 defines 3rd value of 4th row
  3619. * @param initialM44 defines 4th value of 4th row
  3620. * @returns the new matrix
  3621. */
  3622. 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;
  3623. /**
  3624. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3625. * @param scale defines the scale vector3
  3626. * @param rotation defines the rotation quaternion
  3627. * @param translation defines the translation vector3
  3628. * @returns a new matrix
  3629. */
  3630. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3631. /**
  3632. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3633. * @param scale defines the scale vector3
  3634. * @param rotation defines the rotation quaternion
  3635. * @param translation defines the translation vector3
  3636. * @param result defines the target matrix
  3637. */
  3638. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3639. /**
  3640. * Creates a new identity matrix
  3641. * @returns a new identity matrix
  3642. */
  3643. static Identity(): Matrix;
  3644. /**
  3645. * Creates a new identity matrix and stores the result in a given matrix
  3646. * @param result defines the target matrix
  3647. */
  3648. static IdentityToRef(result: Matrix): void;
  3649. /**
  3650. * Creates a new zero matrix
  3651. * @returns a new zero matrix
  3652. */
  3653. static Zero(): Matrix;
  3654. /**
  3655. * Creates a new rotation matrix for "angle" radians around the X axis
  3656. * @param angle defines the angle (in radians) to use
  3657. * @return the new matrix
  3658. */
  3659. static RotationX(angle: number): Matrix;
  3660. /**
  3661. * Creates a new matrix as the invert of a given matrix
  3662. * @param source defines the source matrix
  3663. * @returns the new matrix
  3664. */
  3665. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3668. * @param angle defines the angle (in radians) to use
  3669. * @param result defines the target matrix
  3670. */
  3671. static RotationXToRef(angle: number, result: Matrix): void;
  3672. /**
  3673. * Creates a new rotation matrix for "angle" radians around the Y axis
  3674. * @param angle defines the angle (in radians) to use
  3675. * @return the new matrix
  3676. */
  3677. static RotationY(angle: number): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationYToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Z axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationZ(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationZToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the given axis
  3698. * @param axis defines the axis to use
  3699. * @param angle defines the angle (in radians) to use
  3700. * @return the new matrix
  3701. */
  3702. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @param result defines the target matrix
  3708. */
  3709. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3710. /**
  3711. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3712. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3713. * @param from defines the vector to align
  3714. * @param to defines the vector to align to
  3715. * @param result defines the target matrix
  3716. */
  3717. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3718. /**
  3719. * Creates a rotation matrix
  3720. * @param yaw defines the yaw angle in radians (Y axis)
  3721. * @param pitch defines the pitch angle in radians (X axis)
  3722. * @param roll defines the roll angle in radians (X axis)
  3723. * @returns the new rotation matrix
  3724. */
  3725. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3726. /**
  3727. * Creates a rotation matrix and stores it in a given matrix
  3728. * @param yaw defines the yaw angle in radians (Y axis)
  3729. * @param pitch defines the pitch angle in radians (X axis)
  3730. * @param roll defines the roll angle in radians (X axis)
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3734. /**
  3735. * Creates a scaling matrix
  3736. * @param x defines the scale factor on X axis
  3737. * @param y defines the scale factor on Y axis
  3738. * @param z defines the scale factor on Z axis
  3739. * @returns the new matrix
  3740. */
  3741. static Scaling(x: number, y: number, z: number): Matrix;
  3742. /**
  3743. * Creates a scaling matrix and stores it in a given matrix
  3744. * @param x defines the scale factor on X axis
  3745. * @param y defines the scale factor on Y axis
  3746. * @param z defines the scale factor on Z axis
  3747. * @param result defines the target matrix
  3748. */
  3749. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3750. /**
  3751. * Creates a translation matrix
  3752. * @param x defines the translation on X axis
  3753. * @param y defines the translation on Y axis
  3754. * @param z defines the translationon Z axis
  3755. * @returns the new matrix
  3756. */
  3757. static Translation(x: number, y: number, z: number): Matrix;
  3758. /**
  3759. * Creates a translation matrix and stores it in a given matrix
  3760. * @param x defines the translation on X axis
  3761. * @param y defines the translation on Y axis
  3762. * @param z defines the translationon Z axis
  3763. * @param result defines the target matrix
  3764. */
  3765. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3766. /**
  3767. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3768. * @param startValue defines the start value
  3769. * @param endValue defines the end value
  3770. * @param gradient defines the gradient factor
  3771. * @returns the new matrix
  3772. */
  3773. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3774. /**
  3775. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3776. * @param startValue defines the start value
  3777. * @param endValue defines the end value
  3778. * @param gradient defines the gradient factor
  3779. * @param result defines the Matrix object where to store data
  3780. */
  3781. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3782. /**
  3783. * Builds a new matrix whose values are computed by:
  3784. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3785. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3786. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3787. * @param startValue defines the first matrix
  3788. * @param endValue defines the second matrix
  3789. * @param gradient defines the gradient between the two matrices
  3790. * @returns the new matrix
  3791. */
  3792. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3793. /**
  3794. * Update a matrix to values which are computed by:
  3795. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3796. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3797. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3798. * @param startValue defines the first matrix
  3799. * @param endValue defines the second matrix
  3800. * @param gradient defines the gradient between the two matrices
  3801. * @param result defines the target matrix
  3802. */
  3803. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3804. /**
  3805. * 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"
  3806. * This function works in left handed mode
  3807. * @param eye defines the final position of the entity
  3808. * @param target defines where the entity should look at
  3809. * @param up defines the up vector for the entity
  3810. * @returns the new matrix
  3811. */
  3812. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3813. /**
  3814. * 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".
  3815. * This function works in left handed mode
  3816. * @param eye defines the final position of the entity
  3817. * @param target defines where the entity should look at
  3818. * @param up defines the up vector for the entity
  3819. * @param result defines the target matrix
  3820. */
  3821. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3822. /**
  3823. * 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"
  3824. * This function works in right handed mode
  3825. * @param eye defines the final position of the entity
  3826. * @param target defines where the entity should look at
  3827. * @param up defines the up vector for the entity
  3828. * @returns the new matrix
  3829. */
  3830. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3831. /**
  3832. * 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".
  3833. * This function works in right handed mode
  3834. * @param eye defines the final position of the entity
  3835. * @param target defines where the entity should look at
  3836. * @param up defines the up vector for the entity
  3837. * @param result defines the target matrix
  3838. */
  3839. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3840. /**
  3841. * Create a left-handed orthographic projection matrix
  3842. * @param width defines the viewport width
  3843. * @param height defines the viewport height
  3844. * @param znear defines the near clip plane
  3845. * @param zfar defines the far clip plane
  3846. * @returns a new matrix as a left-handed orthographic projection matrix
  3847. */
  3848. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3849. /**
  3850. * Store a left-handed orthographic projection to a given matrix
  3851. * @param width defines the viewport width
  3852. * @param height defines the viewport height
  3853. * @param znear defines the near clip plane
  3854. * @param zfar defines the far clip plane
  3855. * @param result defines the target matrix
  3856. */
  3857. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3858. /**
  3859. * Create a left-handed orthographic projection matrix
  3860. * @param left defines the viewport left coordinate
  3861. * @param right defines the viewport right coordinate
  3862. * @param bottom defines the viewport bottom coordinate
  3863. * @param top defines the viewport top coordinate
  3864. * @param znear defines the near clip plane
  3865. * @param zfar defines the far clip plane
  3866. * @returns a new matrix as a left-handed orthographic projection matrix
  3867. */
  3868. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3869. /**
  3870. * Stores a left-handed orthographic projection into a given matrix
  3871. * @param left defines the viewport left coordinate
  3872. * @param right defines the viewport right coordinate
  3873. * @param bottom defines the viewport bottom coordinate
  3874. * @param top defines the viewport top coordinate
  3875. * @param znear defines the near clip plane
  3876. * @param zfar defines the far clip plane
  3877. * @param result defines the target matrix
  3878. */
  3879. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3880. /**
  3881. * Creates a right-handed orthographic projection matrix
  3882. * @param left defines the viewport left coordinate
  3883. * @param right defines the viewport right coordinate
  3884. * @param bottom defines the viewport bottom coordinate
  3885. * @param top defines the viewport top coordinate
  3886. * @param znear defines the near clip plane
  3887. * @param zfar defines the far clip plane
  3888. * @returns a new matrix as a right-handed orthographic projection matrix
  3889. */
  3890. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3891. /**
  3892. * Stores a right-handed orthographic projection into a given matrix
  3893. * @param left defines the viewport left coordinate
  3894. * @param right defines the viewport right coordinate
  3895. * @param bottom defines the viewport bottom coordinate
  3896. * @param top defines the viewport top coordinate
  3897. * @param znear defines the near clip plane
  3898. * @param zfar defines the far clip plane
  3899. * @param result defines the target matrix
  3900. */
  3901. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3902. /**
  3903. * Creates a left-handed perspective projection matrix
  3904. * @param width defines the viewport width
  3905. * @param height defines the viewport height
  3906. * @param znear defines the near clip plane
  3907. * @param zfar defines the far clip plane
  3908. * @returns a new matrix as a left-handed perspective projection matrix
  3909. */
  3910. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3911. /**
  3912. * Creates a left-handed perspective projection matrix
  3913. * @param fov defines the horizontal field of view
  3914. * @param aspect defines the aspect ratio
  3915. * @param znear defines the near clip plane
  3916. * @param zfar defines the far clip plane
  3917. * @returns a new matrix as a left-handed perspective projection matrix
  3918. */
  3919. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3920. /**
  3921. * Stores a left-handed perspective projection into a given matrix
  3922. * @param fov defines the horizontal field of view
  3923. * @param aspect defines the aspect ratio
  3924. * @param znear defines the near clip plane
  3925. * @param zfar defines the far clip plane
  3926. * @param result defines the target matrix
  3927. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3928. */
  3929. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3930. /**
  3931. * Creates a right-handed perspective projection matrix
  3932. * @param fov defines the horizontal field of view
  3933. * @param aspect defines the aspect ratio
  3934. * @param znear defines the near clip plane
  3935. * @param zfar defines the far clip plane
  3936. * @returns a new matrix as a right-handed perspective projection matrix
  3937. */
  3938. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3939. /**
  3940. * Stores a right-handed perspective projection into a given matrix
  3941. * @param fov defines the horizontal field of view
  3942. * @param aspect defines the aspect ratio
  3943. * @param znear defines the near clip plane
  3944. * @param zfar defines the far clip plane
  3945. * @param result defines the target matrix
  3946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3947. */
  3948. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3949. /**
  3950. * Stores a perspective projection for WebVR info a given matrix
  3951. * @param fov defines the field of view
  3952. * @param znear defines the near clip plane
  3953. * @param zfar defines the far clip plane
  3954. * @param result defines the target matrix
  3955. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3956. */
  3957. static PerspectiveFovWebVRToRef(fov: {
  3958. upDegrees: number;
  3959. downDegrees: number;
  3960. leftDegrees: number;
  3961. rightDegrees: number;
  3962. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3963. /**
  3964. * Computes a complete transformation matrix
  3965. * @param viewport defines the viewport to use
  3966. * @param world defines the world matrix
  3967. * @param view defines the view matrix
  3968. * @param projection defines the projection matrix
  3969. * @param zmin defines the near clip plane
  3970. * @param zmax defines the far clip plane
  3971. * @returns the transformation matrix
  3972. */
  3973. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3974. /**
  3975. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3976. * @param matrix defines the matrix to use
  3977. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3978. */
  3979. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3980. /**
  3981. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3982. * @param matrix defines the matrix to use
  3983. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3984. */
  3985. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3986. /**
  3987. * Compute the transpose of a given matrix
  3988. * @param matrix defines the matrix to transpose
  3989. * @returns the new matrix
  3990. */
  3991. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3992. /**
  3993. * Compute the transpose of a matrix and store it in a target matrix
  3994. * @param matrix defines the matrix to transpose
  3995. * @param result defines the target matrix
  3996. */
  3997. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3998. /**
  3999. * Computes a reflection matrix from a plane
  4000. * @param plane defines the reflection plane
  4001. * @returns a new matrix
  4002. */
  4003. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4004. /**
  4005. * Computes a reflection matrix from a plane
  4006. * @param plane defines the reflection plane
  4007. * @param result defines the target matrix
  4008. */
  4009. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4010. /**
  4011. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4012. * @param xaxis defines the value of the 1st axis
  4013. * @param yaxis defines the value of the 2nd axis
  4014. * @param zaxis defines the value of the 3rd axis
  4015. * @param result defines the target matrix
  4016. */
  4017. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4018. /**
  4019. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4020. * @param quat defines the quaternion to use
  4021. * @param result defines the target matrix
  4022. */
  4023. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4024. }
  4025. /**
  4026. * @hidden
  4027. */
  4028. export class TmpVectors {
  4029. static Vector2: Vector2[];
  4030. static Vector3: Vector3[];
  4031. static Vector4: Vector4[];
  4032. static Quaternion: Quaternion[];
  4033. static Matrix: Matrix[];
  4034. }
  4035. }
  4036. declare module BABYLON {
  4037. /** Defines the cross module used constants to avoid circular dependncies */
  4038. export class Constants {
  4039. /** Defines that alpha blending is disabled */
  4040. static readonly ALPHA_DISABLE: number;
  4041. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4042. static readonly ALPHA_ADD: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4044. static readonly ALPHA_COMBINE: number;
  4045. /** Defines that alpha blending to DEST - SRC * DEST */
  4046. static readonly ALPHA_SUBTRACT: number;
  4047. /** Defines that alpha blending to SRC * DEST */
  4048. static readonly ALPHA_MULTIPLY: number;
  4049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4050. static readonly ALPHA_MAXIMIZED: number;
  4051. /** Defines that alpha blending to SRC + DEST */
  4052. static readonly ALPHA_ONEONE: number;
  4053. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4054. static readonly ALPHA_PREMULTIPLIED: number;
  4055. /**
  4056. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4057. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4058. */
  4059. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4060. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4061. static readonly ALPHA_INTERPOLATE: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4064. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_SCREENMODE: number;
  4067. /** Defines that the ressource is not delayed*/
  4068. static readonly DELAYLOADSTATE_NONE: number;
  4069. /** Defines that the ressource was successfully delay loaded */
  4070. static readonly DELAYLOADSTATE_LOADED: number;
  4071. /** Defines that the ressource is currently delay loading */
  4072. static readonly DELAYLOADSTATE_LOADING: number;
  4073. /** Defines that the ressource is delayed and has not started loading */
  4074. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4076. static readonly NEVER: number;
  4077. /** 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 */
  4078. static readonly ALWAYS: number;
  4079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4080. static readonly LESS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4082. static readonly EQUAL: number;
  4083. /** 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 */
  4084. static readonly LEQUAL: number;
  4085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4086. static readonly GREATER: number;
  4087. /** 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 */
  4088. static readonly GEQUAL: number;
  4089. /** 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 */
  4090. static readonly NOTEQUAL: number;
  4091. /** Passed to stencilOperation to specify that stencil value must be kept */
  4092. static readonly KEEP: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4094. static readonly REPLACE: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4096. static readonly INCR: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4098. static readonly DECR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4100. static readonly INVERT: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4102. static readonly INCR_WRAP: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4104. static readonly DECR_WRAP: number;
  4105. /** Texture is not repeating outside of 0..1 UVs */
  4106. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4107. /** Texture is repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4109. /** Texture is repeating and mirrored */
  4110. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4111. /** ALPHA */
  4112. static readonly TEXTUREFORMAT_ALPHA: number;
  4113. /** LUMINANCE */
  4114. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4115. /** LUMINANCE_ALPHA */
  4116. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4117. /** RGB */
  4118. static readonly TEXTUREFORMAT_RGB: number;
  4119. /** RGBA */
  4120. static readonly TEXTUREFORMAT_RGBA: number;
  4121. /** RED */
  4122. static readonly TEXTUREFORMAT_RED: number;
  4123. /** RED (2nd reference) */
  4124. static readonly TEXTUREFORMAT_R: number;
  4125. /** RG */
  4126. static readonly TEXTUREFORMAT_RG: number;
  4127. /** RED_INTEGER */
  4128. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4129. /** RED_INTEGER (2nd reference) */
  4130. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4131. /** RG_INTEGER */
  4132. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4133. /** RGB_INTEGER */
  4134. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4135. /** RGBA_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4137. /** UNSIGNED_BYTE */
  4138. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4139. /** UNSIGNED_BYTE (2nd reference) */
  4140. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4141. /** FLOAT */
  4142. static readonly TEXTURETYPE_FLOAT: number;
  4143. /** HALF_FLOAT */
  4144. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4145. /** BYTE */
  4146. static readonly TEXTURETYPE_BYTE: number;
  4147. /** SHORT */
  4148. static readonly TEXTURETYPE_SHORT: number;
  4149. /** UNSIGNED_SHORT */
  4150. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4151. /** INT */
  4152. static readonly TEXTURETYPE_INT: number;
  4153. /** UNSIGNED_INT */
  4154. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4155. /** UNSIGNED_SHORT_4_4_4_4 */
  4156. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4157. /** UNSIGNED_SHORT_5_5_5_1 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4159. /** UNSIGNED_SHORT_5_6_5 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4161. /** UNSIGNED_INT_2_10_10_10_REV */
  4162. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4163. /** UNSIGNED_INT_24_8 */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4165. /** UNSIGNED_INT_10F_11F_11F_REV */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4167. /** UNSIGNED_INT_5_9_9_9_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4169. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4170. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4171. /** nearest is mag = nearest and min = nearest and mip = linear */
  4172. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4173. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4174. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4175. /** Trilinear is mag = linear and min = linear and mip = linear */
  4176. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4177. /** nearest is mag = nearest and min = nearest and mip = linear */
  4178. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4179. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4180. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4181. /** Trilinear is mag = linear and min = linear and mip = linear */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4183. /** mag = nearest and min = nearest and mip = nearest */
  4184. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4185. /** mag = nearest and min = linear and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = linear */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4189. /** mag = nearest and min = linear and mip = none */
  4190. static readonly TEXTURE_NEAREST_LINEAR: number;
  4191. /** mag = nearest and min = nearest and mip = none */
  4192. static readonly TEXTURE_NEAREST_NEAREST: number;
  4193. /** mag = linear and min = nearest and mip = nearest */
  4194. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4195. /** mag = linear and min = nearest and mip = linear */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4197. /** mag = linear and min = linear and mip = none */
  4198. static readonly TEXTURE_LINEAR_LINEAR: number;
  4199. /** mag = linear and min = nearest and mip = none */
  4200. static readonly TEXTURE_LINEAR_NEAREST: number;
  4201. /** Explicit coordinates mode */
  4202. static readonly TEXTURE_EXPLICIT_MODE: number;
  4203. /** Spherical coordinates mode */
  4204. static readonly TEXTURE_SPHERICAL_MODE: number;
  4205. /** Planar coordinates mode */
  4206. static readonly TEXTURE_PLANAR_MODE: number;
  4207. /** Cubic coordinates mode */
  4208. static readonly TEXTURE_CUBIC_MODE: number;
  4209. /** Projection coordinates mode */
  4210. static readonly TEXTURE_PROJECTION_MODE: number;
  4211. /** Skybox coordinates mode */
  4212. static readonly TEXTURE_SKYBOX_MODE: number;
  4213. /** Inverse Cubic coordinates mode */
  4214. static readonly TEXTURE_INVCUBIC_MODE: number;
  4215. /** Equirectangular coordinates mode */
  4216. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4217. /** Equirectangular Fixed coordinates mode */
  4218. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed Mirrored coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4221. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4222. static readonly SCALEMODE_FLOOR: number;
  4223. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4224. static readonly SCALEMODE_NEAREST: number;
  4225. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4226. static readonly SCALEMODE_CEILING: number;
  4227. /**
  4228. * The dirty texture flag value
  4229. */
  4230. static readonly MATERIAL_TextureDirtyFlag: number;
  4231. /**
  4232. * The dirty light flag value
  4233. */
  4234. static readonly MATERIAL_LightDirtyFlag: number;
  4235. /**
  4236. * The dirty fresnel flag value
  4237. */
  4238. static readonly MATERIAL_FresnelDirtyFlag: number;
  4239. /**
  4240. * The dirty attribute flag value
  4241. */
  4242. static readonly MATERIAL_AttributesDirtyFlag: number;
  4243. /**
  4244. * The dirty misc flag value
  4245. */
  4246. static readonly MATERIAL_MiscDirtyFlag: number;
  4247. /**
  4248. * The all dirty flag value
  4249. */
  4250. static readonly MATERIAL_AllDirtyFlag: number;
  4251. /**
  4252. * Returns the triangle fill mode
  4253. */
  4254. static readonly MATERIAL_TriangleFillMode: number;
  4255. /**
  4256. * Returns the wireframe mode
  4257. */
  4258. static readonly MATERIAL_WireFrameFillMode: number;
  4259. /**
  4260. * Returns the point fill mode
  4261. */
  4262. static readonly MATERIAL_PointFillMode: number;
  4263. /**
  4264. * Returns the point list draw mode
  4265. */
  4266. static readonly MATERIAL_PointListDrawMode: number;
  4267. /**
  4268. * Returns the line list draw mode
  4269. */
  4270. static readonly MATERIAL_LineListDrawMode: number;
  4271. /**
  4272. * Returns the line loop draw mode
  4273. */
  4274. static readonly MATERIAL_LineLoopDrawMode: number;
  4275. /**
  4276. * Returns the line strip draw mode
  4277. */
  4278. static readonly MATERIAL_LineStripDrawMode: number;
  4279. /**
  4280. * Returns the triangle strip draw mode
  4281. */
  4282. static readonly MATERIAL_TriangleStripDrawMode: number;
  4283. /**
  4284. * Returns the triangle fan draw mode
  4285. */
  4286. static readonly MATERIAL_TriangleFanDrawMode: number;
  4287. /**
  4288. * Stores the clock-wise side orientation
  4289. */
  4290. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4291. /**
  4292. * Stores the counter clock-wise side orientation
  4293. */
  4294. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4295. /**
  4296. * Nothing
  4297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4298. */
  4299. static readonly ACTION_NothingTrigger: number;
  4300. /**
  4301. * On pick
  4302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4303. */
  4304. static readonly ACTION_OnPickTrigger: number;
  4305. /**
  4306. * On left pick
  4307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4308. */
  4309. static readonly ACTION_OnLeftPickTrigger: number;
  4310. /**
  4311. * On right pick
  4312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4313. */
  4314. static readonly ACTION_OnRightPickTrigger: number;
  4315. /**
  4316. * On center pick
  4317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4318. */
  4319. static readonly ACTION_OnCenterPickTrigger: number;
  4320. /**
  4321. * On pick down
  4322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4323. */
  4324. static readonly ACTION_OnPickDownTrigger: number;
  4325. /**
  4326. * On double pick
  4327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4328. */
  4329. static readonly ACTION_OnDoublePickTrigger: number;
  4330. /**
  4331. * On pick up
  4332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4333. */
  4334. static readonly ACTION_OnPickUpTrigger: number;
  4335. /**
  4336. * On pick out.
  4337. * This trigger will only be raised if you also declared a OnPickDown
  4338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4339. */
  4340. static readonly ACTION_OnPickOutTrigger: number;
  4341. /**
  4342. * On long press
  4343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4344. */
  4345. static readonly ACTION_OnLongPressTrigger: number;
  4346. /**
  4347. * On pointer over
  4348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4349. */
  4350. static readonly ACTION_OnPointerOverTrigger: number;
  4351. /**
  4352. * On pointer out
  4353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4354. */
  4355. static readonly ACTION_OnPointerOutTrigger: number;
  4356. /**
  4357. * On every frame
  4358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4359. */
  4360. static readonly ACTION_OnEveryFrameTrigger: number;
  4361. /**
  4362. * On intersection enter
  4363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4364. */
  4365. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4366. /**
  4367. * On intersection exit
  4368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4369. */
  4370. static readonly ACTION_OnIntersectionExitTrigger: number;
  4371. /**
  4372. * On key down
  4373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4374. */
  4375. static readonly ACTION_OnKeyDownTrigger: number;
  4376. /**
  4377. * On key up
  4378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4379. */
  4380. static readonly ACTION_OnKeyUpTrigger: number;
  4381. /**
  4382. * Billboard mode will only apply to Y axis
  4383. */
  4384. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4385. /**
  4386. * Billboard mode will apply to all axes
  4387. */
  4388. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4389. /**
  4390. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4391. */
  4392. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4393. /**
  4394. * Gets or sets base Assets URL
  4395. */
  4396. static PARTICLES_BaseAssetsUrl: string;
  4397. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4398. * Test order :
  4399. * Is the bounding sphere outside the frustum ?
  4400. * If not, are the bounding box vertices outside the frustum ?
  4401. * It not, then the cullable object is in the frustum.
  4402. */
  4403. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4404. /** Culling strategy : Bounding Sphere Only.
  4405. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4406. * It's also less accurate than the standard because some not visible objects can still be selected.
  4407. * Test : is the bounding sphere outside the frustum ?
  4408. * If not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4411. /** Culling strategy : Optimistic Inclusion.
  4412. * This in an inclusion test first, then the standard exclusion test.
  4413. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4414. * 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.
  4415. * Anyway, it's as accurate as the standard strategy.
  4416. * Test :
  4417. * Is the cullable object bounding sphere center in the frustum ?
  4418. * If not, apply the default culling strategy.
  4419. */
  4420. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4421. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4422. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4423. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4424. * 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.
  4425. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4426. * Test :
  4427. * Is the cullable object bounding sphere center in the frustum ?
  4428. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4429. */
  4430. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4431. /**
  4432. * No logging while loading
  4433. */
  4434. static readonly SCENELOADER_NO_LOGGING: number;
  4435. /**
  4436. * Minimal logging while loading
  4437. */
  4438. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4439. /**
  4440. * Summary logging while loading
  4441. */
  4442. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4443. /**
  4444. * Detailled logging while loading
  4445. */
  4446. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4447. }
  4448. }
  4449. declare module BABYLON {
  4450. /**
  4451. * Class used to store and describe the pipeline context associated with an effect
  4452. */
  4453. export interface IPipelineContext {
  4454. /**
  4455. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4456. */
  4457. isAsync: boolean;
  4458. /**
  4459. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4460. */
  4461. isReady: boolean;
  4462. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4463. }
  4464. }
  4465. declare module BABYLON {
  4466. /** @hidden */
  4467. export interface IShaderProcessor {
  4468. attributeProcessor?: (attribute: string) => string;
  4469. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4470. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4471. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4472. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4473. lineProcessor?: (line: string, isFragment: boolean) => string;
  4474. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4475. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4476. }
  4477. }
  4478. declare module BABYLON {
  4479. /** @hidden */
  4480. export interface ProcessingOptions {
  4481. defines: string[];
  4482. indexParameters: any;
  4483. isFragment: boolean;
  4484. shouldUseHighPrecisionShader: boolean;
  4485. supportsUniformBuffers: boolean;
  4486. shadersRepository: string;
  4487. includesShadersStore: {
  4488. [key: string]: string;
  4489. };
  4490. processor?: IShaderProcessor;
  4491. version: string;
  4492. platformName: string;
  4493. lookForClosingBracketForUniformBuffer?: boolean;
  4494. }
  4495. }
  4496. declare module BABYLON {
  4497. /**
  4498. * Helper to manipulate strings
  4499. */
  4500. export class StringTools {
  4501. /**
  4502. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4503. * @param str Source string
  4504. * @param suffix Suffix to search for in the source string
  4505. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4506. */
  4507. static EndsWith(str: string, suffix: string): boolean;
  4508. /**
  4509. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4510. * @param str Source string
  4511. * @param suffix Suffix to search for in the source string
  4512. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4513. */
  4514. static StartsWith(str: string, suffix: string): boolean;
  4515. }
  4516. }
  4517. declare module BABYLON {
  4518. /** @hidden */
  4519. export class ShaderCodeNode {
  4520. line: string;
  4521. children: ShaderCodeNode[];
  4522. additionalDefineKey?: string;
  4523. additionalDefineValue?: string;
  4524. isValid(preprocessors: {
  4525. [key: string]: string;
  4526. }): boolean;
  4527. process(preprocessors: {
  4528. [key: string]: string;
  4529. }, options: ProcessingOptions): string;
  4530. }
  4531. }
  4532. declare module BABYLON {
  4533. /** @hidden */
  4534. export class ShaderCodeCursor {
  4535. private _lines;
  4536. lineIndex: number;
  4537. readonly currentLine: string;
  4538. readonly canRead: boolean;
  4539. lines: string[];
  4540. }
  4541. }
  4542. declare module BABYLON {
  4543. /** @hidden */
  4544. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4545. process(preprocessors: {
  4546. [key: string]: string;
  4547. }, options: ProcessingOptions): string;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /** @hidden */
  4552. export class ShaderDefineExpression {
  4553. isTrue(preprocessors: {
  4554. [key: string]: string;
  4555. }): boolean;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. /** @hidden */
  4560. export class ShaderCodeTestNode extends ShaderCodeNode {
  4561. testExpression: ShaderDefineExpression;
  4562. isValid(preprocessors: {
  4563. [key: string]: string;
  4564. }): boolean;
  4565. }
  4566. }
  4567. declare module BABYLON {
  4568. /** @hidden */
  4569. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4570. define: string;
  4571. not: boolean;
  4572. constructor(define: string, not?: boolean);
  4573. isTrue(preprocessors: {
  4574. [key: string]: string;
  4575. }): boolean;
  4576. }
  4577. }
  4578. declare module BABYLON {
  4579. /** @hidden */
  4580. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4581. leftOperand: ShaderDefineExpression;
  4582. rightOperand: ShaderDefineExpression;
  4583. isTrue(preprocessors: {
  4584. [key: string]: string;
  4585. }): boolean;
  4586. }
  4587. }
  4588. declare module BABYLON {
  4589. /** @hidden */
  4590. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4591. leftOperand: ShaderDefineExpression;
  4592. rightOperand: ShaderDefineExpression;
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module BABYLON {
  4599. /** @hidden */
  4600. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4601. define: string;
  4602. operand: string;
  4603. testValue: string;
  4604. constructor(define: string, operand: string, testValue: string);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module BABYLON {
  4611. /**
  4612. * @ignore
  4613. * Application error to support additional information when loading a file
  4614. */
  4615. export class LoadFileError extends Error {
  4616. /** defines the optional web request */
  4617. request?: WebRequest | undefined;
  4618. private static _setPrototypeOf;
  4619. /**
  4620. * Creates a new LoadFileError
  4621. * @param message defines the message of the error
  4622. * @param request defines the optional web request
  4623. */
  4624. constructor(message: string,
  4625. /** defines the optional web request */
  4626. request?: WebRequest | undefined);
  4627. }
  4628. }
  4629. declare module BABYLON {
  4630. /**
  4631. * Class used to enable access to offline support
  4632. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4633. */
  4634. export interface IOfflineProvider {
  4635. /**
  4636. * Gets a boolean indicating if scene must be saved in the database
  4637. */
  4638. enableSceneOffline: boolean;
  4639. /**
  4640. * Gets a boolean indicating if textures must be saved in the database
  4641. */
  4642. enableTexturesOffline: boolean;
  4643. /**
  4644. * Open the offline support and make it available
  4645. * @param successCallback defines the callback to call on success
  4646. * @param errorCallback defines the callback to call on error
  4647. */
  4648. open(successCallback: () => void, errorCallback: () => void): void;
  4649. /**
  4650. * Loads an image from the offline support
  4651. * @param url defines the url to load from
  4652. * @param image defines the target DOM image
  4653. */
  4654. loadImage(url: string, image: HTMLImageElement): void;
  4655. /**
  4656. * Loads a file from offline support
  4657. * @param url defines the URL to load from
  4658. * @param sceneLoaded defines a callback to call on success
  4659. * @param progressCallBack defines a callback to call when progress changed
  4660. * @param errorCallback defines a callback to call on error
  4661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4662. */
  4663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4664. }
  4665. }
  4666. declare module BABYLON {
  4667. /**
  4668. * Class used to help managing file picking and drag'n'drop
  4669. * File Storage
  4670. */
  4671. export class FilesInputStore {
  4672. /**
  4673. * List of files ready to be loaded
  4674. */
  4675. static FilesToLoad: {
  4676. [key: string]: File;
  4677. };
  4678. }
  4679. }
  4680. declare module BABYLON {
  4681. /**
  4682. * Class used to define a retry strategy when error happens while loading assets
  4683. */
  4684. export class RetryStrategy {
  4685. /**
  4686. * Function used to defines an exponential back off strategy
  4687. * @param maxRetries defines the maximum number of retries (3 by default)
  4688. * @param baseInterval defines the interval between retries
  4689. * @returns the strategy function to use
  4690. */
  4691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4692. }
  4693. }
  4694. declare module BABYLON {
  4695. /**
  4696. * @hidden
  4697. */
  4698. export class FileTools {
  4699. /**
  4700. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4701. */
  4702. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4703. /**
  4704. * Gets or sets the base URL to use to load assets
  4705. */
  4706. static BaseUrl: string;
  4707. /**
  4708. * Default behaviour for cors in the application.
  4709. * It can be a string if the expected behavior is identical in the entire app.
  4710. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4711. */
  4712. static CorsBehavior: string | ((url: string | string[]) => string);
  4713. /**
  4714. * Gets or sets a function used to pre-process url before using them to load assets
  4715. */
  4716. static PreprocessUrl: (url: string) => string;
  4717. /**
  4718. * Removes unwanted characters from an url
  4719. * @param url defines the url to clean
  4720. * @returns the cleaned url
  4721. */
  4722. private static _CleanUrl;
  4723. /**
  4724. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4725. * @param url define the url we are trying
  4726. * @param element define the dom element where to configure the cors policy
  4727. */
  4728. static SetCorsBehavior(url: string | string[], element: {
  4729. crossOrigin: string | null;
  4730. }): void;
  4731. /**
  4732. * Loads an image as an HTMLImageElement.
  4733. * @param input url string, ArrayBuffer, or Blob to load
  4734. * @param onLoad callback called when the image successfully loads
  4735. * @param onError callback called when the image fails to load
  4736. * @param offlineProvider offline provider for caching
  4737. * @returns the HTMLImageElement of the loaded image
  4738. */
  4739. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4740. /**
  4741. * Loads a file
  4742. * @param fileToLoad defines the file to load
  4743. * @param callback defines the callback to call when data is loaded
  4744. * @param progressCallBack defines the callback to call during loading process
  4745. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4746. * @returns a file request object
  4747. */
  4748. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4749. /**
  4750. * Loads a file
  4751. * @param url url string, ArrayBuffer, or Blob to load
  4752. * @param onSuccess callback called when the file successfully loads
  4753. * @param onProgress callback called while file is loading (if the server supports this mode)
  4754. * @param offlineProvider defines the offline provider for caching
  4755. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4756. * @param onError callback called when the file fails to load
  4757. * @returns a file request object
  4758. */
  4759. 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;
  4760. /**
  4761. * Checks if the loaded document was accessed via `file:`-Protocol.
  4762. * @returns boolean
  4763. */
  4764. static IsFileURL(): boolean;
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /** @hidden */
  4769. export class ShaderProcessor {
  4770. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4771. private static _ProcessPrecision;
  4772. private static _ExtractOperation;
  4773. private static _BuildSubExpression;
  4774. private static _BuildExpression;
  4775. private static _MoveCursorWithinIf;
  4776. private static _MoveCursor;
  4777. private static _EvaluatePreProcessors;
  4778. private static _PreparePreProcessors;
  4779. private static _ProcessShaderConversion;
  4780. private static _ProcessIncludes;
  4781. }
  4782. }
  4783. declare module BABYLON {
  4784. /**
  4785. * Class used to hold a RBG color
  4786. */
  4787. export class Color3 {
  4788. /**
  4789. * Defines the red component (between 0 and 1, default is 0)
  4790. */
  4791. r: number;
  4792. /**
  4793. * Defines the green component (between 0 and 1, default is 0)
  4794. */
  4795. g: number;
  4796. /**
  4797. * Defines the blue component (between 0 and 1, default is 0)
  4798. */
  4799. b: number;
  4800. /**
  4801. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4802. * @param r defines the red component (between 0 and 1, default is 0)
  4803. * @param g defines the green component (between 0 and 1, default is 0)
  4804. * @param b defines the blue component (between 0 and 1, default is 0)
  4805. */
  4806. constructor(
  4807. /**
  4808. * Defines the red component (between 0 and 1, default is 0)
  4809. */
  4810. r?: number,
  4811. /**
  4812. * Defines the green component (between 0 and 1, default is 0)
  4813. */
  4814. g?: number,
  4815. /**
  4816. * Defines the blue component (between 0 and 1, default is 0)
  4817. */
  4818. b?: number);
  4819. /**
  4820. * Creates a string with the Color3 current values
  4821. * @returns the string representation of the Color3 object
  4822. */
  4823. toString(): string;
  4824. /**
  4825. * Returns the string "Color3"
  4826. * @returns "Color3"
  4827. */
  4828. getClassName(): string;
  4829. /**
  4830. * Compute the Color3 hash code
  4831. * @returns an unique number that can be used to hash Color3 objects
  4832. */
  4833. getHashCode(): number;
  4834. /**
  4835. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4836. * @param array defines the array where to store the r,g,b components
  4837. * @param index defines an optional index in the target array to define where to start storing values
  4838. * @returns the current Color3 object
  4839. */
  4840. toArray(array: FloatArray, index?: number): Color3;
  4841. /**
  4842. * Returns a new Color4 object from the current Color3 and the given alpha
  4843. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4844. * @returns a new Color4 object
  4845. */
  4846. toColor4(alpha?: number): Color4;
  4847. /**
  4848. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4849. * @returns the new array
  4850. */
  4851. asArray(): number[];
  4852. /**
  4853. * Returns the luminance value
  4854. * @returns a float value
  4855. */
  4856. toLuminance(): number;
  4857. /**
  4858. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4859. * @param otherColor defines the second operand
  4860. * @returns the new Color3 object
  4861. */
  4862. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4863. /**
  4864. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4865. * @param otherColor defines the second operand
  4866. * @param result defines the Color3 object where to store the result
  4867. * @returns the current Color3
  4868. */
  4869. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4870. /**
  4871. * Determines equality between Color3 objects
  4872. * @param otherColor defines the second operand
  4873. * @returns true if the rgb values are equal to the given ones
  4874. */
  4875. equals(otherColor: DeepImmutable<Color3>): boolean;
  4876. /**
  4877. * Determines equality between the current Color3 object and a set of r,b,g values
  4878. * @param r defines the red component to check
  4879. * @param g defines the green component to check
  4880. * @param b defines the blue component to check
  4881. * @returns true if the rgb values are equal to the given ones
  4882. */
  4883. equalsFloats(r: number, g: number, b: number): boolean;
  4884. /**
  4885. * Multiplies in place each rgb value by scale
  4886. * @param scale defines the scaling factor
  4887. * @returns the updated Color3
  4888. */
  4889. scale(scale: number): Color3;
  4890. /**
  4891. * Multiplies the rgb values by scale and stores the result into "result"
  4892. * @param scale defines the scaling factor
  4893. * @param result defines the Color3 object where to store the result
  4894. * @returns the unmodified current Color3
  4895. */
  4896. scaleToRef(scale: number, result: Color3): Color3;
  4897. /**
  4898. * Scale the current Color3 values by a factor and add the result to a given Color3
  4899. * @param scale defines the scale factor
  4900. * @param result defines color to store the result into
  4901. * @returns the unmodified current Color3
  4902. */
  4903. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4904. /**
  4905. * Clamps the rgb values by the min and max values and stores the result into "result"
  4906. * @param min defines minimum clamping value (default is 0)
  4907. * @param max defines maximum clamping value (default is 1)
  4908. * @param result defines color to store the result into
  4909. * @returns the original Color3
  4910. */
  4911. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4912. /**
  4913. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4914. * @param otherColor defines the second operand
  4915. * @returns the new Color3
  4916. */
  4917. add(otherColor: DeepImmutable<Color3>): Color3;
  4918. /**
  4919. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4920. * @param otherColor defines the second operand
  4921. * @param result defines Color3 object to store the result into
  4922. * @returns the unmodified current Color3
  4923. */
  4924. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4925. /**
  4926. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4927. * @param otherColor defines the second operand
  4928. * @returns the new Color3
  4929. */
  4930. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4931. /**
  4932. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4933. * @param otherColor defines the second operand
  4934. * @param result defines Color3 object to store the result into
  4935. * @returns the unmodified current Color3
  4936. */
  4937. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4938. /**
  4939. * Copy the current object
  4940. * @returns a new Color3 copied the current one
  4941. */
  4942. clone(): Color3;
  4943. /**
  4944. * Copies the rgb values from the source in the current Color3
  4945. * @param source defines the source Color3 object
  4946. * @returns the updated Color3 object
  4947. */
  4948. copyFrom(source: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Updates the Color3 rgb values from the given floats
  4951. * @param r defines the red component to read from
  4952. * @param g defines the green component to read from
  4953. * @param b defines the blue component to read from
  4954. * @returns the current Color3 object
  4955. */
  4956. copyFromFloats(r: number, g: number, b: number): Color3;
  4957. /**
  4958. * Updates the Color3 rgb values from the given floats
  4959. * @param r defines the red component to read from
  4960. * @param g defines the green component to read from
  4961. * @param b defines the blue component to read from
  4962. * @returns the current Color3 object
  4963. */
  4964. set(r: number, g: number, b: number): Color3;
  4965. /**
  4966. * Compute the Color3 hexadecimal code as a string
  4967. * @returns a string containing the hexadecimal representation of the Color3 object
  4968. */
  4969. toHexString(): string;
  4970. /**
  4971. * Computes a new Color3 converted from the current one to linear space
  4972. * @returns a new Color3 object
  4973. */
  4974. toLinearSpace(): Color3;
  4975. /**
  4976. * Converts current color in rgb space to HSV values
  4977. * @returns a new color3 representing the HSV values
  4978. */
  4979. toHSV(): Color3;
  4980. /**
  4981. * Converts current color in rgb space to HSV values
  4982. * @param result defines the Color3 where to store the HSV values
  4983. */
  4984. toHSVToRef(result: Color3): void;
  4985. /**
  4986. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4987. * @param convertedColor defines the Color3 object where to store the linear space version
  4988. * @returns the unmodified Color3
  4989. */
  4990. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4991. /**
  4992. * Computes a new Color3 converted from the current one to gamma space
  4993. * @returns a new Color3 object
  4994. */
  4995. toGammaSpace(): Color3;
  4996. /**
  4997. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4998. * @param convertedColor defines the Color3 object where to store the gamma space version
  4999. * @returns the unmodified Color3
  5000. */
  5001. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5002. private static _BlackReadOnly;
  5003. /**
  5004. * Convert Hue, saturation and value to a Color3 (RGB)
  5005. * @param hue defines the hue
  5006. * @param saturation defines the saturation
  5007. * @param value defines the value
  5008. * @param result defines the Color3 where to store the RGB values
  5009. */
  5010. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5011. /**
  5012. * Creates a new Color3 from the string containing valid hexadecimal values
  5013. * @param hex defines a string containing valid hexadecimal values
  5014. * @returns a new Color3 object
  5015. */
  5016. static FromHexString(hex: string): Color3;
  5017. /**
  5018. * Creates a new Color3 from the starting index of the given array
  5019. * @param array defines the source array
  5020. * @param offset defines an offset in the source array
  5021. * @returns a new Color3 object
  5022. */
  5023. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5024. /**
  5025. * Creates a new Color3 from integer values (< 256)
  5026. * @param r defines the red component to read from (value between 0 and 255)
  5027. * @param g defines the green component to read from (value between 0 and 255)
  5028. * @param b defines the blue component to read from (value between 0 and 255)
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromInts(r: number, g: number, b: number): Color3;
  5032. /**
  5033. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5034. * @param start defines the start Color3 value
  5035. * @param end defines the end Color3 value
  5036. * @param amount defines the gradient value between start and end
  5037. * @returns a new Color3 object
  5038. */
  5039. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5040. /**
  5041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5042. * @param left defines the start value
  5043. * @param right defines the end value
  5044. * @param amount defines the gradient factor
  5045. * @param result defines the Color3 object where to store the result
  5046. */
  5047. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5048. /**
  5049. * Returns a Color3 value containing a red color
  5050. * @returns a new Color3 object
  5051. */
  5052. static Red(): Color3;
  5053. /**
  5054. * Returns a Color3 value containing a green color
  5055. * @returns a new Color3 object
  5056. */
  5057. static Green(): Color3;
  5058. /**
  5059. * Returns a Color3 value containing a blue color
  5060. * @returns a new Color3 object
  5061. */
  5062. static Blue(): Color3;
  5063. /**
  5064. * Returns a Color3 value containing a black color
  5065. * @returns a new Color3 object
  5066. */
  5067. static Black(): Color3;
  5068. /**
  5069. * Gets a Color3 value containing a black color that must not be updated
  5070. */
  5071. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5072. /**
  5073. * Returns a Color3 value containing a white color
  5074. * @returns a new Color3 object
  5075. */
  5076. static White(): Color3;
  5077. /**
  5078. * Returns a Color3 value containing a purple color
  5079. * @returns a new Color3 object
  5080. */
  5081. static Purple(): Color3;
  5082. /**
  5083. * Returns a Color3 value containing a magenta color
  5084. * @returns a new Color3 object
  5085. */
  5086. static Magenta(): Color3;
  5087. /**
  5088. * Returns a Color3 value containing a yellow color
  5089. * @returns a new Color3 object
  5090. */
  5091. static Yellow(): Color3;
  5092. /**
  5093. * Returns a Color3 value containing a gray color
  5094. * @returns a new Color3 object
  5095. */
  5096. static Gray(): Color3;
  5097. /**
  5098. * Returns a Color3 value containing a teal color
  5099. * @returns a new Color3 object
  5100. */
  5101. static Teal(): Color3;
  5102. /**
  5103. * Returns a Color3 value containing a random color
  5104. * @returns a new Color3 object
  5105. */
  5106. static Random(): Color3;
  5107. }
  5108. /**
  5109. * Class used to hold a RBGA color
  5110. */
  5111. export class Color4 {
  5112. /**
  5113. * Defines the red component (between 0 and 1, default is 0)
  5114. */
  5115. r: number;
  5116. /**
  5117. * Defines the green component (between 0 and 1, default is 0)
  5118. */
  5119. g: number;
  5120. /**
  5121. * Defines the blue component (between 0 and 1, default is 0)
  5122. */
  5123. b: number;
  5124. /**
  5125. * Defines the alpha component (between 0 and 1, default is 1)
  5126. */
  5127. a: number;
  5128. /**
  5129. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5130. * @param r defines the red component (between 0 and 1, default is 0)
  5131. * @param g defines the green component (between 0 and 1, default is 0)
  5132. * @param b defines the blue component (between 0 and 1, default is 0)
  5133. * @param a defines the alpha component (between 0 and 1, default is 1)
  5134. */
  5135. constructor(
  5136. /**
  5137. * Defines the red component (between 0 and 1, default is 0)
  5138. */
  5139. r?: number,
  5140. /**
  5141. * Defines the green component (between 0 and 1, default is 0)
  5142. */
  5143. g?: number,
  5144. /**
  5145. * Defines the blue component (between 0 and 1, default is 0)
  5146. */
  5147. b?: number,
  5148. /**
  5149. * Defines the alpha component (between 0 and 1, default is 1)
  5150. */
  5151. a?: number);
  5152. /**
  5153. * Adds in place the given Color4 values to the current Color4 object
  5154. * @param right defines the second operand
  5155. * @returns the current updated Color4 object
  5156. */
  5157. addInPlace(right: DeepImmutable<Color4>): Color4;
  5158. /**
  5159. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5160. * @returns the new array
  5161. */
  5162. asArray(): number[];
  5163. /**
  5164. * Stores from the starting index in the given array the Color4 successive values
  5165. * @param array defines the array where to store the r,g,b components
  5166. * @param index defines an optional index in the target array to define where to start storing values
  5167. * @returns the current Color4 object
  5168. */
  5169. toArray(array: number[], index?: number): Color4;
  5170. /**
  5171. * Determines equality between Color4 objects
  5172. * @param otherColor defines the second operand
  5173. * @returns true if the rgba values are equal to the given ones
  5174. */
  5175. equals(otherColor: DeepImmutable<Color4>): boolean;
  5176. /**
  5177. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5178. * @param right defines the second operand
  5179. * @returns a new Color4 object
  5180. */
  5181. add(right: DeepImmutable<Color4>): Color4;
  5182. /**
  5183. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5184. * @param right defines the second operand
  5185. * @returns a new Color4 object
  5186. */
  5187. subtract(right: DeepImmutable<Color4>): Color4;
  5188. /**
  5189. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5190. * @param right defines the second operand
  5191. * @param result defines the Color4 object where to store the result
  5192. * @returns the current Color4 object
  5193. */
  5194. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5195. /**
  5196. * Creates a new Color4 with the current Color4 values multiplied by scale
  5197. * @param scale defines the scaling factor to apply
  5198. * @returns a new Color4 object
  5199. */
  5200. scale(scale: number): Color4;
  5201. /**
  5202. * Multiplies the current Color4 values by scale and stores the result in "result"
  5203. * @param scale defines the scaling factor to apply
  5204. * @param result defines the Color4 object where to store the result
  5205. * @returns the current unmodified Color4
  5206. */
  5207. scaleToRef(scale: number, result: Color4): Color4;
  5208. /**
  5209. * Scale the current Color4 values by a factor and add the result to a given Color4
  5210. * @param scale defines the scale factor
  5211. * @param result defines the Color4 object where to store the result
  5212. * @returns the unmodified current Color4
  5213. */
  5214. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5215. /**
  5216. * Clamps the rgb values by the min and max values and stores the result into "result"
  5217. * @param min defines minimum clamping value (default is 0)
  5218. * @param max defines maximum clamping value (default is 1)
  5219. * @param result defines color to store the result into.
  5220. * @returns the cuurent Color4
  5221. */
  5222. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5223. /**
  5224. * Multipy an Color4 value by another and return a new Color4 object
  5225. * @param color defines the Color4 value to multiply by
  5226. * @returns a new Color4 object
  5227. */
  5228. multiply(color: Color4): Color4;
  5229. /**
  5230. * Multipy a Color4 value by another and push the result in a reference value
  5231. * @param color defines the Color4 value to multiply by
  5232. * @param result defines the Color4 to fill the result in
  5233. * @returns the result Color4
  5234. */
  5235. multiplyToRef(color: Color4, result: Color4): Color4;
  5236. /**
  5237. * Creates a string with the Color4 current values
  5238. * @returns the string representation of the Color4 object
  5239. */
  5240. toString(): string;
  5241. /**
  5242. * Returns the string "Color4"
  5243. * @returns "Color4"
  5244. */
  5245. getClassName(): string;
  5246. /**
  5247. * Compute the Color4 hash code
  5248. * @returns an unique number that can be used to hash Color4 objects
  5249. */
  5250. getHashCode(): number;
  5251. /**
  5252. * Creates a new Color4 copied from the current one
  5253. * @returns a new Color4 object
  5254. */
  5255. clone(): Color4;
  5256. /**
  5257. * Copies the given Color4 values into the current one
  5258. * @param source defines the source Color4 object
  5259. * @returns the current updated Color4 object
  5260. */
  5261. copyFrom(source: Color4): Color4;
  5262. /**
  5263. * Copies the given float values into the current one
  5264. * @param r defines the red component to read from
  5265. * @param g defines the green component to read from
  5266. * @param b defines the blue component to read from
  5267. * @param a defines the alpha component to read from
  5268. * @returns the current updated Color4 object
  5269. */
  5270. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5271. /**
  5272. * Copies the given float values into the current one
  5273. * @param r defines the red component to read from
  5274. * @param g defines the green component to read from
  5275. * @param b defines the blue component to read from
  5276. * @param a defines the alpha component to read from
  5277. * @returns the current updated Color4 object
  5278. */
  5279. set(r: number, g: number, b: number, a: number): Color4;
  5280. /**
  5281. * Compute the Color4 hexadecimal code as a string
  5282. * @returns a string containing the hexadecimal representation of the Color4 object
  5283. */
  5284. toHexString(): string;
  5285. /**
  5286. * Computes a new Color4 converted from the current one to linear space
  5287. * @returns a new Color4 object
  5288. */
  5289. toLinearSpace(): Color4;
  5290. /**
  5291. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5292. * @param convertedColor defines the Color4 object where to store the linear space version
  5293. * @returns the unmodified Color4
  5294. */
  5295. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5296. /**
  5297. * Computes a new Color4 converted from the current one to gamma space
  5298. * @returns a new Color4 object
  5299. */
  5300. toGammaSpace(): Color4;
  5301. /**
  5302. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5303. * @param convertedColor defines the Color4 object where to store the gamma space version
  5304. * @returns the unmodified Color4
  5305. */
  5306. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5307. /**
  5308. * Creates a new Color4 from the string containing valid hexadecimal values
  5309. * @param hex defines a string containing valid hexadecimal values
  5310. * @returns a new Color4 object
  5311. */
  5312. static FromHexString(hex: string): Color4;
  5313. /**
  5314. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5315. * @param left defines the start value
  5316. * @param right defines the end value
  5317. * @param amount defines the gradient factor
  5318. * @returns a new Color4 object
  5319. */
  5320. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5321. /**
  5322. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5323. * @param left defines the start value
  5324. * @param right defines the end value
  5325. * @param amount defines the gradient factor
  5326. * @param result defines the Color4 object where to store data
  5327. */
  5328. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5329. /**
  5330. * Creates a new Color4 from a Color3 and an alpha value
  5331. * @param color3 defines the source Color3 to read from
  5332. * @param alpha defines the alpha component (1.0 by default)
  5333. * @returns a new Color4 object
  5334. */
  5335. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5336. /**
  5337. * Creates a new Color4 from the starting index element of the given array
  5338. * @param array defines the source array to read from
  5339. * @param offset defines the offset in the source array
  5340. * @returns a new Color4 object
  5341. */
  5342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5343. /**
  5344. * Creates a new Color3 from integer values (< 256)
  5345. * @param r defines the red component to read from (value between 0 and 255)
  5346. * @param g defines the green component to read from (value between 0 and 255)
  5347. * @param b defines the blue component to read from (value between 0 and 255)
  5348. * @param a defines the alpha component to read from (value between 0 and 255)
  5349. * @returns a new Color3 object
  5350. */
  5351. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5352. /**
  5353. * Check the content of a given array and convert it to an array containing RGBA data
  5354. * If the original array was already containing count * 4 values then it is returned directly
  5355. * @param colors defines the array to check
  5356. * @param count defines the number of RGBA data to expect
  5357. * @returns an array containing count * 4 values (RGBA)
  5358. */
  5359. static CheckColors4(colors: number[], count: number): number[];
  5360. }
  5361. /**
  5362. * @hidden
  5363. */
  5364. export class TmpColors {
  5365. static Color3: Color3[];
  5366. static Color4: Color4[];
  5367. }
  5368. }
  5369. declare module BABYLON {
  5370. /**
  5371. * Class representing spherical harmonics coefficients to the 3rd degree
  5372. */
  5373. export class SphericalHarmonics {
  5374. /**
  5375. * Defines whether or not the harmonics have been prescaled for rendering.
  5376. */
  5377. preScaled: boolean;
  5378. /**
  5379. * The l0,0 coefficients of the spherical harmonics
  5380. */
  5381. l00: Vector3;
  5382. /**
  5383. * The l1,-1 coefficients of the spherical harmonics
  5384. */
  5385. l1_1: Vector3;
  5386. /**
  5387. * The l1,0 coefficients of the spherical harmonics
  5388. */
  5389. l10: Vector3;
  5390. /**
  5391. * The l1,1 coefficients of the spherical harmonics
  5392. */
  5393. l11: Vector3;
  5394. /**
  5395. * The l2,-2 coefficients of the spherical harmonics
  5396. */
  5397. l2_2: Vector3;
  5398. /**
  5399. * The l2,-1 coefficients of the spherical harmonics
  5400. */
  5401. l2_1: Vector3;
  5402. /**
  5403. * The l2,0 coefficients of the spherical harmonics
  5404. */
  5405. l20: Vector3;
  5406. /**
  5407. * The l2,1 coefficients of the spherical harmonics
  5408. */
  5409. l21: Vector3;
  5410. /**
  5411. * The l2,2 coefficients of the spherical harmonics
  5412. */
  5413. l22: Vector3;
  5414. /**
  5415. * Adds a light to the spherical harmonics
  5416. * @param direction the direction of the light
  5417. * @param color the color of the light
  5418. * @param deltaSolidAngle the delta solid angle of the light
  5419. */
  5420. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5421. /**
  5422. * Scales the spherical harmonics by the given amount
  5423. * @param scale the amount to scale
  5424. */
  5425. scaleInPlace(scale: number): void;
  5426. /**
  5427. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5428. *
  5429. * ```
  5430. * E_lm = A_l * L_lm
  5431. * ```
  5432. *
  5433. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5434. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5435. * the scaling factors are given in equation 9.
  5436. */
  5437. convertIncidentRadianceToIrradiance(): void;
  5438. /**
  5439. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5440. *
  5441. * ```
  5442. * L = (1/pi) * E * rho
  5443. * ```
  5444. *
  5445. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5446. */
  5447. convertIrradianceToLambertianRadiance(): void;
  5448. /**
  5449. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5450. * required operations at run time.
  5451. *
  5452. * This is simply done by scaling back the SH with Ylm constants parameter.
  5453. * The trigonometric part being applied by the shader at run time.
  5454. */
  5455. preScaleForRendering(): void;
  5456. /**
  5457. * Constructs a spherical harmonics from an array.
  5458. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5459. * @returns the spherical harmonics
  5460. */
  5461. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5462. /**
  5463. * Gets the spherical harmonics from polynomial
  5464. * @param polynomial the spherical polynomial
  5465. * @returns the spherical harmonics
  5466. */
  5467. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5468. }
  5469. /**
  5470. * Class representing spherical polynomial coefficients to the 3rd degree
  5471. */
  5472. export class SphericalPolynomial {
  5473. private _harmonics;
  5474. /**
  5475. * The spherical harmonics used to create the polynomials.
  5476. */
  5477. readonly preScaledHarmonics: SphericalHarmonics;
  5478. /**
  5479. * The x coefficients of the spherical polynomial
  5480. */
  5481. x: Vector3;
  5482. /**
  5483. * The y coefficients of the spherical polynomial
  5484. */
  5485. y: Vector3;
  5486. /**
  5487. * The z coefficients of the spherical polynomial
  5488. */
  5489. z: Vector3;
  5490. /**
  5491. * The xx coefficients of the spherical polynomial
  5492. */
  5493. xx: Vector3;
  5494. /**
  5495. * The yy coefficients of the spherical polynomial
  5496. */
  5497. yy: Vector3;
  5498. /**
  5499. * The zz coefficients of the spherical polynomial
  5500. */
  5501. zz: Vector3;
  5502. /**
  5503. * The xy coefficients of the spherical polynomial
  5504. */
  5505. xy: Vector3;
  5506. /**
  5507. * The yz coefficients of the spherical polynomial
  5508. */
  5509. yz: Vector3;
  5510. /**
  5511. * The zx coefficients of the spherical polynomial
  5512. */
  5513. zx: Vector3;
  5514. /**
  5515. * Adds an ambient color to the spherical polynomial
  5516. * @param color the color to add
  5517. */
  5518. addAmbient(color: Color3): void;
  5519. /**
  5520. * Scales the spherical polynomial by the given amount
  5521. * @param scale the amount to scale
  5522. */
  5523. scaleInPlace(scale: number): void;
  5524. /**
  5525. * Gets the spherical polynomial from harmonics
  5526. * @param harmonics the spherical harmonics
  5527. * @returns the spherical polynomial
  5528. */
  5529. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5530. /**
  5531. * Constructs a spherical polynomial from an array.
  5532. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5533. * @returns the spherical polynomial
  5534. */
  5535. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5536. }
  5537. }
  5538. declare module BABYLON {
  5539. /**
  5540. * Define options used to create a render target texture
  5541. */
  5542. export class RenderTargetCreationOptions {
  5543. /**
  5544. * Specifies is mipmaps must be generated
  5545. */
  5546. generateMipMaps?: boolean;
  5547. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5548. generateDepthBuffer?: boolean;
  5549. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5550. generateStencilBuffer?: boolean;
  5551. /** Defines texture type (int by default) */
  5552. type?: number;
  5553. /** Defines sampling mode (trilinear by default) */
  5554. samplingMode?: number;
  5555. /** Defines format (RGBA by default) */
  5556. format?: number;
  5557. }
  5558. }
  5559. declare module BABYLON {
  5560. /**
  5561. * @hidden
  5562. **/
  5563. export class _AlphaState {
  5564. private _isAlphaBlendDirty;
  5565. private _isBlendFunctionParametersDirty;
  5566. private _isBlendEquationParametersDirty;
  5567. private _isBlendConstantsDirty;
  5568. private _alphaBlend;
  5569. private _blendFunctionParameters;
  5570. private _blendEquationParameters;
  5571. private _blendConstants;
  5572. /**
  5573. * Initializes the state.
  5574. */
  5575. constructor();
  5576. readonly isDirty: boolean;
  5577. alphaBlend: boolean;
  5578. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5579. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5580. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5581. reset(): void;
  5582. apply(gl: WebGLRenderingContext): void;
  5583. }
  5584. }
  5585. declare module BABYLON {
  5586. /**
  5587. * @hidden
  5588. **/
  5589. export class _DepthCullingState {
  5590. private _isDepthTestDirty;
  5591. private _isDepthMaskDirty;
  5592. private _isDepthFuncDirty;
  5593. private _isCullFaceDirty;
  5594. private _isCullDirty;
  5595. private _isZOffsetDirty;
  5596. private _isFrontFaceDirty;
  5597. private _depthTest;
  5598. private _depthMask;
  5599. private _depthFunc;
  5600. private _cull;
  5601. private _cullFace;
  5602. private _zOffset;
  5603. private _frontFace;
  5604. /**
  5605. * Initializes the state.
  5606. */
  5607. constructor();
  5608. readonly isDirty: boolean;
  5609. zOffset: number;
  5610. cullFace: Nullable<number>;
  5611. cull: Nullable<boolean>;
  5612. depthFunc: Nullable<number>;
  5613. depthMask: boolean;
  5614. depthTest: boolean;
  5615. frontFace: Nullable<number>;
  5616. reset(): void;
  5617. apply(gl: WebGLRenderingContext): void;
  5618. }
  5619. }
  5620. declare module BABYLON {
  5621. /**
  5622. * @hidden
  5623. **/
  5624. export class _StencilState {
  5625. /** 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 */
  5626. static readonly ALWAYS: number;
  5627. /** Passed to stencilOperation to specify that stencil value must be kept */
  5628. static readonly KEEP: number;
  5629. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5630. static readonly REPLACE: number;
  5631. private _isStencilTestDirty;
  5632. private _isStencilMaskDirty;
  5633. private _isStencilFuncDirty;
  5634. private _isStencilOpDirty;
  5635. private _stencilTest;
  5636. private _stencilMask;
  5637. private _stencilFunc;
  5638. private _stencilFuncRef;
  5639. private _stencilFuncMask;
  5640. private _stencilOpStencilFail;
  5641. private _stencilOpDepthFail;
  5642. private _stencilOpStencilDepthPass;
  5643. readonly isDirty: boolean;
  5644. stencilFunc: number;
  5645. stencilFuncRef: number;
  5646. stencilFuncMask: number;
  5647. stencilOpStencilFail: number;
  5648. stencilOpDepthFail: number;
  5649. stencilOpStencilDepthPass: number;
  5650. stencilMask: number;
  5651. stencilTest: boolean;
  5652. constructor();
  5653. reset(): void;
  5654. apply(gl: WebGLRenderingContext): void;
  5655. }
  5656. }
  5657. declare module BABYLON {
  5658. /**
  5659. * @hidden
  5660. **/
  5661. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5662. }
  5663. }
  5664. declare module BABYLON {
  5665. /**
  5666. * Class used to evalaute queries containing `and` and `or` operators
  5667. */
  5668. export class AndOrNotEvaluator {
  5669. /**
  5670. * Evaluate a query
  5671. * @param query defines the query to evaluate
  5672. * @param evaluateCallback defines the callback used to filter result
  5673. * @returns true if the query matches
  5674. */
  5675. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5676. private static _HandleParenthesisContent;
  5677. private static _SimplifyNegation;
  5678. }
  5679. }
  5680. declare module BABYLON {
  5681. /**
  5682. * Class used to store custom tags
  5683. */
  5684. export class Tags {
  5685. /**
  5686. * Adds support for tags on the given object
  5687. * @param obj defines the object to use
  5688. */
  5689. static EnableFor(obj: any): void;
  5690. /**
  5691. * Removes tags support
  5692. * @param obj defines the object to use
  5693. */
  5694. static DisableFor(obj: any): void;
  5695. /**
  5696. * Gets a boolean indicating if the given object has tags
  5697. * @param obj defines the object to use
  5698. * @returns a boolean
  5699. */
  5700. static HasTags(obj: any): boolean;
  5701. /**
  5702. * Gets the tags available on a given object
  5703. * @param obj defines the object to use
  5704. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5705. * @returns the tags
  5706. */
  5707. static GetTags(obj: any, asString?: boolean): any;
  5708. /**
  5709. * Adds tags to an object
  5710. * @param obj defines the object to use
  5711. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5712. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5713. */
  5714. static AddTagsTo(obj: any, tagsString: string): void;
  5715. /**
  5716. * @hidden
  5717. */ private static _AddTagTo(obj: any, tag: string): void;
  5718. /**
  5719. * Removes specific tags from a specific object
  5720. * @param obj defines the object to use
  5721. * @param tagsString defines the tags to remove
  5722. */
  5723. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5724. /**
  5725. * @hidden
  5726. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5727. /**
  5728. * Defines if tags hosted on an object match a given query
  5729. * @param obj defines the object to use
  5730. * @param tagsQuery defines the tag query
  5731. * @returns a boolean
  5732. */
  5733. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5734. }
  5735. }
  5736. declare module BABYLON {
  5737. /**
  5738. * Defines potential orientation for back face culling
  5739. */
  5740. export enum Orientation {
  5741. /**
  5742. * Clockwise
  5743. */
  5744. CW = 0,
  5745. /** Counter clockwise */
  5746. CCW = 1
  5747. }
  5748. /** Class used to represent a Bezier curve */
  5749. export class BezierCurve {
  5750. /**
  5751. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5752. * @param t defines the time
  5753. * @param x1 defines the left coordinate on X axis
  5754. * @param y1 defines the left coordinate on Y axis
  5755. * @param x2 defines the right coordinate on X axis
  5756. * @param y2 defines the right coordinate on Y axis
  5757. * @returns the interpolated value
  5758. */
  5759. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5760. }
  5761. /**
  5762. * Defines angle representation
  5763. */
  5764. export class Angle {
  5765. private _radians;
  5766. /**
  5767. * Creates an Angle object of "radians" radians (float).
  5768. * @param radians the angle in radians
  5769. */
  5770. constructor(radians: number);
  5771. /**
  5772. * Get value in degrees
  5773. * @returns the Angle value in degrees (float)
  5774. */
  5775. degrees(): number;
  5776. /**
  5777. * Get value in radians
  5778. * @returns the Angle value in radians (float)
  5779. */
  5780. radians(): number;
  5781. /**
  5782. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5783. * @param a defines first vector
  5784. * @param b defines second vector
  5785. * @returns a new Angle
  5786. */
  5787. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5788. /**
  5789. * Gets a new Angle object from the given float in radians
  5790. * @param radians defines the angle value in radians
  5791. * @returns a new Angle
  5792. */
  5793. static FromRadians(radians: number): Angle;
  5794. /**
  5795. * Gets a new Angle object from the given float in degrees
  5796. * @param degrees defines the angle value in degrees
  5797. * @returns a new Angle
  5798. */
  5799. static FromDegrees(degrees: number): Angle;
  5800. }
  5801. /**
  5802. * This represents an arc in a 2d space.
  5803. */
  5804. export class Arc2 {
  5805. /** Defines the start point of the arc */
  5806. startPoint: Vector2;
  5807. /** Defines the mid point of the arc */
  5808. midPoint: Vector2;
  5809. /** Defines the end point of the arc */
  5810. endPoint: Vector2;
  5811. /**
  5812. * Defines the center point of the arc.
  5813. */
  5814. centerPoint: Vector2;
  5815. /**
  5816. * Defines the radius of the arc.
  5817. */
  5818. radius: number;
  5819. /**
  5820. * Defines the angle of the arc (from mid point to end point).
  5821. */
  5822. angle: Angle;
  5823. /**
  5824. * Defines the start angle of the arc (from start point to middle point).
  5825. */
  5826. startAngle: Angle;
  5827. /**
  5828. * Defines the orientation of the arc (clock wise/counter clock wise).
  5829. */
  5830. orientation: Orientation;
  5831. /**
  5832. * Creates an Arc object from the three given points : start, middle and end.
  5833. * @param startPoint Defines the start point of the arc
  5834. * @param midPoint Defines the midlle point of the arc
  5835. * @param endPoint Defines the end point of the arc
  5836. */
  5837. constructor(
  5838. /** Defines the start point of the arc */
  5839. startPoint: Vector2,
  5840. /** Defines the mid point of the arc */
  5841. midPoint: Vector2,
  5842. /** Defines the end point of the arc */
  5843. endPoint: Vector2);
  5844. }
  5845. /**
  5846. * Represents a 2D path made up of multiple 2D points
  5847. */
  5848. export class Path2 {
  5849. private _points;
  5850. private _length;
  5851. /**
  5852. * If the path start and end point are the same
  5853. */
  5854. closed: boolean;
  5855. /**
  5856. * Creates a Path2 object from the starting 2D coordinates x and y.
  5857. * @param x the starting points x value
  5858. * @param y the starting points y value
  5859. */
  5860. constructor(x: number, y: number);
  5861. /**
  5862. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5863. * @param x the added points x value
  5864. * @param y the added points y value
  5865. * @returns the updated Path2.
  5866. */
  5867. addLineTo(x: number, y: number): Path2;
  5868. /**
  5869. * 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.
  5870. * @param midX middle point x value
  5871. * @param midY middle point y value
  5872. * @param endX end point x value
  5873. * @param endY end point y value
  5874. * @param numberOfSegments (default: 36)
  5875. * @returns the updated Path2.
  5876. */
  5877. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5878. /**
  5879. * Closes the Path2.
  5880. * @returns the Path2.
  5881. */
  5882. close(): Path2;
  5883. /**
  5884. * Gets the sum of the distance between each sequential point in the path
  5885. * @returns the Path2 total length (float).
  5886. */
  5887. length(): number;
  5888. /**
  5889. * Gets the points which construct the path
  5890. * @returns the Path2 internal array of points.
  5891. */
  5892. getPoints(): Vector2[];
  5893. /**
  5894. * Retreives the point at the distance aways from the starting point
  5895. * @param normalizedLengthPosition the length along the path to retreive the point from
  5896. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5897. */
  5898. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5899. /**
  5900. * Creates a new path starting from an x and y position
  5901. * @param x starting x value
  5902. * @param y starting y value
  5903. * @returns a new Path2 starting at the coordinates (x, y).
  5904. */
  5905. static StartingAt(x: number, y: number): Path2;
  5906. }
  5907. /**
  5908. * Represents a 3D path made up of multiple 3D points
  5909. */
  5910. export class Path3D {
  5911. /**
  5912. * an array of Vector3, the curve axis of the Path3D
  5913. */
  5914. path: Vector3[];
  5915. private _curve;
  5916. private _distances;
  5917. private _tangents;
  5918. private _normals;
  5919. private _binormals;
  5920. private _raw;
  5921. /**
  5922. * new Path3D(path, normal, raw)
  5923. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5924. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5925. * @param path an array of Vector3, the curve axis of the Path3D
  5926. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5927. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5928. */
  5929. constructor(
  5930. /**
  5931. * an array of Vector3, the curve axis of the Path3D
  5932. */
  5933. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5934. /**
  5935. * Returns the Path3D array of successive Vector3 designing its curve.
  5936. * @returns the Path3D array of successive Vector3 designing its curve.
  5937. */
  5938. getCurve(): Vector3[];
  5939. /**
  5940. * Returns an array populated with tangent vectors on each Path3D curve point.
  5941. * @returns an array populated with tangent vectors on each Path3D curve point.
  5942. */
  5943. getTangents(): Vector3[];
  5944. /**
  5945. * Returns an array populated with normal vectors on each Path3D curve point.
  5946. * @returns an array populated with normal vectors on each Path3D curve point.
  5947. */
  5948. getNormals(): Vector3[];
  5949. /**
  5950. * Returns an array populated with binormal vectors on each Path3D curve point.
  5951. * @returns an array populated with binormal vectors on each Path3D curve point.
  5952. */
  5953. getBinormals(): Vector3[];
  5954. /**
  5955. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5956. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5957. */
  5958. getDistances(): number[];
  5959. /**
  5960. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5961. * @param path path which all values are copied into the curves points
  5962. * @param firstNormal which should be projected onto the curve
  5963. * @returns the same object updated.
  5964. */
  5965. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5966. private _compute;
  5967. private _getFirstNonNullVector;
  5968. private _getLastNonNullVector;
  5969. private _normalVector;
  5970. }
  5971. /**
  5972. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5973. * A Curve3 is designed from a series of successive Vector3.
  5974. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5975. */
  5976. export class Curve3 {
  5977. private _points;
  5978. private _length;
  5979. /**
  5980. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5981. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5982. * @param v1 (Vector3) the control point
  5983. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5984. * @param nbPoints (integer) the wanted number of points in the curve
  5985. * @returns the created Curve3
  5986. */
  5987. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5988. /**
  5989. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5991. * @param v1 (Vector3) the first control point
  5992. * @param v2 (Vector3) the second control point
  5993. * @param v3 (Vector3) the end point of the Cubic Bezier
  5994. * @param nbPoints (integer) the wanted number of points in the curve
  5995. * @returns the created Curve3
  5996. */
  5997. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5998. /**
  5999. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6000. * @param p1 (Vector3) the origin point of the Hermite Spline
  6001. * @param t1 (Vector3) the tangent vector at the origin point
  6002. * @param p2 (Vector3) the end point of the Hermite Spline
  6003. * @param t2 (Vector3) the tangent vector at the end point
  6004. * @param nbPoints (integer) the wanted number of points in the curve
  6005. * @returns the created Curve3
  6006. */
  6007. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6008. /**
  6009. * Returns a Curve3 object along a CatmullRom Spline curve :
  6010. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6011. * @param nbPoints (integer) the wanted number of points between each curve control points
  6012. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6013. * @returns the created Curve3
  6014. */
  6015. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6016. /**
  6017. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6018. * A Curve3 is designed from a series of successive Vector3.
  6019. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6020. * @param points points which make up the curve
  6021. */
  6022. constructor(points: Vector3[]);
  6023. /**
  6024. * @returns the Curve3 stored array of successive Vector3
  6025. */
  6026. getPoints(): Vector3[];
  6027. /**
  6028. * @returns the computed length (float) of the curve.
  6029. */
  6030. length(): number;
  6031. /**
  6032. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6033. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6034. * curveA and curveB keep unchanged.
  6035. * @param curve the curve to continue from this curve
  6036. * @returns the newly constructed curve
  6037. */
  6038. continue(curve: DeepImmutable<Curve3>): Curve3;
  6039. private _computeLength;
  6040. }
  6041. }
  6042. declare module BABYLON {
  6043. /**
  6044. * This represents the main contract an easing function should follow.
  6045. * Easing functions are used throughout the animation system.
  6046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6047. */
  6048. export interface IEasingFunction {
  6049. /**
  6050. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6051. * of the easing function.
  6052. * The link below provides some of the most common examples of easing functions.
  6053. * @see https://easings.net/
  6054. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6055. * @returns the corresponding value on the curve defined by the easing function
  6056. */
  6057. ease(gradient: number): number;
  6058. }
  6059. /**
  6060. * Base class used for every default easing function.
  6061. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6062. */
  6063. export class EasingFunction implements IEasingFunction {
  6064. /**
  6065. * Interpolation follows the mathematical formula associated with the easing function.
  6066. */
  6067. static readonly EASINGMODE_EASEIN: number;
  6068. /**
  6069. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6070. */
  6071. static readonly EASINGMODE_EASEOUT: number;
  6072. /**
  6073. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6074. */
  6075. static readonly EASINGMODE_EASEINOUT: number;
  6076. private _easingMode;
  6077. /**
  6078. * Sets the easing mode of the current function.
  6079. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6080. */
  6081. setEasingMode(easingMode: number): void;
  6082. /**
  6083. * Gets the current easing mode.
  6084. * @returns the easing mode
  6085. */
  6086. getEasingMode(): number;
  6087. /**
  6088. * @hidden
  6089. */
  6090. easeInCore(gradient: number): number;
  6091. /**
  6092. * Given an input gradient between 0 and 1, this returns the corresponding value
  6093. * of the easing function.
  6094. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6095. * @returns the corresponding value on the curve defined by the easing function
  6096. */
  6097. ease(gradient: number): number;
  6098. }
  6099. /**
  6100. * Easing function with a circle shape (see link below).
  6101. * @see https://easings.net/#easeInCirc
  6102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6103. */
  6104. export class CircleEase extends EasingFunction implements IEasingFunction {
  6105. /** @hidden */
  6106. easeInCore(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a ease back shape (see link below).
  6110. * @see https://easings.net/#easeInBack
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class BackEase extends EasingFunction implements IEasingFunction {
  6114. /** Defines the amplitude of the function */
  6115. amplitude: number;
  6116. /**
  6117. * Instantiates a back ease easing
  6118. * @see https://easings.net/#easeInBack
  6119. * @param amplitude Defines the amplitude of the function
  6120. */
  6121. constructor(
  6122. /** Defines the amplitude of the function */
  6123. amplitude?: number);
  6124. /** @hidden */
  6125. easeInCore(gradient: number): number;
  6126. }
  6127. /**
  6128. * Easing function with a bouncing shape (see link below).
  6129. * @see https://easings.net/#easeInBounce
  6130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6131. */
  6132. export class BounceEase extends EasingFunction implements IEasingFunction {
  6133. /** Defines the number of bounces */
  6134. bounces: number;
  6135. /** Defines the amplitude of the bounce */
  6136. bounciness: number;
  6137. /**
  6138. * Instantiates a bounce easing
  6139. * @see https://easings.net/#easeInBounce
  6140. * @param bounces Defines the number of bounces
  6141. * @param bounciness Defines the amplitude of the bounce
  6142. */
  6143. constructor(
  6144. /** Defines the number of bounces */
  6145. bounces?: number,
  6146. /** Defines the amplitude of the bounce */
  6147. bounciness?: number);
  6148. /** @hidden */
  6149. easeInCore(gradient: number): number;
  6150. }
  6151. /**
  6152. * Easing function with a power of 3 shape (see link below).
  6153. * @see https://easings.net/#easeInCubic
  6154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6155. */
  6156. export class CubicEase extends EasingFunction implements IEasingFunction {
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with an elastic shape (see link below).
  6162. * @see https://easings.net/#easeInElastic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6166. /** Defines the number of oscillations*/
  6167. oscillations: number;
  6168. /** Defines the amplitude of the oscillations*/
  6169. springiness: number;
  6170. /**
  6171. * Instantiates an elastic easing function
  6172. * @see https://easings.net/#easeInElastic
  6173. * @param oscillations Defines the number of oscillations
  6174. * @param springiness Defines the amplitude of the oscillations
  6175. */
  6176. constructor(
  6177. /** Defines the number of oscillations*/
  6178. oscillations?: number,
  6179. /** Defines the amplitude of the oscillations*/
  6180. springiness?: number);
  6181. /** @hidden */
  6182. easeInCore(gradient: number): number;
  6183. }
  6184. /**
  6185. * Easing function with an exponential shape (see link below).
  6186. * @see https://easings.net/#easeInExpo
  6187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6188. */
  6189. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6190. /** Defines the exponent of the function */
  6191. exponent: number;
  6192. /**
  6193. * Instantiates an exponential easing function
  6194. * @see https://easings.net/#easeInExpo
  6195. * @param exponent Defines the exponent of the function
  6196. */
  6197. constructor(
  6198. /** Defines the exponent of the function */
  6199. exponent?: number);
  6200. /** @hidden */
  6201. easeInCore(gradient: number): number;
  6202. }
  6203. /**
  6204. * Easing function with a power shape (see link below).
  6205. * @see https://easings.net/#easeInQuad
  6206. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6207. */
  6208. export class PowerEase extends EasingFunction implements IEasingFunction {
  6209. /** Defines the power of the function */
  6210. power: number;
  6211. /**
  6212. * Instantiates an power base easing function
  6213. * @see https://easings.net/#easeInQuad
  6214. * @param power Defines the power of the function
  6215. */
  6216. constructor(
  6217. /** Defines the power of the function */
  6218. power?: number);
  6219. /** @hidden */
  6220. easeInCore(gradient: number): number;
  6221. }
  6222. /**
  6223. * Easing function with a power of 2 shape (see link below).
  6224. * @see https://easings.net/#easeInQuad
  6225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6226. */
  6227. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 4 shape (see link below).
  6233. * @see https://easings.net/#easeInQuart
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 5 shape (see link below).
  6242. * @see https://easings.net/#easeInQuint
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a sin shape (see link below).
  6251. * @see https://easings.net/#easeInSine
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class SineEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a bezier shape (see link below).
  6260. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6264. /** Defines the x component of the start tangent in the bezier curve */
  6265. x1: number;
  6266. /** Defines the y component of the start tangent in the bezier curve */
  6267. y1: number;
  6268. /** Defines the x component of the end tangent in the bezier curve */
  6269. x2: number;
  6270. /** Defines the y component of the end tangent in the bezier curve */
  6271. y2: number;
  6272. /**
  6273. * Instantiates a bezier function
  6274. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6275. * @param x1 Defines the x component of the start tangent in the bezier curve
  6276. * @param y1 Defines the y component of the start tangent in the bezier curve
  6277. * @param x2 Defines the x component of the end tangent in the bezier curve
  6278. * @param y2 Defines the y component of the end tangent in the bezier curve
  6279. */
  6280. constructor(
  6281. /** Defines the x component of the start tangent in the bezier curve */
  6282. x1?: number,
  6283. /** Defines the y component of the start tangent in the bezier curve */
  6284. y1?: number,
  6285. /** Defines the x component of the end tangent in the bezier curve */
  6286. x2?: number,
  6287. /** Defines the y component of the end tangent in the bezier curve */
  6288. y2?: number);
  6289. /** @hidden */
  6290. easeInCore(gradient: number): number;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. /**
  6295. * Defines an interface which represents an animation key frame
  6296. */
  6297. export interface IAnimationKey {
  6298. /**
  6299. * Frame of the key frame
  6300. */
  6301. frame: number;
  6302. /**
  6303. * Value at the specifies key frame
  6304. */
  6305. value: any;
  6306. /**
  6307. * The input tangent for the cubic hermite spline
  6308. */
  6309. inTangent?: any;
  6310. /**
  6311. * The output tangent for the cubic hermite spline
  6312. */
  6313. outTangent?: any;
  6314. /**
  6315. * The animation interpolation type
  6316. */
  6317. interpolation?: AnimationKeyInterpolation;
  6318. }
  6319. /**
  6320. * Enum for the animation key frame interpolation type
  6321. */
  6322. export enum AnimationKeyInterpolation {
  6323. /**
  6324. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6325. */
  6326. STEP = 1
  6327. }
  6328. }
  6329. declare module BABYLON {
  6330. /**
  6331. * Represents the range of an animation
  6332. */
  6333. export class AnimationRange {
  6334. /**The name of the animation range**/
  6335. name: string;
  6336. /**The starting frame of the animation */
  6337. from: number;
  6338. /**The ending frame of the animation*/
  6339. to: number;
  6340. /**
  6341. * Initializes the range of an animation
  6342. * @param name The name of the animation range
  6343. * @param from The starting frame of the animation
  6344. * @param to The ending frame of the animation
  6345. */
  6346. constructor(
  6347. /**The name of the animation range**/
  6348. name: string,
  6349. /**The starting frame of the animation */
  6350. from: number,
  6351. /**The ending frame of the animation*/
  6352. to: number);
  6353. /**
  6354. * Makes a copy of the animation range
  6355. * @returns A copy of the animation range
  6356. */
  6357. clone(): AnimationRange;
  6358. }
  6359. }
  6360. declare module BABYLON {
  6361. /**
  6362. * Composed of a frame, and an action function
  6363. */
  6364. export class AnimationEvent {
  6365. /** The frame for which the event is triggered **/
  6366. frame: number;
  6367. /** The event to perform when triggered **/
  6368. action: (currentFrame: number) => void;
  6369. /** Specifies if the event should be triggered only once**/
  6370. onlyOnce?: boolean | undefined;
  6371. /**
  6372. * Specifies if the animation event is done
  6373. */
  6374. isDone: boolean;
  6375. /**
  6376. * Initializes the animation event
  6377. * @param frame The frame for which the event is triggered
  6378. * @param action The event to perform when triggered
  6379. * @param onlyOnce Specifies if the event should be triggered only once
  6380. */
  6381. constructor(
  6382. /** The frame for which the event is triggered **/
  6383. frame: number,
  6384. /** The event to perform when triggered **/
  6385. action: (currentFrame: number) => void,
  6386. /** Specifies if the event should be triggered only once**/
  6387. onlyOnce?: boolean | undefined);
  6388. /** @hidden */ private _clone(): AnimationEvent;
  6389. }
  6390. }
  6391. declare module BABYLON {
  6392. /**
  6393. * Interface used to define a behavior
  6394. */
  6395. export interface Behavior<T> {
  6396. /** gets or sets behavior's name */
  6397. name: string;
  6398. /**
  6399. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6400. */
  6401. init(): void;
  6402. /**
  6403. * Called when the behavior is attached to a target
  6404. * @param target defines the target where the behavior is attached to
  6405. */
  6406. attach(target: T): void;
  6407. /**
  6408. * Called when the behavior is detached from its target
  6409. */
  6410. detach(): void;
  6411. }
  6412. /**
  6413. * Interface implemented by classes supporting behaviors
  6414. */
  6415. export interface IBehaviorAware<T> {
  6416. /**
  6417. * Attach a behavior
  6418. * @param behavior defines the behavior to attach
  6419. * @returns the current host
  6420. */
  6421. addBehavior(behavior: Behavior<T>): T;
  6422. /**
  6423. * Remove a behavior from the current object
  6424. * @param behavior defines the behavior to detach
  6425. * @returns the current host
  6426. */
  6427. removeBehavior(behavior: Behavior<T>): T;
  6428. /**
  6429. * Gets a behavior using its name to search
  6430. * @param name defines the name to search
  6431. * @returns the behavior or null if not found
  6432. */
  6433. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6434. }
  6435. }
  6436. declare module BABYLON {
  6437. /**
  6438. * Defines an array and its length.
  6439. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6440. */
  6441. export interface ISmartArrayLike<T> {
  6442. /**
  6443. * The data of the array.
  6444. */
  6445. data: Array<T>;
  6446. /**
  6447. * The active length of the array.
  6448. */
  6449. length: number;
  6450. }
  6451. /**
  6452. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6453. */
  6454. export class SmartArray<T> implements ISmartArrayLike<T> {
  6455. /**
  6456. * The full set of data from the array.
  6457. */
  6458. data: Array<T>;
  6459. /**
  6460. * The active length of the array.
  6461. */
  6462. length: number;
  6463. protected _id: number;
  6464. /**
  6465. * Instantiates a Smart Array.
  6466. * @param capacity defines the default capacity of the array.
  6467. */
  6468. constructor(capacity: number);
  6469. /**
  6470. * Pushes a value at the end of the active data.
  6471. * @param value defines the object to push in the array.
  6472. */
  6473. push(value: T): void;
  6474. /**
  6475. * Iterates over the active data and apply the lambda to them.
  6476. * @param func defines the action to apply on each value.
  6477. */
  6478. forEach(func: (content: T) => void): void;
  6479. /**
  6480. * Sorts the full sets of data.
  6481. * @param compareFn defines the comparison function to apply.
  6482. */
  6483. sort(compareFn: (a: T, b: T) => number): void;
  6484. /**
  6485. * Resets the active data to an empty array.
  6486. */
  6487. reset(): void;
  6488. /**
  6489. * Releases all the data from the array as well as the array.
  6490. */
  6491. dispose(): void;
  6492. /**
  6493. * Concats the active data with a given array.
  6494. * @param array defines the data to concatenate with.
  6495. */
  6496. concat(array: any): void;
  6497. /**
  6498. * Returns the position of a value in the active data.
  6499. * @param value defines the value to find the index for
  6500. * @returns the index if found in the active data otherwise -1
  6501. */
  6502. indexOf(value: T): number;
  6503. /**
  6504. * Returns whether an element is part of the active data.
  6505. * @param value defines the value to look for
  6506. * @returns true if found in the active data otherwise false
  6507. */
  6508. contains(value: T): boolean;
  6509. private static _GlobalId;
  6510. }
  6511. /**
  6512. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6513. * The data in this array can only be present once
  6514. */
  6515. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6516. private _duplicateId;
  6517. /**
  6518. * Pushes a value at the end of the active data.
  6519. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6520. * @param value defines the object to push in the array.
  6521. */
  6522. push(value: T): void;
  6523. /**
  6524. * Pushes a value at the end of the active data.
  6525. * If the data is already present, it won t be added again
  6526. * @param value defines the object to push in the array.
  6527. * @returns true if added false if it was already present
  6528. */
  6529. pushNoDuplicate(value: T): boolean;
  6530. /**
  6531. * Resets the active data to an empty array.
  6532. */
  6533. reset(): void;
  6534. /**
  6535. * Concats the active data with a given array.
  6536. * This ensures no dupplicate will be present in the result.
  6537. * @param array defines the data to concatenate with.
  6538. */
  6539. concatWithNoDuplicate(array: any): void;
  6540. }
  6541. }
  6542. declare module BABYLON {
  6543. /**
  6544. * @ignore
  6545. * This is a list of all the different input types that are available in the application.
  6546. * Fo instance: ArcRotateCameraGamepadInput...
  6547. */
  6548. export var CameraInputTypes: {};
  6549. /**
  6550. * This is the contract to implement in order to create a new input class.
  6551. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6552. */
  6553. export interface ICameraInput<TCamera extends Camera> {
  6554. /**
  6555. * Defines the camera the input is attached to.
  6556. */
  6557. camera: Nullable<TCamera>;
  6558. /**
  6559. * Gets the class name of the current intput.
  6560. * @returns the class name
  6561. */
  6562. getClassName(): string;
  6563. /**
  6564. * Get the friendly name associated with the input class.
  6565. * @returns the input friendly name
  6566. */
  6567. getSimpleName(): string;
  6568. /**
  6569. * Attach the input controls to a specific dom element to get the input from.
  6570. * @param element Defines the element the controls should be listened from
  6571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6572. */
  6573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6574. /**
  6575. * Detach the current controls from the specified dom element.
  6576. * @param element Defines the element to stop listening the inputs from
  6577. */
  6578. detachControl(element: Nullable<HTMLElement>): void;
  6579. /**
  6580. * Update the current camera state depending on the inputs that have been used this frame.
  6581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6582. */
  6583. checkInputs?: () => void;
  6584. }
  6585. /**
  6586. * Represents a map of input types to input instance or input index to input instance.
  6587. */
  6588. export interface CameraInputsMap<TCamera extends Camera> {
  6589. /**
  6590. * Accessor to the input by input type.
  6591. */
  6592. [name: string]: ICameraInput<TCamera>;
  6593. /**
  6594. * Accessor to the input by input index.
  6595. */
  6596. [idx: number]: ICameraInput<TCamera>;
  6597. }
  6598. /**
  6599. * This represents the input manager used within a camera.
  6600. * It helps dealing with all the different kind of input attached to a camera.
  6601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6602. */
  6603. export class CameraInputsManager<TCamera extends Camera> {
  6604. /**
  6605. * Defines the list of inputs attahed to the camera.
  6606. */
  6607. attached: CameraInputsMap<TCamera>;
  6608. /**
  6609. * Defines the dom element the camera is collecting inputs from.
  6610. * This is null if the controls have not been attached.
  6611. */
  6612. attachedElement: Nullable<HTMLElement>;
  6613. /**
  6614. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6615. */
  6616. noPreventDefault: boolean;
  6617. /**
  6618. * Defined the camera the input manager belongs to.
  6619. */
  6620. camera: TCamera;
  6621. /**
  6622. * Update the current camera state depending on the inputs that have been used this frame.
  6623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6624. */
  6625. checkInputs: () => void;
  6626. /**
  6627. * Instantiate a new Camera Input Manager.
  6628. * @param camera Defines the camera the input manager blongs to
  6629. */
  6630. constructor(camera: TCamera);
  6631. /**
  6632. * Add an input method to a camera
  6633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6634. * @param input camera input method
  6635. */
  6636. add(input: ICameraInput<TCamera>): void;
  6637. /**
  6638. * Remove a specific input method from a camera
  6639. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6640. * @param inputToRemove camera input method
  6641. */
  6642. remove(inputToRemove: ICameraInput<TCamera>): void;
  6643. /**
  6644. * Remove a specific input type from a camera
  6645. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6646. * @param inputType the type of the input to remove
  6647. */
  6648. removeByType(inputType: string): void;
  6649. private _addCheckInputs;
  6650. /**
  6651. * Attach the input controls to the currently attached dom element to listen the events from.
  6652. * @param input Defines the input to attach
  6653. */
  6654. attachInput(input: ICameraInput<TCamera>): void;
  6655. /**
  6656. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6657. * @param element Defines the dom element to collect the events from
  6658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6659. */
  6660. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6661. /**
  6662. * Detach the current manager inputs controls from a specific dom element.
  6663. * @param element Defines the dom element to collect the events from
  6664. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6665. */
  6666. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6667. /**
  6668. * Rebuild the dynamic inputCheck function from the current list of
  6669. * defined inputs in the manager.
  6670. */
  6671. rebuildInputCheck(): void;
  6672. /**
  6673. * Remove all attached input methods from a camera
  6674. */
  6675. clear(): void;
  6676. /**
  6677. * Serialize the current input manager attached to a camera.
  6678. * This ensures than once parsed,
  6679. * the input associated to the camera will be identical to the current ones
  6680. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6681. */
  6682. serialize(serializedCamera: any): void;
  6683. /**
  6684. * Parses an input manager serialized JSON to restore the previous list of inputs
  6685. * and states associated to a camera.
  6686. * @param parsedCamera Defines the JSON to parse
  6687. */
  6688. parse(parsedCamera: any): void;
  6689. }
  6690. }
  6691. declare module BABYLON {
  6692. /**
  6693. * @hidden
  6694. */
  6695. export class IntersectionInfo {
  6696. bu: Nullable<number>;
  6697. bv: Nullable<number>;
  6698. distance: number;
  6699. faceId: number;
  6700. subMeshId: number;
  6701. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /**
  6706. * Represens a plane by the equation ax + by + cz + d = 0
  6707. */
  6708. export class Plane {
  6709. private static _TmpMatrix;
  6710. /**
  6711. * Normal of the plane (a,b,c)
  6712. */
  6713. normal: Vector3;
  6714. /**
  6715. * d component of the plane
  6716. */
  6717. d: number;
  6718. /**
  6719. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6720. * @param a a component of the plane
  6721. * @param b b component of the plane
  6722. * @param c c component of the plane
  6723. * @param d d component of the plane
  6724. */
  6725. constructor(a: number, b: number, c: number, d: number);
  6726. /**
  6727. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6728. */
  6729. asArray(): number[];
  6730. /**
  6731. * @returns a new plane copied from the current Plane.
  6732. */
  6733. clone(): Plane;
  6734. /**
  6735. * @returns the string "Plane".
  6736. */
  6737. getClassName(): string;
  6738. /**
  6739. * @returns the Plane hash code.
  6740. */
  6741. getHashCode(): number;
  6742. /**
  6743. * Normalize the current Plane in place.
  6744. * @returns the updated Plane.
  6745. */
  6746. normalize(): Plane;
  6747. /**
  6748. * Applies a transformation the plane and returns the result
  6749. * @param transformation the transformation matrix to be applied to the plane
  6750. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6751. */
  6752. transform(transformation: DeepImmutable<Matrix>): Plane;
  6753. /**
  6754. * Calcualtte the dot product between the point and the plane normal
  6755. * @param point point to calculate the dot product with
  6756. * @returns the dot product (float) of the point coordinates and the plane normal.
  6757. */
  6758. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6759. /**
  6760. * Updates the current Plane from the plane defined by the three given points.
  6761. * @param point1 one of the points used to contruct the plane
  6762. * @param point2 one of the points used to contruct the plane
  6763. * @param point3 one of the points used to contruct the plane
  6764. * @returns the updated Plane.
  6765. */
  6766. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6767. /**
  6768. * Checks if the plane is facing a given direction
  6769. * @param direction the direction to check if the plane is facing
  6770. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6771. * @returns True is the vector "direction" is the same side than the plane normal.
  6772. */
  6773. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6774. /**
  6775. * Calculates the distance to a point
  6776. * @param point point to calculate distance to
  6777. * @returns the signed distance (float) from the given point to the Plane.
  6778. */
  6779. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6780. /**
  6781. * Creates a plane from an array
  6782. * @param array the array to create a plane from
  6783. * @returns a new Plane from the given array.
  6784. */
  6785. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6786. /**
  6787. * Creates a plane from three points
  6788. * @param point1 point used to create the plane
  6789. * @param point2 point used to create the plane
  6790. * @param point3 point used to create the plane
  6791. * @returns a new Plane defined by the three given points.
  6792. */
  6793. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6794. /**
  6795. * Creates a plane from an origin point and a normal
  6796. * @param origin origin of the plane to be constructed
  6797. * @param normal normal of the plane to be constructed
  6798. * @returns a new Plane the normal vector to this plane at the given origin point.
  6799. * Note : the vector "normal" is updated because normalized.
  6800. */
  6801. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6802. /**
  6803. * Calculates the distance from a plane and a point
  6804. * @param origin origin of the plane to be constructed
  6805. * @param normal normal of the plane to be constructed
  6806. * @param point point to calculate distance to
  6807. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6808. */
  6809. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6810. }
  6811. }
  6812. declare module BABYLON {
  6813. /**
  6814. * Class used to store bounding sphere information
  6815. */
  6816. export class BoundingSphere {
  6817. /**
  6818. * Gets the center of the bounding sphere in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Radius of the bounding sphere in local space
  6823. */
  6824. radius: number;
  6825. /**
  6826. * Gets the center of the bounding sphere in world space
  6827. */
  6828. readonly centerWorld: Vector3;
  6829. /**
  6830. * Radius of the bounding sphere in world space
  6831. */
  6832. radiusWorld: number;
  6833. /**
  6834. * Gets the minimum vector in local space
  6835. */
  6836. readonly minimum: Vector3;
  6837. /**
  6838. * Gets the maximum vector in local space
  6839. */
  6840. readonly maximum: Vector3;
  6841. private _worldMatrix;
  6842. private static readonly TmpVector3;
  6843. /**
  6844. * Creates a new bounding sphere
  6845. * @param min defines the minimum vector (in local space)
  6846. * @param max defines the maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6850. /**
  6851. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6852. * @param min defines the new minimum vector (in local space)
  6853. * @param max defines the new maximum vector (in local space)
  6854. * @param worldMatrix defines the new world matrix
  6855. */
  6856. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6857. /**
  6858. * Scale the current bounding sphere by applying a scale factor
  6859. * @param factor defines the scale factor to apply
  6860. * @returns the current bounding box
  6861. */
  6862. scale(factor: number): BoundingSphere;
  6863. /**
  6864. * Gets the world matrix of the bounding box
  6865. * @returns a matrix
  6866. */
  6867. getWorldMatrix(): DeepImmutable<Matrix>;
  6868. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6869. /**
  6870. * Tests if the bounding sphere is intersecting the frustum planes
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @returns true if there is an intersection
  6873. */
  6874. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. /**
  6876. * Tests if the bounding sphere center is in between the frustum planes.
  6877. * Used for optimistic fast inclusion.
  6878. * @param frustumPlanes defines the frustum planes to test
  6879. * @returns true if the sphere center is in between the frustum planes
  6880. */
  6881. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6882. /**
  6883. * Tests if a point is inside the bounding sphere
  6884. * @param point defines the point to test
  6885. * @returns true if the point is inside the bounding sphere
  6886. */
  6887. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6888. /**
  6889. * Checks if two sphere intersct
  6890. * @param sphere0 sphere 0
  6891. * @param sphere1 sphere 1
  6892. * @returns true if the speres intersect
  6893. */
  6894. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6895. }
  6896. }
  6897. declare module BABYLON {
  6898. /**
  6899. * Class used to store bounding box information
  6900. */
  6901. export class BoundingBox implements ICullable {
  6902. /**
  6903. * Gets the 8 vectors representing the bounding box in local space
  6904. */
  6905. readonly vectors: Vector3[];
  6906. /**
  6907. * Gets the center of the bounding box in local space
  6908. */
  6909. readonly center: Vector3;
  6910. /**
  6911. * Gets the center of the bounding box in world space
  6912. */
  6913. readonly centerWorld: Vector3;
  6914. /**
  6915. * Gets the extend size in local space
  6916. */
  6917. readonly extendSize: Vector3;
  6918. /**
  6919. * Gets the extend size in world space
  6920. */
  6921. readonly extendSizeWorld: Vector3;
  6922. /**
  6923. * Gets the OBB (object bounding box) directions
  6924. */
  6925. readonly directions: Vector3[];
  6926. /**
  6927. * Gets the 8 vectors representing the bounding box in world space
  6928. */
  6929. readonly vectorsWorld: Vector3[];
  6930. /**
  6931. * Gets the minimum vector in world space
  6932. */
  6933. readonly minimumWorld: Vector3;
  6934. /**
  6935. * Gets the maximum vector in world space
  6936. */
  6937. readonly maximumWorld: Vector3;
  6938. /**
  6939. * Gets the minimum vector in local space
  6940. */
  6941. readonly minimum: Vector3;
  6942. /**
  6943. * Gets the maximum vector in local space
  6944. */
  6945. readonly maximum: Vector3;
  6946. private _worldMatrix;
  6947. private static readonly TmpVector3;
  6948. /**
  6949. * @hidden
  6950. */ private _tag: number;
  6951. /**
  6952. * Creates a new bounding box
  6953. * @param min defines the minimum vector (in local space)
  6954. * @param max defines the maximum vector (in local space)
  6955. * @param worldMatrix defines the new world matrix
  6956. */
  6957. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6958. /**
  6959. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6960. * @param min defines the new minimum vector (in local space)
  6961. * @param max defines the new maximum vector (in local space)
  6962. * @param worldMatrix defines the new world matrix
  6963. */
  6964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6965. /**
  6966. * Scale the current bounding box by applying a scale factor
  6967. * @param factor defines the scale factor to apply
  6968. * @returns the current bounding box
  6969. */
  6970. scale(factor: number): BoundingBox;
  6971. /**
  6972. * Gets the world matrix of the bounding box
  6973. * @returns a matrix
  6974. */
  6975. getWorldMatrix(): DeepImmutable<Matrix>;
  6976. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Tests if the bounding box is intersecting the frustum planes
  6979. * @param frustumPlanes defines the frustum planes to test
  6980. * @returns true if there is an intersection
  6981. */
  6982. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6983. /**
  6984. * Tests if the bounding box is entirely inside the frustum planes
  6985. * @param frustumPlanes defines the frustum planes to test
  6986. * @returns true if there is an inclusion
  6987. */
  6988. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6989. /**
  6990. * Tests if a point is inside the bounding box
  6991. * @param point defines the point to test
  6992. * @returns true if the point is inside the bounding box
  6993. */
  6994. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if the bounding box intersects with a bounding sphere
  6997. * @param sphere defines the sphere to test
  6998. * @returns true if there is an intersection
  6999. */
  7000. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7001. /**
  7002. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7003. * @param min defines the min vector to use
  7004. * @param max defines the max vector to use
  7005. * @returns true if there is an intersection
  7006. */
  7007. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if two bounding boxes are intersections
  7010. * @param box0 defines the first box to test
  7011. * @param box1 defines the second box to test
  7012. * @returns true if there is an intersection
  7013. */
  7014. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7015. /**
  7016. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7017. * @param minPoint defines the minimum vector of the bounding box
  7018. * @param maxPoint defines the maximum vector of the bounding box
  7019. * @param sphereCenter defines the sphere center
  7020. * @param sphereRadius defines the sphere radius
  7021. * @returns true if there is an intersection
  7022. */
  7023. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7024. /**
  7025. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7026. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @return true if there is an inclusion
  7029. */
  7030. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7033. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7034. * @param frustumPlanes defines the frustum planes to test
  7035. * @return true if there is an intersection
  7036. */
  7037. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /** @hidden */
  7042. export class Collider {
  7043. /** Define if a collision was found */
  7044. collisionFound: boolean;
  7045. /**
  7046. * Define last intersection point in local space
  7047. */
  7048. intersectionPoint: Vector3;
  7049. /**
  7050. * Define last collided mesh
  7051. */
  7052. collidedMesh: Nullable<AbstractMesh>;
  7053. private _collisionPoint;
  7054. private _planeIntersectionPoint;
  7055. private _tempVector;
  7056. private _tempVector2;
  7057. private _tempVector3;
  7058. private _tempVector4;
  7059. private _edge;
  7060. private _baseToVertex;
  7061. private _destinationPoint;
  7062. private _slidePlaneNormal;
  7063. private _displacementVector;
  7064. /** @hidden */ private _radius: Vector3;
  7065. /** @hidden */ private _retry: number;
  7066. private _velocity;
  7067. private _basePoint;
  7068. private _epsilon;
  7069. /** @hidden */ private _velocityWorldLength: number;
  7070. /** @hidden */ private _basePointWorld: Vector3;
  7071. private _velocityWorld;
  7072. private _normalizedVelocity;
  7073. /** @hidden */ private _initialVelocity: Vector3;
  7074. /** @hidden */ private _initialPosition: Vector3;
  7075. private _nearestDistance;
  7076. private _collisionMask;
  7077. collisionMask: number;
  7078. /**
  7079. * Gets the plane normal used to compute the sliding response (in local space)
  7080. */
  7081. readonly slidePlaneNormal: Vector3;
  7082. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7083. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7084. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7085. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7086. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7087. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7088. }
  7089. }
  7090. declare module BABYLON {
  7091. /**
  7092. * Interface for cullable objects
  7093. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7094. */
  7095. export interface ICullable {
  7096. /**
  7097. * Checks if the object or part of the object is in the frustum
  7098. * @param frustumPlanes Camera near/planes
  7099. * @returns true if the object is in frustum otherwise false
  7100. */
  7101. isInFrustum(frustumPlanes: Plane[]): boolean;
  7102. /**
  7103. * Checks if a cullable object (mesh...) is in the camera frustum
  7104. * Unlike isInFrustum this cheks the full bounding box
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7109. }
  7110. /**
  7111. * Info for a bounding data of a mesh
  7112. */
  7113. export class BoundingInfo implements ICullable {
  7114. /**
  7115. * Bounding box for the mesh
  7116. */
  7117. readonly boundingBox: BoundingBox;
  7118. /**
  7119. * Bounding sphere for the mesh
  7120. */
  7121. readonly boundingSphere: BoundingSphere;
  7122. private _isLocked;
  7123. private static readonly TmpVector3;
  7124. /**
  7125. * Constructs bounding info
  7126. * @param minimum min vector of the bounding box/sphere
  7127. * @param maximum max vector of the bounding box/sphere
  7128. * @param worldMatrix defines the new world matrix
  7129. */
  7130. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7131. /**
  7132. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7133. * @param min defines the new minimum vector (in local space)
  7134. * @param max defines the new maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7138. /**
  7139. * min vector of the bounding box/sphere
  7140. */
  7141. readonly minimum: Vector3;
  7142. /**
  7143. * max vector of the bounding box/sphere
  7144. */
  7145. readonly maximum: Vector3;
  7146. /**
  7147. * If the info is locked and won't be updated to avoid perf overhead
  7148. */
  7149. isLocked: boolean;
  7150. /**
  7151. * Updates the bounding sphere and box
  7152. * @param world world matrix to be used to update
  7153. */
  7154. update(world: DeepImmutable<Matrix>): void;
  7155. /**
  7156. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7157. * @param center New center of the bounding info
  7158. * @param extend New extend of the bounding info
  7159. * @returns the current bounding info
  7160. */
  7161. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7162. /**
  7163. * Scale the current bounding info by applying a scale factor
  7164. * @param factor defines the scale factor to apply
  7165. * @returns the current bounding info
  7166. */
  7167. scale(factor: number): BoundingInfo;
  7168. /**
  7169. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7170. * @param frustumPlanes defines the frustum to test
  7171. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7172. * @returns true if the bounding info is in the frustum planes
  7173. */
  7174. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7175. /**
  7176. * Gets the world distance between the min and max points of the bounding box
  7177. */
  7178. readonly diagonalLength: number;
  7179. /**
  7180. * Checks if a cullable object (mesh...) is in the camera frustum
  7181. * Unlike isInFrustum this cheks the full bounding box
  7182. * @param frustumPlanes Camera near/planes
  7183. * @returns true if the object is in frustum otherwise false
  7184. */
  7185. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7186. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7187. /**
  7188. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7189. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7190. * @param point the point to check intersection with
  7191. * @returns if the point intersects
  7192. */
  7193. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7194. /**
  7195. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7196. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7197. * @param boundingInfo the bounding info to check intersection with
  7198. * @param precise if the intersection should be done using OBB
  7199. * @returns if the bounding info intersects
  7200. */
  7201. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Extracts minimum and maximum values from a list of indexed positions
  7207. * @param positions defines the positions to use
  7208. * @param indices defines the indices to the positions
  7209. * @param indexStart defines the start index
  7210. * @param indexCount defines the end index
  7211. * @param bias defines bias value to add to the result
  7212. * @return minimum and maximum values
  7213. */
  7214. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7215. minimum: Vector3;
  7216. maximum: Vector3;
  7217. };
  7218. /**
  7219. * Extracts minimum and maximum values from a list of positions
  7220. * @param positions defines the positions to use
  7221. * @param start defines the start index in the positions array
  7222. * @param count defines the number of positions to handle
  7223. * @param bias defines bias value to add to the result
  7224. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7225. * @return minimum and maximum values
  7226. */
  7227. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7228. minimum: Vector3;
  7229. maximum: Vector3;
  7230. };
  7231. }
  7232. declare module BABYLON {
  7233. /**
  7234. * Enum that determines the text-wrapping mode to use.
  7235. */
  7236. export enum InspectableType {
  7237. /**
  7238. * Checkbox for booleans
  7239. */
  7240. Checkbox = 0,
  7241. /**
  7242. * Sliders for numbers
  7243. */
  7244. Slider = 1,
  7245. /**
  7246. * Vector3
  7247. */
  7248. Vector3 = 2,
  7249. /**
  7250. * Quaternions
  7251. */
  7252. Quaternion = 3,
  7253. /**
  7254. * Color3
  7255. */
  7256. Color3 = 4,
  7257. /**
  7258. * String
  7259. */
  7260. String = 5
  7261. }
  7262. /**
  7263. * Interface used to define custom inspectable properties.
  7264. * This interface is used by the inspector to display custom property grids
  7265. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7266. */
  7267. export interface IInspectable {
  7268. /**
  7269. * Gets the label to display
  7270. */
  7271. label: string;
  7272. /**
  7273. * Gets the name of the property to edit
  7274. */
  7275. propertyName: string;
  7276. /**
  7277. * Gets the type of the editor to use
  7278. */
  7279. type: InspectableType;
  7280. /**
  7281. * Gets the minimum value of the property when using in "slider" mode
  7282. */
  7283. min?: number;
  7284. /**
  7285. * Gets the maximum value of the property when using in "slider" mode
  7286. */
  7287. max?: number;
  7288. /**
  7289. * Gets the setp to use when using in "slider" mode
  7290. */
  7291. step?: number;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Class used to provide helper for timing
  7297. */
  7298. export class TimingTools {
  7299. /**
  7300. * Polyfill for setImmediate
  7301. * @param action defines the action to execute after the current execution block
  7302. */
  7303. static SetImmediate(action: () => void): void;
  7304. }
  7305. }
  7306. declare module BABYLON {
  7307. /**
  7308. * Class used to enable instatition of objects by class name
  7309. */
  7310. export class InstantiationTools {
  7311. /**
  7312. * Use this object to register external classes like custom textures or material
  7313. * to allow the laoders to instantiate them
  7314. */
  7315. static RegisteredExternalClasses: {
  7316. [key: string]: Object;
  7317. };
  7318. /**
  7319. * Tries to instantiate a new object from a given class name
  7320. * @param className defines the class name to instantiate
  7321. * @returns the new object or null if the system was not able to do the instantiation
  7322. */
  7323. static Instantiate(className: string): any;
  7324. }
  7325. }
  7326. declare module BABYLON {
  7327. /**
  7328. * This represents the required contract to create a new type of texture loader.
  7329. */
  7330. export interface IInternalTextureLoader {
  7331. /**
  7332. * Defines wether the loader supports cascade loading the different faces.
  7333. */
  7334. supportCascades: boolean;
  7335. /**
  7336. * This returns if the loader support the current file information.
  7337. * @param extension defines the file extension of the file being loaded
  7338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7339. * @param fallback defines the fallback internal texture if any
  7340. * @param isBase64 defines whether the texture is encoded as a base64
  7341. * @param isBuffer defines whether the texture data are stored as a buffer
  7342. * @returns true if the loader can load the specified file
  7343. */
  7344. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7345. /**
  7346. * Transform the url before loading if required.
  7347. * @param rootUrl the url of the texture
  7348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7349. * @returns the transformed texture
  7350. */
  7351. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7352. /**
  7353. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7354. * @param rootUrl the url of the texture
  7355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7356. * @returns the fallback texture
  7357. */
  7358. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7359. /**
  7360. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7361. * @param data contains the texture data
  7362. * @param texture defines the BabylonJS internal texture
  7363. * @param createPolynomials will be true if polynomials have been requested
  7364. * @param onLoad defines the callback to trigger once the texture is ready
  7365. * @param onError defines the callback to trigger in case of error
  7366. */
  7367. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7368. /**
  7369. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7370. * @param data contains the texture data
  7371. * @param texture defines the BabylonJS internal texture
  7372. * @param callback defines the method to call once ready to upload
  7373. */
  7374. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7375. }
  7376. }
  7377. declare module BABYLON {
  7378. interface Engine {
  7379. /**
  7380. * Creates a depth stencil cube texture.
  7381. * This is only available in WebGL 2.
  7382. * @param size The size of face edge in the cube texture.
  7383. * @param options The options defining the cube texture.
  7384. * @returns The cube texture
  7385. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7386. /**
  7387. * Creates a cube texture
  7388. * @param rootUrl defines the url where the files to load is located
  7389. * @param scene defines the current scene
  7390. * @param files defines the list of files to load (1 per face)
  7391. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7392. * @param onLoad defines an optional callback raised when the texture is loaded
  7393. * @param onError defines an optional callback raised if there is an issue to load the texture
  7394. * @param format defines the format of the data
  7395. * @param forcedExtension defines the extension to use to pick the right loader
  7396. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7397. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7398. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7399. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7400. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7401. * @returns the cube texture as an InternalTexture
  7402. */
  7403. 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;
  7404. /**
  7405. * Creates a cube texture
  7406. * @param rootUrl defines the url where the files to load is located
  7407. * @param scene defines the current scene
  7408. * @param files defines the list of files to load (1 per face)
  7409. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7410. * @param onLoad defines an optional callback raised when the texture is loaded
  7411. * @param onError defines an optional callback raised if there is an issue to load the texture
  7412. * @param format defines the format of the data
  7413. * @param forcedExtension defines the extension to use to pick the right loader
  7414. * @returns the cube texture as an InternalTexture
  7415. */
  7416. 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;
  7417. /**
  7418. * Creates a cube texture
  7419. * @param rootUrl defines the url where the files to load is located
  7420. * @param scene defines the current scene
  7421. * @param files defines the list of files to load (1 per face)
  7422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7423. * @param onLoad defines an optional callback raised when the texture is loaded
  7424. * @param onError defines an optional callback raised if there is an issue to load the texture
  7425. * @param format defines the format of the data
  7426. * @param forcedExtension defines the extension to use to pick the right loader
  7427. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7428. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7429. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7430. * @returns the cube texture as an InternalTexture
  7431. */
  7432. 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;
  7433. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7434. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7435. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7436. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7437. }
  7438. }
  7439. declare module BABYLON {
  7440. /**
  7441. * Class for creating a cube texture
  7442. */
  7443. export class CubeTexture extends BaseTexture {
  7444. private _delayedOnLoad;
  7445. /**
  7446. * The url of the texture
  7447. */
  7448. url: string;
  7449. /**
  7450. * Gets or sets the center of the bounding box associated with the cube texture.
  7451. * It must define where the camera used to render the texture was set
  7452. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7453. */
  7454. boundingBoxPosition: Vector3;
  7455. private _boundingBoxSize;
  7456. /**
  7457. * Gets or sets the size of the bounding box associated with the cube texture
  7458. * When defined, the cubemap will switch to local mode
  7459. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7460. * @example https://www.babylonjs-playground.com/#RNASML
  7461. */
  7462. /**
  7463. * Returns the bounding box size
  7464. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7465. */
  7466. boundingBoxSize: Vector3;
  7467. protected _rotationY: number;
  7468. /**
  7469. * Sets texture matrix rotation angle around Y axis in radians.
  7470. */
  7471. /**
  7472. * Gets texture matrix rotation angle around Y axis radians.
  7473. */
  7474. rotationY: number;
  7475. /**
  7476. * Are mip maps generated for this texture or not.
  7477. */
  7478. readonly noMipmap: boolean;
  7479. private _noMipmap;
  7480. private _files;
  7481. private _extensions;
  7482. private _textureMatrix;
  7483. private _format;
  7484. private _createPolynomials;
  7485. /** @hidden */ private _prefiltered: boolean;
  7486. /**
  7487. * Creates a cube texture from an array of image urls
  7488. * @param files defines an array of image urls
  7489. * @param scene defines the hosting scene
  7490. * @param noMipmap specifies if mip maps are not used
  7491. * @returns a cube texture
  7492. */
  7493. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7494. /**
  7495. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7496. * @param url defines the url of the prefiltered texture
  7497. * @param scene defines the scene the texture is attached to
  7498. * @param forcedExtension defines the extension of the file if different from the url
  7499. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7500. * @return the prefiltered texture
  7501. */
  7502. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7503. /**
  7504. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7505. * as prefiltered data.
  7506. * @param rootUrl defines the url of the texture or the root name of the six images
  7507. * @param scene defines the scene the texture is attached to
  7508. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7509. * @param noMipmap defines if mipmaps should be created or not
  7510. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7511. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7512. * @param onError defines a callback triggered in case of error during load
  7513. * @param format defines the internal format to use for the texture once loaded
  7514. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7515. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7516. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7519. * @return the cube texture
  7520. */
  7521. 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);
  7522. /**
  7523. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7524. */
  7525. readonly isPrefiltered: boolean;
  7526. /**
  7527. * Get the current class name of the texture useful for serialization or dynamic coding.
  7528. * @returns "CubeTexture"
  7529. */
  7530. getClassName(): string;
  7531. /**
  7532. * Update the url (and optional buffer) of this texture if url was null during construction.
  7533. * @param url the url of the texture
  7534. * @param forcedExtension defines the extension to use
  7535. * @param onLoad callback called when the texture is loaded (defaults to null)
  7536. */
  7537. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7538. /**
  7539. * Delays loading of the cube texture
  7540. * @param forcedExtension defines the extension to use
  7541. */
  7542. delayLoad(forcedExtension?: string): void;
  7543. /**
  7544. * Returns the reflection texture matrix
  7545. * @returns the reflection texture matrix
  7546. */
  7547. getReflectionTextureMatrix(): Matrix;
  7548. /**
  7549. * Sets the reflection texture matrix
  7550. * @param value Reflection texture matrix
  7551. */
  7552. setReflectionTextureMatrix(value: Matrix): void;
  7553. /**
  7554. * Parses text to create a cube texture
  7555. * @param parsedTexture define the serialized text to read from
  7556. * @param scene defines the hosting scene
  7557. * @param rootUrl defines the root url of the cube texture
  7558. * @returns a cube texture
  7559. */
  7560. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7561. /**
  7562. * Makes a clone, or deep copy, of the cube texture
  7563. * @returns a new cube texture
  7564. */
  7565. clone(): CubeTexture;
  7566. }
  7567. }
  7568. declare module BABYLON {
  7569. /**
  7570. * Manages the defines for the Material
  7571. */
  7572. export class MaterialDefines {
  7573. /** @hidden */
  7574. protected _keys: string[];
  7575. private _isDirty;
  7576. /** @hidden */ private _renderId: number;
  7577. /** @hidden */ private _areLightsDirty: boolean;
  7578. /** @hidden */ private _areLightsDisposed: boolean;
  7579. /** @hidden */ private _areAttributesDirty: boolean;
  7580. /** @hidden */ private _areTexturesDirty: boolean;
  7581. /** @hidden */ private _areFresnelDirty: boolean;
  7582. /** @hidden */ private _areMiscDirty: boolean;
  7583. /** @hidden */ private _areImageProcessingDirty: boolean;
  7584. /** @hidden */ private _normals: boolean;
  7585. /** @hidden */ private _uvs: boolean;
  7586. /** @hidden */ private _needNormals: boolean;
  7587. /** @hidden */ private _needUVs: boolean;
  7588. [id: string]: any;
  7589. /**
  7590. * Specifies if the material needs to be re-calculated
  7591. */
  7592. readonly isDirty: boolean;
  7593. /**
  7594. * Marks the material to indicate that it has been re-calculated
  7595. */
  7596. markAsProcessed(): void;
  7597. /**
  7598. * Marks the material to indicate that it needs to be re-calculated
  7599. */
  7600. markAsUnprocessed(): void;
  7601. /**
  7602. * Marks the material to indicate all of its defines need to be re-calculated
  7603. */
  7604. markAllAsDirty(): void;
  7605. /**
  7606. * Marks the material to indicate that image processing needs to be re-calculated
  7607. */
  7608. markAsImageProcessingDirty(): void;
  7609. /**
  7610. * Marks the material to indicate the lights need to be re-calculated
  7611. * @param disposed Defines whether the light is dirty due to dispose or not
  7612. */
  7613. markAsLightDirty(disposed?: boolean): void;
  7614. /**
  7615. * Marks the attribute state as changed
  7616. */
  7617. markAsAttributesDirty(): void;
  7618. /**
  7619. * Marks the texture state as changed
  7620. */
  7621. markAsTexturesDirty(): void;
  7622. /**
  7623. * Marks the fresnel state as changed
  7624. */
  7625. markAsFresnelDirty(): void;
  7626. /**
  7627. * Marks the misc state as changed
  7628. */
  7629. markAsMiscDirty(): void;
  7630. /**
  7631. * Rebuilds the material defines
  7632. */
  7633. rebuild(): void;
  7634. /**
  7635. * Specifies if two material defines are equal
  7636. * @param other - A material define instance to compare to
  7637. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7638. */
  7639. isEqual(other: MaterialDefines): boolean;
  7640. /**
  7641. * Clones this instance's defines to another instance
  7642. * @param other - material defines to clone values to
  7643. */
  7644. cloneTo(other: MaterialDefines): void;
  7645. /**
  7646. * Resets the material define values
  7647. */
  7648. reset(): void;
  7649. /**
  7650. * Converts the material define values to a string
  7651. * @returns - String of material define information
  7652. */
  7653. toString(): string;
  7654. }
  7655. }
  7656. declare module BABYLON {
  7657. /**
  7658. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7659. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7660. * 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;
  7661. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7662. */
  7663. export class ColorCurves {
  7664. private _dirty;
  7665. private _tempColor;
  7666. private _globalCurve;
  7667. private _highlightsCurve;
  7668. private _midtonesCurve;
  7669. private _shadowsCurve;
  7670. private _positiveCurve;
  7671. private _negativeCurve;
  7672. private _globalHue;
  7673. private _globalDensity;
  7674. private _globalSaturation;
  7675. private _globalExposure;
  7676. /**
  7677. * Gets the global Hue value.
  7678. * 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).
  7679. */
  7680. /**
  7681. * Sets the global Hue value.
  7682. * 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).
  7683. */
  7684. globalHue: number;
  7685. /**
  7686. * Gets the global Density value.
  7687. * 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.
  7688. * Values less than zero provide a filter of opposite hue.
  7689. */
  7690. /**
  7691. * Sets the global Density value.
  7692. * 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.
  7693. * Values less than zero provide a filter of opposite hue.
  7694. */
  7695. globalDensity: number;
  7696. /**
  7697. * Gets the global Saturation value.
  7698. * 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.
  7699. */
  7700. /**
  7701. * Sets the global Saturation value.
  7702. * 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.
  7703. */
  7704. globalSaturation: number;
  7705. /**
  7706. * Gets the global Exposure value.
  7707. * 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.
  7708. */
  7709. /**
  7710. * Sets the global Exposure value.
  7711. * 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.
  7712. */
  7713. globalExposure: number;
  7714. private _highlightsHue;
  7715. private _highlightsDensity;
  7716. private _highlightsSaturation;
  7717. private _highlightsExposure;
  7718. /**
  7719. * Gets the highlights Hue value.
  7720. * 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).
  7721. */
  7722. /**
  7723. * Sets the highlights Hue value.
  7724. * 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).
  7725. */
  7726. highlightsHue: number;
  7727. /**
  7728. * Gets the highlights Density value.
  7729. * 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.
  7730. * Values less than zero provide a filter of opposite hue.
  7731. */
  7732. /**
  7733. * Sets the highlights Density value.
  7734. * 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.
  7735. * Values less than zero provide a filter of opposite hue.
  7736. */
  7737. highlightsDensity: number;
  7738. /**
  7739. * Gets the highlights Saturation value.
  7740. * 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.
  7741. */
  7742. /**
  7743. * Sets the highlights Saturation value.
  7744. * 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.
  7745. */
  7746. highlightsSaturation: number;
  7747. /**
  7748. * Gets the highlights Exposure value.
  7749. * 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.
  7750. */
  7751. /**
  7752. * Sets the highlights Exposure value.
  7753. * 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.
  7754. */
  7755. highlightsExposure: number;
  7756. private _midtonesHue;
  7757. private _midtonesDensity;
  7758. private _midtonesSaturation;
  7759. private _midtonesExposure;
  7760. /**
  7761. * Gets the midtones Hue value.
  7762. * 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).
  7763. */
  7764. /**
  7765. * Sets the midtones Hue value.
  7766. * 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).
  7767. */
  7768. midtonesHue: number;
  7769. /**
  7770. * Gets the midtones Density value.
  7771. * 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.
  7772. * Values less than zero provide a filter of opposite hue.
  7773. */
  7774. /**
  7775. * Sets the midtones Density value.
  7776. * 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.
  7777. * Values less than zero provide a filter of opposite hue.
  7778. */
  7779. midtonesDensity: number;
  7780. /**
  7781. * Gets the midtones Saturation value.
  7782. * 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.
  7783. */
  7784. /**
  7785. * Sets the midtones Saturation value.
  7786. * 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.
  7787. */
  7788. midtonesSaturation: number;
  7789. /**
  7790. * Gets the midtones Exposure value.
  7791. * 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.
  7792. */
  7793. /**
  7794. * Sets the midtones Exposure value.
  7795. * 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.
  7796. */
  7797. midtonesExposure: number;
  7798. private _shadowsHue;
  7799. private _shadowsDensity;
  7800. private _shadowsSaturation;
  7801. private _shadowsExposure;
  7802. /**
  7803. * Gets the shadows Hue value.
  7804. * 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).
  7805. */
  7806. /**
  7807. * Sets the shadows Hue value.
  7808. * 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).
  7809. */
  7810. shadowsHue: number;
  7811. /**
  7812. * Gets the shadows Density value.
  7813. * 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.
  7814. * Values less than zero provide a filter of opposite hue.
  7815. */
  7816. /**
  7817. * Sets the shadows Density value.
  7818. * 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.
  7819. * Values less than zero provide a filter of opposite hue.
  7820. */
  7821. shadowsDensity: number;
  7822. /**
  7823. * Gets the shadows Saturation value.
  7824. * 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.
  7825. */
  7826. /**
  7827. * Sets the shadows Saturation value.
  7828. * 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.
  7829. */
  7830. shadowsSaturation: number;
  7831. /**
  7832. * Gets the shadows Exposure value.
  7833. * 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.
  7834. */
  7835. /**
  7836. * Sets the shadows Exposure value.
  7837. * 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.
  7838. */
  7839. shadowsExposure: number;
  7840. /**
  7841. * Returns the class name
  7842. * @returns The class name
  7843. */
  7844. getClassName(): string;
  7845. /**
  7846. * Binds the color curves to the shader.
  7847. * @param colorCurves The color curve to bind
  7848. * @param effect The effect to bind to
  7849. * @param positiveUniform The positive uniform shader parameter
  7850. * @param neutralUniform The neutral uniform shader parameter
  7851. * @param negativeUniform The negative uniform shader parameter
  7852. */
  7853. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7854. /**
  7855. * Prepare the list of uniforms associated with the ColorCurves effects.
  7856. * @param uniformsList The list of uniforms used in the effect
  7857. */
  7858. static PrepareUniforms(uniformsList: string[]): void;
  7859. /**
  7860. * Returns color grading data based on a hue, density, saturation and exposure value.
  7861. * @param filterHue The hue of the color filter.
  7862. * @param filterDensity The density of the color filter.
  7863. * @param saturation The saturation.
  7864. * @param exposure The exposure.
  7865. * @param result The result data container.
  7866. */
  7867. private getColorGradingDataToRef;
  7868. /**
  7869. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7870. * @param value The input slider value in range [-100,100].
  7871. * @returns Adjusted value.
  7872. */
  7873. private static applyColorGradingSliderNonlinear;
  7874. /**
  7875. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7876. * @param hue The hue (H) input.
  7877. * @param saturation The saturation (S) input.
  7878. * @param brightness The brightness (B) input.
  7879. * @result An RGBA color represented as Vector4.
  7880. */
  7881. private static fromHSBToRef;
  7882. /**
  7883. * Returns a value clamped between min and max
  7884. * @param value The value to clamp
  7885. * @param min The minimum of value
  7886. * @param max The maximum of value
  7887. * @returns The clamped value.
  7888. */
  7889. private static clamp;
  7890. /**
  7891. * Clones the current color curve instance.
  7892. * @return The cloned curves
  7893. */
  7894. clone(): ColorCurves;
  7895. /**
  7896. * Serializes the current color curve instance to a json representation.
  7897. * @return a JSON representation
  7898. */
  7899. serialize(): any;
  7900. /**
  7901. * Parses the color curve from a json representation.
  7902. * @param source the JSON source to parse
  7903. * @return The parsed curves
  7904. */
  7905. static Parse(source: any): ColorCurves;
  7906. }
  7907. }
  7908. declare module BABYLON {
  7909. /**
  7910. * Interface to follow in your material defines to integrate easily the
  7911. * Image proccessing functions.
  7912. * @hidden
  7913. */
  7914. export interface IImageProcessingConfigurationDefines {
  7915. IMAGEPROCESSING: boolean;
  7916. VIGNETTE: boolean;
  7917. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7918. VIGNETTEBLENDMODEOPAQUE: boolean;
  7919. TONEMAPPING: boolean;
  7920. TONEMAPPING_ACES: boolean;
  7921. CONTRAST: boolean;
  7922. EXPOSURE: boolean;
  7923. COLORCURVES: boolean;
  7924. COLORGRADING: boolean;
  7925. COLORGRADING3D: boolean;
  7926. SAMPLER3DGREENDEPTH: boolean;
  7927. SAMPLER3DBGRMAP: boolean;
  7928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7929. }
  7930. /**
  7931. * @hidden
  7932. */
  7933. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7934. IMAGEPROCESSING: boolean;
  7935. VIGNETTE: boolean;
  7936. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7937. VIGNETTEBLENDMODEOPAQUE: boolean;
  7938. TONEMAPPING: boolean;
  7939. TONEMAPPING_ACES: boolean;
  7940. CONTRAST: boolean;
  7941. COLORCURVES: boolean;
  7942. COLORGRADING: boolean;
  7943. COLORGRADING3D: boolean;
  7944. SAMPLER3DGREENDEPTH: boolean;
  7945. SAMPLER3DBGRMAP: boolean;
  7946. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7947. EXPOSURE: boolean;
  7948. constructor();
  7949. }
  7950. /**
  7951. * This groups together the common properties used for image processing either in direct forward pass
  7952. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7953. * or not.
  7954. */
  7955. export class ImageProcessingConfiguration {
  7956. /**
  7957. * Default tone mapping applied in BabylonJS.
  7958. */
  7959. static readonly TONEMAPPING_STANDARD: number;
  7960. /**
  7961. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7962. * to other engines rendering to increase portability.
  7963. */
  7964. static readonly TONEMAPPING_ACES: number;
  7965. /**
  7966. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7967. */
  7968. colorCurves: Nullable<ColorCurves>;
  7969. private _colorCurvesEnabled;
  7970. /**
  7971. * Gets wether the color curves effect is enabled.
  7972. */
  7973. /**
  7974. * Sets wether the color curves effect is enabled.
  7975. */
  7976. colorCurvesEnabled: boolean;
  7977. private _colorGradingTexture;
  7978. /**
  7979. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7980. */
  7981. /**
  7982. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7983. */
  7984. colorGradingTexture: Nullable<BaseTexture>;
  7985. private _colorGradingEnabled;
  7986. /**
  7987. * Gets wether the color grading effect is enabled.
  7988. */
  7989. /**
  7990. * Sets wether the color grading effect is enabled.
  7991. */
  7992. colorGradingEnabled: boolean;
  7993. private _colorGradingWithGreenDepth;
  7994. /**
  7995. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7996. */
  7997. /**
  7998. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7999. */
  8000. colorGradingWithGreenDepth: boolean;
  8001. private _colorGradingBGR;
  8002. /**
  8003. * Gets wether the color grading texture contains BGR values.
  8004. */
  8005. /**
  8006. * Sets wether the color grading texture contains BGR values.
  8007. */
  8008. colorGradingBGR: boolean;
  8009. /** @hidden */ private _exposure: number;
  8010. /**
  8011. * Gets the Exposure used in the effect.
  8012. */
  8013. /**
  8014. * Sets the Exposure used in the effect.
  8015. */
  8016. exposure: number;
  8017. private _toneMappingEnabled;
  8018. /**
  8019. * Gets wether the tone mapping effect is enabled.
  8020. */
  8021. /**
  8022. * Sets wether the tone mapping effect is enabled.
  8023. */
  8024. toneMappingEnabled: boolean;
  8025. private _toneMappingType;
  8026. /**
  8027. * Gets the type of tone mapping effect.
  8028. */
  8029. /**
  8030. * Sets the type of tone mapping effect used in BabylonJS.
  8031. */
  8032. toneMappingType: number;
  8033. protected _contrast: number;
  8034. /**
  8035. * Gets the contrast used in the effect.
  8036. */
  8037. /**
  8038. * Sets the contrast used in the effect.
  8039. */
  8040. contrast: number;
  8041. /**
  8042. * Vignette stretch size.
  8043. */
  8044. vignetteStretch: number;
  8045. /**
  8046. * Vignette centre X Offset.
  8047. */
  8048. vignetteCentreX: number;
  8049. /**
  8050. * Vignette centre Y Offset.
  8051. */
  8052. vignetteCentreY: number;
  8053. /**
  8054. * Vignette weight or intensity of the vignette effect.
  8055. */
  8056. vignetteWeight: number;
  8057. /**
  8058. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8059. * if vignetteEnabled is set to true.
  8060. */
  8061. vignetteColor: Color4;
  8062. /**
  8063. * Camera field of view used by the Vignette effect.
  8064. */
  8065. vignetteCameraFov: number;
  8066. private _vignetteBlendMode;
  8067. /**
  8068. * Gets the vignette blend mode allowing different kind of effect.
  8069. */
  8070. /**
  8071. * Sets the vignette blend mode allowing different kind of effect.
  8072. */
  8073. vignetteBlendMode: number;
  8074. private _vignetteEnabled;
  8075. /**
  8076. * Gets wether the vignette effect is enabled.
  8077. */
  8078. /**
  8079. * Sets wether the vignette effect is enabled.
  8080. */
  8081. vignetteEnabled: boolean;
  8082. private _applyByPostProcess;
  8083. /**
  8084. * Gets wether the image processing is applied through a post process or not.
  8085. */
  8086. /**
  8087. * Sets wether the image processing is applied through a post process or not.
  8088. */
  8089. applyByPostProcess: boolean;
  8090. private _isEnabled;
  8091. /**
  8092. * Gets wether the image processing is enabled or not.
  8093. */
  8094. /**
  8095. * Sets wether the image processing is enabled or not.
  8096. */
  8097. isEnabled: boolean;
  8098. /**
  8099. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8100. */
  8101. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8102. /**
  8103. * Method called each time the image processing information changes requires to recompile the effect.
  8104. */
  8105. protected _updateParameters(): void;
  8106. /**
  8107. * Gets the current class name.
  8108. * @return "ImageProcessingConfiguration"
  8109. */
  8110. getClassName(): string;
  8111. /**
  8112. * Prepare the list of uniforms associated with the Image Processing effects.
  8113. * @param uniforms The list of uniforms used in the effect
  8114. * @param defines the list of defines currently in use
  8115. */
  8116. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8117. /**
  8118. * Prepare the list of samplers associated with the Image Processing effects.
  8119. * @param samplersList The list of uniforms used in the effect
  8120. * @param defines the list of defines currently in use
  8121. */
  8122. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8123. /**
  8124. * Prepare the list of defines associated to the shader.
  8125. * @param defines the list of defines to complete
  8126. * @param forPostProcess Define if we are currently in post process mode or not
  8127. */
  8128. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8129. /**
  8130. * Returns true if all the image processing information are ready.
  8131. * @returns True if ready, otherwise, false
  8132. */
  8133. isReady(): boolean;
  8134. /**
  8135. * Binds the image processing to the shader.
  8136. * @param effect The effect to bind to
  8137. * @param aspectRatio Define the current aspect ratio of the effect
  8138. */
  8139. bind(effect: Effect, aspectRatio?: number): void;
  8140. /**
  8141. * Clones the current image processing instance.
  8142. * @return The cloned image processing
  8143. */
  8144. clone(): ImageProcessingConfiguration;
  8145. /**
  8146. * Serializes the current image processing instance to a json representation.
  8147. * @return a JSON representation
  8148. */
  8149. serialize(): any;
  8150. /**
  8151. * Parses the image processing from a json representation.
  8152. * @param source the JSON source to parse
  8153. * @return The parsed image processing
  8154. */
  8155. static Parse(source: any): ImageProcessingConfiguration;
  8156. private static _VIGNETTEMODE_MULTIPLY;
  8157. private static _VIGNETTEMODE_OPAQUE;
  8158. /**
  8159. * Used to apply the vignette as a mix with the pixel color.
  8160. */
  8161. static readonly VIGNETTEMODE_MULTIPLY: number;
  8162. /**
  8163. * Used to apply the vignette as a replacement of the pixel color.
  8164. */
  8165. static readonly VIGNETTEMODE_OPAQUE: number;
  8166. }
  8167. }
  8168. declare module BABYLON {
  8169. /** @hidden */
  8170. export var postprocessVertexShader: {
  8171. name: string;
  8172. shader: string;
  8173. };
  8174. }
  8175. declare module BABYLON {
  8176. /** Defines supported spaces */
  8177. export enum Space {
  8178. /** Local (object) space */
  8179. LOCAL = 0,
  8180. /** World space */
  8181. WORLD = 1,
  8182. /** Bone space */
  8183. BONE = 2
  8184. }
  8185. /** Defines the 3 main axes */
  8186. export class Axis {
  8187. /** X axis */
  8188. static X: Vector3;
  8189. /** Y axis */
  8190. static Y: Vector3;
  8191. /** Z axis */
  8192. static Z: Vector3;
  8193. }
  8194. }
  8195. declare module BABYLON {
  8196. /**
  8197. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8198. * This is the base of the follow, arc rotate cameras and Free camera
  8199. * @see http://doc.babylonjs.com/features/cameras
  8200. */
  8201. export class TargetCamera extends Camera {
  8202. private static _RigCamTransformMatrix;
  8203. private static _TargetTransformMatrix;
  8204. private static _TargetFocalPoint;
  8205. /**
  8206. * Define the current direction the camera is moving to
  8207. */
  8208. cameraDirection: Vector3;
  8209. /**
  8210. * Define the current rotation the camera is rotating to
  8211. */
  8212. cameraRotation: Vector2;
  8213. /**
  8214. * When set, the up vector of the camera will be updated by the rotation of the camera
  8215. */
  8216. updateUpVectorFromRotation: boolean;
  8217. private _tmpQuaternion;
  8218. /**
  8219. * Define the current rotation of the camera
  8220. */
  8221. rotation: Vector3;
  8222. /**
  8223. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8224. */
  8225. rotationQuaternion: Quaternion;
  8226. /**
  8227. * Define the current speed of the camera
  8228. */
  8229. speed: number;
  8230. /**
  8231. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8232. * around all axis.
  8233. */
  8234. noRotationConstraint: boolean;
  8235. /**
  8236. * Define the current target of the camera as an object or a position.
  8237. */
  8238. lockedTarget: any;
  8239. /** @hidden */ private _currentTarget: Vector3;
  8240. /** @hidden */ private _initialFocalDistance: number;
  8241. /** @hidden */ private _viewMatrix: Matrix;
  8242. /** @hidden */ private _camMatrix: Matrix;
  8243. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8244. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8245. /** @hidden */ private _referencePoint: Vector3;
  8246. /** @hidden */ private _transformedReferencePoint: Vector3;
  8247. protected _globalCurrentTarget: Vector3;
  8248. protected _globalCurrentUpVector: Vector3;
  8249. /** @hidden */ private _reset: () => void;
  8250. private _defaultUp;
  8251. /**
  8252. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8253. * This is the base of the follow, arc rotate cameras and Free camera
  8254. * @see http://doc.babylonjs.com/features/cameras
  8255. * @param name Defines the name of the camera in the scene
  8256. * @param position Defines the start position of the camera in the scene
  8257. * @param scene Defines the scene the camera belongs to
  8258. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8259. */
  8260. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8261. /**
  8262. * Gets the position in front of the camera at a given distance.
  8263. * @param distance The distance from the camera we want the position to be
  8264. * @returns the position
  8265. */
  8266. getFrontPosition(distance: number): Vector3;
  8267. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8268. private _storedPosition;
  8269. private _storedRotation;
  8270. private _storedRotationQuaternion;
  8271. /**
  8272. * Store current camera state of the camera (fov, position, rotation, etc..)
  8273. * @returns the camera
  8274. */
  8275. storeState(): Camera;
  8276. /**
  8277. * Restored camera state. You must call storeState() first
  8278. * @returns whether it was successful or not
  8279. * @hidden
  8280. */ private _restoreStateValues(): boolean;
  8281. /** @hidden */ private _initCache(): void;
  8282. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8283. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8284. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8285. /**
  8286. * Defines the target the camera should look at.
  8287. * @param target Defines the new target as a Vector or a mesh
  8288. */
  8289. setTarget(target: Vector3): void;
  8290. /**
  8291. * Return the current target position of the camera. This value is expressed in local space.
  8292. * @returns the target position
  8293. */
  8294. getTarget(): Vector3;
  8295. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8296. /** @hidden */ private _updatePosition(): void;
  8297. /** @hidden */ private _checkInputs(): void;
  8298. protected _updateCameraRotationMatrix(): void;
  8299. /**
  8300. * 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)
  8301. * @returns the current camera
  8302. */
  8303. private _rotateUpVectorWithCameraRotationMatrix;
  8304. private _cachedRotationZ;
  8305. private _cachedQuaternionRotationZ;
  8306. /** @hidden */ private _getViewMatrix(): Matrix;
  8307. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8308. /**
  8309. * @hidden
  8310. */
  8311. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8312. /**
  8313. * @hidden
  8314. */ private _updateRigCameras(): void;
  8315. private _getRigCamPositionAndTarget;
  8316. /**
  8317. * Gets the current object class name.
  8318. * @return the class name
  8319. */
  8320. getClassName(): string;
  8321. }
  8322. }
  8323. declare module BABYLON {
  8324. /**
  8325. * Gather the list of keyboard event types as constants.
  8326. */
  8327. export class KeyboardEventTypes {
  8328. /**
  8329. * The keydown event is fired when a key becomes active (pressed).
  8330. */
  8331. static readonly KEYDOWN: number;
  8332. /**
  8333. * The keyup event is fired when a key has been released.
  8334. */
  8335. static readonly KEYUP: number;
  8336. }
  8337. /**
  8338. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8339. */
  8340. export class KeyboardInfo {
  8341. /**
  8342. * Defines the type of event (KeyboardEventTypes)
  8343. */
  8344. type: number;
  8345. /**
  8346. * Defines the related dom event
  8347. */
  8348. event: KeyboardEvent;
  8349. /**
  8350. * Instantiates a new keyboard info.
  8351. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8352. * @param type Defines the type of event (KeyboardEventTypes)
  8353. * @param event Defines the related dom event
  8354. */
  8355. constructor(
  8356. /**
  8357. * Defines the type of event (KeyboardEventTypes)
  8358. */
  8359. type: number,
  8360. /**
  8361. * Defines the related dom event
  8362. */
  8363. event: KeyboardEvent);
  8364. }
  8365. /**
  8366. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8367. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8368. */
  8369. export class KeyboardInfoPre extends KeyboardInfo {
  8370. /**
  8371. * Defines the type of event (KeyboardEventTypes)
  8372. */
  8373. type: number;
  8374. /**
  8375. * Defines the related dom event
  8376. */
  8377. event: KeyboardEvent;
  8378. /**
  8379. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8380. */
  8381. skipOnPointerObservable: boolean;
  8382. /**
  8383. * Instantiates a new keyboard pre info.
  8384. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8385. * @param type Defines the type of event (KeyboardEventTypes)
  8386. * @param event Defines the related dom event
  8387. */
  8388. constructor(
  8389. /**
  8390. * Defines the type of event (KeyboardEventTypes)
  8391. */
  8392. type: number,
  8393. /**
  8394. * Defines the related dom event
  8395. */
  8396. event: KeyboardEvent);
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /**
  8401. * Manage the keyboard inputs to control the movement of a free camera.
  8402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8403. */
  8404. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8405. /**
  8406. * Defines the camera the input is attached to.
  8407. */
  8408. camera: FreeCamera;
  8409. /**
  8410. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8411. */
  8412. keysUp: number[];
  8413. /**
  8414. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8415. */
  8416. keysDown: number[];
  8417. /**
  8418. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8419. */
  8420. keysLeft: number[];
  8421. /**
  8422. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8423. */
  8424. keysRight: number[];
  8425. private _keys;
  8426. private _onCanvasBlurObserver;
  8427. private _onKeyboardObserver;
  8428. private _engine;
  8429. private _scene;
  8430. /**
  8431. * Attach the input controls to a specific dom element to get the input from.
  8432. * @param element Defines the element the controls should be listened from
  8433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8434. */
  8435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8436. /**
  8437. * Detach the current controls from the specified dom element.
  8438. * @param element Defines the element to stop listening the inputs from
  8439. */
  8440. detachControl(element: Nullable<HTMLElement>): void;
  8441. /**
  8442. * Update the current camera state depending on the inputs that have been used this frame.
  8443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8444. */
  8445. checkInputs(): void;
  8446. /**
  8447. * Gets the class name of the current intput.
  8448. * @returns the class name
  8449. */
  8450. getClassName(): string;
  8451. /** @hidden */ private _onLostFocus(): void;
  8452. /**
  8453. * Get the friendly name associated with the input class.
  8454. * @returns the input friendly name
  8455. */
  8456. getSimpleName(): string;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /**
  8461. * Interface describing all the common properties and methods a shadow light needs to implement.
  8462. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8463. * as well as binding the different shadow properties to the effects.
  8464. */
  8465. export interface IShadowLight extends Light {
  8466. /**
  8467. * The light id in the scene (used in scene.findLighById for instance)
  8468. */
  8469. id: string;
  8470. /**
  8471. * The position the shdow will be casted from.
  8472. */
  8473. position: Vector3;
  8474. /**
  8475. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8476. */
  8477. direction: Vector3;
  8478. /**
  8479. * The transformed position. Position of the light in world space taking parenting in account.
  8480. */
  8481. transformedPosition: Vector3;
  8482. /**
  8483. * The transformed direction. Direction of the light in world space taking parenting in account.
  8484. */
  8485. transformedDirection: Vector3;
  8486. /**
  8487. * The friendly name of the light in the scene.
  8488. */
  8489. name: string;
  8490. /**
  8491. * Defines the shadow projection clipping minimum z value.
  8492. */
  8493. shadowMinZ: number;
  8494. /**
  8495. * Defines the shadow projection clipping maximum z value.
  8496. */
  8497. shadowMaxZ: number;
  8498. /**
  8499. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8500. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8501. */
  8502. computeTransformedInformation(): boolean;
  8503. /**
  8504. * Gets the scene the light belongs to.
  8505. * @returns The scene
  8506. */
  8507. getScene(): Scene;
  8508. /**
  8509. * Callback defining a custom Projection Matrix Builder.
  8510. * This can be used to override the default projection matrix computation.
  8511. */
  8512. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8513. /**
  8514. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8515. * @param matrix The materix to updated with the projection information
  8516. * @param viewMatrix The transform matrix of the light
  8517. * @param renderList The list of mesh to render in the map
  8518. * @returns The current light
  8519. */
  8520. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8521. /**
  8522. * Gets the current depth scale used in ESM.
  8523. * @returns The scale
  8524. */
  8525. getDepthScale(): number;
  8526. /**
  8527. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8528. * @returns true if a cube texture needs to be use
  8529. */
  8530. needCube(): boolean;
  8531. /**
  8532. * Detects if the projection matrix requires to be recomputed this frame.
  8533. * @returns true if it requires to be recomputed otherwise, false.
  8534. */
  8535. needProjectionMatrixCompute(): boolean;
  8536. /**
  8537. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8538. */
  8539. forceProjectionMatrixCompute(): void;
  8540. /**
  8541. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8542. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8543. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8544. */
  8545. getShadowDirection(faceIndex?: number): Vector3;
  8546. /**
  8547. * Gets the minZ used for shadow according to both the scene and the light.
  8548. * @param activeCamera The camera we are returning the min for
  8549. * @returns the depth min z
  8550. */
  8551. getDepthMinZ(activeCamera: Camera): number;
  8552. /**
  8553. * Gets the maxZ used for shadow according to both the scene and the light.
  8554. * @param activeCamera The camera we are returning the max for
  8555. * @returns the depth max z
  8556. */
  8557. getDepthMaxZ(activeCamera: Camera): number;
  8558. }
  8559. /**
  8560. * Base implementation IShadowLight
  8561. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8562. */
  8563. export abstract class ShadowLight extends Light implements IShadowLight {
  8564. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8565. protected _position: Vector3;
  8566. protected _setPosition(value: Vector3): void;
  8567. /**
  8568. * Sets the position the shadow will be casted from. Also use as the light position for both
  8569. * point and spot lights.
  8570. */
  8571. /**
  8572. * Sets the position the shadow will be casted from. Also use as the light position for both
  8573. * point and spot lights.
  8574. */
  8575. position: Vector3;
  8576. protected _direction: Vector3;
  8577. protected _setDirection(value: Vector3): void;
  8578. /**
  8579. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8580. * Also use as the light direction on spot and directional lights.
  8581. */
  8582. /**
  8583. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8584. * Also use as the light direction on spot and directional lights.
  8585. */
  8586. direction: Vector3;
  8587. private _shadowMinZ;
  8588. /**
  8589. * Gets the shadow projection clipping minimum z value.
  8590. */
  8591. /**
  8592. * Sets the shadow projection clipping minimum z value.
  8593. */
  8594. shadowMinZ: number;
  8595. private _shadowMaxZ;
  8596. /**
  8597. * Sets the shadow projection clipping maximum z value.
  8598. */
  8599. /**
  8600. * Gets the shadow projection clipping maximum z value.
  8601. */
  8602. shadowMaxZ: number;
  8603. /**
  8604. * Callback defining a custom Projection Matrix Builder.
  8605. * This can be used to override the default projection matrix computation.
  8606. */
  8607. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8608. /**
  8609. * The transformed position. Position of the light in world space taking parenting in account.
  8610. */
  8611. transformedPosition: Vector3;
  8612. /**
  8613. * The transformed direction. Direction of the light in world space taking parenting in account.
  8614. */
  8615. transformedDirection: Vector3;
  8616. private _needProjectionMatrixCompute;
  8617. /**
  8618. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8619. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8620. */
  8621. computeTransformedInformation(): boolean;
  8622. /**
  8623. * Return the depth scale used for the shadow map.
  8624. * @returns the depth scale.
  8625. */
  8626. getDepthScale(): number;
  8627. /**
  8628. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8629. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8630. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8631. */
  8632. getShadowDirection(faceIndex?: number): Vector3;
  8633. /**
  8634. * Returns the ShadowLight absolute position in the World.
  8635. * @returns the position vector in world space
  8636. */
  8637. getAbsolutePosition(): Vector3;
  8638. /**
  8639. * Sets the ShadowLight direction toward the passed target.
  8640. * @param target The point to target in local space
  8641. * @returns the updated ShadowLight direction
  8642. */
  8643. setDirectionToTarget(target: Vector3): Vector3;
  8644. /**
  8645. * Returns the light rotation in euler definition.
  8646. * @returns the x y z rotation in local space.
  8647. */
  8648. getRotation(): Vector3;
  8649. /**
  8650. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8651. * @returns true if a cube texture needs to be use
  8652. */
  8653. needCube(): boolean;
  8654. /**
  8655. * Detects if the projection matrix requires to be recomputed this frame.
  8656. * @returns true if it requires to be recomputed otherwise, false.
  8657. */
  8658. needProjectionMatrixCompute(): boolean;
  8659. /**
  8660. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8661. */
  8662. forceProjectionMatrixCompute(): void;
  8663. /** @hidden */ private _initCache(): void;
  8664. /** @hidden */ private _isSynchronized(): boolean;
  8665. /**
  8666. * Computes the world matrix of the node
  8667. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8668. * @returns the world matrix
  8669. */
  8670. computeWorldMatrix(force?: boolean): Matrix;
  8671. /**
  8672. * Gets the minZ used for shadow according to both the scene and the light.
  8673. * @param activeCamera The camera we are returning the min for
  8674. * @returns the depth min z
  8675. */
  8676. getDepthMinZ(activeCamera: Camera): number;
  8677. /**
  8678. * Gets the maxZ used for shadow according to both the scene and the light.
  8679. * @param activeCamera The camera we are returning the max for
  8680. * @returns the depth max z
  8681. */
  8682. getDepthMaxZ(activeCamera: Camera): number;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. }
  8692. }
  8693. declare module BABYLON {
  8694. /**
  8695. * "Static Class" containing the most commonly used helper while dealing with material for
  8696. * rendering purpose.
  8697. *
  8698. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8699. *
  8700. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8701. */
  8702. export class MaterialHelper {
  8703. /**
  8704. * Bind the current view position to an effect.
  8705. * @param effect The effect to be bound
  8706. * @param scene The scene the eyes position is used from
  8707. */
  8708. static BindEyePosition(effect: Effect, scene: Scene): void;
  8709. /**
  8710. * Helps preparing the defines values about the UVs in used in the effect.
  8711. * UVs are shared as much as we can accross channels in the shaders.
  8712. * @param texture The texture we are preparing the UVs for
  8713. * @param defines The defines to update
  8714. * @param key The channel key "diffuse", "specular"... used in the shader
  8715. */
  8716. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8717. /**
  8718. * Binds a texture matrix value to its corrsponding uniform
  8719. * @param texture The texture to bind the matrix for
  8720. * @param uniformBuffer The uniform buffer receivin the data
  8721. * @param key The channel key "diffuse", "specular"... used in the shader
  8722. */
  8723. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8724. /**
  8725. * Gets the current status of the fog (should it be enabled?)
  8726. * @param mesh defines the mesh to evaluate for fog support
  8727. * @param scene defines the hosting scene
  8728. * @returns true if fog must be enabled
  8729. */
  8730. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8731. /**
  8732. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8733. * @param mesh defines the current mesh
  8734. * @param scene defines the current scene
  8735. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8736. * @param pointsCloud defines if point cloud rendering has to be turned on
  8737. * @param fogEnabled defines if fog has to be turned on
  8738. * @param alphaTest defines if alpha testing has to be turned on
  8739. * @param defines defines the current list of defines
  8740. */
  8741. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8742. /**
  8743. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8744. * @param scene defines the current scene
  8745. * @param engine defines the current engine
  8746. * @param defines specifies the list of active defines
  8747. * @param useInstances defines if instances have to be turned on
  8748. * @param useClipPlane defines if clip plane have to be turned on
  8749. */
  8750. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8751. /**
  8752. * Prepares the defines for bones
  8753. * @param mesh The mesh containing the geometry data we will draw
  8754. * @param defines The defines to update
  8755. */
  8756. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8757. /**
  8758. * Prepares the defines for morph targets
  8759. * @param mesh The mesh containing the geometry data we will draw
  8760. * @param defines The defines to update
  8761. */
  8762. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8763. /**
  8764. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8765. * @param mesh The mesh containing the geometry data we will draw
  8766. * @param defines The defines to update
  8767. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8768. * @param useBones Precise whether bones should be used or not (override mesh info)
  8769. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8770. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8771. * @returns false if defines are considered not dirty and have not been checked
  8772. */
  8773. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8774. /**
  8775. * Prepares the defines related to multiview
  8776. * @param scene The scene we are intending to draw
  8777. * @param defines The defines to update
  8778. */
  8779. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8780. /**
  8781. * Prepares the defines related to the light information passed in parameter
  8782. * @param scene The scene we are intending to draw
  8783. * @param mesh The mesh the effect is compiling for
  8784. * @param light The light the effect is compiling for
  8785. * @param lightIndex The index of the light
  8786. * @param defines The defines to update
  8787. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8788. * @param state Defines the current state regarding what is needed (normals, etc...)
  8789. */
  8790. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8791. needNormals: boolean;
  8792. needRebuild: boolean;
  8793. shadowEnabled: boolean;
  8794. specularEnabled: boolean;
  8795. lightmapMode: boolean;
  8796. }): void;
  8797. /**
  8798. * Prepares the defines related to the light information passed in parameter
  8799. * @param scene The scene we are intending to draw
  8800. * @param mesh The mesh the effect is compiling for
  8801. * @param defines The defines to update
  8802. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8803. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8804. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8805. * @returns true if normals will be required for the rest of the effect
  8806. */
  8807. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8808. /**
  8809. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8810. * @param lightIndex defines the light index
  8811. * @param uniformsList The uniform list
  8812. * @param samplersList The sampler list
  8813. * @param projectedLightTexture defines if projected texture must be used
  8814. * @param uniformBuffersList defines an optional list of uniform buffers
  8815. */
  8816. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8817. /**
  8818. * Prepares the uniforms and samplers list to be used in the effect
  8819. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8820. * @param samplersList The sampler list
  8821. * @param defines The defines helping in the list generation
  8822. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8823. */
  8824. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8825. /**
  8826. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8827. * @param defines The defines to update while falling back
  8828. * @param fallbacks The authorized effect fallbacks
  8829. * @param maxSimultaneousLights The maximum number of lights allowed
  8830. * @param rank the current rank of the Effect
  8831. * @returns The newly affected rank
  8832. */
  8833. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8834. private static _TmpMorphInfluencers;
  8835. /**
  8836. * Prepares the list of attributes required for morph targets according to the effect defines.
  8837. * @param attribs The current list of supported attribs
  8838. * @param mesh The mesh to prepare the morph targets attributes for
  8839. * @param influencers The number of influencers
  8840. */
  8841. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8842. /**
  8843. * Prepares the list of attributes required for morph targets according to the effect defines.
  8844. * @param attribs The current list of supported attribs
  8845. * @param mesh The mesh to prepare the morph targets attributes for
  8846. * @param defines The current Defines of the effect
  8847. */
  8848. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8849. /**
  8850. * Prepares the list of attributes required for bones according to the effect defines.
  8851. * @param attribs The current list of supported attribs
  8852. * @param mesh The mesh to prepare the bones attributes for
  8853. * @param defines The current Defines of the effect
  8854. * @param fallbacks The current efffect fallback strategy
  8855. */
  8856. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8857. /**
  8858. * Check and prepare the list of attributes required for instances according to the effect defines.
  8859. * @param attribs The current list of supported attribs
  8860. * @param defines The current MaterialDefines of the effect
  8861. */
  8862. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8863. /**
  8864. * Add the list of attributes required for instances to the attribs array.
  8865. * @param attribs The current list of supported attribs
  8866. */
  8867. static PushAttributesForInstances(attribs: string[]): void;
  8868. /**
  8869. * Binds the light shadow information to the effect for the given mesh.
  8870. * @param light The light containing the generator
  8871. * @param scene The scene the lights belongs to
  8872. * @param mesh The mesh we are binding the information to render
  8873. * @param lightIndex The light index in the effect used to render the mesh
  8874. * @param effect The effect we are binding the data to
  8875. */
  8876. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8877. /**
  8878. * Binds the light information to the effect.
  8879. * @param light The light containing the generator
  8880. * @param effect The effect we are binding the data to
  8881. * @param lightIndex The light index in the effect used to render
  8882. */
  8883. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8884. /**
  8885. * Binds the lights information from the scene to the effect for the given mesh.
  8886. * @param light Light to bind
  8887. * @param lightIndex Light index
  8888. * @param scene The scene where the light belongs to
  8889. * @param mesh The mesh we are binding the information to render
  8890. * @param effect The effect we are binding the data to
  8891. * @param useSpecular Defines if specular is supported
  8892. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8893. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8894. */
  8895. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8896. /**
  8897. * Binds the lights information from the scene to the effect for the given mesh.
  8898. * @param scene The scene the lights belongs to
  8899. * @param mesh The mesh we are binding the information to render
  8900. * @param effect The effect we are binding the data to
  8901. * @param defines The generated defines for the effect
  8902. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8903. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8904. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8905. */
  8906. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8907. private static _tempFogColor;
  8908. /**
  8909. * Binds the fog information from the scene to the effect for the given mesh.
  8910. * @param scene The scene the lights belongs to
  8911. * @param mesh The mesh we are binding the information to render
  8912. * @param effect The effect we are binding the data to
  8913. * @param linearSpace Defines if the fog effect is applied in linear space
  8914. */
  8915. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8916. /**
  8917. * Binds the bones information from the mesh to the effect.
  8918. * @param mesh The mesh we are binding the information to render
  8919. * @param effect The effect we are binding the data to
  8920. */
  8921. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8922. /**
  8923. * Binds the morph targets information from the mesh to the effect.
  8924. * @param abstractMesh The mesh we are binding the information to render
  8925. * @param effect The effect we are binding the data to
  8926. */
  8927. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8928. /**
  8929. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8930. * @param defines The generated defines used in the effect
  8931. * @param effect The effect we are binding the data to
  8932. * @param scene The scene we are willing to render with logarithmic scale for
  8933. */
  8934. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8935. /**
  8936. * Binds the clip plane information from the scene to the effect.
  8937. * @param scene The scene the clip plane information are extracted from
  8938. * @param effect The effect we are binding the data to
  8939. */
  8940. static BindClipPlane(effect: Effect, scene: Scene): void;
  8941. }
  8942. }
  8943. declare module BABYLON {
  8944. /** @hidden */
  8945. export var packingFunctions: {
  8946. name: string;
  8947. shader: string;
  8948. };
  8949. }
  8950. declare module BABYLON {
  8951. /** @hidden */
  8952. export var shadowMapPixelShader: {
  8953. name: string;
  8954. shader: string;
  8955. };
  8956. }
  8957. declare module BABYLON {
  8958. /** @hidden */
  8959. export var bonesDeclaration: {
  8960. name: string;
  8961. shader: string;
  8962. };
  8963. }
  8964. declare module BABYLON {
  8965. /** @hidden */
  8966. export var morphTargetsVertexGlobalDeclaration: {
  8967. name: string;
  8968. shader: string;
  8969. };
  8970. }
  8971. declare module BABYLON {
  8972. /** @hidden */
  8973. export var morphTargetsVertexDeclaration: {
  8974. name: string;
  8975. shader: string;
  8976. };
  8977. }
  8978. declare module BABYLON {
  8979. /** @hidden */
  8980. export var instancesDeclaration: {
  8981. name: string;
  8982. shader: string;
  8983. };
  8984. }
  8985. declare module BABYLON {
  8986. /** @hidden */
  8987. export var helperFunctions: {
  8988. name: string;
  8989. shader: string;
  8990. };
  8991. }
  8992. declare module BABYLON {
  8993. /** @hidden */
  8994. export var morphTargetsVertex: {
  8995. name: string;
  8996. shader: string;
  8997. };
  8998. }
  8999. declare module BABYLON {
  9000. /** @hidden */
  9001. export var instancesVertex: {
  9002. name: string;
  9003. shader: string;
  9004. };
  9005. }
  9006. declare module BABYLON {
  9007. /** @hidden */
  9008. export var bonesVertex: {
  9009. name: string;
  9010. shader: string;
  9011. };
  9012. }
  9013. declare module BABYLON {
  9014. /** @hidden */
  9015. export var shadowMapVertexShader: {
  9016. name: string;
  9017. shader: string;
  9018. };
  9019. }
  9020. declare module BABYLON {
  9021. /** @hidden */
  9022. export var depthBoxBlurPixelShader: {
  9023. name: string;
  9024. shader: string;
  9025. };
  9026. }
  9027. declare module BABYLON {
  9028. /**
  9029. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9030. */
  9031. export interface ICustomShaderOptions {
  9032. /**
  9033. * Gets or sets the custom shader name to use
  9034. */
  9035. shaderName: string;
  9036. /**
  9037. * The list of attribute names used in the shader
  9038. */
  9039. attributes?: string[];
  9040. /**
  9041. * The list of unifrom names used in the shader
  9042. */
  9043. uniforms?: string[];
  9044. /**
  9045. * The list of sampler names used in the shader
  9046. */
  9047. samplers?: string[];
  9048. /**
  9049. * The list of defines used in the shader
  9050. */
  9051. defines?: string[];
  9052. }
  9053. /**
  9054. * Interface to implement to create a shadow generator compatible with BJS.
  9055. */
  9056. export interface IShadowGenerator {
  9057. /**
  9058. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9059. * @returns The render target texture if present otherwise, null
  9060. */
  9061. getShadowMap(): Nullable<RenderTargetTexture>;
  9062. /**
  9063. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9064. * @returns The render target texture if the shadow map is present otherwise, null
  9065. */
  9066. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9067. /**
  9068. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9069. * @param subMesh The submesh we want to render in the shadow map
  9070. * @param useInstances Defines wether will draw in the map using instances
  9071. * @returns true if ready otherwise, false
  9072. */
  9073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9074. /**
  9075. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9076. * @param defines Defines of the material we want to update
  9077. * @param lightIndex Index of the light in the enabled light list of the material
  9078. */
  9079. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9080. /**
  9081. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9082. * defined in the generator but impacting the effect).
  9083. * It implies the unifroms available on the materials are the standard BJS ones.
  9084. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9085. * @param effect The effect we are binfing the information for
  9086. */
  9087. bindShadowLight(lightIndex: string, effect: Effect): void;
  9088. /**
  9089. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9090. * (eq to shadow prjection matrix * light transform matrix)
  9091. * @returns The transform matrix used to create the shadow map
  9092. */
  9093. getTransformMatrix(): Matrix;
  9094. /**
  9095. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9096. * Cube and 2D textures for instance.
  9097. */
  9098. recreateShadowMap(): void;
  9099. /**
  9100. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9101. * @param onCompiled Callback triggered at the and of the effects compilation
  9102. * @param options Sets of optional options forcing the compilation with different modes
  9103. */
  9104. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9105. useInstances: boolean;
  9106. }>): void;
  9107. /**
  9108. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9109. * @param options Sets of optional options forcing the compilation with different modes
  9110. * @returns A promise that resolves when the compilation completes
  9111. */
  9112. forceCompilationAsync(options?: Partial<{
  9113. useInstances: boolean;
  9114. }>): Promise<void>;
  9115. /**
  9116. * Serializes the shadow generator setup to a json object.
  9117. * @returns The serialized JSON object
  9118. */
  9119. serialize(): any;
  9120. /**
  9121. * Disposes the Shadow map and related Textures and effects.
  9122. */
  9123. dispose(): void;
  9124. }
  9125. /**
  9126. * Default implementation IShadowGenerator.
  9127. * This is the main object responsible of generating shadows in the framework.
  9128. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9129. */
  9130. export class ShadowGenerator implements IShadowGenerator {
  9131. /**
  9132. * Shadow generator mode None: no filtering applied.
  9133. */
  9134. static readonly FILTER_NONE: number;
  9135. /**
  9136. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9137. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9138. */
  9139. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9140. /**
  9141. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9142. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9143. */
  9144. static readonly FILTER_POISSONSAMPLING: number;
  9145. /**
  9146. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9147. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9148. */
  9149. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9150. /**
  9151. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9152. * edge artifacts on steep falloff.
  9153. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9154. */
  9155. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9156. /**
  9157. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9158. * edge artifacts on steep falloff.
  9159. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9160. */
  9161. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9162. /**
  9163. * Shadow generator mode PCF: Percentage Closer Filtering
  9164. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9165. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9166. */
  9167. static readonly FILTER_PCF: number;
  9168. /**
  9169. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9170. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9171. * Contact Hardening
  9172. */
  9173. static readonly FILTER_PCSS: number;
  9174. /**
  9175. * Reserved for PCF and PCSS
  9176. * Highest Quality.
  9177. *
  9178. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9179. *
  9180. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9181. */
  9182. static readonly QUALITY_HIGH: number;
  9183. /**
  9184. * Reserved for PCF and PCSS
  9185. * Good tradeoff for quality/perf cross devices
  9186. *
  9187. * Execute PCF on a 3*3 kernel.
  9188. *
  9189. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9190. */
  9191. static readonly QUALITY_MEDIUM: number;
  9192. /**
  9193. * Reserved for PCF and PCSS
  9194. * The lowest quality but the fastest.
  9195. *
  9196. * Execute PCF on a 1*1 kernel.
  9197. *
  9198. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9199. */
  9200. static readonly QUALITY_LOW: number;
  9201. /** Gets or sets the custom shader name to use */
  9202. customShaderOptions: ICustomShaderOptions;
  9203. /**
  9204. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9205. */
  9206. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9207. /**
  9208. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9209. */
  9210. onAfterShadowMapRenderObservable: Observable<Effect>;
  9211. /**
  9212. * Observable triggered before a mesh is rendered in the shadow map.
  9213. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9214. */
  9215. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9216. /**
  9217. * Observable triggered after a mesh is rendered in the shadow map.
  9218. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9219. */
  9220. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9221. private _bias;
  9222. /**
  9223. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9224. */
  9225. /**
  9226. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9227. */
  9228. bias: number;
  9229. private _normalBias;
  9230. /**
  9231. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9232. */
  9233. /**
  9234. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9235. */
  9236. normalBias: number;
  9237. private _blurBoxOffset;
  9238. /**
  9239. * Gets the blur box offset: offset applied during the blur pass.
  9240. * Only useful if useKernelBlur = false
  9241. */
  9242. /**
  9243. * Sets the blur box offset: offset applied during the blur pass.
  9244. * Only useful if useKernelBlur = false
  9245. */
  9246. blurBoxOffset: number;
  9247. private _blurScale;
  9248. /**
  9249. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9250. * 2 means half of the size.
  9251. */
  9252. /**
  9253. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9254. * 2 means half of the size.
  9255. */
  9256. blurScale: number;
  9257. private _blurKernel;
  9258. /**
  9259. * Gets the blur kernel: kernel size of the blur pass.
  9260. * Only useful if useKernelBlur = true
  9261. */
  9262. /**
  9263. * Sets the blur kernel: kernel size of the blur pass.
  9264. * Only useful if useKernelBlur = true
  9265. */
  9266. blurKernel: number;
  9267. private _useKernelBlur;
  9268. /**
  9269. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9270. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9271. */
  9272. /**
  9273. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9274. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9275. */
  9276. useKernelBlur: boolean;
  9277. private _depthScale;
  9278. /**
  9279. * Gets the depth scale used in ESM mode.
  9280. */
  9281. /**
  9282. * Sets the depth scale used in ESM mode.
  9283. * This can override the scale stored on the light.
  9284. */
  9285. depthScale: number;
  9286. private _filter;
  9287. /**
  9288. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9289. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9290. */
  9291. /**
  9292. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9293. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9294. */
  9295. filter: number;
  9296. /**
  9297. * Gets if the current filter is set to Poisson Sampling.
  9298. */
  9299. /**
  9300. * Sets the current filter to Poisson Sampling.
  9301. */
  9302. usePoissonSampling: boolean;
  9303. /**
  9304. * Gets if the current filter is set to ESM.
  9305. */
  9306. /**
  9307. * Sets the current filter is to ESM.
  9308. */
  9309. useExponentialShadowMap: boolean;
  9310. /**
  9311. * Gets if the current filter is set to filtered ESM.
  9312. */
  9313. /**
  9314. * Gets if the current filter is set to filtered ESM.
  9315. */
  9316. useBlurExponentialShadowMap: boolean;
  9317. /**
  9318. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9319. * exponential to prevent steep falloff artifacts).
  9320. */
  9321. /**
  9322. * Sets the current filter to "close ESM" (using the inverse of the
  9323. * exponential to prevent steep falloff artifacts).
  9324. */
  9325. useCloseExponentialShadowMap: boolean;
  9326. /**
  9327. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9328. * exponential to prevent steep falloff artifacts).
  9329. */
  9330. /**
  9331. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9332. * exponential to prevent steep falloff artifacts).
  9333. */
  9334. useBlurCloseExponentialShadowMap: boolean;
  9335. /**
  9336. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9337. */
  9338. /**
  9339. * Sets the current filter to "PCF" (percentage closer filtering).
  9340. */
  9341. usePercentageCloserFiltering: boolean;
  9342. private _filteringQuality;
  9343. /**
  9344. * Gets the PCF or PCSS Quality.
  9345. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9346. */
  9347. /**
  9348. * Sets the PCF or PCSS Quality.
  9349. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9350. */
  9351. filteringQuality: number;
  9352. /**
  9353. * Gets if the current filter is set to "PCSS" (contact hardening).
  9354. */
  9355. /**
  9356. * Sets the current filter to "PCSS" (contact hardening).
  9357. */
  9358. useContactHardeningShadow: boolean;
  9359. private _contactHardeningLightSizeUVRatio;
  9360. /**
  9361. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9362. * Using a ratio helps keeping shape stability independently of the map size.
  9363. *
  9364. * It does not account for the light projection as it was having too much
  9365. * instability during the light setup or during light position changes.
  9366. *
  9367. * Only valid if useContactHardeningShadow is true.
  9368. */
  9369. /**
  9370. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9371. * Using a ratio helps keeping shape stability independently of the map size.
  9372. *
  9373. * It does not account for the light projection as it was having too much
  9374. * instability during the light setup or during light position changes.
  9375. *
  9376. * Only valid if useContactHardeningShadow is true.
  9377. */
  9378. contactHardeningLightSizeUVRatio: number;
  9379. private _darkness;
  9380. /** Gets or sets the actual darkness of a shadow */
  9381. darkness: number;
  9382. /**
  9383. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9384. * 0 means strongest and 1 would means no shadow.
  9385. * @returns the darkness.
  9386. */
  9387. getDarkness(): number;
  9388. /**
  9389. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9390. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9391. * @returns the shadow generator allowing fluent coding.
  9392. */
  9393. setDarkness(darkness: number): ShadowGenerator;
  9394. private _transparencyShadow;
  9395. /** Gets or sets the ability to have transparent shadow */
  9396. transparencyShadow: boolean;
  9397. /**
  9398. * Sets the ability to have transparent shadow (boolean).
  9399. * @param transparent True if transparent else False
  9400. * @returns the shadow generator allowing fluent coding
  9401. */
  9402. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9403. private _shadowMap;
  9404. private _shadowMap2;
  9405. /**
  9406. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9407. * @returns The render target texture if present otherwise, null
  9408. */
  9409. getShadowMap(): Nullable<RenderTargetTexture>;
  9410. /**
  9411. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9412. * @returns The render target texture if the shadow map is present otherwise, null
  9413. */
  9414. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9415. /**
  9416. * Gets the class name of that object
  9417. * @returns "ShadowGenerator"
  9418. */
  9419. getClassName(): string;
  9420. /**
  9421. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9422. * @param mesh Mesh to add
  9423. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9424. * @returns the Shadow Generator itself
  9425. */
  9426. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9427. /**
  9428. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9429. * @param mesh Mesh to remove
  9430. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9431. * @returns the Shadow Generator itself
  9432. */
  9433. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9434. /**
  9435. * Controls the extent to which the shadows fade out at the edge of the frustum
  9436. * Used only by directionals and spots
  9437. */
  9438. frustumEdgeFalloff: number;
  9439. private _light;
  9440. /**
  9441. * Returns the associated light object.
  9442. * @returns the light generating the shadow
  9443. */
  9444. getLight(): IShadowLight;
  9445. /**
  9446. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9447. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9448. * It might on the other hand introduce peter panning.
  9449. */
  9450. forceBackFacesOnly: boolean;
  9451. private _scene;
  9452. private _lightDirection;
  9453. private _effect;
  9454. private _viewMatrix;
  9455. private _projectionMatrix;
  9456. private _transformMatrix;
  9457. private _cachedPosition;
  9458. private _cachedDirection;
  9459. private _cachedDefines;
  9460. private _currentRenderID;
  9461. private _boxBlurPostprocess;
  9462. private _kernelBlurXPostprocess;
  9463. private _kernelBlurYPostprocess;
  9464. private _blurPostProcesses;
  9465. private _mapSize;
  9466. private _currentFaceIndex;
  9467. private _currentFaceIndexCache;
  9468. private _textureType;
  9469. private _defaultTextureMatrix;
  9470. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9471. /**
  9472. * Creates a ShadowGenerator object.
  9473. * A ShadowGenerator is the required tool to use the shadows.
  9474. * Each light casting shadows needs to use its own ShadowGenerator.
  9475. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9476. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9477. * @param light The light object generating the shadows.
  9478. * @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.
  9479. */
  9480. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9481. private _initializeGenerator;
  9482. private _initializeShadowMap;
  9483. private _initializeBlurRTTAndPostProcesses;
  9484. private _renderForShadowMap;
  9485. private _renderSubMeshForShadowMap;
  9486. private _applyFilterValues;
  9487. /**
  9488. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9489. * @param onCompiled Callback triggered at the and of the effects compilation
  9490. * @param options Sets of optional options forcing the compilation with different modes
  9491. */
  9492. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9493. useInstances: boolean;
  9494. }>): void;
  9495. /**
  9496. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9497. * @param options Sets of optional options forcing the compilation with different modes
  9498. * @returns A promise that resolves when the compilation completes
  9499. */
  9500. forceCompilationAsync(options?: Partial<{
  9501. useInstances: boolean;
  9502. }>): Promise<void>;
  9503. /**
  9504. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9505. * @param subMesh The submesh we want to render in the shadow map
  9506. * @param useInstances Defines wether will draw in the map using instances
  9507. * @returns true if ready otherwise, false
  9508. */
  9509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9510. /**
  9511. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9512. * @param defines Defines of the material we want to update
  9513. * @param lightIndex Index of the light in the enabled light list of the material
  9514. */
  9515. prepareDefines(defines: any, lightIndex: number): void;
  9516. /**
  9517. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9518. * defined in the generator but impacting the effect).
  9519. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9520. * @param effect The effect we are binfing the information for
  9521. */
  9522. bindShadowLight(lightIndex: string, effect: Effect): void;
  9523. /**
  9524. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9525. * (eq to shadow prjection matrix * light transform matrix)
  9526. * @returns The transform matrix used to create the shadow map
  9527. */
  9528. getTransformMatrix(): Matrix;
  9529. /**
  9530. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9531. * Cube and 2D textures for instance.
  9532. */
  9533. recreateShadowMap(): void;
  9534. private _disposeBlurPostProcesses;
  9535. private _disposeRTTandPostProcesses;
  9536. /**
  9537. * Disposes the ShadowGenerator.
  9538. * Returns nothing.
  9539. */
  9540. dispose(): void;
  9541. /**
  9542. * Serializes the shadow generator setup to a json object.
  9543. * @returns The serialized JSON object
  9544. */
  9545. serialize(): any;
  9546. /**
  9547. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9548. * @param parsedShadowGenerator The JSON object to parse
  9549. * @param scene The scene to create the shadow map for
  9550. * @returns The parsed shadow generator
  9551. */
  9552. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9553. }
  9554. }
  9555. declare module BABYLON {
  9556. /**
  9557. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9558. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9559. * 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.
  9560. */
  9561. export abstract class Light extends Node {
  9562. /**
  9563. * Falloff Default: light is falling off following the material specification:
  9564. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9565. */
  9566. static readonly FALLOFF_DEFAULT: number;
  9567. /**
  9568. * Falloff Physical: light is falling off following the inverse squared distance law.
  9569. */
  9570. static readonly FALLOFF_PHYSICAL: number;
  9571. /**
  9572. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9573. * to enhance interoperability with other engines.
  9574. */
  9575. static readonly FALLOFF_GLTF: number;
  9576. /**
  9577. * Falloff Standard: light is falling off like in the standard material
  9578. * to enhance interoperability with other materials.
  9579. */
  9580. static readonly FALLOFF_STANDARD: number;
  9581. /**
  9582. * If every light affecting the material is in this lightmapMode,
  9583. * material.lightmapTexture adds or multiplies
  9584. * (depends on material.useLightmapAsShadowmap)
  9585. * after every other light calculations.
  9586. */
  9587. static readonly LIGHTMAP_DEFAULT: number;
  9588. /**
  9589. * material.lightmapTexture as only diffuse lighting from this light
  9590. * adds only specular lighting from this light
  9591. * adds dynamic shadows
  9592. */
  9593. static readonly LIGHTMAP_SPECULAR: number;
  9594. /**
  9595. * material.lightmapTexture as only lighting
  9596. * no light calculation from this light
  9597. * only adds dynamic shadows from this light
  9598. */
  9599. static readonly LIGHTMAP_SHADOWSONLY: number;
  9600. /**
  9601. * Each light type uses the default quantity according to its type:
  9602. * point/spot lights use luminous intensity
  9603. * directional lights use illuminance
  9604. */
  9605. static readonly INTENSITYMODE_AUTOMATIC: number;
  9606. /**
  9607. * lumen (lm)
  9608. */
  9609. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9610. /**
  9611. * candela (lm/sr)
  9612. */
  9613. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9614. /**
  9615. * lux (lm/m^2)
  9616. */
  9617. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9618. /**
  9619. * nit (cd/m^2)
  9620. */
  9621. static readonly INTENSITYMODE_LUMINANCE: number;
  9622. /**
  9623. * Light type const id of the point light.
  9624. */
  9625. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9626. /**
  9627. * Light type const id of the directional light.
  9628. */
  9629. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9630. /**
  9631. * Light type const id of the spot light.
  9632. */
  9633. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9634. /**
  9635. * Light type const id of the hemispheric light.
  9636. */
  9637. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9638. /**
  9639. * Diffuse gives the basic color to an object.
  9640. */
  9641. diffuse: Color3;
  9642. /**
  9643. * Specular produces a highlight color on an object.
  9644. * Note: This is note affecting PBR materials.
  9645. */
  9646. specular: Color3;
  9647. /**
  9648. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9649. * falling off base on range or angle.
  9650. * This can be set to any values in Light.FALLOFF_x.
  9651. *
  9652. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9653. * other types of materials.
  9654. */
  9655. falloffType: number;
  9656. /**
  9657. * Strength of the light.
  9658. * Note: By default it is define in the framework own unit.
  9659. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9660. */
  9661. intensity: number;
  9662. private _range;
  9663. protected _inverseSquaredRange: number;
  9664. /**
  9665. * Defines how far from the source the light is impacting in scene units.
  9666. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9667. */
  9668. /**
  9669. * Defines how far from the source the light is impacting in scene units.
  9670. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9671. */
  9672. range: number;
  9673. /**
  9674. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9675. * of light.
  9676. */
  9677. private _photometricScale;
  9678. private _intensityMode;
  9679. /**
  9680. * Gets the photometric scale used to interpret the intensity.
  9681. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9682. */
  9683. /**
  9684. * Sets the photometric scale used to interpret the intensity.
  9685. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9686. */
  9687. intensityMode: number;
  9688. private _radius;
  9689. /**
  9690. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9691. */
  9692. /**
  9693. * sets the light radius used by PBR Materials to simulate soft area lights.
  9694. */
  9695. radius: number;
  9696. private _renderPriority;
  9697. /**
  9698. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9699. * exceeding the number allowed of the materials.
  9700. */
  9701. renderPriority: number;
  9702. private _shadowEnabled;
  9703. /**
  9704. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9705. * the current shadow generator.
  9706. */
  9707. /**
  9708. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9709. * the current shadow generator.
  9710. */
  9711. shadowEnabled: boolean;
  9712. private _includedOnlyMeshes;
  9713. /**
  9714. * Gets the only meshes impacted by this light.
  9715. */
  9716. /**
  9717. * Sets the only meshes impacted by this light.
  9718. */
  9719. includedOnlyMeshes: AbstractMesh[];
  9720. private _excludedMeshes;
  9721. /**
  9722. * Gets the meshes not impacted by this light.
  9723. */
  9724. /**
  9725. * Sets the meshes not impacted by this light.
  9726. */
  9727. excludedMeshes: AbstractMesh[];
  9728. private _excludeWithLayerMask;
  9729. /**
  9730. * Gets the layer id use to find what meshes are not impacted by the light.
  9731. * Inactive if 0
  9732. */
  9733. /**
  9734. * Sets the layer id use to find what meshes are not impacted by the light.
  9735. * Inactive if 0
  9736. */
  9737. excludeWithLayerMask: number;
  9738. private _includeOnlyWithLayerMask;
  9739. /**
  9740. * Gets the layer id use to find what meshes are impacted by the light.
  9741. * Inactive if 0
  9742. */
  9743. /**
  9744. * Sets the layer id use to find what meshes are impacted by the light.
  9745. * Inactive if 0
  9746. */
  9747. includeOnlyWithLayerMask: number;
  9748. private _lightmapMode;
  9749. /**
  9750. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9751. */
  9752. /**
  9753. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9754. */
  9755. lightmapMode: number;
  9756. /**
  9757. * Shadow generator associted to the light.
  9758. * @hidden Internal use only.
  9759. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9760. /**
  9761. * @hidden Internal use only.
  9762. */ private _excludedMeshesIds: string[];
  9763. /**
  9764. * @hidden Internal use only.
  9765. */ private _includedOnlyMeshesIds: string[];
  9766. /**
  9767. * The current light unifom buffer.
  9768. * @hidden Internal use only.
  9769. */ private _uniformBuffer: UniformBuffer;
  9770. /**
  9771. * Creates a Light object in the scene.
  9772. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9773. * @param name The firendly name of the light
  9774. * @param scene The scene the light belongs too
  9775. */
  9776. constructor(name: string, scene: Scene);
  9777. protected abstract _buildUniformLayout(): void;
  9778. /**
  9779. * Sets the passed Effect "effect" with the Light information.
  9780. * @param effect The effect to update
  9781. * @param lightIndex The index of the light in the effect to update
  9782. * @returns The light
  9783. */
  9784. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9785. /**
  9786. * Sets the passed Effect "effect" with the Light information.
  9787. * @param effect The effect to update
  9788. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9789. * @returns The light
  9790. */
  9791. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9792. /**
  9793. * Returns the string "Light".
  9794. * @returns the class name
  9795. */
  9796. getClassName(): string;
  9797. /** @hidden */ protected readonly _isLight: boolean;
  9798. /**
  9799. * Converts the light information to a readable string for debug purpose.
  9800. * @param fullDetails Supports for multiple levels of logging within scene loading
  9801. * @returns the human readable light info
  9802. */
  9803. toString(fullDetails?: boolean): string;
  9804. /** @hidden */
  9805. protected _syncParentEnabledState(): void;
  9806. /**
  9807. * Set the enabled state of this node.
  9808. * @param value - the new enabled state
  9809. */
  9810. setEnabled(value: boolean): void;
  9811. /**
  9812. * Returns the Light associated shadow generator if any.
  9813. * @return the associated shadow generator.
  9814. */
  9815. getShadowGenerator(): Nullable<IShadowGenerator>;
  9816. /**
  9817. * Returns a Vector3, the absolute light position in the World.
  9818. * @returns the world space position of the light
  9819. */
  9820. getAbsolutePosition(): Vector3;
  9821. /**
  9822. * Specifies if the light will affect the passed mesh.
  9823. * @param mesh The mesh to test against the light
  9824. * @return true the mesh is affected otherwise, false.
  9825. */
  9826. canAffectMesh(mesh: AbstractMesh): boolean;
  9827. /**
  9828. * Sort function to order lights for rendering.
  9829. * @param a First Light object to compare to second.
  9830. * @param b Second Light object to compare first.
  9831. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9832. */
  9833. static CompareLightsPriority(a: Light, b: Light): number;
  9834. /**
  9835. * Releases resources associated with this node.
  9836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9838. */
  9839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9840. /**
  9841. * Returns the light type ID (integer).
  9842. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9843. */
  9844. getTypeID(): number;
  9845. /**
  9846. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9847. * @returns the scaled intensity in intensity mode unit
  9848. */
  9849. getScaledIntensity(): number;
  9850. /**
  9851. * Returns a new Light object, named "name", from the current one.
  9852. * @param name The name of the cloned light
  9853. * @returns the new created light
  9854. */
  9855. clone(name: string): Nullable<Light>;
  9856. /**
  9857. * Serializes the current light into a Serialization object.
  9858. * @returns the serialized object.
  9859. */
  9860. serialize(): any;
  9861. /**
  9862. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9863. * This new light is named "name" and added to the passed scene.
  9864. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9865. * @param name The friendly name of the light
  9866. * @param scene The scene the new light will belong to
  9867. * @returns the constructor function
  9868. */
  9869. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9870. /**
  9871. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9872. * @param parsedLight The JSON representation of the light
  9873. * @param scene The scene to create the parsed light in
  9874. * @returns the created light after parsing
  9875. */
  9876. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9877. private _hookArrayForExcluded;
  9878. private _hookArrayForIncludedOnly;
  9879. private _resyncMeshes;
  9880. /**
  9881. * Forces the meshes to update their light related information in their rendering used effects
  9882. * @hidden Internal Use Only
  9883. */ private _markMeshesAsLightDirty(): void;
  9884. /**
  9885. * Recomputes the cached photometric scale if needed.
  9886. */
  9887. private _computePhotometricScale;
  9888. /**
  9889. * Returns the Photometric Scale according to the light type and intensity mode.
  9890. */
  9891. private _getPhotometricScale;
  9892. /**
  9893. * Reorder the light in the scene according to their defined priority.
  9894. * @hidden Internal Use Only
  9895. */ private _reorderLightsInScene(): void;
  9896. /**
  9897. * Prepares the list of defines specific to the light type.
  9898. * @param defines the list of defines
  9899. * @param lightIndex defines the index of the light for the effect
  9900. */
  9901. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9902. }
  9903. }
  9904. declare module BABYLON {
  9905. /**
  9906. * Interface used to define Action
  9907. */
  9908. export interface IAction {
  9909. /**
  9910. * Trigger for the action
  9911. */
  9912. trigger: number;
  9913. /** Options of the trigger */
  9914. triggerOptions: any;
  9915. /**
  9916. * Gets the trigger parameters
  9917. * @returns the trigger parameters
  9918. */
  9919. getTriggerParameter(): any;
  9920. /**
  9921. * Internal only - executes current action event
  9922. * @hidden
  9923. */ private _executeCurrent(evt?: ActionEvent): void;
  9924. /**
  9925. * Serialize placeholder for child classes
  9926. * @param parent of child
  9927. * @returns the serialized object
  9928. */
  9929. serialize(parent: any): any;
  9930. /**
  9931. * Internal only
  9932. * @hidden
  9933. */ private _prepare(): void;
  9934. /**
  9935. * Internal only - manager for action
  9936. * @hidden
  9937. */ private _actionManager: AbstractActionManager;
  9938. /**
  9939. * Adds action to chain of actions, may be a DoNothingAction
  9940. * @param action defines the next action to execute
  9941. * @returns The action passed in
  9942. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9943. */
  9944. then(action: IAction): IAction;
  9945. }
  9946. /**
  9947. * The action to be carried out following a trigger
  9948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9949. */
  9950. export class Action implements IAction {
  9951. /** the trigger, with or without parameters, for the action */
  9952. triggerOptions: any;
  9953. /**
  9954. * Trigger for the action
  9955. */
  9956. trigger: number;
  9957. /**
  9958. * Internal only - manager for action
  9959. * @hidden
  9960. */ private _actionManager: ActionManager;
  9961. private _nextActiveAction;
  9962. private _child;
  9963. private _condition?;
  9964. private _triggerParameter;
  9965. /**
  9966. * An event triggered prior to action being executed.
  9967. */
  9968. onBeforeExecuteObservable: Observable<Action>;
  9969. /**
  9970. * Creates a new Action
  9971. * @param triggerOptions the trigger, with or without parameters, for the action
  9972. * @param condition an optional determinant of action
  9973. */
  9974. constructor(
  9975. /** the trigger, with or without parameters, for the action */
  9976. triggerOptions: any, condition?: Condition);
  9977. /**
  9978. * Internal only
  9979. * @hidden
  9980. */ private _prepare(): void;
  9981. /**
  9982. * Gets the trigger parameters
  9983. * @returns the trigger parameters
  9984. */
  9985. getTriggerParameter(): any;
  9986. /**
  9987. * Internal only - executes current action event
  9988. * @hidden
  9989. */ private _executeCurrent(evt?: ActionEvent): void;
  9990. /**
  9991. * Execute placeholder for child classes
  9992. * @param evt optional action event
  9993. */
  9994. execute(evt?: ActionEvent): void;
  9995. /**
  9996. * Skips to next active action
  9997. */
  9998. skipToNextActiveAction(): void;
  9999. /**
  10000. * Adds action to chain of actions, may be a DoNothingAction
  10001. * @param action defines the next action to execute
  10002. * @returns The action passed in
  10003. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10004. */
  10005. then(action: Action): Action;
  10006. /**
  10007. * Internal only
  10008. * @hidden
  10009. */ private _getProperty(propertyPath: string): string;
  10010. /**
  10011. * Internal only
  10012. * @hidden
  10013. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10014. /**
  10015. * Serialize placeholder for child classes
  10016. * @param parent of child
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. /**
  10021. * Internal only called by serialize
  10022. * @hidden
  10023. */
  10024. protected _serialize(serializedAction: any, parent?: any): any;
  10025. /**
  10026. * Internal only
  10027. * @hidden
  10028. */ private static _SerializeValueAsString: (value: any) => string;
  10029. /**
  10030. * Internal only
  10031. * @hidden
  10032. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10033. name: string;
  10034. targetType: string;
  10035. value: string;
  10036. };
  10037. }
  10038. }
  10039. declare module BABYLON {
  10040. /**
  10041. * A Condition applied to an Action
  10042. */
  10043. export class Condition {
  10044. /**
  10045. * Internal only - manager for action
  10046. * @hidden
  10047. */ private _actionManager: ActionManager;
  10048. /**
  10049. * Internal only
  10050. * @hidden
  10051. */ private _evaluationId: number;
  10052. /**
  10053. * Internal only
  10054. * @hidden
  10055. */ private _currentResult: boolean;
  10056. /**
  10057. * Creates a new Condition
  10058. * @param actionManager the manager of the action the condition is applied to
  10059. */
  10060. constructor(actionManager: ActionManager);
  10061. /**
  10062. * Check if the current condition is valid
  10063. * @returns a boolean
  10064. */
  10065. isValid(): boolean;
  10066. /**
  10067. * Internal only
  10068. * @hidden
  10069. */ private _getProperty(propertyPath: string): string;
  10070. /**
  10071. * Internal only
  10072. * @hidden
  10073. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10074. /**
  10075. * Serialize placeholder for child classes
  10076. * @returns the serialized object
  10077. */
  10078. serialize(): any;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. protected _serialize(serializedCondition: any): any;
  10084. }
  10085. /**
  10086. * Defines specific conditional operators as extensions of Condition
  10087. */
  10088. export class ValueCondition extends Condition {
  10089. /** path to specify the property of the target the conditional operator uses */
  10090. propertyPath: string;
  10091. /** the value compared by the conditional operator against the current value of the property */
  10092. value: any;
  10093. /** the conditional operator, default ValueCondition.IsEqual */
  10094. operator: number;
  10095. /**
  10096. * Internal only
  10097. * @hidden
  10098. */
  10099. private static _IsEqual;
  10100. /**
  10101. * Internal only
  10102. * @hidden
  10103. */
  10104. private static _IsDifferent;
  10105. /**
  10106. * Internal only
  10107. * @hidden
  10108. */
  10109. private static _IsGreater;
  10110. /**
  10111. * Internal only
  10112. * @hidden
  10113. */
  10114. private static _IsLesser;
  10115. /**
  10116. * returns the number for IsEqual
  10117. */
  10118. static readonly IsEqual: number;
  10119. /**
  10120. * Returns the number for IsDifferent
  10121. */
  10122. static readonly IsDifferent: number;
  10123. /**
  10124. * Returns the number for IsGreater
  10125. */
  10126. static readonly IsGreater: number;
  10127. /**
  10128. * Returns the number for IsLesser
  10129. */
  10130. static readonly IsLesser: number;
  10131. /**
  10132. * Internal only The action manager for the condition
  10133. * @hidden
  10134. */ private _actionManager: ActionManager;
  10135. /**
  10136. * Internal only
  10137. * @hidden
  10138. */
  10139. private _target;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. private _effectiveTarget;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. private _property;
  10150. /**
  10151. * Creates a new ValueCondition
  10152. * @param actionManager manager for the action the condition applies to
  10153. * @param target for the action
  10154. * @param propertyPath path to specify the property of the target the conditional operator uses
  10155. * @param value the value compared by the conditional operator against the current value of the property
  10156. * @param operator the conditional operator, default ValueCondition.IsEqual
  10157. */
  10158. constructor(actionManager: ActionManager, target: any,
  10159. /** path to specify the property of the target the conditional operator uses */
  10160. propertyPath: string,
  10161. /** the value compared by the conditional operator against the current value of the property */
  10162. value: any,
  10163. /** the conditional operator, default ValueCondition.IsEqual */
  10164. operator?: number);
  10165. /**
  10166. * Compares the given value with the property value for the specified conditional operator
  10167. * @returns the result of the comparison
  10168. */
  10169. isValid(): boolean;
  10170. /**
  10171. * Serialize the ValueCondition into a JSON compatible object
  10172. * @returns serialization object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Gets the name of the conditional operator for the ValueCondition
  10177. * @param operator the conditional operator
  10178. * @returns the name
  10179. */
  10180. static GetOperatorName(operator: number): string;
  10181. }
  10182. /**
  10183. * Defines a predicate condition as an extension of Condition
  10184. */
  10185. export class PredicateCondition extends Condition {
  10186. /** defines the predicate function used to validate the condition */
  10187. predicate: () => boolean;
  10188. /**
  10189. * Internal only - manager for action
  10190. * @hidden
  10191. */ private _actionManager: ActionManager;
  10192. /**
  10193. * Creates a new PredicateCondition
  10194. * @param actionManager manager for the action the condition applies to
  10195. * @param predicate defines the predicate function used to validate the condition
  10196. */
  10197. constructor(actionManager: ActionManager,
  10198. /** defines the predicate function used to validate the condition */
  10199. predicate: () => boolean);
  10200. /**
  10201. * @returns the validity of the predicate condition
  10202. */
  10203. isValid(): boolean;
  10204. }
  10205. /**
  10206. * Defines a state condition as an extension of Condition
  10207. */
  10208. export class StateCondition extends Condition {
  10209. /** Value to compare with target state */
  10210. value: string;
  10211. /**
  10212. * Internal only - manager for action
  10213. * @hidden
  10214. */ private _actionManager: ActionManager;
  10215. /**
  10216. * Internal only
  10217. * @hidden
  10218. */
  10219. private _target;
  10220. /**
  10221. * Creates a new StateCondition
  10222. * @param actionManager manager for the action the condition applies to
  10223. * @param target of the condition
  10224. * @param value to compare with target state
  10225. */
  10226. constructor(actionManager: ActionManager, target: any,
  10227. /** Value to compare with target state */
  10228. value: string);
  10229. /**
  10230. * Gets a boolean indicating if the current condition is met
  10231. * @returns the validity of the state
  10232. */
  10233. isValid(): boolean;
  10234. /**
  10235. * Serialize the StateCondition into a JSON compatible object
  10236. * @returns serialization object
  10237. */
  10238. serialize(): any;
  10239. }
  10240. }
  10241. declare module BABYLON {
  10242. /**
  10243. * This defines an action responsible to toggle a boolean once triggered.
  10244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10245. */
  10246. export class SwitchBooleanAction extends Action {
  10247. /**
  10248. * The path to the boolean property in the target object
  10249. */
  10250. propertyPath: string;
  10251. private _target;
  10252. private _effectiveTarget;
  10253. private _property;
  10254. /**
  10255. * Instantiate the action
  10256. * @param triggerOptions defines the trigger options
  10257. * @param target defines the object containing the boolean
  10258. * @param propertyPath defines the path to the boolean property in the target object
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10262. /** @hidden */ private _prepare(): void;
  10263. /**
  10264. * Execute the action toggle the boolean value.
  10265. */
  10266. execute(): void;
  10267. /**
  10268. * Serializes the actions and its related information.
  10269. * @param parent defines the object to serialize in
  10270. * @returns the serialized object
  10271. */
  10272. serialize(parent: any): any;
  10273. }
  10274. /**
  10275. * This defines an action responsible to set a the state field of the target
  10276. * to a desired value once triggered.
  10277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10278. */
  10279. export class SetStateAction extends Action {
  10280. /**
  10281. * The value to store in the state field.
  10282. */
  10283. value: string;
  10284. private _target;
  10285. /**
  10286. * Instantiate the action
  10287. * @param triggerOptions defines the trigger options
  10288. * @param target defines the object containing the state property
  10289. * @param value defines the value to store in the state field
  10290. * @param condition defines the trigger related conditions
  10291. */
  10292. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10293. /**
  10294. * Execute the action and store the value on the target state property.
  10295. */
  10296. execute(): void;
  10297. /**
  10298. * Serializes the actions and its related information.
  10299. * @param parent defines the object to serialize in
  10300. * @returns the serialized object
  10301. */
  10302. serialize(parent: any): any;
  10303. }
  10304. /**
  10305. * This defines an action responsible to set a property of the target
  10306. * to a desired value once triggered.
  10307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10308. */
  10309. export class SetValueAction extends Action {
  10310. /**
  10311. * The path of the property to set in the target.
  10312. */
  10313. propertyPath: string;
  10314. /**
  10315. * The value to set in the property
  10316. */
  10317. value: any;
  10318. private _target;
  10319. private _effectiveTarget;
  10320. private _property;
  10321. /**
  10322. * Instantiate the action
  10323. * @param triggerOptions defines the trigger options
  10324. * @param target defines the object containing the property
  10325. * @param propertyPath defines the path of the property to set in the target
  10326. * @param value defines the value to set in the property
  10327. * @param condition defines the trigger related conditions
  10328. */
  10329. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10330. /** @hidden */ private _prepare(): void;
  10331. /**
  10332. * Execute the action and set the targetted property to the desired value.
  10333. */
  10334. execute(): void;
  10335. /**
  10336. * Serializes the actions and its related information.
  10337. * @param parent defines the object to serialize in
  10338. * @returns the serialized object
  10339. */
  10340. serialize(parent: any): any;
  10341. }
  10342. /**
  10343. * This defines an action responsible to increment the target value
  10344. * to a desired value once triggered.
  10345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10346. */
  10347. export class IncrementValueAction extends Action {
  10348. /**
  10349. * The path of the property to increment in the target.
  10350. */
  10351. propertyPath: string;
  10352. /**
  10353. * The value we should increment the property by.
  10354. */
  10355. value: any;
  10356. private _target;
  10357. private _effectiveTarget;
  10358. private _property;
  10359. /**
  10360. * Instantiate the action
  10361. * @param triggerOptions defines the trigger options
  10362. * @param target defines the object containing the property
  10363. * @param propertyPath defines the path of the property to increment in the target
  10364. * @param value defines the value value we should increment the property by
  10365. * @param condition defines the trigger related conditions
  10366. */
  10367. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10368. /** @hidden */ private _prepare(): void;
  10369. /**
  10370. * Execute the action and increment the target of the value amount.
  10371. */
  10372. execute(): void;
  10373. /**
  10374. * Serializes the actions and its related information.
  10375. * @param parent defines the object to serialize in
  10376. * @returns the serialized object
  10377. */
  10378. serialize(parent: any): any;
  10379. }
  10380. /**
  10381. * This defines an action responsible to start an animation once triggered.
  10382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10383. */
  10384. export class PlayAnimationAction extends Action {
  10385. /**
  10386. * Where the animation should start (animation frame)
  10387. */
  10388. from: number;
  10389. /**
  10390. * Where the animation should stop (animation frame)
  10391. */
  10392. to: number;
  10393. /**
  10394. * Define if the animation should loop or stop after the first play.
  10395. */
  10396. loop?: boolean;
  10397. private _target;
  10398. /**
  10399. * Instantiate the action
  10400. * @param triggerOptions defines the trigger options
  10401. * @param target defines the target animation or animation name
  10402. * @param from defines from where the animation should start (animation frame)
  10403. * @param end defines where the animation should stop (animation frame)
  10404. * @param loop defines if the animation should loop or stop after the first play
  10405. * @param condition defines the trigger related conditions
  10406. */
  10407. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10408. /** @hidden */ private _prepare(): void;
  10409. /**
  10410. * Execute the action and play the animation.
  10411. */
  10412. execute(): void;
  10413. /**
  10414. * Serializes the actions and its related information.
  10415. * @param parent defines the object to serialize in
  10416. * @returns the serialized object
  10417. */
  10418. serialize(parent: any): any;
  10419. }
  10420. /**
  10421. * This defines an action responsible to stop an animation once triggered.
  10422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10423. */
  10424. export class StopAnimationAction extends Action {
  10425. private _target;
  10426. /**
  10427. * Instantiate the action
  10428. * @param triggerOptions defines the trigger options
  10429. * @param target defines the target animation or animation name
  10430. * @param condition defines the trigger related conditions
  10431. */
  10432. constructor(triggerOptions: any, target: any, condition?: Condition);
  10433. /** @hidden */ private _prepare(): void;
  10434. /**
  10435. * Execute the action and stop the animation.
  10436. */
  10437. execute(): void;
  10438. /**
  10439. * Serializes the actions and its related information.
  10440. * @param parent defines the object to serialize in
  10441. * @returns the serialized object
  10442. */
  10443. serialize(parent: any): any;
  10444. }
  10445. /**
  10446. * This defines an action responsible that does nothing once triggered.
  10447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10448. */
  10449. export class DoNothingAction extends Action {
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param condition defines the trigger related conditions
  10454. */
  10455. constructor(triggerOptions?: any, condition?: Condition);
  10456. /**
  10457. * Execute the action and do nothing.
  10458. */
  10459. execute(): void;
  10460. /**
  10461. * Serializes the actions and its related information.
  10462. * @param parent defines the object to serialize in
  10463. * @returns the serialized object
  10464. */
  10465. serialize(parent: any): any;
  10466. }
  10467. /**
  10468. * This defines an action responsible to trigger several actions once triggered.
  10469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10470. */
  10471. export class CombineAction extends Action {
  10472. /**
  10473. * The list of aggregated animations to run.
  10474. */
  10475. children: Action[];
  10476. /**
  10477. * Instantiate the action
  10478. * @param triggerOptions defines the trigger options
  10479. * @param children defines the list of aggregated animations to run
  10480. * @param condition defines the trigger related conditions
  10481. */
  10482. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10483. /** @hidden */ private _prepare(): void;
  10484. /**
  10485. * Execute the action and executes all the aggregated actions.
  10486. */
  10487. execute(evt: ActionEvent): void;
  10488. /**
  10489. * Serializes the actions and its related information.
  10490. * @param parent defines the object to serialize in
  10491. * @returns the serialized object
  10492. */
  10493. serialize(parent: any): any;
  10494. }
  10495. /**
  10496. * This defines an action responsible to run code (external event) once triggered.
  10497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10498. */
  10499. export class ExecuteCodeAction extends Action {
  10500. /**
  10501. * The callback function to run.
  10502. */
  10503. func: (evt: ActionEvent) => void;
  10504. /**
  10505. * Instantiate the action
  10506. * @param triggerOptions defines the trigger options
  10507. * @param func defines the callback function to run
  10508. * @param condition defines the trigger related conditions
  10509. */
  10510. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10511. /**
  10512. * Execute the action and run the attached code.
  10513. */
  10514. execute(evt: ActionEvent): void;
  10515. }
  10516. /**
  10517. * This defines an action responsible to set the parent property of the target once triggered.
  10518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10519. */
  10520. export class SetParentAction extends Action {
  10521. private _parent;
  10522. private _target;
  10523. /**
  10524. * Instantiate the action
  10525. * @param triggerOptions defines the trigger options
  10526. * @param target defines the target containing the parent property
  10527. * @param parent defines from where the animation should start (animation frame)
  10528. * @param condition defines the trigger related conditions
  10529. */
  10530. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10531. /** @hidden */ private _prepare(): void;
  10532. /**
  10533. * Execute the action and set the parent property.
  10534. */
  10535. execute(): void;
  10536. /**
  10537. * Serializes the actions and its related information.
  10538. * @param parent defines the object to serialize in
  10539. * @returns the serialized object
  10540. */
  10541. serialize(parent: any): any;
  10542. }
  10543. }
  10544. declare module BABYLON {
  10545. /**
  10546. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10547. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10549. */
  10550. export class ActionManager extends AbstractActionManager {
  10551. /**
  10552. * Nothing
  10553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10554. */
  10555. static readonly NothingTrigger: number;
  10556. /**
  10557. * On pick
  10558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10559. */
  10560. static readonly OnPickTrigger: number;
  10561. /**
  10562. * On left pick
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10564. */
  10565. static readonly OnLeftPickTrigger: number;
  10566. /**
  10567. * On right pick
  10568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10569. */
  10570. static readonly OnRightPickTrigger: number;
  10571. /**
  10572. * On center pick
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10574. */
  10575. static readonly OnCenterPickTrigger: number;
  10576. /**
  10577. * On pick down
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10579. */
  10580. static readonly OnPickDownTrigger: number;
  10581. /**
  10582. * On double pick
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10584. */
  10585. static readonly OnDoublePickTrigger: number;
  10586. /**
  10587. * On pick up
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10589. */
  10590. static readonly OnPickUpTrigger: number;
  10591. /**
  10592. * On pick out.
  10593. * This trigger will only be raised if you also declared a OnPickDown
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10595. */
  10596. static readonly OnPickOutTrigger: number;
  10597. /**
  10598. * On long press
  10599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10600. */
  10601. static readonly OnLongPressTrigger: number;
  10602. /**
  10603. * On pointer over
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10605. */
  10606. static readonly OnPointerOverTrigger: number;
  10607. /**
  10608. * On pointer out
  10609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10610. */
  10611. static readonly OnPointerOutTrigger: number;
  10612. /**
  10613. * On every frame
  10614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10615. */
  10616. static readonly OnEveryFrameTrigger: number;
  10617. /**
  10618. * On intersection enter
  10619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10620. */
  10621. static readonly OnIntersectionEnterTrigger: number;
  10622. /**
  10623. * On intersection exit
  10624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10625. */
  10626. static readonly OnIntersectionExitTrigger: number;
  10627. /**
  10628. * On key down
  10629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10630. */
  10631. static readonly OnKeyDownTrigger: number;
  10632. /**
  10633. * On key up
  10634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10635. */
  10636. static readonly OnKeyUpTrigger: number;
  10637. private _scene;
  10638. /**
  10639. * Creates a new action manager
  10640. * @param scene defines the hosting scene
  10641. */
  10642. constructor(scene: Scene);
  10643. /**
  10644. * Releases all associated resources
  10645. */
  10646. dispose(): void;
  10647. /**
  10648. * Gets hosting scene
  10649. * @returns the hosting scene
  10650. */
  10651. getScene(): Scene;
  10652. /**
  10653. * Does this action manager handles actions of any of the given triggers
  10654. * @param triggers defines the triggers to be tested
  10655. * @return a boolean indicating whether one (or more) of the triggers is handled
  10656. */
  10657. hasSpecificTriggers(triggers: number[]): boolean;
  10658. /**
  10659. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10660. * speed.
  10661. * @param triggerA defines the trigger to be tested
  10662. * @param triggerB defines the trigger to be tested
  10663. * @return a boolean indicating whether one (or more) of the triggers is handled
  10664. */
  10665. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10666. /**
  10667. * Does this action manager handles actions of a given trigger
  10668. * @param trigger defines the trigger to be tested
  10669. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10670. * @return whether the trigger is handled
  10671. */
  10672. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10673. /**
  10674. * Does this action manager has pointer triggers
  10675. */
  10676. readonly hasPointerTriggers: boolean;
  10677. /**
  10678. * Does this action manager has pick triggers
  10679. */
  10680. readonly hasPickTriggers: boolean;
  10681. /**
  10682. * Registers an action to this action manager
  10683. * @param action defines the action to be registered
  10684. * @return the action amended (prepared) after registration
  10685. */
  10686. registerAction(action: IAction): Nullable<IAction>;
  10687. /**
  10688. * Unregisters an action to this action manager
  10689. * @param action defines the action to be unregistered
  10690. * @return a boolean indicating whether the action has been unregistered
  10691. */
  10692. unregisterAction(action: IAction): Boolean;
  10693. /**
  10694. * Process a specific trigger
  10695. * @param trigger defines the trigger to process
  10696. * @param evt defines the event details to be processed
  10697. */
  10698. processTrigger(trigger: number, evt?: IActionEvent): void;
  10699. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10700. /** @hidden */ private _getProperty(propertyPath: string): string;
  10701. /**
  10702. * Serialize this manager to a JSON object
  10703. * @param name defines the property name to store this manager
  10704. * @returns a JSON representation of this manager
  10705. */
  10706. serialize(name: string): any;
  10707. /**
  10708. * Creates a new ActionManager from a JSON data
  10709. * @param parsedActions defines the JSON data to read from
  10710. * @param object defines the hosting mesh
  10711. * @param scene defines the hosting scene
  10712. */
  10713. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10714. /**
  10715. * Get a trigger name by index
  10716. * @param trigger defines the trigger index
  10717. * @returns a trigger name
  10718. */
  10719. static GetTriggerName(trigger: number): string;
  10720. }
  10721. }
  10722. declare module BABYLON {
  10723. /**
  10724. * Class representing a ray with position and direction
  10725. */
  10726. export class Ray {
  10727. /** origin point */
  10728. origin: Vector3;
  10729. /** direction */
  10730. direction: Vector3;
  10731. /** length of the ray */
  10732. length: number;
  10733. private static readonly TmpVector3;
  10734. private _tmpRay;
  10735. /**
  10736. * Creates a new ray
  10737. * @param origin origin point
  10738. * @param direction direction
  10739. * @param length length of the ray
  10740. */
  10741. constructor(
  10742. /** origin point */
  10743. origin: Vector3,
  10744. /** direction */
  10745. direction: Vector3,
  10746. /** length of the ray */
  10747. length?: number);
  10748. /**
  10749. * Checks if the ray intersects a box
  10750. * @param minimum bound of the box
  10751. * @param maximum bound of the box
  10752. * @param intersectionTreshold extra extend to be added to the box in all direction
  10753. * @returns if the box was hit
  10754. */
  10755. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10756. /**
  10757. * Checks if the ray intersects a box
  10758. * @param box the bounding box to check
  10759. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10760. * @returns if the box was hit
  10761. */
  10762. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10763. /**
  10764. * If the ray hits a sphere
  10765. * @param sphere the bounding sphere to check
  10766. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10767. * @returns true if it hits the sphere
  10768. */
  10769. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10770. /**
  10771. * If the ray hits a triange
  10772. * @param vertex0 triangle vertex
  10773. * @param vertex1 triangle vertex
  10774. * @param vertex2 triangle vertex
  10775. * @returns intersection information if hit
  10776. */
  10777. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10778. /**
  10779. * Checks if ray intersects a plane
  10780. * @param plane the plane to check
  10781. * @returns the distance away it was hit
  10782. */
  10783. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10784. /**
  10785. * Calculate the intercept of a ray on a given axis
  10786. * @param axis to check 'x' | 'y' | 'z'
  10787. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10788. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10789. */
  10790. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10791. /**
  10792. * Checks if ray intersects a mesh
  10793. * @param mesh the mesh to check
  10794. * @param fastCheck if only the bounding box should checked
  10795. * @returns picking info of the intersecton
  10796. */
  10797. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10798. /**
  10799. * Checks if ray intersects a mesh
  10800. * @param meshes the meshes to check
  10801. * @param fastCheck if only the bounding box should checked
  10802. * @param results array to store result in
  10803. * @returns Array of picking infos
  10804. */
  10805. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10806. private _comparePickingInfo;
  10807. private static smallnum;
  10808. private static rayl;
  10809. /**
  10810. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10811. * @param sega the first point of the segment to test the intersection against
  10812. * @param segb the second point of the segment to test the intersection against
  10813. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10814. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10815. */
  10816. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10817. /**
  10818. * Update the ray from viewport position
  10819. * @param x position
  10820. * @param y y position
  10821. * @param viewportWidth viewport width
  10822. * @param viewportHeight viewport height
  10823. * @param world world matrix
  10824. * @param view view matrix
  10825. * @param projection projection matrix
  10826. * @returns this ray updated
  10827. */
  10828. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10829. /**
  10830. * Creates a ray with origin and direction of 0,0,0
  10831. * @returns the new ray
  10832. */
  10833. static Zero(): Ray;
  10834. /**
  10835. * Creates a new ray from screen space and viewport
  10836. * @param x position
  10837. * @param y y position
  10838. * @param viewportWidth viewport width
  10839. * @param viewportHeight viewport height
  10840. * @param world world matrix
  10841. * @param view view matrix
  10842. * @param projection projection matrix
  10843. * @returns new ray
  10844. */
  10845. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * 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
  10848. * transformed to the given world matrix.
  10849. * @param origin The origin point
  10850. * @param end The end point
  10851. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10852. * @returns the new ray
  10853. */
  10854. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10855. /**
  10856. * Transforms a ray by a matrix
  10857. * @param ray ray to transform
  10858. * @param matrix matrix to apply
  10859. * @returns the resulting new ray
  10860. */
  10861. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10862. /**
  10863. * Transforms a ray by a matrix
  10864. * @param ray ray to transform
  10865. * @param matrix matrix to apply
  10866. * @param result ray to store result in
  10867. */
  10868. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10869. /**
  10870. * Unproject a ray from screen space to object space
  10871. * @param sourceX defines the screen space x coordinate to use
  10872. * @param sourceY defines the screen space y coordinate to use
  10873. * @param viewportWidth defines the current width of the viewport
  10874. * @param viewportHeight defines the current height of the viewport
  10875. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10876. * @param view defines the view matrix to use
  10877. * @param projection defines the projection matrix to use
  10878. */
  10879. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10880. }
  10881. /**
  10882. * Type used to define predicate used to select faces when a mesh intersection is detected
  10883. */
  10884. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10885. interface Scene {
  10886. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10887. /** @hidden */ private _cachedRayForTransform: Ray;
  10888. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10889. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10890. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10891. }
  10892. }
  10893. declare module BABYLON {
  10894. /**
  10895. * Groups all the scene component constants in one place to ease maintenance.
  10896. * @hidden
  10897. */
  10898. export class SceneComponentConstants {
  10899. static readonly NAME_EFFECTLAYER: string;
  10900. static readonly NAME_LAYER: string;
  10901. static readonly NAME_LENSFLARESYSTEM: string;
  10902. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10903. static readonly NAME_PARTICLESYSTEM: string;
  10904. static readonly NAME_GAMEPAD: string;
  10905. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10906. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10907. static readonly NAME_DEPTHRENDERER: string;
  10908. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10909. static readonly NAME_SPRITE: string;
  10910. static readonly NAME_OUTLINERENDERER: string;
  10911. static readonly NAME_PROCEDURALTEXTURE: string;
  10912. static readonly NAME_SHADOWGENERATOR: string;
  10913. static readonly NAME_OCTREE: string;
  10914. static readonly NAME_PHYSICSENGINE: string;
  10915. static readonly NAME_AUDIO: string;
  10916. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10917. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10918. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10919. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10920. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10921. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10922. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10923. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10924. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10925. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10926. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10927. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10928. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10929. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10930. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10931. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10932. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10933. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10934. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10935. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10936. static readonly STEP_AFTERRENDER_AUDIO: number;
  10937. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10938. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10939. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10940. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10941. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10942. static readonly STEP_POINTERMOVE_SPRITE: number;
  10943. static readonly STEP_POINTERDOWN_SPRITE: number;
  10944. static readonly STEP_POINTERUP_SPRITE: number;
  10945. }
  10946. /**
  10947. * This represents a scene component.
  10948. *
  10949. * This is used to decouple the dependency the scene is having on the different workloads like
  10950. * layers, post processes...
  10951. */
  10952. export interface ISceneComponent {
  10953. /**
  10954. * The name of the component. Each component must have a unique name.
  10955. */
  10956. name: string;
  10957. /**
  10958. * The scene the component belongs to.
  10959. */
  10960. scene: Scene;
  10961. /**
  10962. * Register the component to one instance of a scene.
  10963. */
  10964. register(): void;
  10965. /**
  10966. * Rebuilds the elements related to this component in case of
  10967. * context lost for instance.
  10968. */
  10969. rebuild(): void;
  10970. /**
  10971. * Disposes the component and the associated ressources.
  10972. */
  10973. dispose(): void;
  10974. }
  10975. /**
  10976. * This represents a SERIALIZABLE scene component.
  10977. *
  10978. * This extends Scene Component to add Serialization methods on top.
  10979. */
  10980. export interface ISceneSerializableComponent extends ISceneComponent {
  10981. /**
  10982. * Adds all the elements from the container to the scene
  10983. * @param container the container holding the elements
  10984. */
  10985. addFromContainer(container: AbstractScene): void;
  10986. /**
  10987. * Removes all the elements in the container from the scene
  10988. * @param container contains the elements to remove
  10989. * @param dispose if the removed element should be disposed (default: false)
  10990. */
  10991. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10992. /**
  10993. * Serializes the component data to the specified json object
  10994. * @param serializationObject The object to serialize to
  10995. */
  10996. serialize(serializationObject: any): void;
  10997. }
  10998. /**
  10999. * Strong typing of a Mesh related stage step action
  11000. */
  11001. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11002. /**
  11003. * Strong typing of a Evaluate Sub Mesh related stage step action
  11004. */
  11005. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11006. /**
  11007. * Strong typing of a Active Mesh related stage step action
  11008. */
  11009. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11010. /**
  11011. * Strong typing of a Camera related stage step action
  11012. */
  11013. export type CameraStageAction = (camera: Camera) => void;
  11014. /**
  11015. * Strong typing of a Camera Frame buffer related stage step action
  11016. */
  11017. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11018. /**
  11019. * Strong typing of a Render Target related stage step action
  11020. */
  11021. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11022. /**
  11023. * Strong typing of a RenderingGroup related stage step action
  11024. */
  11025. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11026. /**
  11027. * Strong typing of a Mesh Render related stage step action
  11028. */
  11029. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11030. /**
  11031. * Strong typing of a simple stage step action
  11032. */
  11033. export type SimpleStageAction = () => void;
  11034. /**
  11035. * Strong typing of a render target action.
  11036. */
  11037. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11038. /**
  11039. * Strong typing of a pointer move action.
  11040. */
  11041. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11042. /**
  11043. * Strong typing of a pointer up/down action.
  11044. */
  11045. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11046. /**
  11047. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11048. * @hidden
  11049. */
  11050. export class Stage<T extends Function> extends Array<{
  11051. index: number;
  11052. component: ISceneComponent;
  11053. action: T;
  11054. }> {
  11055. /**
  11056. * Hide ctor from the rest of the world.
  11057. * @param items The items to add.
  11058. */
  11059. private constructor();
  11060. /**
  11061. * Creates a new Stage.
  11062. * @returns A new instance of a Stage
  11063. */
  11064. static Create<T extends Function>(): Stage<T>;
  11065. /**
  11066. * Registers a step in an ordered way in the targeted stage.
  11067. * @param index Defines the position to register the step in
  11068. * @param component Defines the component attached to the step
  11069. * @param action Defines the action to launch during the step
  11070. */
  11071. registerStep(index: number, component: ISceneComponent, action: T): void;
  11072. /**
  11073. * Clears all the steps from the stage.
  11074. */
  11075. clear(): void;
  11076. }
  11077. }
  11078. declare module BABYLON {
  11079. interface Scene {
  11080. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11081. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11082. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11083. /**
  11084. * All of the sprite managers added to this scene
  11085. * @see http://doc.babylonjs.com/babylon101/sprites
  11086. */
  11087. spriteManagers: Array<ISpriteManager>;
  11088. /**
  11089. * An event triggered when sprites rendering is about to start
  11090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11091. */
  11092. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11093. /**
  11094. * An event triggered when sprites rendering is done
  11095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11096. */
  11097. onAfterSpritesRenderingObservable: Observable<Scene>;
  11098. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11099. /** Launch a ray to try to pick a sprite in the scene
  11100. * @param x position on screen
  11101. * @param y position on screen
  11102. * @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
  11103. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11104. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11105. * @returns a PickingInfo
  11106. */
  11107. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11108. /** Use the given ray to pick a sprite in the scene
  11109. * @param ray The ray (in world space) to use to pick meshes
  11110. * @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
  11111. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11112. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11113. * @returns a PickingInfo
  11114. */
  11115. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11116. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11117. /** Launch a ray to try to pick sprites in the scene
  11118. * @param x position on screen
  11119. * @param y position on screen
  11120. * @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
  11121. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11122. * @returns a PickingInfo array
  11123. */
  11124. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11125. /** Use the given ray to pick sprites in the scene
  11126. * @param ray The ray (in world space) to use to pick meshes
  11127. * @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
  11128. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11129. * @returns a PickingInfo array
  11130. */
  11131. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11132. /**
  11133. * Force the sprite under the pointer
  11134. * @param sprite defines the sprite to use
  11135. */
  11136. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11137. /**
  11138. * Gets the sprite under the pointer
  11139. * @returns a Sprite or null if no sprite is under the pointer
  11140. */
  11141. getPointerOverSprite(): Nullable<Sprite>;
  11142. }
  11143. /**
  11144. * Defines the sprite scene component responsible to manage sprites
  11145. * in a given scene.
  11146. */
  11147. export class SpriteSceneComponent implements ISceneComponent {
  11148. /**
  11149. * The component name helpfull to identify the component in the list of scene components.
  11150. */
  11151. readonly name: string;
  11152. /**
  11153. * The scene the component belongs to.
  11154. */
  11155. scene: Scene;
  11156. /** @hidden */
  11157. private _spritePredicate;
  11158. /**
  11159. * Creates a new instance of the component for the given scene
  11160. * @param scene Defines the scene to register the component in
  11161. */
  11162. constructor(scene: Scene);
  11163. /**
  11164. * Registers the component in a given scene
  11165. */
  11166. register(): void;
  11167. /**
  11168. * Rebuilds the elements related to this component in case of
  11169. * context lost for instance.
  11170. */
  11171. rebuild(): void;
  11172. /**
  11173. * Disposes the component and the associated ressources.
  11174. */
  11175. dispose(): void;
  11176. private _pickSpriteButKeepRay;
  11177. private _pointerMove;
  11178. private _pointerDown;
  11179. private _pointerUp;
  11180. }
  11181. }
  11182. declare module BABYLON {
  11183. /** @hidden */
  11184. export var fogFragmentDeclaration: {
  11185. name: string;
  11186. shader: string;
  11187. };
  11188. }
  11189. declare module BABYLON {
  11190. /** @hidden */
  11191. export var fogFragment: {
  11192. name: string;
  11193. shader: string;
  11194. };
  11195. }
  11196. declare module BABYLON {
  11197. /** @hidden */
  11198. export var spritesPixelShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module BABYLON {
  11204. /** @hidden */
  11205. export var fogVertexDeclaration: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module BABYLON {
  11211. /** @hidden */
  11212. export var spritesVertexShader: {
  11213. name: string;
  11214. shader: string;
  11215. };
  11216. }
  11217. declare module BABYLON {
  11218. /**
  11219. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11220. */
  11221. export interface ISpriteManager extends IDisposable {
  11222. /**
  11223. * Restricts the camera to viewing objects with the same layerMask.
  11224. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11225. */
  11226. layerMask: number;
  11227. /**
  11228. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11229. */
  11230. isPickable: boolean;
  11231. /**
  11232. * Specifies the rendering group id for this mesh (0 by default)
  11233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11234. */
  11235. renderingGroupId: number;
  11236. /**
  11237. * Defines the list of sprites managed by the manager.
  11238. */
  11239. sprites: Array<Sprite>;
  11240. /**
  11241. * Tests the intersection of a sprite with a specific ray.
  11242. * @param ray The ray we are sending to test the collision
  11243. * @param camera The camera space we are sending rays in
  11244. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11245. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11246. * @returns picking info or null.
  11247. */
  11248. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11249. /**
  11250. * Intersects the sprites with a ray
  11251. * @param ray defines the ray to intersect with
  11252. * @param camera defines the current active camera
  11253. * @param predicate defines a predicate used to select candidate sprites
  11254. * @returns null if no hit or a PickingInfo array
  11255. */
  11256. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11257. /**
  11258. * Renders the list of sprites on screen.
  11259. */
  11260. render(): void;
  11261. }
  11262. /**
  11263. * Class used to manage multiple sprites on the same spritesheet
  11264. * @see http://doc.babylonjs.com/babylon101/sprites
  11265. */
  11266. export class SpriteManager implements ISpriteManager {
  11267. /** defines the manager's name */
  11268. name: string;
  11269. /** Gets the list of sprites */
  11270. sprites: Sprite[];
  11271. /** Gets or sets the rendering group id (0 by default) */
  11272. renderingGroupId: number;
  11273. /** Gets or sets camera layer mask */
  11274. layerMask: number;
  11275. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11276. fogEnabled: boolean;
  11277. /** Gets or sets a boolean indicating if the sprites are pickable */
  11278. isPickable: boolean;
  11279. /** Defines the default width of a cell in the spritesheet */
  11280. cellWidth: number;
  11281. /** Defines the default height of a cell in the spritesheet */
  11282. cellHeight: number;
  11283. /** Associative array from JSON sprite data file */
  11284. private _cellData;
  11285. /** Array of sprite names from JSON sprite data file */
  11286. private _spriteMap;
  11287. /** True when packed cell data from JSON file is ready*/
  11288. private _packedAndReady;
  11289. /**
  11290. * An event triggered when the manager is disposed.
  11291. */
  11292. onDisposeObservable: Observable<SpriteManager>;
  11293. private _onDisposeObserver;
  11294. /**
  11295. * Callback called when the manager is disposed
  11296. */
  11297. onDispose: () => void;
  11298. private _capacity;
  11299. private _fromPacked;
  11300. private _spriteTexture;
  11301. private _epsilon;
  11302. private _scene;
  11303. private _vertexData;
  11304. private _buffer;
  11305. private _vertexBuffers;
  11306. private _indexBuffer;
  11307. private _effectBase;
  11308. private _effectFog;
  11309. /**
  11310. * Gets or sets the spritesheet texture
  11311. */
  11312. texture: Texture;
  11313. /**
  11314. * Creates a new sprite manager
  11315. * @param name defines the manager's name
  11316. * @param imgUrl defines the sprite sheet url
  11317. * @param capacity defines the maximum allowed number of sprites
  11318. * @param cellSize defines the size of a sprite cell
  11319. * @param scene defines the hosting scene
  11320. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11321. * @param samplingMode defines the smapling mode to use with spritesheet
  11322. * @param fromPacked set to false; do not alter
  11323. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11324. */
  11325. constructor(
  11326. /** defines the manager's name */
  11327. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11328. private _makePacked;
  11329. private _appendSpriteVertex;
  11330. /**
  11331. * Intersects the sprites with a ray
  11332. * @param ray defines the ray to intersect with
  11333. * @param camera defines the current active camera
  11334. * @param predicate defines a predicate used to select candidate sprites
  11335. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11336. * @returns null if no hit or a PickingInfo
  11337. */
  11338. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /**
  11340. * Intersects the sprites with a ray
  11341. * @param ray defines the ray to intersect with
  11342. * @param camera defines the current active camera
  11343. * @param predicate defines a predicate used to select candidate sprites
  11344. * @returns null if no hit or a PickingInfo array
  11345. */
  11346. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11347. /**
  11348. * Render all child sprites
  11349. */
  11350. render(): void;
  11351. /**
  11352. * Release associated resources
  11353. */
  11354. dispose(): void;
  11355. }
  11356. }
  11357. declare module BABYLON {
  11358. /**
  11359. * Class used to represent a sprite
  11360. * @see http://doc.babylonjs.com/babylon101/sprites
  11361. */
  11362. export class Sprite {
  11363. /** defines the name */
  11364. name: string;
  11365. /** Gets or sets the current world position */
  11366. position: Vector3;
  11367. /** Gets or sets the main color */
  11368. color: Color4;
  11369. /** Gets or sets the width */
  11370. width: number;
  11371. /** Gets or sets the height */
  11372. height: number;
  11373. /** Gets or sets rotation angle */
  11374. angle: number;
  11375. /** Gets or sets the cell index in the sprite sheet */
  11376. cellIndex: number;
  11377. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11378. cellRef: string;
  11379. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11380. invertU: number;
  11381. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11382. invertV: number;
  11383. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11384. disposeWhenFinishedAnimating: boolean;
  11385. /** Gets the list of attached animations */
  11386. animations: Animation[];
  11387. /** Gets or sets a boolean indicating if the sprite can be picked */
  11388. isPickable: boolean;
  11389. /**
  11390. * Gets or sets the associated action manager
  11391. */
  11392. actionManager: Nullable<ActionManager>;
  11393. private _animationStarted;
  11394. private _loopAnimation;
  11395. private _fromIndex;
  11396. private _toIndex;
  11397. private _delay;
  11398. private _direction;
  11399. private _manager;
  11400. private _time;
  11401. private _onAnimationEnd;
  11402. /**
  11403. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11404. */
  11405. isVisible: boolean;
  11406. /**
  11407. * Gets or sets the sprite size
  11408. */
  11409. size: number;
  11410. /**
  11411. * Creates a new Sprite
  11412. * @param name defines the name
  11413. * @param manager defines the manager
  11414. */
  11415. constructor(
  11416. /** defines the name */
  11417. name: string, manager: ISpriteManager);
  11418. /**
  11419. * Starts an animation
  11420. * @param from defines the initial key
  11421. * @param to defines the end key
  11422. * @param loop defines if the animation must loop
  11423. * @param delay defines the start delay (in ms)
  11424. * @param onAnimationEnd defines a callback to call when animation ends
  11425. */
  11426. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11427. /** Stops current animation (if any) */
  11428. stopAnimation(): void;
  11429. /** @hidden */ private _animate(deltaTime: number): void;
  11430. /** Release associated resources */
  11431. dispose(): void;
  11432. }
  11433. }
  11434. declare module BABYLON {
  11435. /**
  11436. * Information about the result of picking within a scene
  11437. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11438. */
  11439. export class PickingInfo {
  11440. /** @hidden */ private _pickingUnavailable: boolean;
  11441. /**
  11442. * If the pick collided with an object
  11443. */
  11444. hit: boolean;
  11445. /**
  11446. * Distance away where the pick collided
  11447. */
  11448. distance: number;
  11449. /**
  11450. * The location of pick collision
  11451. */
  11452. pickedPoint: Nullable<Vector3>;
  11453. /**
  11454. * The mesh corresponding the the pick collision
  11455. */
  11456. pickedMesh: Nullable<AbstractMesh>;
  11457. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11458. bu: number;
  11459. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11460. bv: number;
  11461. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11462. faceId: number;
  11463. /** Id of the the submesh that was picked */
  11464. subMeshId: number;
  11465. /** If a sprite was picked, this will be the sprite the pick collided with */
  11466. pickedSprite: Nullable<Sprite>;
  11467. /**
  11468. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11469. */
  11470. originMesh: Nullable<AbstractMesh>;
  11471. /**
  11472. * The ray that was used to perform the picking.
  11473. */
  11474. ray: Nullable<Ray>;
  11475. /**
  11476. * Gets the normal correspodning to the face the pick collided with
  11477. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11478. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11479. * @returns The normal correspodning to the face the pick collided with
  11480. */
  11481. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11482. /**
  11483. * Gets the texture coordinates of where the pick occured
  11484. * @returns the vector containing the coordnates of the texture
  11485. */
  11486. getTextureCoordinates(): Nullable<Vector2>;
  11487. }
  11488. }
  11489. declare module BABYLON {
  11490. /**
  11491. * Gather the list of pointer event types as constants.
  11492. */
  11493. export class PointerEventTypes {
  11494. /**
  11495. * 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.
  11496. */
  11497. static readonly POINTERDOWN: number;
  11498. /**
  11499. * The pointerup event is fired when a pointer is no longer active.
  11500. */
  11501. static readonly POINTERUP: number;
  11502. /**
  11503. * The pointermove event is fired when a pointer changes coordinates.
  11504. */
  11505. static readonly POINTERMOVE: number;
  11506. /**
  11507. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11508. */
  11509. static readonly POINTERWHEEL: number;
  11510. /**
  11511. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11512. */
  11513. static readonly POINTERPICK: number;
  11514. /**
  11515. * The pointertap event is fired when a the object has been touched and released without drag.
  11516. */
  11517. static readonly POINTERTAP: number;
  11518. /**
  11519. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11520. */
  11521. static readonly POINTERDOUBLETAP: number;
  11522. }
  11523. /**
  11524. * Base class of pointer info types.
  11525. */
  11526. export class PointerInfoBase {
  11527. /**
  11528. * Defines the type of event (PointerEventTypes)
  11529. */
  11530. type: number;
  11531. /**
  11532. * Defines the related dom event
  11533. */
  11534. event: PointerEvent | MouseWheelEvent;
  11535. /**
  11536. * Instantiates the base class of pointers info.
  11537. * @param type Defines the type of event (PointerEventTypes)
  11538. * @param event Defines the related dom event
  11539. */
  11540. constructor(
  11541. /**
  11542. * Defines the type of event (PointerEventTypes)
  11543. */
  11544. type: number,
  11545. /**
  11546. * Defines the related dom event
  11547. */
  11548. event: PointerEvent | MouseWheelEvent);
  11549. }
  11550. /**
  11551. * This class is used to store pointer related info for the onPrePointerObservable event.
  11552. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11553. */
  11554. export class PointerInfoPre extends PointerInfoBase {
  11555. /**
  11556. * Ray from a pointer if availible (eg. 6dof controller)
  11557. */
  11558. ray: Nullable<Ray>;
  11559. /**
  11560. * Defines the local position of the pointer on the canvas.
  11561. */
  11562. localPosition: Vector2;
  11563. /**
  11564. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11565. */
  11566. skipOnPointerObservable: boolean;
  11567. /**
  11568. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11569. * @param type Defines the type of event (PointerEventTypes)
  11570. * @param event Defines the related dom event
  11571. * @param localX Defines the local x coordinates of the pointer when the event occured
  11572. * @param localY Defines the local y coordinates of the pointer when the event occured
  11573. */
  11574. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11575. }
  11576. /**
  11577. * This type contains all the data related to a pointer event in Babylon.js.
  11578. * 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.
  11579. */
  11580. export class PointerInfo extends PointerInfoBase {
  11581. /**
  11582. * Defines the picking info associated to the info (if any)\
  11583. */
  11584. pickInfo: Nullable<PickingInfo>;
  11585. /**
  11586. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11587. * @param type Defines the type of event (PointerEventTypes)
  11588. * @param event Defines the related dom event
  11589. * @param pickInfo Defines the picking info associated to the info (if any)\
  11590. */
  11591. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11592. /**
  11593. * Defines the picking info associated to the info (if any)\
  11594. */
  11595. pickInfo: Nullable<PickingInfo>);
  11596. }
  11597. /**
  11598. * Data relating to a touch event on the screen.
  11599. */
  11600. export interface PointerTouch {
  11601. /**
  11602. * X coordinate of touch.
  11603. */
  11604. x: number;
  11605. /**
  11606. * Y coordinate of touch.
  11607. */
  11608. y: number;
  11609. /**
  11610. * Id of touch. Unique for each finger.
  11611. */
  11612. pointerId: number;
  11613. /**
  11614. * Event type passed from DOM.
  11615. */
  11616. type: any;
  11617. }
  11618. }
  11619. declare module BABYLON {
  11620. /**
  11621. * Manage the mouse inputs to control the movement of a free camera.
  11622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11623. */
  11624. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11625. /**
  11626. * Define if touch is enabled in the mouse input
  11627. */
  11628. touchEnabled: boolean;
  11629. /**
  11630. * Defines the camera the input is attached to.
  11631. */
  11632. camera: FreeCamera;
  11633. /**
  11634. * Defines the buttons associated with the input to handle camera move.
  11635. */
  11636. buttons: number[];
  11637. /**
  11638. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11639. */
  11640. angularSensibility: number;
  11641. private _pointerInput;
  11642. private _onMouseMove;
  11643. private _observer;
  11644. private previousPosition;
  11645. /**
  11646. * Observable for when a pointer move event occurs containing the move offset
  11647. */
  11648. onPointerMovedObservable: Observable<{
  11649. offsetX: number;
  11650. offsetY: number;
  11651. }>;
  11652. /**
  11653. * @hidden
  11654. * If the camera should be rotated automatically based on pointer movement
  11655. */ private _allowCameraRotation: boolean;
  11656. /**
  11657. * Manage the mouse inputs to control the movement of a free camera.
  11658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11659. * @param touchEnabled Defines if touch is enabled or not
  11660. */
  11661. constructor(
  11662. /**
  11663. * Define if touch is enabled in the mouse input
  11664. */
  11665. touchEnabled?: boolean);
  11666. /**
  11667. * Attach the input controls to a specific dom element to get the input from.
  11668. * @param element Defines the element the controls should be listened from
  11669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11670. */
  11671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11672. /**
  11673. * Called on JS contextmenu event.
  11674. * Override this method to provide functionality.
  11675. */
  11676. protected onContextMenu(evt: PointerEvent): void;
  11677. /**
  11678. * Detach the current controls from the specified dom element.
  11679. * @param element Defines the element to stop listening the inputs from
  11680. */
  11681. detachControl(element: Nullable<HTMLElement>): void;
  11682. /**
  11683. * Gets the class name of the current intput.
  11684. * @returns the class name
  11685. */
  11686. getClassName(): string;
  11687. /**
  11688. * Get the friendly name associated with the input class.
  11689. * @returns the input friendly name
  11690. */
  11691. getSimpleName(): string;
  11692. }
  11693. }
  11694. declare module BABYLON {
  11695. /**
  11696. * Manage the touch inputs to control the movement of a free camera.
  11697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11698. */
  11699. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11700. /**
  11701. * Defines the camera the input is attached to.
  11702. */
  11703. camera: FreeCamera;
  11704. /**
  11705. * Defines the touch sensibility for rotation.
  11706. * The higher the faster.
  11707. */
  11708. touchAngularSensibility: number;
  11709. /**
  11710. * Defines the touch sensibility for move.
  11711. * The higher the faster.
  11712. */
  11713. touchMoveSensibility: number;
  11714. private _offsetX;
  11715. private _offsetY;
  11716. private _pointerPressed;
  11717. private _pointerInput;
  11718. private _observer;
  11719. private _onLostFocus;
  11720. /**
  11721. * Attach the input controls to a specific dom element to get the input from.
  11722. * @param element Defines the element the controls should be listened from
  11723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11724. */
  11725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11726. /**
  11727. * Detach the current controls from the specified dom element.
  11728. * @param element Defines the element to stop listening the inputs from
  11729. */
  11730. detachControl(element: Nullable<HTMLElement>): void;
  11731. /**
  11732. * Update the current camera state depending on the inputs that have been used this frame.
  11733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11734. */
  11735. checkInputs(): void;
  11736. /**
  11737. * Gets the class name of the current intput.
  11738. * @returns the class name
  11739. */
  11740. getClassName(): string;
  11741. /**
  11742. * Get the friendly name associated with the input class.
  11743. * @returns the input friendly name
  11744. */
  11745. getSimpleName(): string;
  11746. }
  11747. }
  11748. declare module BABYLON {
  11749. /**
  11750. * Default Inputs manager for the FreeCamera.
  11751. * It groups all the default supported inputs for ease of use.
  11752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11753. */
  11754. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11755. /**
  11756. * @hidden
  11757. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11758. /**
  11759. * Instantiates a new FreeCameraInputsManager.
  11760. * @param camera Defines the camera the inputs belong to
  11761. */
  11762. constructor(camera: FreeCamera);
  11763. /**
  11764. * Add keyboard input support to the input manager.
  11765. * @returns the current input manager
  11766. */
  11767. addKeyboard(): FreeCameraInputsManager;
  11768. /**
  11769. * Add mouse input support to the input manager.
  11770. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11771. * @returns the current input manager
  11772. */
  11773. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11774. /**
  11775. * Removes the mouse input support from the manager
  11776. * @returns the current input manager
  11777. */
  11778. removeMouse(): FreeCameraInputsManager;
  11779. /**
  11780. * Add touch input support to the input manager.
  11781. * @returns the current input manager
  11782. */
  11783. addTouch(): FreeCameraInputsManager;
  11784. /**
  11785. * Remove all attached input methods from a camera
  11786. */
  11787. clear(): void;
  11788. }
  11789. }
  11790. declare module BABYLON {
  11791. /**
  11792. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11793. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11795. */
  11796. export class FreeCamera extends TargetCamera {
  11797. /**
  11798. * Define the collision ellipsoid of the camera.
  11799. * This is helpful to simulate a camera body like the player body around the camera
  11800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11801. */
  11802. ellipsoid: Vector3;
  11803. /**
  11804. * Define an offset for the position of the ellipsoid around the camera.
  11805. * This can be helpful to determine the center of the body near the gravity center of the body
  11806. * instead of its head.
  11807. */
  11808. ellipsoidOffset: Vector3;
  11809. /**
  11810. * Enable or disable collisions of the camera with the rest of the scene objects.
  11811. */
  11812. checkCollisions: boolean;
  11813. /**
  11814. * Enable or disable gravity on the camera.
  11815. */
  11816. applyGravity: boolean;
  11817. /**
  11818. * Define the input manager associated to the camera.
  11819. */
  11820. inputs: FreeCameraInputsManager;
  11821. /**
  11822. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11823. * Higher values reduce sensitivity.
  11824. */
  11825. /**
  11826. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11827. * Higher values reduce sensitivity.
  11828. */
  11829. angularSensibility: number;
  11830. /**
  11831. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11832. */
  11833. keysUp: number[];
  11834. /**
  11835. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11836. */
  11837. keysDown: number[];
  11838. /**
  11839. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11840. */
  11841. keysLeft: number[];
  11842. /**
  11843. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11844. */
  11845. keysRight: number[];
  11846. /**
  11847. * Event raised when the camera collide with a mesh in the scene.
  11848. */
  11849. onCollide: (collidedMesh: AbstractMesh) => void;
  11850. private _collider;
  11851. private _needMoveForGravity;
  11852. private _oldPosition;
  11853. private _diffPosition;
  11854. private _newPosition;
  11855. /** @hidden */ private _localDirection: Vector3;
  11856. /** @hidden */ private _transformedDirection: Vector3;
  11857. /**
  11858. * Instantiates a Free Camera.
  11859. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11860. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11862. * @param name Define the name of the camera in the scene
  11863. * @param position Define the start position of the camera in the scene
  11864. * @param scene Define the scene the camera belongs to
  11865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11866. */
  11867. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11868. /**
  11869. * Attached controls to the current camera.
  11870. * @param element Defines the element the controls should be listened from
  11871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11872. */
  11873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11874. /**
  11875. * Detach the current controls from the camera.
  11876. * The camera will stop reacting to inputs.
  11877. * @param element Defines the element to stop listening the inputs from
  11878. */
  11879. detachControl(element: HTMLElement): void;
  11880. private _collisionMask;
  11881. /**
  11882. * Define a collision mask to limit the list of object the camera can collide with
  11883. */
  11884. collisionMask: number;
  11885. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11886. private _onCollisionPositionChange;
  11887. /** @hidden */ private _checkInputs(): void;
  11888. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11889. /** @hidden */ private _updatePosition(): void;
  11890. /**
  11891. * Destroy the camera and release the current resources hold by it.
  11892. */
  11893. dispose(): void;
  11894. /**
  11895. * Gets the current object class name.
  11896. * @return the class name
  11897. */
  11898. getClassName(): string;
  11899. }
  11900. }
  11901. declare module BABYLON {
  11902. /**
  11903. * Represents a gamepad control stick position
  11904. */
  11905. export class StickValues {
  11906. /**
  11907. * The x component of the control stick
  11908. */
  11909. x: number;
  11910. /**
  11911. * The y component of the control stick
  11912. */
  11913. y: number;
  11914. /**
  11915. * Initializes the gamepad x and y control stick values
  11916. * @param x The x component of the gamepad control stick value
  11917. * @param y The y component of the gamepad control stick value
  11918. */
  11919. constructor(
  11920. /**
  11921. * The x component of the control stick
  11922. */
  11923. x: number,
  11924. /**
  11925. * The y component of the control stick
  11926. */
  11927. y: number);
  11928. }
  11929. /**
  11930. * An interface which manages callbacks for gamepad button changes
  11931. */
  11932. export interface GamepadButtonChanges {
  11933. /**
  11934. * Called when a gamepad has been changed
  11935. */
  11936. changed: boolean;
  11937. /**
  11938. * Called when a gamepad press event has been triggered
  11939. */
  11940. pressChanged: boolean;
  11941. /**
  11942. * Called when a touch event has been triggered
  11943. */
  11944. touchChanged: boolean;
  11945. /**
  11946. * Called when a value has changed
  11947. */
  11948. valueChanged: boolean;
  11949. }
  11950. /**
  11951. * Represents a gamepad
  11952. */
  11953. export class Gamepad {
  11954. /**
  11955. * The id of the gamepad
  11956. */
  11957. id: string;
  11958. /**
  11959. * The index of the gamepad
  11960. */
  11961. index: number;
  11962. /**
  11963. * The browser gamepad
  11964. */
  11965. browserGamepad: any;
  11966. /**
  11967. * Specifies what type of gamepad this represents
  11968. */
  11969. type: number;
  11970. private _leftStick;
  11971. private _rightStick;
  11972. /** @hidden */ private _isConnected: boolean;
  11973. private _leftStickAxisX;
  11974. private _leftStickAxisY;
  11975. private _rightStickAxisX;
  11976. private _rightStickAxisY;
  11977. /**
  11978. * Triggered when the left control stick has been changed
  11979. */
  11980. private _onleftstickchanged;
  11981. /**
  11982. * Triggered when the right control stick has been changed
  11983. */
  11984. private _onrightstickchanged;
  11985. /**
  11986. * Represents a gamepad controller
  11987. */
  11988. static GAMEPAD: number;
  11989. /**
  11990. * Represents a generic controller
  11991. */
  11992. static GENERIC: number;
  11993. /**
  11994. * Represents an XBox controller
  11995. */
  11996. static XBOX: number;
  11997. /**
  11998. * Represents a pose-enabled controller
  11999. */
  12000. static POSE_ENABLED: number;
  12001. /**
  12002. * Represents an Dual Shock controller
  12003. */
  12004. static DUALSHOCK: number;
  12005. /**
  12006. * Specifies whether the left control stick should be Y-inverted
  12007. */
  12008. protected _invertLeftStickY: boolean;
  12009. /**
  12010. * Specifies if the gamepad has been connected
  12011. */
  12012. readonly isConnected: boolean;
  12013. /**
  12014. * Initializes the gamepad
  12015. * @param id The id of the gamepad
  12016. * @param index The index of the gamepad
  12017. * @param browserGamepad The browser gamepad
  12018. * @param leftStickX The x component of the left joystick
  12019. * @param leftStickY The y component of the left joystick
  12020. * @param rightStickX The x component of the right joystick
  12021. * @param rightStickY The y component of the right joystick
  12022. */
  12023. constructor(
  12024. /**
  12025. * The id of the gamepad
  12026. */
  12027. id: string,
  12028. /**
  12029. * The index of the gamepad
  12030. */
  12031. index: number,
  12032. /**
  12033. * The browser gamepad
  12034. */
  12035. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12036. /**
  12037. * Callback triggered when the left joystick has changed
  12038. * @param callback
  12039. */
  12040. onleftstickchanged(callback: (values: StickValues) => void): void;
  12041. /**
  12042. * Callback triggered when the right joystick has changed
  12043. * @param callback
  12044. */
  12045. onrightstickchanged(callback: (values: StickValues) => void): void;
  12046. /**
  12047. * Gets the left joystick
  12048. */
  12049. /**
  12050. * Sets the left joystick values
  12051. */
  12052. leftStick: StickValues;
  12053. /**
  12054. * Gets the right joystick
  12055. */
  12056. /**
  12057. * Sets the right joystick value
  12058. */
  12059. rightStick: StickValues;
  12060. /**
  12061. * Updates the gamepad joystick positions
  12062. */
  12063. update(): void;
  12064. /**
  12065. * Disposes the gamepad
  12066. */
  12067. dispose(): void;
  12068. }
  12069. /**
  12070. * Represents a generic gamepad
  12071. */
  12072. export class GenericPad extends Gamepad {
  12073. private _buttons;
  12074. private _onbuttondown;
  12075. private _onbuttonup;
  12076. /**
  12077. * Observable triggered when a button has been pressed
  12078. */
  12079. onButtonDownObservable: Observable<number>;
  12080. /**
  12081. * Observable triggered when a button has been released
  12082. */
  12083. onButtonUpObservable: Observable<number>;
  12084. /**
  12085. * Callback triggered when a button has been pressed
  12086. * @param callback Called when a button has been pressed
  12087. */
  12088. onbuttondown(callback: (buttonPressed: number) => void): void;
  12089. /**
  12090. * Callback triggered when a button has been released
  12091. * @param callback Called when a button has been released
  12092. */
  12093. onbuttonup(callback: (buttonReleased: number) => void): void;
  12094. /**
  12095. * Initializes the generic gamepad
  12096. * @param id The id of the generic gamepad
  12097. * @param index The index of the generic gamepad
  12098. * @param browserGamepad The browser gamepad
  12099. */
  12100. constructor(id: string, index: number, browserGamepad: any);
  12101. private _setButtonValue;
  12102. /**
  12103. * Updates the generic gamepad
  12104. */
  12105. update(): void;
  12106. /**
  12107. * Disposes the generic gamepad
  12108. */
  12109. dispose(): void;
  12110. }
  12111. }
  12112. declare module BABYLON {
  12113. interface Engine {
  12114. /**
  12115. * Creates a raw texture
  12116. * @param data defines the data to store in the texture
  12117. * @param width defines the width of the texture
  12118. * @param height defines the height of the texture
  12119. * @param format defines the format of the data
  12120. * @param generateMipMaps defines if the engine should generate the mip levels
  12121. * @param invertY defines if data must be stored with Y axis inverted
  12122. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12123. * @param compression defines the compression used (null by default)
  12124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12125. * @returns the raw texture inside an InternalTexture
  12126. */
  12127. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12128. /**
  12129. * Update a raw texture
  12130. * @param texture defines the texture to update
  12131. * @param data defines the data to store in the texture
  12132. * @param format defines the format of the data
  12133. * @param invertY defines if data must be stored with Y axis inverted
  12134. */
  12135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12136. /**
  12137. * Update a raw texture
  12138. * @param texture defines the texture to update
  12139. * @param data defines the data to store in the texture
  12140. * @param format defines the format of the data
  12141. * @param invertY defines if data must be stored with Y axis inverted
  12142. * @param compression defines the compression used (null by default)
  12143. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12144. */
  12145. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12146. /**
  12147. * Creates a new raw cube texture
  12148. * @param data defines the array of data to use to create each face
  12149. * @param size defines the size of the textures
  12150. * @param format defines the format of the data
  12151. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12152. * @param generateMipMaps defines if the engine should generate the mip levels
  12153. * @param invertY defines if data must be stored with Y axis inverted
  12154. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12155. * @param compression defines the compression used (null by default)
  12156. * @returns the cube texture as an InternalTexture
  12157. */
  12158. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12159. /**
  12160. * Update a raw cube texture
  12161. * @param texture defines the texture to udpdate
  12162. * @param data defines the data to store
  12163. * @param format defines the data format
  12164. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12165. * @param invertY defines if data must be stored with Y axis inverted
  12166. */
  12167. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12168. /**
  12169. * Update a raw cube texture
  12170. * @param texture defines the texture to udpdate
  12171. * @param data defines the data to store
  12172. * @param format defines the data format
  12173. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12174. * @param invertY defines if data must be stored with Y axis inverted
  12175. * @param compression defines the compression used (null by default)
  12176. */
  12177. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12178. /**
  12179. * Update a raw cube texture
  12180. * @param texture defines the texture to udpdate
  12181. * @param data defines the data to store
  12182. * @param format defines the data format
  12183. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12184. * @param invertY defines if data must be stored with Y axis inverted
  12185. * @param compression defines the compression used (null by default)
  12186. * @param level defines which level of the texture to update
  12187. */
  12188. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12189. /**
  12190. * Creates a new raw cube texture from a specified url
  12191. * @param url defines the url where the data is located
  12192. * @param scene defines the current scene
  12193. * @param size defines the size of the textures
  12194. * @param format defines the format of the data
  12195. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12196. * @param noMipmap defines if the engine should avoid generating the mip levels
  12197. * @param callback defines a callback used to extract texture data from loaded data
  12198. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12199. * @param onLoad defines a callback called when texture is loaded
  12200. * @param onError defines a callback called if there is an error
  12201. * @returns the cube texture as an InternalTexture
  12202. */
  12203. 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;
  12204. /**
  12205. * Creates a new raw cube texture from a specified url
  12206. * @param url defines the url where the data is located
  12207. * @param scene defines the current scene
  12208. * @param size defines the size of the textures
  12209. * @param format defines the format of the data
  12210. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12211. * @param noMipmap defines if the engine should avoid generating the mip levels
  12212. * @param callback defines a callback used to extract texture data from loaded data
  12213. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12214. * @param onLoad defines a callback called when texture is loaded
  12215. * @param onError defines a callback called if there is an error
  12216. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12217. * @param invertY defines if data must be stored with Y axis inverted
  12218. * @returns the cube texture as an InternalTexture
  12219. */
  12220. 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;
  12221. /**
  12222. * Creates a new raw 3D texture
  12223. * @param data defines the data used to create the texture
  12224. * @param width defines the width of the texture
  12225. * @param height defines the height of the texture
  12226. * @param depth defines the depth of the texture
  12227. * @param format defines the format of the texture
  12228. * @param generateMipMaps defines if the engine must generate mip levels
  12229. * @param invertY defines if data must be stored with Y axis inverted
  12230. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12231. * @param compression defines the compressed used (can be null)
  12232. * @param textureType defines the compressed used (can be null)
  12233. * @returns a new raw 3D texture (stored in an InternalTexture)
  12234. */
  12235. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12236. /**
  12237. * Update a raw 3D texture
  12238. * @param texture defines the texture to update
  12239. * @param data defines the data to store
  12240. * @param format defines the data format
  12241. * @param invertY defines if data must be stored with Y axis inverted
  12242. */
  12243. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12244. /**
  12245. * Update a raw 3D texture
  12246. * @param texture defines the texture to update
  12247. * @param data defines the data to store
  12248. * @param format defines the data format
  12249. * @param invertY defines if data must be stored with Y axis inverted
  12250. * @param compression defines the used compression (can be null)
  12251. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12252. */
  12253. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12254. }
  12255. }
  12256. declare module BABYLON {
  12257. /**
  12258. * Raw texture can help creating a texture directly from an array of data.
  12259. * This can be super useful if you either get the data from an uncompressed source or
  12260. * if you wish to create your texture pixel by pixel.
  12261. */
  12262. export class RawTexture extends Texture {
  12263. /**
  12264. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12265. */
  12266. format: number;
  12267. private _engine;
  12268. /**
  12269. * Instantiates a new RawTexture.
  12270. * Raw texture can help creating a texture directly from an array of data.
  12271. * This can be super useful if you either get the data from an uncompressed source or
  12272. * if you wish to create your texture pixel by pixel.
  12273. * @param data define the array of data to use to create the texture
  12274. * @param width define the width of the texture
  12275. * @param height define the height of the texture
  12276. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12277. * @param scene define the scene the texture belongs to
  12278. * @param generateMipMaps define whether mip maps should be generated or not
  12279. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12280. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12281. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12282. */
  12283. constructor(data: ArrayBufferView, width: number, height: number,
  12284. /**
  12285. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12286. */
  12287. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12288. /**
  12289. * Updates the texture underlying data.
  12290. * @param data Define the new data of the texture
  12291. */
  12292. update(data: ArrayBufferView): void;
  12293. /**
  12294. * Creates a luminance texture from some data.
  12295. * @param data Define the texture data
  12296. * @param width Define the width of the texture
  12297. * @param height Define the height of the texture
  12298. * @param scene Define the scene the texture belongs to
  12299. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12302. * @returns the luminance texture
  12303. */
  12304. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12305. /**
  12306. * Creates a luminance alpha texture from some data.
  12307. * @param data Define the texture data
  12308. * @param width Define the width of the texture
  12309. * @param height Define the height of the texture
  12310. * @param scene Define the scene the texture belongs to
  12311. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12314. * @returns the luminance alpha texture
  12315. */
  12316. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12317. /**
  12318. * Creates an alpha texture from some data.
  12319. * @param data Define the texture data
  12320. * @param width Define the width of the texture
  12321. * @param height Define the height of the texture
  12322. * @param scene Define the scene the texture belongs to
  12323. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12324. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12325. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12326. * @returns the alpha texture
  12327. */
  12328. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12329. /**
  12330. * Creates a RGB texture from some data.
  12331. * @param data Define the texture data
  12332. * @param width Define the width of the texture
  12333. * @param height Define the height of the texture
  12334. * @param scene Define the scene the texture belongs to
  12335. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12336. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12337. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12338. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12339. * @returns the RGB alpha texture
  12340. */
  12341. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12342. /**
  12343. * Creates a RGBA texture from some data.
  12344. * @param data Define the texture data
  12345. * @param width Define the width of the texture
  12346. * @param height Define the height of the texture
  12347. * @param scene Define the scene the texture belongs to
  12348. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12349. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12350. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12351. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12352. * @returns the RGBA texture
  12353. */
  12354. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12355. /**
  12356. * Creates a R texture from some data.
  12357. * @param data Define the texture data
  12358. * @param width Define the width of the texture
  12359. * @param height Define the height of the texture
  12360. * @param scene Define the scene the texture belongs to
  12361. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12362. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12363. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12364. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12365. * @returns the R texture
  12366. */
  12367. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12368. }
  12369. }
  12370. declare module BABYLON {
  12371. /**
  12372. * Interface for the size containing width and height
  12373. */
  12374. export interface ISize {
  12375. /**
  12376. * Width
  12377. */
  12378. width: number;
  12379. /**
  12380. * Heighht
  12381. */
  12382. height: number;
  12383. }
  12384. /**
  12385. * Size containing widht and height
  12386. */
  12387. export class Size implements ISize {
  12388. /**
  12389. * Width
  12390. */
  12391. width: number;
  12392. /**
  12393. * Height
  12394. */
  12395. height: number;
  12396. /**
  12397. * Creates a Size object from the given width and height (floats).
  12398. * @param width width of the new size
  12399. * @param height height of the new size
  12400. */
  12401. constructor(width: number, height: number);
  12402. /**
  12403. * Returns a string with the Size width and height
  12404. * @returns a string with the Size width and height
  12405. */
  12406. toString(): string;
  12407. /**
  12408. * "Size"
  12409. * @returns the string "Size"
  12410. */
  12411. getClassName(): string;
  12412. /**
  12413. * Returns the Size hash code.
  12414. * @returns a hash code for a unique width and height
  12415. */
  12416. getHashCode(): number;
  12417. /**
  12418. * Updates the current size from the given one.
  12419. * @param src the given size
  12420. */
  12421. copyFrom(src: Size): void;
  12422. /**
  12423. * Updates in place the current Size from the given floats.
  12424. * @param width width of the new size
  12425. * @param height height of the new size
  12426. * @returns the updated Size.
  12427. */
  12428. copyFromFloats(width: number, height: number): Size;
  12429. /**
  12430. * Updates in place the current Size from the given floats.
  12431. * @param width width to set
  12432. * @param height height to set
  12433. * @returns the updated Size.
  12434. */
  12435. set(width: number, height: number): Size;
  12436. /**
  12437. * Multiplies the width and height by numbers
  12438. * @param w factor to multiple the width by
  12439. * @param h factor to multiple the height by
  12440. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12441. */
  12442. multiplyByFloats(w: number, h: number): Size;
  12443. /**
  12444. * Clones the size
  12445. * @returns a new Size copied from the given one.
  12446. */
  12447. clone(): Size;
  12448. /**
  12449. * True if the current Size and the given one width and height are strictly equal.
  12450. * @param other the other size to compare against
  12451. * @returns True if the current Size and the given one width and height are strictly equal.
  12452. */
  12453. equals(other: Size): boolean;
  12454. /**
  12455. * The surface of the Size : width * height (float).
  12456. */
  12457. readonly surface: number;
  12458. /**
  12459. * Create a new size of zero
  12460. * @returns a new Size set to (0.0, 0.0)
  12461. */
  12462. static Zero(): Size;
  12463. /**
  12464. * Sums the width and height of two sizes
  12465. * @param otherSize size to add to this size
  12466. * @returns a new Size set as the addition result of the current Size and the given one.
  12467. */
  12468. add(otherSize: Size): Size;
  12469. /**
  12470. * Subtracts the width and height of two
  12471. * @param otherSize size to subtract to this size
  12472. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12473. */
  12474. subtract(otherSize: Size): Size;
  12475. /**
  12476. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12477. * @param start starting size to lerp between
  12478. * @param end end size to lerp between
  12479. * @param amount amount to lerp between the start and end values
  12480. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12481. */
  12482. static Lerp(start: Size, end: Size, amount: number): Size;
  12483. }
  12484. }
  12485. declare module BABYLON {
  12486. /**
  12487. * Defines a runtime animation
  12488. */
  12489. export class RuntimeAnimation {
  12490. private _events;
  12491. /**
  12492. * The current frame of the runtime animation
  12493. */
  12494. private _currentFrame;
  12495. /**
  12496. * The animation used by the runtime animation
  12497. */
  12498. private _animation;
  12499. /**
  12500. * The target of the runtime animation
  12501. */
  12502. private _target;
  12503. /**
  12504. * The initiating animatable
  12505. */
  12506. private _host;
  12507. /**
  12508. * The original value of the runtime animation
  12509. */
  12510. private _originalValue;
  12511. /**
  12512. * The original blend value of the runtime animation
  12513. */
  12514. private _originalBlendValue;
  12515. /**
  12516. * The offsets cache of the runtime animation
  12517. */
  12518. private _offsetsCache;
  12519. /**
  12520. * The high limits cache of the runtime animation
  12521. */
  12522. private _highLimitsCache;
  12523. /**
  12524. * Specifies if the runtime animation has been stopped
  12525. */
  12526. private _stopped;
  12527. /**
  12528. * The blending factor of the runtime animation
  12529. */
  12530. private _blendingFactor;
  12531. /**
  12532. * The BabylonJS scene
  12533. */
  12534. private _scene;
  12535. /**
  12536. * The current value of the runtime animation
  12537. */
  12538. private _currentValue;
  12539. /** @hidden */ private _animationState: _IAnimationState;
  12540. /**
  12541. * The active target of the runtime animation
  12542. */
  12543. private _activeTargets;
  12544. private _currentActiveTarget;
  12545. private _directTarget;
  12546. /**
  12547. * The target path of the runtime animation
  12548. */
  12549. private _targetPath;
  12550. /**
  12551. * The weight of the runtime animation
  12552. */
  12553. private _weight;
  12554. /**
  12555. * The ratio offset of the runtime animation
  12556. */
  12557. private _ratioOffset;
  12558. /**
  12559. * The previous delay of the runtime animation
  12560. */
  12561. private _previousDelay;
  12562. /**
  12563. * The previous ratio of the runtime animation
  12564. */
  12565. private _previousRatio;
  12566. private _enableBlending;
  12567. private _keys;
  12568. private _minFrame;
  12569. private _maxFrame;
  12570. private _minValue;
  12571. private _maxValue;
  12572. private _targetIsArray;
  12573. /**
  12574. * Gets the current frame of the runtime animation
  12575. */
  12576. readonly currentFrame: number;
  12577. /**
  12578. * Gets the weight of the runtime animation
  12579. */
  12580. readonly weight: number;
  12581. /**
  12582. * Gets the current value of the runtime animation
  12583. */
  12584. readonly currentValue: any;
  12585. /**
  12586. * Gets the target path of the runtime animation
  12587. */
  12588. readonly targetPath: string;
  12589. /**
  12590. * Gets the actual target of the runtime animation
  12591. */
  12592. readonly target: any;
  12593. /** @hidden */ private _onLoop: () => void;
  12594. /**
  12595. * Create a new RuntimeAnimation object
  12596. * @param target defines the target of the animation
  12597. * @param animation defines the source animation object
  12598. * @param scene defines the hosting scene
  12599. * @param host defines the initiating Animatable
  12600. */
  12601. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12602. private _preparePath;
  12603. /**
  12604. * Gets the animation from the runtime animation
  12605. */
  12606. readonly animation: Animation;
  12607. /**
  12608. * Resets the runtime animation to the beginning
  12609. * @param restoreOriginal defines whether to restore the target property to the original value
  12610. */
  12611. reset(restoreOriginal?: boolean): void;
  12612. /**
  12613. * Specifies if the runtime animation is stopped
  12614. * @returns Boolean specifying if the runtime animation is stopped
  12615. */
  12616. isStopped(): boolean;
  12617. /**
  12618. * Disposes of the runtime animation
  12619. */
  12620. dispose(): void;
  12621. /**
  12622. * Apply the interpolated value to the target
  12623. * @param currentValue defines the value computed by the animation
  12624. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12625. */
  12626. setValue(currentValue: any, weight: number): void;
  12627. private _getOriginalValues;
  12628. private _setValue;
  12629. /**
  12630. * Gets the loop pmode of the runtime animation
  12631. * @returns Loop Mode
  12632. */
  12633. private _getCorrectLoopMode;
  12634. /**
  12635. * Move the current animation to a given frame
  12636. * @param frame defines the frame to move to
  12637. */
  12638. goToFrame(frame: number): void;
  12639. /**
  12640. * @hidden Internal use only
  12641. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12642. /**
  12643. * Execute the current animation
  12644. * @param delay defines the delay to add to the current frame
  12645. * @param from defines the lower bound of the animation range
  12646. * @param to defines the upper bound of the animation range
  12647. * @param loop defines if the current animation must loop
  12648. * @param speedRatio defines the current speed ratio
  12649. * @param weight defines the weight of the animation (default is -1 so no weight)
  12650. * @param onLoop optional callback called when animation loops
  12651. * @returns a boolean indicating if the animation is running
  12652. */
  12653. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12654. }
  12655. }
  12656. declare module BABYLON {
  12657. /**
  12658. * Class used to store an actual running animation
  12659. */
  12660. export class Animatable {
  12661. /** defines the target object */
  12662. target: any;
  12663. /** defines the starting frame number (default is 0) */
  12664. fromFrame: number;
  12665. /** defines the ending frame number (default is 100) */
  12666. toFrame: number;
  12667. /** defines if the animation must loop (default is false) */
  12668. loopAnimation: boolean;
  12669. /** defines a callback to call when animation ends if it is not looping */
  12670. onAnimationEnd?: (() => void) | null | undefined;
  12671. /** defines a callback to call when animation loops */
  12672. onAnimationLoop?: (() => void) | null | undefined;
  12673. private _localDelayOffset;
  12674. private _pausedDelay;
  12675. private _runtimeAnimations;
  12676. private _paused;
  12677. private _scene;
  12678. private _speedRatio;
  12679. private _weight;
  12680. private _syncRoot;
  12681. /**
  12682. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12683. * This will only apply for non looping animation (default is true)
  12684. */
  12685. disposeOnEnd: boolean;
  12686. /**
  12687. * Gets a boolean indicating if the animation has started
  12688. */
  12689. animationStarted: boolean;
  12690. /**
  12691. * Observer raised when the animation ends
  12692. */
  12693. onAnimationEndObservable: Observable<Animatable>;
  12694. /**
  12695. * Observer raised when the animation loops
  12696. */
  12697. onAnimationLoopObservable: Observable<Animatable>;
  12698. /**
  12699. * Gets the root Animatable used to synchronize and normalize animations
  12700. */
  12701. readonly syncRoot: Nullable<Animatable>;
  12702. /**
  12703. * Gets the current frame of the first RuntimeAnimation
  12704. * Used to synchronize Animatables
  12705. */
  12706. readonly masterFrame: number;
  12707. /**
  12708. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12709. */
  12710. weight: number;
  12711. /**
  12712. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12713. */
  12714. speedRatio: number;
  12715. /**
  12716. * Creates a new Animatable
  12717. * @param scene defines the hosting scene
  12718. * @param target defines the target object
  12719. * @param fromFrame defines the starting frame number (default is 0)
  12720. * @param toFrame defines the ending frame number (default is 100)
  12721. * @param loopAnimation defines if the animation must loop (default is false)
  12722. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12723. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12724. * @param animations defines a group of animation to add to the new Animatable
  12725. * @param onAnimationLoop defines a callback to call when animation loops
  12726. */
  12727. constructor(scene: Scene,
  12728. /** defines the target object */
  12729. target: any,
  12730. /** defines the starting frame number (default is 0) */
  12731. fromFrame?: number,
  12732. /** defines the ending frame number (default is 100) */
  12733. toFrame?: number,
  12734. /** defines if the animation must loop (default is false) */
  12735. loopAnimation?: boolean, speedRatio?: number,
  12736. /** defines a callback to call when animation ends if it is not looping */
  12737. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12738. /** defines a callback to call when animation loops */
  12739. onAnimationLoop?: (() => void) | null | undefined);
  12740. /**
  12741. * Synchronize and normalize current Animatable with a source Animatable
  12742. * This is useful when using animation weights and when animations are not of the same length
  12743. * @param root defines the root Animatable to synchronize with
  12744. * @returns the current Animatable
  12745. */
  12746. syncWith(root: Animatable): Animatable;
  12747. /**
  12748. * Gets the list of runtime animations
  12749. * @returns an array of RuntimeAnimation
  12750. */
  12751. getAnimations(): RuntimeAnimation[];
  12752. /**
  12753. * Adds more animations to the current animatable
  12754. * @param target defines the target of the animations
  12755. * @param animations defines the new animations to add
  12756. */
  12757. appendAnimations(target: any, animations: Animation[]): void;
  12758. /**
  12759. * Gets the source animation for a specific property
  12760. * @param property defines the propertyu to look for
  12761. * @returns null or the source animation for the given property
  12762. */
  12763. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12764. /**
  12765. * Gets the runtime animation for a specific property
  12766. * @param property defines the propertyu to look for
  12767. * @returns null or the runtime animation for the given property
  12768. */
  12769. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12770. /**
  12771. * Resets the animatable to its original state
  12772. */
  12773. reset(): void;
  12774. /**
  12775. * Allows the animatable to blend with current running animations
  12776. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12777. * @param blendingSpeed defines the blending speed to use
  12778. */
  12779. enableBlending(blendingSpeed: number): void;
  12780. /**
  12781. * Disable animation blending
  12782. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12783. */
  12784. disableBlending(): void;
  12785. /**
  12786. * Jump directly to a given frame
  12787. * @param frame defines the frame to jump to
  12788. */
  12789. goToFrame(frame: number): void;
  12790. /**
  12791. * Pause the animation
  12792. */
  12793. pause(): void;
  12794. /**
  12795. * Restart the animation
  12796. */
  12797. restart(): void;
  12798. private _raiseOnAnimationEnd;
  12799. /**
  12800. * Stop and delete the current animation
  12801. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12802. * @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)
  12803. */
  12804. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12805. /**
  12806. * Wait asynchronously for the animation to end
  12807. * @returns a promise which will be fullfilled when the animation ends
  12808. */
  12809. waitAsync(): Promise<Animatable>;
  12810. /** @hidden */ private _animate(delay: number): boolean;
  12811. }
  12812. interface Scene {
  12813. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12814. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12815. totalWeight: number;
  12816. animations: RuntimeAnimation[];
  12817. originalValue: Matrix;
  12818. }): any;
  12819. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12820. totalWeight: number;
  12821. animations: RuntimeAnimation[];
  12822. originalValue: Quaternion;
  12823. }, refQuaternion: Quaternion): Quaternion;
  12824. /** @hidden */ private _processLateAnimationBindings(): void;
  12825. /**
  12826. * Will start the animation sequence of a given target
  12827. * @param target defines the target
  12828. * @param from defines from which frame should animation start
  12829. * @param to defines until which frame should animation run.
  12830. * @param weight defines the weight to apply to the animation (1.0 by default)
  12831. * @param loop defines if the animation loops
  12832. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12833. * @param onAnimationEnd defines the function to be executed when the animation ends
  12834. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12835. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12836. * @param onAnimationLoop defines the callback to call when an animation loops
  12837. * @returns the animatable object created for this animation
  12838. */
  12839. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12840. /**
  12841. * Will start the animation sequence of a given target
  12842. * @param target defines the target
  12843. * @param from defines from which frame should animation start
  12844. * @param to defines until which frame should animation run.
  12845. * @param loop defines if the animation loops
  12846. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12847. * @param onAnimationEnd defines the function to be executed when the animation ends
  12848. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12849. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12850. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12851. * @param onAnimationLoop defines the callback to call when an animation loops
  12852. * @returns the animatable object created for this animation
  12853. */
  12854. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12855. /**
  12856. * Will start the animation sequence of a given target and its hierarchy
  12857. * @param target defines the target
  12858. * @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.
  12859. * @param from defines from which frame should animation start
  12860. * @param to defines until which frame should animation run.
  12861. * @param loop defines if the animation loops
  12862. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12863. * @param onAnimationEnd defines the function to be executed when the animation ends
  12864. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12865. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12866. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12867. * @param onAnimationLoop defines the callback to call when an animation loops
  12868. * @returns the list of created animatables
  12869. */
  12870. 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[];
  12871. /**
  12872. * Begin a new animation on a given node
  12873. * @param target defines the target where the animation will take place
  12874. * @param animations defines the list of animations to start
  12875. * @param from defines the initial value
  12876. * @param to defines the final value
  12877. * @param loop defines if you want animation to loop (off by default)
  12878. * @param speedRatio defines the speed ratio to apply to all animations
  12879. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12880. * @param onAnimationLoop defines the callback to call when an animation loops
  12881. * @returns the list of created animatables
  12882. */
  12883. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12884. /**
  12885. * Begin a new animation on a given node and its hierarchy
  12886. * @param target defines the root node where the animation will take place
  12887. * @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.
  12888. * @param animations defines the list of animations to start
  12889. * @param from defines the initial value
  12890. * @param to defines the final value
  12891. * @param loop defines if you want animation to loop (off by default)
  12892. * @param speedRatio defines the speed ratio to apply to all animations
  12893. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12894. * @param onAnimationLoop defines the callback to call when an animation loops
  12895. * @returns the list of animatables created for all nodes
  12896. */
  12897. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12898. /**
  12899. * Gets the animatable associated with a specific target
  12900. * @param target defines the target of the animatable
  12901. * @returns the required animatable if found
  12902. */
  12903. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12904. /**
  12905. * Gets all animatables associated with a given target
  12906. * @param target defines the target to look animatables for
  12907. * @returns an array of Animatables
  12908. */
  12909. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12910. /**
  12911. * Stops and removes all animations that have been applied to the scene
  12912. */
  12913. stopAllAnimations(): void;
  12914. }
  12915. interface Bone {
  12916. /**
  12917. * Copy an animation range from another bone
  12918. * @param source defines the source bone
  12919. * @param rangeName defines the range name to copy
  12920. * @param frameOffset defines the frame offset
  12921. * @param rescaleAsRequired defines if rescaling must be applied if required
  12922. * @param skelDimensionsRatio defines the scaling ratio
  12923. * @returns true if operation was successful
  12924. */
  12925. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12926. }
  12927. }
  12928. declare module BABYLON {
  12929. /**
  12930. * Class used to override all child animations of a given target
  12931. */
  12932. export class AnimationPropertiesOverride {
  12933. /**
  12934. * Gets or sets a value indicating if animation blending must be used
  12935. */
  12936. enableBlending: boolean;
  12937. /**
  12938. * Gets or sets the blending speed to use when enableBlending is true
  12939. */
  12940. blendingSpeed: number;
  12941. /**
  12942. * Gets or sets the default loop mode to use
  12943. */
  12944. loopMode: number;
  12945. }
  12946. }
  12947. declare module BABYLON {
  12948. /**
  12949. * Class used to handle skinning animations
  12950. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12951. */
  12952. export class Skeleton implements IAnimatable {
  12953. /** defines the skeleton name */
  12954. name: string;
  12955. /** defines the skeleton Id */
  12956. id: string;
  12957. /**
  12958. * Defines the list of child bones
  12959. */
  12960. bones: Bone[];
  12961. /**
  12962. * Defines an estimate of the dimension of the skeleton at rest
  12963. */
  12964. dimensionsAtRest: Vector3;
  12965. /**
  12966. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12967. */
  12968. needInitialSkinMatrix: boolean;
  12969. /**
  12970. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12971. */
  12972. overrideMesh: Nullable<AbstractMesh>;
  12973. /**
  12974. * Gets the list of animations attached to this skeleton
  12975. */
  12976. animations: Array<Animation>;
  12977. private _scene;
  12978. private _isDirty;
  12979. private _transformMatrices;
  12980. private _transformMatrixTexture;
  12981. private _meshesWithPoseMatrix;
  12982. private _animatables;
  12983. private _identity;
  12984. private _synchronizedWithMesh;
  12985. private _ranges;
  12986. private _lastAbsoluteTransformsUpdateId;
  12987. private _canUseTextureForBones;
  12988. private _uniqueId;
  12989. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  12990. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  12991. /**
  12992. * Specifies if the skeleton should be serialized
  12993. */
  12994. doNotSerialize: boolean;
  12995. private _useTextureToStoreBoneMatrices;
  12996. /**
  12997. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  12998. * Please note that this option is not available if the hardware does not support it
  12999. */
  13000. useTextureToStoreBoneMatrices: boolean;
  13001. private _animationPropertiesOverride;
  13002. /**
  13003. * Gets or sets the animation properties override
  13004. */
  13005. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13006. /**
  13007. * List of inspectable custom properties (used by the Inspector)
  13008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13009. */
  13010. inspectableCustomProperties: IInspectable[];
  13011. /**
  13012. * An observable triggered before computing the skeleton's matrices
  13013. */
  13014. onBeforeComputeObservable: Observable<Skeleton>;
  13015. /**
  13016. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13017. */
  13018. readonly isUsingTextureForMatrices: boolean;
  13019. /**
  13020. * Gets the unique ID of this skeleton
  13021. */
  13022. readonly uniqueId: number;
  13023. /**
  13024. * Creates a new skeleton
  13025. * @param name defines the skeleton name
  13026. * @param id defines the skeleton Id
  13027. * @param scene defines the hosting scene
  13028. */
  13029. constructor(
  13030. /** defines the skeleton name */
  13031. name: string,
  13032. /** defines the skeleton Id */
  13033. id: string, scene: Scene);
  13034. /**
  13035. * Gets the current object class name.
  13036. * @return the class name
  13037. */
  13038. getClassName(): string;
  13039. /**
  13040. * Returns an array containing the root bones
  13041. * @returns an array containing the root bones
  13042. */
  13043. getChildren(): Array<Bone>;
  13044. /**
  13045. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13046. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13047. * @returns a Float32Array containing matrices data
  13048. */
  13049. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13050. /**
  13051. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13052. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13053. * @returns a raw texture containing the data
  13054. */
  13055. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13056. /**
  13057. * Gets the current hosting scene
  13058. * @returns a scene object
  13059. */
  13060. getScene(): Scene;
  13061. /**
  13062. * Gets a string representing the current skeleton data
  13063. * @param fullDetails defines a boolean indicating if we want a verbose version
  13064. * @returns a string representing the current skeleton data
  13065. */
  13066. toString(fullDetails?: boolean): string;
  13067. /**
  13068. * Get bone's index searching by name
  13069. * @param name defines bone's name to search for
  13070. * @return the indice of the bone. Returns -1 if not found
  13071. */
  13072. getBoneIndexByName(name: string): number;
  13073. /**
  13074. * Creater a new animation range
  13075. * @param name defines the name of the range
  13076. * @param from defines the start key
  13077. * @param to defines the end key
  13078. */
  13079. createAnimationRange(name: string, from: number, to: number): void;
  13080. /**
  13081. * Delete a specific animation range
  13082. * @param name defines the name of the range
  13083. * @param deleteFrames defines if frames must be removed as well
  13084. */
  13085. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13086. /**
  13087. * Gets a specific animation range
  13088. * @param name defines the name of the range to look for
  13089. * @returns the requested animation range or null if not found
  13090. */
  13091. getAnimationRange(name: string): Nullable<AnimationRange>;
  13092. /**
  13093. * Gets the list of all animation ranges defined on this skeleton
  13094. * @returns an array
  13095. */
  13096. getAnimationRanges(): Nullable<AnimationRange>[];
  13097. /**
  13098. * Copy animation range from a source skeleton.
  13099. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13100. * @param source defines the source skeleton
  13101. * @param name defines the name of the range to copy
  13102. * @param rescaleAsRequired defines if rescaling must be applied if required
  13103. * @returns true if operation was successful
  13104. */
  13105. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13106. /**
  13107. * Forces the skeleton to go to rest pose
  13108. */
  13109. returnToRest(): void;
  13110. private _getHighestAnimationFrame;
  13111. /**
  13112. * Begin a specific animation range
  13113. * @param name defines the name of the range to start
  13114. * @param loop defines if looping must be turned on (false by default)
  13115. * @param speedRatio defines the speed ratio to apply (1 by default)
  13116. * @param onAnimationEnd defines a callback which will be called when animation will end
  13117. * @returns a new animatable
  13118. */
  13119. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13120. /** @hidden */ private _markAsDirty(): void;
  13121. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13122. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13123. private _computeTransformMatrices;
  13124. /**
  13125. * Build all resources required to render a skeleton
  13126. */
  13127. prepare(): void;
  13128. /**
  13129. * Gets the list of animatables currently running for this skeleton
  13130. * @returns an array of animatables
  13131. */
  13132. getAnimatables(): IAnimatable[];
  13133. /**
  13134. * Clone the current skeleton
  13135. * @param name defines the name of the new skeleton
  13136. * @param id defines the id of the new skeleton
  13137. * @returns the new skeleton
  13138. */
  13139. clone(name: string, id: string): Skeleton;
  13140. /**
  13141. * Enable animation blending for this skeleton
  13142. * @param blendingSpeed defines the blending speed to apply
  13143. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13144. */
  13145. enableBlending(blendingSpeed?: number): void;
  13146. /**
  13147. * Releases all resources associated with the current skeleton
  13148. */
  13149. dispose(): void;
  13150. /**
  13151. * Serialize the skeleton in a JSON object
  13152. * @returns a JSON object
  13153. */
  13154. serialize(): any;
  13155. /**
  13156. * Creates a new skeleton from serialized data
  13157. * @param parsedSkeleton defines the serialized data
  13158. * @param scene defines the hosting scene
  13159. * @returns a new skeleton
  13160. */
  13161. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13162. /**
  13163. * Compute all node absolute transforms
  13164. * @param forceUpdate defines if computation must be done even if cache is up to date
  13165. */
  13166. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13167. /**
  13168. * Gets the root pose matrix
  13169. * @returns a matrix
  13170. */
  13171. getPoseMatrix(): Nullable<Matrix>;
  13172. /**
  13173. * Sorts bones per internal index
  13174. */
  13175. sortBones(): void;
  13176. private _sortBones;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * Class used to store bone information
  13182. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13183. */
  13184. export class Bone extends Node {
  13185. /**
  13186. * defines the bone name
  13187. */
  13188. name: string;
  13189. private static _tmpVecs;
  13190. private static _tmpQuat;
  13191. private static _tmpMats;
  13192. /**
  13193. * Gets the list of child bones
  13194. */
  13195. children: Bone[];
  13196. /** Gets the animations associated with this bone */
  13197. animations: Animation[];
  13198. /**
  13199. * Gets or sets bone length
  13200. */
  13201. length: number;
  13202. /**
  13203. * @hidden Internal only
  13204. * Set this value to map this bone to a different index in the transform matrices
  13205. * Set this value to -1 to exclude the bone from the transform matrices
  13206. */ private _index: Nullable<number>;
  13207. private _skeleton;
  13208. private _localMatrix;
  13209. private _restPose;
  13210. private _baseMatrix;
  13211. private _absoluteTransform;
  13212. private _invertedAbsoluteTransform;
  13213. private _parent;
  13214. private _scalingDeterminant;
  13215. private _worldTransform;
  13216. private _localScaling;
  13217. private _localRotation;
  13218. private _localPosition;
  13219. private _needToDecompose;
  13220. private _needToCompose;
  13221. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13222. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13223. /** @hidden */
  13224. /** @hidden */ private _matrix: Matrix;
  13225. /**
  13226. * Create a new bone
  13227. * @param name defines the bone name
  13228. * @param skeleton defines the parent skeleton
  13229. * @param parentBone defines the parent (can be null if the bone is the root)
  13230. * @param localMatrix defines the local matrix
  13231. * @param restPose defines the rest pose matrix
  13232. * @param baseMatrix defines the base matrix
  13233. * @param index defines index of the bone in the hiearchy
  13234. */
  13235. constructor(
  13236. /**
  13237. * defines the bone name
  13238. */
  13239. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13240. /**
  13241. * Gets the current object class name.
  13242. * @return the class name
  13243. */
  13244. getClassName(): string;
  13245. /**
  13246. * Gets the parent skeleton
  13247. * @returns a skeleton
  13248. */
  13249. getSkeleton(): Skeleton;
  13250. /**
  13251. * Gets parent bone
  13252. * @returns a bone or null if the bone is the root of the bone hierarchy
  13253. */
  13254. getParent(): Nullable<Bone>;
  13255. /**
  13256. * Returns an array containing the root bones
  13257. * @returns an array containing the root bones
  13258. */
  13259. getChildren(): Array<Bone>;
  13260. /**
  13261. * Sets the parent bone
  13262. * @param parent defines the parent (can be null if the bone is the root)
  13263. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13264. */
  13265. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13266. /**
  13267. * Gets the local matrix
  13268. * @returns a matrix
  13269. */
  13270. getLocalMatrix(): Matrix;
  13271. /**
  13272. * Gets the base matrix (initial matrix which remains unchanged)
  13273. * @returns a matrix
  13274. */
  13275. getBaseMatrix(): Matrix;
  13276. /**
  13277. * Gets the rest pose matrix
  13278. * @returns a matrix
  13279. */
  13280. getRestPose(): Matrix;
  13281. /**
  13282. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13283. */
  13284. getWorldMatrix(): Matrix;
  13285. /**
  13286. * Sets the local matrix to rest pose matrix
  13287. */
  13288. returnToRest(): void;
  13289. /**
  13290. * Gets the inverse of the absolute transform matrix.
  13291. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13292. * @returns a matrix
  13293. */
  13294. getInvertedAbsoluteTransform(): Matrix;
  13295. /**
  13296. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13297. * @returns a matrix
  13298. */
  13299. getAbsoluteTransform(): Matrix;
  13300. /**
  13301. * Links with the given transform node.
  13302. * The local matrix of this bone is copied from the transform node every frame.
  13303. * @param transformNode defines the transform node to link to
  13304. */
  13305. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13306. /**
  13307. * Gets the node used to drive the bone's transformation
  13308. * @returns a transform node or null
  13309. */
  13310. getTransformNode(): Nullable<TransformNode>;
  13311. /** Gets or sets current position (in local space) */
  13312. position: Vector3;
  13313. /** Gets or sets current rotation (in local space) */
  13314. rotation: Vector3;
  13315. /** Gets or sets current rotation quaternion (in local space) */
  13316. rotationQuaternion: Quaternion;
  13317. /** Gets or sets current scaling (in local space) */
  13318. scaling: Vector3;
  13319. /**
  13320. * Gets the animation properties override
  13321. */
  13322. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13323. private _decompose;
  13324. private _compose;
  13325. /**
  13326. * Update the base and local matrices
  13327. * @param matrix defines the new base or local matrix
  13328. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13329. * @param updateLocalMatrix defines if the local matrix should be updated
  13330. */
  13331. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13332. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13333. /**
  13334. * Flag the bone as dirty (Forcing it to update everything)
  13335. */
  13336. markAsDirty(): void;
  13337. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13338. private _markAsDirtyAndDecompose;
  13339. /**
  13340. * Translate the bone in local or world space
  13341. * @param vec The amount to translate the bone
  13342. * @param space The space that the translation is in
  13343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13344. */
  13345. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13346. /**
  13347. * Set the postion of the bone in local or world space
  13348. * @param position The position to set the bone
  13349. * @param space The space that the position is in
  13350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13351. */
  13352. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13353. /**
  13354. * Set the absolute position of the bone (world space)
  13355. * @param position The position to set the bone
  13356. * @param mesh The mesh that this bone is attached to
  13357. */
  13358. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13359. /**
  13360. * Scale the bone on the x, y and z axes (in local space)
  13361. * @param x The amount to scale the bone on the x axis
  13362. * @param y The amount to scale the bone on the y axis
  13363. * @param z The amount to scale the bone on the z axis
  13364. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13365. */
  13366. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13367. /**
  13368. * Set the bone scaling in local space
  13369. * @param scale defines the scaling vector
  13370. */
  13371. setScale(scale: Vector3): void;
  13372. /**
  13373. * Gets the current scaling in local space
  13374. * @returns the current scaling vector
  13375. */
  13376. getScale(): Vector3;
  13377. /**
  13378. * Gets the current scaling in local space and stores it in a target vector
  13379. * @param result defines the target vector
  13380. */
  13381. getScaleToRef(result: Vector3): void;
  13382. /**
  13383. * Set the yaw, pitch, and roll of the bone in local or world space
  13384. * @param yaw The rotation of the bone on the y axis
  13385. * @param pitch The rotation of the bone on the x axis
  13386. * @param roll The rotation of the bone on the z axis
  13387. * @param space The space that the axes of rotation are in
  13388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13389. */
  13390. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13391. /**
  13392. * Add a rotation to the bone on an axis in local or world space
  13393. * @param axis The axis to rotate the bone on
  13394. * @param amount The amount to rotate the bone
  13395. * @param space The space that the axis is in
  13396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13397. */
  13398. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13399. /**
  13400. * Set the rotation of the bone to a particular axis angle in local or world space
  13401. * @param axis The axis to rotate the bone on
  13402. * @param angle The angle that the bone should be rotated to
  13403. * @param space The space that the axis is in
  13404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13405. */
  13406. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13407. /**
  13408. * Set the euler rotation of the bone in local of world space
  13409. * @param rotation The euler rotation that the bone should be set to
  13410. * @param space The space that the rotation is in
  13411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13412. */
  13413. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13414. /**
  13415. * Set the quaternion rotation of the bone in local of world space
  13416. * @param quat The quaternion rotation that the bone should be set to
  13417. * @param space The space that the rotation is in
  13418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13419. */
  13420. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13421. /**
  13422. * Set the rotation matrix of the bone in local of world space
  13423. * @param rotMat The rotation matrix that the bone should be set to
  13424. * @param space The space that the rotation is in
  13425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13426. */
  13427. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13428. private _rotateWithMatrix;
  13429. private _getNegativeRotationToRef;
  13430. /**
  13431. * Get the position of the bone in local or world space
  13432. * @param space The space that the returned position is in
  13433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13434. * @returns The position of the bone
  13435. */
  13436. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13437. /**
  13438. * Copy the position of the bone to a vector3 in local or world space
  13439. * @param space The space that the returned position is in
  13440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13441. * @param result The vector3 to copy the position to
  13442. */
  13443. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13444. /**
  13445. * Get the absolute position of the bone (world space)
  13446. * @param mesh The mesh that this bone is attached to
  13447. * @returns The absolute position of the bone
  13448. */
  13449. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13450. /**
  13451. * Copy the absolute position of the bone (world space) to the result param
  13452. * @param mesh The mesh that this bone is attached to
  13453. * @param result The vector3 to copy the absolute position to
  13454. */
  13455. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13456. /**
  13457. * Compute the absolute transforms of this bone and its children
  13458. */
  13459. computeAbsoluteTransforms(): void;
  13460. /**
  13461. * Get the world direction from an axis that is in the local space of the bone
  13462. * @param localAxis The local direction that is used to compute the world direction
  13463. * @param mesh The mesh that this bone is attached to
  13464. * @returns The world direction
  13465. */
  13466. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13467. /**
  13468. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13469. * @param localAxis The local direction that is used to compute the world direction
  13470. * @param mesh The mesh that this bone is attached to
  13471. * @param result The vector3 that the world direction will be copied to
  13472. */
  13473. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13474. /**
  13475. * Get the euler rotation of the bone in local or world space
  13476. * @param space The space that the rotation should be in
  13477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13478. * @returns The euler rotation
  13479. */
  13480. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13481. /**
  13482. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13483. * @param space The space that the rotation should be in
  13484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13485. * @param result The vector3 that the rotation should be copied to
  13486. */
  13487. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13488. /**
  13489. * Get the quaternion rotation of the bone in either local or world space
  13490. * @param space The space that the rotation should be in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. * @returns The quaternion rotation
  13493. */
  13494. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13495. /**
  13496. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13497. * @param space The space that the rotation should be in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. * @param result The quaternion that the rotation should be copied to
  13500. */
  13501. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13502. /**
  13503. * Get the rotation matrix of the bone in local or world space
  13504. * @param space The space that the rotation should be in
  13505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13506. * @returns The rotation matrix
  13507. */
  13508. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13509. /**
  13510. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13511. * @param space The space that the rotation should be in
  13512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13513. * @param result The quaternion that the rotation should be copied to
  13514. */
  13515. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13516. /**
  13517. * Get the world position of a point that is in the local space of the bone
  13518. * @param position The local position
  13519. * @param mesh The mesh that this bone is attached to
  13520. * @returns The world position
  13521. */
  13522. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13523. /**
  13524. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13525. * @param position The local position
  13526. * @param mesh The mesh that this bone is attached to
  13527. * @param result The vector3 that the world position should be copied to
  13528. */
  13529. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13530. /**
  13531. * Get the local position of a point that is in world space
  13532. * @param position The world position
  13533. * @param mesh The mesh that this bone is attached to
  13534. * @returns The local position
  13535. */
  13536. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13537. /**
  13538. * Get the local position of a point that is in world space and copy it to the result param
  13539. * @param position The world position
  13540. * @param mesh The mesh that this bone is attached to
  13541. * @param result The vector3 that the local position should be copied to
  13542. */
  13543. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13544. }
  13545. }
  13546. declare module BABYLON {
  13547. /**
  13548. * 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.
  13549. * @see https://doc.babylonjs.com/how_to/transformnode
  13550. */
  13551. export class TransformNode extends Node {
  13552. /**
  13553. * Object will not rotate to face the camera
  13554. */
  13555. static BILLBOARDMODE_NONE: number;
  13556. /**
  13557. * Object will rotate to face the camera but only on the x axis
  13558. */
  13559. static BILLBOARDMODE_X: number;
  13560. /**
  13561. * Object will rotate to face the camera but only on the y axis
  13562. */
  13563. static BILLBOARDMODE_Y: number;
  13564. /**
  13565. * Object will rotate to face the camera but only on the z axis
  13566. */
  13567. static BILLBOARDMODE_Z: number;
  13568. /**
  13569. * Object will rotate to face the camera
  13570. */
  13571. static BILLBOARDMODE_ALL: number;
  13572. /**
  13573. * Object will rotate to face the camera's position instead of orientation
  13574. */
  13575. static BILLBOARDMODE_USE_POSITION: number;
  13576. private _forward;
  13577. private _forwardInverted;
  13578. private _up;
  13579. private _right;
  13580. private _rightInverted;
  13581. private _position;
  13582. private _rotation;
  13583. private _rotationQuaternion;
  13584. protected _scaling: Vector3;
  13585. protected _isDirty: boolean;
  13586. private _transformToBoneReferal;
  13587. private _isAbsoluteSynced;
  13588. private _billboardMode;
  13589. /**
  13590. * Gets or sets the billboard mode. Default is 0.
  13591. *
  13592. * | Value | Type | Description |
  13593. * | --- | --- | --- |
  13594. * | 0 | BILLBOARDMODE_NONE | |
  13595. * | 1 | BILLBOARDMODE_X | |
  13596. * | 2 | BILLBOARDMODE_Y | |
  13597. * | 4 | BILLBOARDMODE_Z | |
  13598. * | 7 | BILLBOARDMODE_ALL | |
  13599. *
  13600. */
  13601. billboardMode: number;
  13602. private _preserveParentRotationForBillboard;
  13603. /**
  13604. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13605. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13606. */
  13607. preserveParentRotationForBillboard: boolean;
  13608. /**
  13609. * 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
  13610. */
  13611. scalingDeterminant: number;
  13612. private _infiniteDistance;
  13613. /**
  13614. * Gets or sets the distance of the object to max, often used by skybox
  13615. */
  13616. infiniteDistance: boolean;
  13617. /**
  13618. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13619. * By default the system will update normals to compensate
  13620. */
  13621. ignoreNonUniformScaling: boolean;
  13622. /**
  13623. * 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
  13624. */
  13625. reIntegrateRotationIntoRotationQuaternion: boolean;
  13626. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13627. /** @hidden */ private _localMatrix: Matrix;
  13628. private _usePivotMatrix;
  13629. private _absolutePosition;
  13630. private _absoluteScaling;
  13631. private _absoluteRotationQuaternion;
  13632. private _pivotMatrix;
  13633. private _pivotMatrixInverse;
  13634. protected _postMultiplyPivotMatrix: boolean;
  13635. protected _isWorldMatrixFrozen: boolean;
  13636. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13637. /**
  13638. * An event triggered after the world matrix is updated
  13639. */
  13640. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13641. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13642. /**
  13643. * Gets a string identifying the name of the class
  13644. * @returns "TransformNode" string
  13645. */
  13646. getClassName(): string;
  13647. /**
  13648. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13649. */
  13650. position: Vector3;
  13651. /**
  13652. * 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)).
  13653. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13654. */
  13655. rotation: Vector3;
  13656. /**
  13657. * 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)).
  13658. */
  13659. scaling: Vector3;
  13660. /**
  13661. * 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).
  13662. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13663. */
  13664. rotationQuaternion: Nullable<Quaternion>;
  13665. /**
  13666. * The forward direction of that transform in world space.
  13667. */
  13668. readonly forward: Vector3;
  13669. /**
  13670. * The up direction of that transform in world space.
  13671. */
  13672. readonly up: Vector3;
  13673. /**
  13674. * The right direction of that transform in world space.
  13675. */
  13676. readonly right: Vector3;
  13677. /**
  13678. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13679. * @param matrix the matrix to copy the pose from
  13680. * @returns this TransformNode.
  13681. */
  13682. updatePoseMatrix(matrix: Matrix): TransformNode;
  13683. /**
  13684. * Returns the mesh Pose matrix.
  13685. * @returns the pose matrix
  13686. */
  13687. getPoseMatrix(): Matrix;
  13688. /** @hidden */ private _isSynchronized(): boolean;
  13689. /** @hidden */ private _initCache(): void;
  13690. /**
  13691. * Flag the transform node as dirty (Forcing it to update everything)
  13692. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13693. * @returns this transform node
  13694. */
  13695. markAsDirty(property: string): TransformNode;
  13696. /**
  13697. * Returns the current mesh absolute position.
  13698. * Returns a Vector3.
  13699. */
  13700. readonly absolutePosition: Vector3;
  13701. /**
  13702. * Returns the current mesh absolute scaling.
  13703. * Returns a Vector3.
  13704. */
  13705. readonly absoluteScaling: Vector3;
  13706. /**
  13707. * Returns the current mesh absolute rotation.
  13708. * Returns a Quaternion.
  13709. */
  13710. readonly absoluteRotationQuaternion: Quaternion;
  13711. /**
  13712. * Sets a new matrix to apply before all other transformation
  13713. * @param matrix defines the transform matrix
  13714. * @returns the current TransformNode
  13715. */
  13716. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13717. /**
  13718. * Sets a new pivot matrix to the current node
  13719. * @param matrix defines the new pivot matrix to use
  13720. * @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
  13721. * @returns the current TransformNode
  13722. */
  13723. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13724. /**
  13725. * Returns the mesh pivot matrix.
  13726. * Default : Identity.
  13727. * @returns the matrix
  13728. */
  13729. getPivotMatrix(): Matrix;
  13730. /**
  13731. * Instantiate (when possible) or clone that node with its hierarchy
  13732. * @param newParent defines the new parent to use for the instance (or clone)
  13733. * @returns an instance (or a clone) of the current node with its hiearchy
  13734. */
  13735. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13736. /**
  13737. * Prevents the World matrix to be computed any longer
  13738. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13739. * @returns the TransformNode.
  13740. */
  13741. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13742. /**
  13743. * Allows back the World matrix computation.
  13744. * @returns the TransformNode.
  13745. */
  13746. unfreezeWorldMatrix(): this;
  13747. /**
  13748. * True if the World matrix has been frozen.
  13749. */
  13750. readonly isWorldMatrixFrozen: boolean;
  13751. /**
  13752. * Retuns the mesh absolute position in the World.
  13753. * @returns a Vector3.
  13754. */
  13755. getAbsolutePosition(): Vector3;
  13756. /**
  13757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13758. * @param absolutePosition the absolute position to set
  13759. * @returns the TransformNode.
  13760. */
  13761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13762. /**
  13763. * Sets the mesh position in its local space.
  13764. * @param vector3 the position to set in localspace
  13765. * @returns the TransformNode.
  13766. */
  13767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13768. /**
  13769. * Returns the mesh position in the local space from the current World matrix values.
  13770. * @returns a new Vector3.
  13771. */
  13772. getPositionExpressedInLocalSpace(): Vector3;
  13773. /**
  13774. * Translates the mesh along the passed Vector3 in its local space.
  13775. * @param vector3 the distance to translate in localspace
  13776. * @returns the TransformNode.
  13777. */
  13778. locallyTranslate(vector3: Vector3): TransformNode;
  13779. private static _lookAtVectorCache;
  13780. /**
  13781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13782. * @param targetPoint the position (must be in same space as current mesh) to look at
  13783. * @param yawCor optional yaw (y-axis) correction in radians
  13784. * @param pitchCor optional pitch (x-axis) correction in radians
  13785. * @param rollCor optional roll (z-axis) correction in radians
  13786. * @param space the choosen space of the target
  13787. * @returns the TransformNode.
  13788. */
  13789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13790. /**
  13791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13792. * This Vector3 is expressed in the World space.
  13793. * @param localAxis axis to rotate
  13794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13795. */
  13796. getDirection(localAxis: Vector3): Vector3;
  13797. /**
  13798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13799. * localAxis is expressed in the mesh local space.
  13800. * result is computed in the Wordl space from the mesh World matrix.
  13801. * @param localAxis axis to rotate
  13802. * @param result the resulting transformnode
  13803. * @returns this TransformNode.
  13804. */
  13805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13806. /**
  13807. * Sets this transform node rotation to the given local axis.
  13808. * @param localAxis the axis in local space
  13809. * @param yawCor optional yaw (y-axis) correction in radians
  13810. * @param pitchCor optional pitch (x-axis) correction in radians
  13811. * @param rollCor optional roll (z-axis) correction in radians
  13812. * @returns this TransformNode
  13813. */
  13814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13815. /**
  13816. * Sets a new pivot point to the current node
  13817. * @param point defines the new pivot point to use
  13818. * @param space defines if the point is in world or local space (local by default)
  13819. * @returns the current TransformNode
  13820. */
  13821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13822. /**
  13823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13824. * @returns the pivot point
  13825. */
  13826. getPivotPoint(): Vector3;
  13827. /**
  13828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13829. * @param result the vector3 to store the result
  13830. * @returns this TransformNode.
  13831. */
  13832. getPivotPointToRef(result: Vector3): TransformNode;
  13833. /**
  13834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13836. */
  13837. getAbsolutePivotPoint(): Vector3;
  13838. /**
  13839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13840. * @param result vector3 to store the result
  13841. * @returns this TransformNode.
  13842. */
  13843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13844. /**
  13845. * Defines the passed node as the parent of the current node.
  13846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13847. * @see https://doc.babylonjs.com/how_to/parenting
  13848. * @param node the node ot set as the parent
  13849. * @returns this TransformNode.
  13850. */
  13851. setParent(node: Nullable<Node>): TransformNode;
  13852. private _nonUniformScaling;
  13853. /**
  13854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13855. */
  13856. readonly nonUniformScaling: boolean;
  13857. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13858. /**
  13859. * Attach the current TransformNode to another TransformNode associated with a bone
  13860. * @param bone Bone affecting the TransformNode
  13861. * @param affectedTransformNode TransformNode associated with the bone
  13862. * @returns this object
  13863. */
  13864. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13865. /**
  13866. * Detach the transform node if its associated with a bone
  13867. * @returns this object
  13868. */
  13869. detachFromBone(): TransformNode;
  13870. private static _rotationAxisCache;
  13871. /**
  13872. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13873. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13874. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13875. * The passed axis is also normalized.
  13876. * @param axis the axis to rotate around
  13877. * @param amount the amount to rotate in radians
  13878. * @param space Space to rotate in (Default: local)
  13879. * @returns the TransformNode.
  13880. */
  13881. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13882. /**
  13883. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13885. * The passed axis is also normalized. .
  13886. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13887. * @param point the point to rotate around
  13888. * @param axis the axis to rotate around
  13889. * @param amount the amount to rotate in radians
  13890. * @returns the TransformNode
  13891. */
  13892. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13893. /**
  13894. * Translates the mesh along the axis vector for the passed distance in the given space.
  13895. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13896. * @param axis the axis to translate in
  13897. * @param distance the distance to translate
  13898. * @param space Space to rotate in (Default: local)
  13899. * @returns the TransformNode.
  13900. */
  13901. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13902. /**
  13903. * Adds a rotation step to the mesh current rotation.
  13904. * x, y, z are Euler angles expressed in radians.
  13905. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13906. * This means this rotation is made in the mesh local space only.
  13907. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13908. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13909. * ```javascript
  13910. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13911. * ```
  13912. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13913. * 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.
  13914. * @param x Rotation to add
  13915. * @param y Rotation to add
  13916. * @param z Rotation to add
  13917. * @returns the TransformNode.
  13918. */
  13919. addRotation(x: number, y: number, z: number): TransformNode;
  13920. /**
  13921. * @hidden
  13922. */
  13923. protected _getEffectiveParent(): Nullable<Node>;
  13924. /**
  13925. * Computes the world matrix of the node
  13926. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13927. * @returns the world matrix
  13928. */
  13929. computeWorldMatrix(force?: boolean): Matrix;
  13930. protected _afterComputeWorldMatrix(): void;
  13931. /**
  13932. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13933. * @param func callback function to add
  13934. *
  13935. * @returns the TransformNode.
  13936. */
  13937. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13938. /**
  13939. * Removes a registered callback function.
  13940. * @param func callback function to remove
  13941. * @returns the TransformNode.
  13942. */
  13943. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13944. /**
  13945. * Gets the position of the current mesh in camera space
  13946. * @param camera defines the camera to use
  13947. * @returns a position
  13948. */
  13949. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13950. /**
  13951. * Returns the distance from the mesh to the active camera
  13952. * @param camera defines the camera to use
  13953. * @returns the distance
  13954. */
  13955. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13956. /**
  13957. * Clone the current transform node
  13958. * @param name Name of the new clone
  13959. * @param newParent New parent for the clone
  13960. * @param doNotCloneChildren Do not clone children hierarchy
  13961. * @returns the new transform node
  13962. */
  13963. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13964. /**
  13965. * Serializes the objects information.
  13966. * @param currentSerializationObject defines the object to serialize in
  13967. * @returns the serialized object
  13968. */
  13969. serialize(currentSerializationObject?: any): any;
  13970. /**
  13971. * Returns a new TransformNode object parsed from the source provided.
  13972. * @param parsedTransformNode is the source.
  13973. * @param scene the scne the object belongs to
  13974. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13975. * @returns a new TransformNode object parsed from the source provided.
  13976. */
  13977. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13978. /**
  13979. * Get all child-transformNodes of this node
  13980. * @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
  13981. * @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
  13982. * @returns an array of TransformNode
  13983. */
  13984. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13985. /**
  13986. * Releases resources associated with this transform node.
  13987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13989. */
  13990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13991. /**
  13992. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13993. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13994. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13995. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13996. * @returns the current mesh
  13997. */
  13998. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13999. private _syncAbsoluteScalingAndRotation;
  14000. }
  14001. }
  14002. declare module BABYLON {
  14003. /**
  14004. * Defines the types of pose enabled controllers that are supported
  14005. */
  14006. export enum PoseEnabledControllerType {
  14007. /**
  14008. * HTC Vive
  14009. */
  14010. VIVE = 0,
  14011. /**
  14012. * Oculus Rift
  14013. */
  14014. OCULUS = 1,
  14015. /**
  14016. * Windows mixed reality
  14017. */
  14018. WINDOWS = 2,
  14019. /**
  14020. * Samsung gear VR
  14021. */
  14022. GEAR_VR = 3,
  14023. /**
  14024. * Google Daydream
  14025. */
  14026. DAYDREAM = 4,
  14027. /**
  14028. * Generic
  14029. */
  14030. GENERIC = 5
  14031. }
  14032. /**
  14033. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14034. */
  14035. export interface MutableGamepadButton {
  14036. /**
  14037. * Value of the button/trigger
  14038. */
  14039. value: number;
  14040. /**
  14041. * If the button/trigger is currently touched
  14042. */
  14043. touched: boolean;
  14044. /**
  14045. * If the button/trigger is currently pressed
  14046. */
  14047. pressed: boolean;
  14048. }
  14049. /**
  14050. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14051. * @hidden
  14052. */
  14053. export interface ExtendedGamepadButton extends GamepadButton {
  14054. /**
  14055. * If the button/trigger is currently pressed
  14056. */
  14057. readonly pressed: boolean;
  14058. /**
  14059. * If the button/trigger is currently touched
  14060. */
  14061. readonly touched: boolean;
  14062. /**
  14063. * Value of the button/trigger
  14064. */
  14065. readonly value: number;
  14066. }
  14067. /** @hidden */
  14068. export interface _GamePadFactory {
  14069. /**
  14070. * Returns wether or not the current gamepad can be created for this type of controller.
  14071. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14072. * @returns true if it can be created, otherwise false
  14073. */
  14074. canCreate(gamepadInfo: any): boolean;
  14075. /**
  14076. * Creates a new instance of the Gamepad.
  14077. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14078. * @returns the new gamepad instance
  14079. */
  14080. create(gamepadInfo: any): Gamepad;
  14081. }
  14082. /**
  14083. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14084. */
  14085. export class PoseEnabledControllerHelper {
  14086. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14087. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14088. /**
  14089. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14090. * @param vrGamepad the gamepad to initialized
  14091. * @returns a vr controller of the type the gamepad identified as
  14092. */
  14093. static InitiateController(vrGamepad: any): Gamepad;
  14094. }
  14095. /**
  14096. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14097. */
  14098. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14099. /**
  14100. * If the controller is used in a webXR session
  14101. */
  14102. isXR: boolean;
  14103. private _deviceRoomPosition;
  14104. private _deviceRoomRotationQuaternion;
  14105. /**
  14106. * The device position in babylon space
  14107. */
  14108. devicePosition: Vector3;
  14109. /**
  14110. * The device rotation in babylon space
  14111. */
  14112. deviceRotationQuaternion: Quaternion;
  14113. /**
  14114. * The scale factor of the device in babylon space
  14115. */
  14116. deviceScaleFactor: number;
  14117. /**
  14118. * (Likely devicePosition should be used instead) The device position in its room space
  14119. */
  14120. position: Vector3;
  14121. /**
  14122. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14123. */
  14124. rotationQuaternion: Quaternion;
  14125. /**
  14126. * The type of controller (Eg. Windows mixed reality)
  14127. */
  14128. controllerType: PoseEnabledControllerType;
  14129. protected _calculatedPosition: Vector3;
  14130. private _calculatedRotation;
  14131. /**
  14132. * The raw pose from the device
  14133. */
  14134. rawPose: DevicePose;
  14135. private _trackPosition;
  14136. private _maxRotationDistFromHeadset;
  14137. private _draggedRoomRotation;
  14138. /**
  14139. * @hidden
  14140. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14141. /**
  14142. * Internal, the mesh attached to the controller
  14143. * @hidden
  14144. */ private _mesh: Nullable<AbstractMesh>;
  14145. private _poseControlledCamera;
  14146. private _leftHandSystemQuaternion;
  14147. /**
  14148. * Internal, matrix used to convert room space to babylon space
  14149. * @hidden
  14150. */ private _deviceToWorld: Matrix;
  14151. /**
  14152. * Node to be used when casting a ray from the controller
  14153. * @hidden
  14154. */ private _pointingPoseNode: Nullable<TransformNode>;
  14155. /**
  14156. * Name of the child mesh that can be used to cast a ray from the controller
  14157. */
  14158. static readonly POINTING_POSE: string;
  14159. /**
  14160. * Creates a new PoseEnabledController from a gamepad
  14161. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14162. */
  14163. constructor(browserGamepad: any);
  14164. private _workingMatrix;
  14165. /**
  14166. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14167. */
  14168. update(): void;
  14169. /**
  14170. * Updates only the pose device and mesh without doing any button event checking
  14171. */
  14172. protected _updatePoseAndMesh(): void;
  14173. /**
  14174. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14175. * @param poseData raw pose fromthe device
  14176. */
  14177. updateFromDevice(poseData: DevicePose): void;
  14178. /**
  14179. * @hidden
  14180. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14181. /**
  14182. * Attaches a mesh to the controller
  14183. * @param mesh the mesh to be attached
  14184. */
  14185. attachToMesh(mesh: AbstractMesh): void;
  14186. /**
  14187. * Attaches the controllers mesh to a camera
  14188. * @param camera the camera the mesh should be attached to
  14189. */
  14190. attachToPoseControlledCamera(camera: TargetCamera): void;
  14191. /**
  14192. * Disposes of the controller
  14193. */
  14194. dispose(): void;
  14195. /**
  14196. * The mesh that is attached to the controller
  14197. */
  14198. readonly mesh: Nullable<AbstractMesh>;
  14199. /**
  14200. * Gets the ray of the controller in the direction the controller is pointing
  14201. * @param length the length the resulting ray should be
  14202. * @returns a ray in the direction the controller is pointing
  14203. */
  14204. getForwardRay(length?: number): Ray;
  14205. }
  14206. }
  14207. declare module BABYLON {
  14208. /**
  14209. * Defines the WebVRController object that represents controllers tracked in 3D space
  14210. */
  14211. export abstract class WebVRController extends PoseEnabledController {
  14212. /**
  14213. * Internal, the default controller model for the controller
  14214. */
  14215. protected _defaultModel: AbstractMesh;
  14216. /**
  14217. * Fired when the trigger state has changed
  14218. */
  14219. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14220. /**
  14221. * Fired when the main button state has changed
  14222. */
  14223. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14224. /**
  14225. * Fired when the secondary button state has changed
  14226. */
  14227. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14228. /**
  14229. * Fired when the pad state has changed
  14230. */
  14231. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14232. /**
  14233. * Fired when controllers stick values have changed
  14234. */
  14235. onPadValuesChangedObservable: Observable<StickValues>;
  14236. /**
  14237. * Array of button availible on the controller
  14238. */
  14239. protected _buttons: Array<MutableGamepadButton>;
  14240. private _onButtonStateChange;
  14241. /**
  14242. * Fired when a controller button's state has changed
  14243. * @param callback the callback containing the button that was modified
  14244. */
  14245. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14246. /**
  14247. * X and Y axis corresponding to the controllers joystick
  14248. */
  14249. pad: StickValues;
  14250. /**
  14251. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14252. */
  14253. hand: string;
  14254. /**
  14255. * The default controller model for the controller
  14256. */
  14257. readonly defaultModel: AbstractMesh;
  14258. /**
  14259. * Creates a new WebVRController from a gamepad
  14260. * @param vrGamepad the gamepad that the WebVRController should be created from
  14261. */
  14262. constructor(vrGamepad: any);
  14263. /**
  14264. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14265. */
  14266. update(): void;
  14267. /**
  14268. * Function to be called when a button is modified
  14269. */
  14270. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14271. /**
  14272. * Loads a mesh and attaches it to the controller
  14273. * @param scene the scene the mesh should be added to
  14274. * @param meshLoaded callback for when the mesh has been loaded
  14275. */
  14276. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14277. private _setButtonValue;
  14278. private _changes;
  14279. private _checkChanges;
  14280. /**
  14281. * Disposes of th webVRCOntroller
  14282. */
  14283. dispose(): void;
  14284. }
  14285. }
  14286. declare module BABYLON {
  14287. /**
  14288. * The HemisphericLight simulates the ambient environment light,
  14289. * so the passed direction is the light reflection direction, not the incoming direction.
  14290. */
  14291. export class HemisphericLight extends Light {
  14292. /**
  14293. * The groundColor is the light in the opposite direction to the one specified during creation.
  14294. * 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.
  14295. */
  14296. groundColor: Color3;
  14297. /**
  14298. * The light reflection direction, not the incoming direction.
  14299. */
  14300. direction: Vector3;
  14301. /**
  14302. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14303. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14304. * The HemisphericLight can't cast shadows.
  14305. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14306. * @param name The friendly name of the light
  14307. * @param direction The direction of the light reflection
  14308. * @param scene The scene the light belongs to
  14309. */
  14310. constructor(name: string, direction: Vector3, scene: Scene);
  14311. protected _buildUniformLayout(): void;
  14312. /**
  14313. * Returns the string "HemisphericLight".
  14314. * @return The class name
  14315. */
  14316. getClassName(): string;
  14317. /**
  14318. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14319. * Returns the updated direction.
  14320. * @param target The target the direction should point to
  14321. * @return The computed direction
  14322. */
  14323. setDirectionToTarget(target: Vector3): Vector3;
  14324. /**
  14325. * Returns the shadow generator associated to the light.
  14326. * @returns Always null for hemispheric lights because it does not support shadows.
  14327. */
  14328. getShadowGenerator(): Nullable<IShadowGenerator>;
  14329. /**
  14330. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14331. * @param effect The effect to update
  14332. * @param lightIndex The index of the light in the effect to update
  14333. * @returns The hemispheric light
  14334. */
  14335. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14336. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14337. /**
  14338. * Computes the world matrix of the node
  14339. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14340. * @param useWasUpdatedFlag defines a reserved property
  14341. * @returns the world matrix
  14342. */
  14343. computeWorldMatrix(): Matrix;
  14344. /**
  14345. * Returns the integer 3.
  14346. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14347. */
  14348. getTypeID(): number;
  14349. /**
  14350. * Prepares the list of defines specific to the light type.
  14351. * @param defines the list of defines
  14352. * @param lightIndex defines the index of the light for the effect
  14353. */
  14354. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14355. }
  14356. }
  14357. declare module BABYLON {
  14358. /** @hidden */
  14359. export var vrMultiviewToSingleviewPixelShader: {
  14360. name: string;
  14361. shader: string;
  14362. };
  14363. }
  14364. declare module BABYLON {
  14365. /**
  14366. * Renders to multiple views with a single draw call
  14367. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14368. */
  14369. export class MultiviewRenderTarget extends RenderTargetTexture {
  14370. /**
  14371. * Creates a multiview render target
  14372. * @param scene scene used with the render target
  14373. * @param size the size of the render target (used for each view)
  14374. */
  14375. constructor(scene: Scene, size?: number | {
  14376. width: number;
  14377. height: number;
  14378. } | {
  14379. ratio: number;
  14380. });
  14381. /**
  14382. * @hidden
  14383. * @param faceIndex the face index, if its a cube texture
  14384. */ private _bindFrameBuffer(faceIndex?: number): void;
  14385. /**
  14386. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14387. * @returns the view count
  14388. */
  14389. getViewCount(): number;
  14390. }
  14391. }
  14392. declare module BABYLON {
  14393. /**
  14394. * Reprasents a camera frustum
  14395. */
  14396. export class Frustum {
  14397. /**
  14398. * Gets the planes representing the frustum
  14399. * @param transform matrix to be applied to the returned planes
  14400. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14401. */
  14402. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14403. /**
  14404. * Gets the near frustum plane transformed by the transform matrix
  14405. * @param transform transformation matrix to be applied to the resulting frustum plane
  14406. * @param frustumPlane the resuling frustum plane
  14407. */
  14408. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14409. /**
  14410. * Gets the far frustum plane transformed by the transform matrix
  14411. * @param transform transformation matrix to be applied to the resulting frustum plane
  14412. * @param frustumPlane the resuling frustum plane
  14413. */
  14414. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14415. /**
  14416. * Gets the left frustum plane transformed by the transform matrix
  14417. * @param transform transformation matrix to be applied to the resulting frustum plane
  14418. * @param frustumPlane the resuling frustum plane
  14419. */
  14420. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14421. /**
  14422. * Gets the right frustum plane transformed by the transform matrix
  14423. * @param transform transformation matrix to be applied to the resulting frustum plane
  14424. * @param frustumPlane the resuling frustum plane
  14425. */
  14426. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14427. /**
  14428. * Gets the top frustum plane transformed by the transform matrix
  14429. * @param transform transformation matrix to be applied to the resulting frustum plane
  14430. * @param frustumPlane the resuling frustum plane
  14431. */
  14432. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14433. /**
  14434. * Gets the bottom frustum plane transformed by the transform matrix
  14435. * @param transform transformation matrix to be applied to the resulting frustum plane
  14436. * @param frustumPlane the resuling frustum plane
  14437. */
  14438. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14439. /**
  14440. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14441. * @param transform transformation matrix to be applied to the resulting frustum planes
  14442. * @param frustumPlanes the resuling frustum planes
  14443. */
  14444. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. interface Engine {
  14449. /**
  14450. * Creates a new multiview render target
  14451. * @param width defines the width of the texture
  14452. * @param height defines the height of the texture
  14453. * @returns the created multiview texture
  14454. */
  14455. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14456. /**
  14457. * Binds a multiview framebuffer to be drawn to
  14458. * @param multiviewTexture texture to bind
  14459. */
  14460. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14461. }
  14462. interface Camera {
  14463. /**
  14464. * @hidden
  14465. * 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)
  14466. */ private _useMultiviewToSingleView: boolean;
  14467. /**
  14468. * @hidden
  14469. * 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)
  14470. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14471. /**
  14472. * @hidden
  14473. * ensures the multiview texture of the camera exists and has the specified width/height
  14474. * @param width height to set on the multiview texture
  14475. * @param height width to set on the multiview texture
  14476. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14477. }
  14478. interface Scene {
  14479. /** @hidden */ private _transformMatrixR: Matrix;
  14480. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14481. /** @hidden */ private _createMultiviewUbo(): void;
  14482. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14483. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14484. }
  14485. }
  14486. declare module BABYLON {
  14487. /**
  14488. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14489. * This will not be used for webXR as it supports displaying texture arrays directly
  14490. */
  14491. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14492. /**
  14493. * Initializes a VRMultiviewToSingleview
  14494. * @param name name of the post process
  14495. * @param camera camera to be applied to
  14496. * @param scaleFactor scaling factor to the size of the output texture
  14497. */
  14498. constructor(name: string, camera: Camera, scaleFactor: number);
  14499. }
  14500. }
  14501. declare module BABYLON {
  14502. interface Engine {
  14503. /** @hidden */ private _vrDisplay: any;
  14504. /** @hidden */ private _vrSupported: boolean;
  14505. /** @hidden */ private _oldSize: Size;
  14506. /** @hidden */ private _oldHardwareScaleFactor: number;
  14507. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14508. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14509. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14510. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14511. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14512. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14513. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14514. /**
  14515. * Observable signaled when VR display mode changes
  14516. */
  14517. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14518. /**
  14519. * Observable signaled when VR request present is complete
  14520. */
  14521. onVRRequestPresentComplete: Observable<boolean>;
  14522. /**
  14523. * Observable signaled when VR request present starts
  14524. */
  14525. onVRRequestPresentStart: Observable<Engine>;
  14526. /**
  14527. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14528. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14529. */
  14530. isInVRExclusivePointerMode: boolean;
  14531. /**
  14532. * Gets a boolean indicating if a webVR device was detected
  14533. * @returns true if a webVR device was detected
  14534. */
  14535. isVRDevicePresent(): boolean;
  14536. /**
  14537. * Gets the current webVR device
  14538. * @returns the current webVR device (or null)
  14539. */
  14540. getVRDevice(): any;
  14541. /**
  14542. * Initializes a webVR display and starts listening to display change events
  14543. * The onVRDisplayChangedObservable will be notified upon these changes
  14544. * @returns A promise containing a VRDisplay and if vr is supported
  14545. */
  14546. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14547. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14548. /**
  14549. * Call this function to switch to webVR mode
  14550. * Will do nothing if webVR is not supported or if there is no webVR device
  14551. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14552. */
  14553. enableVR(): void;
  14554. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14555. }
  14556. }
  14557. declare module BABYLON {
  14558. /**
  14559. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14560. * IMPORTANT!! The data is right-hand data.
  14561. * @export
  14562. * @interface DevicePose
  14563. */
  14564. export interface DevicePose {
  14565. /**
  14566. * The position of the device, values in array are [x,y,z].
  14567. */
  14568. readonly position: Nullable<Float32Array>;
  14569. /**
  14570. * The linearVelocity of the device, values in array are [x,y,z].
  14571. */
  14572. readonly linearVelocity: Nullable<Float32Array>;
  14573. /**
  14574. * The linearAcceleration of the device, values in array are [x,y,z].
  14575. */
  14576. readonly linearAcceleration: Nullable<Float32Array>;
  14577. /**
  14578. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14579. */
  14580. readonly orientation: Nullable<Float32Array>;
  14581. /**
  14582. * The angularVelocity of the device, values in array are [x,y,z].
  14583. */
  14584. readonly angularVelocity: Nullable<Float32Array>;
  14585. /**
  14586. * The angularAcceleration of the device, values in array are [x,y,z].
  14587. */
  14588. readonly angularAcceleration: Nullable<Float32Array>;
  14589. }
  14590. /**
  14591. * Interface representing a pose controlled object in Babylon.
  14592. * A pose controlled object has both regular pose values as well as pose values
  14593. * from an external device such as a VR head mounted display
  14594. */
  14595. export interface PoseControlled {
  14596. /**
  14597. * The position of the object in babylon space.
  14598. */
  14599. position: Vector3;
  14600. /**
  14601. * The rotation quaternion of the object in babylon space.
  14602. */
  14603. rotationQuaternion: Quaternion;
  14604. /**
  14605. * The position of the device in babylon space.
  14606. */
  14607. devicePosition?: Vector3;
  14608. /**
  14609. * The rotation quaternion of the device in babylon space.
  14610. */
  14611. deviceRotationQuaternion: Quaternion;
  14612. /**
  14613. * The raw pose coming from the device.
  14614. */
  14615. rawPose: Nullable<DevicePose>;
  14616. /**
  14617. * The scale of the device to be used when translating from device space to babylon space.
  14618. */
  14619. deviceScaleFactor: number;
  14620. /**
  14621. * Updates the poseControlled values based on the input device pose.
  14622. * @param poseData the pose data to update the object with
  14623. */
  14624. updateFromDevice(poseData: DevicePose): void;
  14625. }
  14626. /**
  14627. * Set of options to customize the webVRCamera
  14628. */
  14629. export interface WebVROptions {
  14630. /**
  14631. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14632. */
  14633. trackPosition?: boolean;
  14634. /**
  14635. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14636. */
  14637. positionScale?: number;
  14638. /**
  14639. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14640. */
  14641. displayName?: string;
  14642. /**
  14643. * Should the native controller meshes be initialized. (default: true)
  14644. */
  14645. controllerMeshes?: boolean;
  14646. /**
  14647. * Creating a default HemiLight only on controllers. (default: true)
  14648. */
  14649. defaultLightingOnControllers?: boolean;
  14650. /**
  14651. * If you don't want to use the default VR button of the helper. (default: false)
  14652. */
  14653. useCustomVRButton?: boolean;
  14654. /**
  14655. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14656. */
  14657. customVRButton?: HTMLButtonElement;
  14658. /**
  14659. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14660. */
  14661. rayLength?: number;
  14662. /**
  14663. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14664. */
  14665. defaultHeight?: number;
  14666. /**
  14667. * If multiview should be used if availible (default: false)
  14668. */
  14669. useMultiview?: boolean;
  14670. }
  14671. /**
  14672. * This represents a WebVR camera.
  14673. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14674. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14675. */
  14676. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14677. private webVROptions;
  14678. /**
  14679. * @hidden
  14680. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14681. */ private _vrDevice: any;
  14682. /**
  14683. * The rawPose of the vrDevice.
  14684. */
  14685. rawPose: Nullable<DevicePose>;
  14686. private _onVREnabled;
  14687. private _specsVersion;
  14688. private _attached;
  14689. private _frameData;
  14690. protected _descendants: Array<Node>;
  14691. private _deviceRoomPosition;
  14692. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14693. private _standingMatrix;
  14694. /**
  14695. * Represents device position in babylon space.
  14696. */
  14697. devicePosition: Vector3;
  14698. /**
  14699. * Represents device rotation in babylon space.
  14700. */
  14701. deviceRotationQuaternion: Quaternion;
  14702. /**
  14703. * The scale of the device to be used when translating from device space to babylon space.
  14704. */
  14705. deviceScaleFactor: number;
  14706. private _deviceToWorld;
  14707. private _worldToDevice;
  14708. /**
  14709. * References to the webVR controllers for the vrDevice.
  14710. */
  14711. controllers: Array<WebVRController>;
  14712. /**
  14713. * Emits an event when a controller is attached.
  14714. */
  14715. onControllersAttachedObservable: Observable<WebVRController[]>;
  14716. /**
  14717. * Emits an event when a controller's mesh has been loaded;
  14718. */
  14719. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14720. /**
  14721. * Emits an event when the HMD's pose has been updated.
  14722. */
  14723. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14724. private _poseSet;
  14725. /**
  14726. * If the rig cameras be used as parent instead of this camera.
  14727. */
  14728. rigParenting: boolean;
  14729. private _lightOnControllers;
  14730. private _defaultHeight?;
  14731. /**
  14732. * Instantiates a WebVRFreeCamera.
  14733. * @param name The name of the WebVRFreeCamera
  14734. * @param position The starting anchor position for the camera
  14735. * @param scene The scene the camera belongs to
  14736. * @param webVROptions a set of customizable options for the webVRCamera
  14737. */
  14738. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14739. /**
  14740. * Gets the device distance from the ground in meters.
  14741. * @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.
  14742. */
  14743. deviceDistanceToRoomGround(): number;
  14744. /**
  14745. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14746. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14747. */
  14748. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14749. /**
  14750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14751. * @returns A promise with a boolean set to if the standing matrix is supported.
  14752. */
  14753. useStandingMatrixAsync(): Promise<boolean>;
  14754. /**
  14755. * Disposes the camera
  14756. */
  14757. dispose(): void;
  14758. /**
  14759. * Gets a vrController by name.
  14760. * @param name The name of the controller to retreive
  14761. * @returns the controller matching the name specified or null if not found
  14762. */
  14763. getControllerByName(name: string): Nullable<WebVRController>;
  14764. private _leftController;
  14765. /**
  14766. * The controller corresponding to the users left hand.
  14767. */
  14768. readonly leftController: Nullable<WebVRController>;
  14769. private _rightController;
  14770. /**
  14771. * The controller corresponding to the users right hand.
  14772. */
  14773. readonly rightController: Nullable<WebVRController>;
  14774. /**
  14775. * Casts a ray forward from the vrCamera's gaze.
  14776. * @param length Length of the ray (default: 100)
  14777. * @returns the ray corresponding to the gaze
  14778. */
  14779. getForwardRay(length?: number): Ray;
  14780. /**
  14781. * @hidden
  14782. * Updates the camera based on device's frame data
  14783. */ private _checkInputs(): void;
  14784. /**
  14785. * Updates the poseControlled values based on the input device pose.
  14786. * @param poseData Pose coming from the device
  14787. */
  14788. updateFromDevice(poseData: DevicePose): void;
  14789. private _htmlElementAttached;
  14790. private _detachIfAttached;
  14791. /**
  14792. * WebVR's attach control will start broadcasting frames to the device.
  14793. * Note that in certain browsers (chrome for example) this function must be called
  14794. * within a user-interaction callback. Example:
  14795. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14796. *
  14797. * @param element html element to attach the vrDevice to
  14798. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14799. */
  14800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14801. /**
  14802. * Detaches the camera from the html element and disables VR
  14803. *
  14804. * @param element html element to detach from
  14805. */
  14806. detachControl(element: HTMLElement): void;
  14807. /**
  14808. * @returns the name of this class
  14809. */
  14810. getClassName(): string;
  14811. /**
  14812. * Calls resetPose on the vrDisplay
  14813. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14814. */
  14815. resetToCurrentRotation(): void;
  14816. /**
  14817. * @hidden
  14818. * Updates the rig cameras (left and right eye)
  14819. */ private _updateRigCameras(): void;
  14820. private _workingVector;
  14821. private _oneVector;
  14822. private _workingMatrix;
  14823. private updateCacheCalled;
  14824. private _correctPositionIfNotTrackPosition;
  14825. /**
  14826. * @hidden
  14827. * Updates the cached values of the camera
  14828. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14829. */ private _updateCache(ignoreParentClass?: boolean): void;
  14830. /**
  14831. * @hidden
  14832. * Get current device position in babylon world
  14833. */ private _computeDevicePosition(): void;
  14834. /**
  14835. * Updates the current device position and rotation in the babylon world
  14836. */
  14837. update(): void;
  14838. /**
  14839. * @hidden
  14840. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14841. * @returns an identity matrix
  14842. */ private _getViewMatrix(): Matrix;
  14843. private _tmpMatrix;
  14844. /**
  14845. * This function is called by the two RIG cameras.
  14846. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14847. * @hidden
  14848. */ private _getWebVRViewMatrix(): Matrix;
  14849. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14850. private _onGamepadConnectedObserver;
  14851. private _onGamepadDisconnectedObserver;
  14852. private _updateCacheWhenTrackingDisabledObserver;
  14853. /**
  14854. * Initializes the controllers and their meshes
  14855. */
  14856. initControllers(): void;
  14857. }
  14858. }
  14859. declare module BABYLON {
  14860. /**
  14861. * Size options for a post process
  14862. */
  14863. export type PostProcessOptions = {
  14864. width: number;
  14865. height: number;
  14866. };
  14867. /**
  14868. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14869. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14870. */
  14871. export class PostProcess {
  14872. /** Name of the PostProcess. */
  14873. name: string;
  14874. /**
  14875. * Gets or sets the unique id of the post process
  14876. */
  14877. uniqueId: number;
  14878. /**
  14879. * Width of the texture to apply the post process on
  14880. */
  14881. width: number;
  14882. /**
  14883. * Height of the texture to apply the post process on
  14884. */
  14885. height: number;
  14886. /**
  14887. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14888. * @hidden
  14889. */ private _outputTexture: Nullable<InternalTexture>;
  14890. /**
  14891. * Sampling mode used by the shader
  14892. * See https://doc.babylonjs.com/classes/3.1/texture
  14893. */
  14894. renderTargetSamplingMode: number;
  14895. /**
  14896. * Clear color to use when screen clearing
  14897. */
  14898. clearColor: Color4;
  14899. /**
  14900. * If the buffer needs to be cleared before applying the post process. (default: true)
  14901. * Should be set to false if shader will overwrite all previous pixels.
  14902. */
  14903. autoClear: boolean;
  14904. /**
  14905. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14906. */
  14907. alphaMode: number;
  14908. /**
  14909. * Sets the setAlphaBlendConstants of the babylon engine
  14910. */
  14911. alphaConstants: Color4;
  14912. /**
  14913. * Animations to be used for the post processing
  14914. */
  14915. animations: Animation[];
  14916. /**
  14917. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14918. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14919. */
  14920. enablePixelPerfectMode: boolean;
  14921. /**
  14922. * Force the postprocess to be applied without taking in account viewport
  14923. */
  14924. forceFullscreenViewport: boolean;
  14925. /**
  14926. * List of inspectable custom properties (used by the Inspector)
  14927. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14928. */
  14929. inspectableCustomProperties: IInspectable[];
  14930. /**
  14931. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14932. *
  14933. * | Value | Type | Description |
  14934. * | ----- | ----------------------------------- | ----------- |
  14935. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14936. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14937. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14938. *
  14939. */
  14940. scaleMode: number;
  14941. /**
  14942. * Force textures to be a power of two (default: false)
  14943. */
  14944. alwaysForcePOT: boolean;
  14945. private _samples;
  14946. /**
  14947. * Number of sample textures (default: 1)
  14948. */
  14949. samples: number;
  14950. /**
  14951. * Modify the scale of the post process to be the same as the viewport (default: false)
  14952. */
  14953. adaptScaleToCurrentViewport: boolean;
  14954. private _camera;
  14955. private _scene;
  14956. private _engine;
  14957. private _options;
  14958. private _reusable;
  14959. private _textureType;
  14960. /**
  14961. * Smart array of input and output textures for the post process.
  14962. * @hidden
  14963. */ private _textures: SmartArray<InternalTexture>;
  14964. /**
  14965. * The index in _textures that corresponds to the output texture.
  14966. * @hidden
  14967. */ private _currentRenderTextureInd: number;
  14968. private _effect;
  14969. private _samplers;
  14970. private _fragmentUrl;
  14971. private _vertexUrl;
  14972. private _parameters;
  14973. private _scaleRatio;
  14974. protected _indexParameters: any;
  14975. private _shareOutputWithPostProcess;
  14976. private _texelSize;
  14977. private _forcedOutputTexture;
  14978. /**
  14979. * Returns the fragment url or shader name used in the post process.
  14980. * @returns the fragment url or name in the shader store.
  14981. */
  14982. getEffectName(): string;
  14983. /**
  14984. * An event triggered when the postprocess is activated.
  14985. */
  14986. onActivateObservable: Observable<Camera>;
  14987. private _onActivateObserver;
  14988. /**
  14989. * A function that is added to the onActivateObservable
  14990. */
  14991. onActivate: Nullable<(camera: Camera) => void>;
  14992. /**
  14993. * An event triggered when the postprocess changes its size.
  14994. */
  14995. onSizeChangedObservable: Observable<PostProcess>;
  14996. private _onSizeChangedObserver;
  14997. /**
  14998. * A function that is added to the onSizeChangedObservable
  14999. */
  15000. onSizeChanged: (postProcess: PostProcess) => void;
  15001. /**
  15002. * An event triggered when the postprocess applies its effect.
  15003. */
  15004. onApplyObservable: Observable<Effect>;
  15005. private _onApplyObserver;
  15006. /**
  15007. * A function that is added to the onApplyObservable
  15008. */
  15009. onApply: (effect: Effect) => void;
  15010. /**
  15011. * An event triggered before rendering the postprocess
  15012. */
  15013. onBeforeRenderObservable: Observable<Effect>;
  15014. private _onBeforeRenderObserver;
  15015. /**
  15016. * A function that is added to the onBeforeRenderObservable
  15017. */
  15018. onBeforeRender: (effect: Effect) => void;
  15019. /**
  15020. * An event triggered after rendering the postprocess
  15021. */
  15022. onAfterRenderObservable: Observable<Effect>;
  15023. private _onAfterRenderObserver;
  15024. /**
  15025. * A function that is added to the onAfterRenderObservable
  15026. */
  15027. onAfterRender: (efect: Effect) => void;
  15028. /**
  15029. * 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
  15030. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15031. */
  15032. inputTexture: InternalTexture;
  15033. /**
  15034. * Gets the camera which post process is applied to.
  15035. * @returns The camera the post process is applied to.
  15036. */
  15037. getCamera(): Camera;
  15038. /**
  15039. * Gets the texel size of the postprocess.
  15040. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15041. */
  15042. readonly texelSize: Vector2;
  15043. /**
  15044. * Creates a new instance PostProcess
  15045. * @param name The name of the PostProcess.
  15046. * @param fragmentUrl The url of the fragment shader to be used.
  15047. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15048. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15049. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15050. * @param camera The camera to apply the render pass to.
  15051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15052. * @param engine The engine which the post process will be applied. (default: current engine)
  15053. * @param reusable If the post process can be reused on the same frame. (default: false)
  15054. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15055. * @param textureType Type of textures used when performing the post process. (default: 0)
  15056. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15057. * @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
  15058. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15059. */
  15060. constructor(
  15061. /** Name of the PostProcess. */
  15062. 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);
  15063. /**
  15064. * Gets a string idenfifying the name of the class
  15065. * @returns "PostProcess" string
  15066. */
  15067. getClassName(): string;
  15068. /**
  15069. * Gets the engine which this post process belongs to.
  15070. * @returns The engine the post process was enabled with.
  15071. */
  15072. getEngine(): Engine;
  15073. /**
  15074. * The effect that is created when initializing the post process.
  15075. * @returns The created effect corresponding the the postprocess.
  15076. */
  15077. getEffect(): Effect;
  15078. /**
  15079. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15080. * @param postProcess The post process to share the output with.
  15081. * @returns This post process.
  15082. */
  15083. shareOutputWith(postProcess: PostProcess): PostProcess;
  15084. /**
  15085. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15086. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15087. */
  15088. useOwnOutput(): void;
  15089. /**
  15090. * Updates the effect with the current post process compile time values and recompiles the shader.
  15091. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15092. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15093. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15094. * @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
  15095. * @param onCompiled Called when the shader has been compiled.
  15096. * @param onError Called if there is an error when compiling a shader.
  15097. */
  15098. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15099. /**
  15100. * The post process is reusable if it can be used multiple times within one frame.
  15101. * @returns If the post process is reusable
  15102. */
  15103. isReusable(): boolean;
  15104. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15105. markTextureDirty(): void;
  15106. /**
  15107. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15108. * 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.
  15109. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15110. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15111. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15112. * @returns The target texture that was bound to be written to.
  15113. */
  15114. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15115. /**
  15116. * If the post process is supported.
  15117. */
  15118. readonly isSupported: boolean;
  15119. /**
  15120. * The aspect ratio of the output texture.
  15121. */
  15122. readonly aspectRatio: number;
  15123. /**
  15124. * Get a value indicating if the post-process is ready to be used
  15125. * @returns true if the post-process is ready (shader is compiled)
  15126. */
  15127. isReady(): boolean;
  15128. /**
  15129. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15130. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15131. */
  15132. apply(): Nullable<Effect>;
  15133. private _disposeTextures;
  15134. /**
  15135. * Disposes the post process.
  15136. * @param camera The camera to dispose the post process on.
  15137. */
  15138. dispose(camera?: Camera): void;
  15139. }
  15140. }
  15141. declare module BABYLON {
  15142. /** @hidden */
  15143. export var kernelBlurVaryingDeclaration: {
  15144. name: string;
  15145. shader: string;
  15146. };
  15147. }
  15148. declare module BABYLON {
  15149. /** @hidden */
  15150. export var kernelBlurFragment: {
  15151. name: string;
  15152. shader: string;
  15153. };
  15154. }
  15155. declare module BABYLON {
  15156. /** @hidden */
  15157. export var kernelBlurFragment2: {
  15158. name: string;
  15159. shader: string;
  15160. };
  15161. }
  15162. declare module BABYLON {
  15163. /** @hidden */
  15164. export var kernelBlurPixelShader: {
  15165. name: string;
  15166. shader: string;
  15167. };
  15168. }
  15169. declare module BABYLON {
  15170. /** @hidden */
  15171. export var kernelBlurVertex: {
  15172. name: string;
  15173. shader: string;
  15174. };
  15175. }
  15176. declare module BABYLON {
  15177. /** @hidden */
  15178. export var kernelBlurVertexShader: {
  15179. name: string;
  15180. shader: string;
  15181. };
  15182. }
  15183. declare module BABYLON {
  15184. /**
  15185. * The Blur Post Process which blurs an image based on a kernel and direction.
  15186. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15187. */
  15188. export class BlurPostProcess extends PostProcess {
  15189. /** The direction in which to blur the image. */
  15190. direction: Vector2;
  15191. private blockCompilation;
  15192. protected _kernel: number;
  15193. protected _idealKernel: number;
  15194. protected _packedFloat: boolean;
  15195. private _staticDefines;
  15196. /**
  15197. * Sets the length in pixels of the blur sample region
  15198. */
  15199. /**
  15200. * Gets the length in pixels of the blur sample region
  15201. */
  15202. kernel: number;
  15203. /**
  15204. * Sets wether or not the blur needs to unpack/repack floats
  15205. */
  15206. /**
  15207. * Gets wether or not the blur is unpacking/repacking floats
  15208. */
  15209. packedFloat: boolean;
  15210. /**
  15211. * Creates a new instance BlurPostProcess
  15212. * @param name The name of the effect.
  15213. * @param direction The direction in which to blur the image.
  15214. * @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.
  15215. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15216. * @param camera The camera to apply the render pass to.
  15217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15218. * @param engine The engine which the post process will be applied. (default: current engine)
  15219. * @param reusable If the post process can be reused on the same frame. (default: false)
  15220. * @param textureType Type of textures used when performing the post process. (default: 0)
  15221. * @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)
  15222. */
  15223. constructor(name: string,
  15224. /** The direction in which to blur the image. */
  15225. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15226. /**
  15227. * Updates the effect with the current post process compile time values and recompiles the shader.
  15228. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15229. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15230. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15231. * @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
  15232. * @param onCompiled Called when the shader has been compiled.
  15233. * @param onError Called if there is an error when compiling a shader.
  15234. */
  15235. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15236. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15237. /**
  15238. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15239. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15240. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15241. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15242. * The gaps between physical kernels are compensated for in the weighting of the samples
  15243. * @param idealKernel Ideal blur kernel.
  15244. * @return Nearest best kernel.
  15245. */
  15246. protected _nearestBestKernel(idealKernel: number): number;
  15247. /**
  15248. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15249. * @param x The point on the Gaussian distribution to sample.
  15250. * @return the value of the Gaussian function at x.
  15251. */
  15252. protected _gaussianWeight(x: number): number;
  15253. /**
  15254. * Generates a string that can be used as a floating point number in GLSL.
  15255. * @param x Value to print.
  15256. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15257. * @return GLSL float string.
  15258. */
  15259. protected _glslFloat(x: number, decimalFigures?: number): string;
  15260. }
  15261. }
  15262. declare module BABYLON {
  15263. /**
  15264. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15265. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15266. * You can then easily use it as a reflectionTexture on a flat surface.
  15267. * In case the surface is not a plane, please consider relying on reflection probes.
  15268. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15269. */
  15270. export class MirrorTexture extends RenderTargetTexture {
  15271. private scene;
  15272. /**
  15273. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15274. * 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.
  15275. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15276. */
  15277. mirrorPlane: Plane;
  15278. /**
  15279. * Define the blur ratio used to blur the reflection if needed.
  15280. */
  15281. blurRatio: number;
  15282. /**
  15283. * Define the adaptive blur kernel used to blur the reflection if needed.
  15284. * This will autocompute the closest best match for the `blurKernel`
  15285. */
  15286. adaptiveBlurKernel: number;
  15287. /**
  15288. * Define the blur kernel used to blur the reflection if needed.
  15289. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15290. */
  15291. blurKernel: number;
  15292. /**
  15293. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15295. */
  15296. blurKernelX: number;
  15297. /**
  15298. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15299. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15300. */
  15301. blurKernelY: number;
  15302. private _autoComputeBlurKernel;
  15303. protected _onRatioRescale(): void;
  15304. private _updateGammaSpace;
  15305. private _imageProcessingConfigChangeObserver;
  15306. private _transformMatrix;
  15307. private _mirrorMatrix;
  15308. private _savedViewMatrix;
  15309. private _blurX;
  15310. private _blurY;
  15311. private _adaptiveBlurKernel;
  15312. private _blurKernelX;
  15313. private _blurKernelY;
  15314. private _blurRatio;
  15315. /**
  15316. * Instantiates a Mirror Texture.
  15317. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15318. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15319. * You can then easily use it as a reflectionTexture on a flat surface.
  15320. * In case the surface is not a plane, please consider relying on reflection probes.
  15321. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15322. * @param name
  15323. * @param size
  15324. * @param scene
  15325. * @param generateMipMaps
  15326. * @param type
  15327. * @param samplingMode
  15328. * @param generateDepthBuffer
  15329. */
  15330. constructor(name: string, size: number | {
  15331. width: number;
  15332. height: number;
  15333. } | {
  15334. ratio: number;
  15335. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15336. private _preparePostProcesses;
  15337. /**
  15338. * Clone the mirror texture.
  15339. * @returns the cloned texture
  15340. */
  15341. clone(): MirrorTexture;
  15342. /**
  15343. * Serialize the texture to a JSON representation you could use in Parse later on
  15344. * @returns the serialized JSON representation
  15345. */
  15346. serialize(): any;
  15347. /**
  15348. * Dispose the texture and release its associated resources.
  15349. */
  15350. dispose(): void;
  15351. }
  15352. }
  15353. declare module BABYLON {
  15354. /**
  15355. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15356. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15357. */
  15358. export class Texture extends BaseTexture {
  15359. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15360. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15361. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15362. /** nearest is mag = nearest and min = nearest and mip = linear */
  15363. static readonly NEAREST_SAMPLINGMODE: number;
  15364. /** nearest is mag = nearest and min = nearest and mip = linear */
  15365. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15366. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15367. static readonly BILINEAR_SAMPLINGMODE: number;
  15368. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15369. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15370. /** Trilinear is mag = linear and min = linear and mip = linear */
  15371. static readonly TRILINEAR_SAMPLINGMODE: number;
  15372. /** Trilinear is mag = linear and min = linear and mip = linear */
  15373. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15374. /** mag = nearest and min = nearest and mip = nearest */
  15375. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15376. /** mag = nearest and min = linear and mip = nearest */
  15377. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15378. /** mag = nearest and min = linear and mip = linear */
  15379. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15380. /** mag = nearest and min = linear and mip = none */
  15381. static readonly NEAREST_LINEAR: number;
  15382. /** mag = nearest and min = nearest and mip = none */
  15383. static readonly NEAREST_NEAREST: number;
  15384. /** mag = linear and min = nearest and mip = nearest */
  15385. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15386. /** mag = linear and min = nearest and mip = linear */
  15387. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15388. /** mag = linear and min = linear and mip = none */
  15389. static readonly LINEAR_LINEAR: number;
  15390. /** mag = linear and min = nearest and mip = none */
  15391. static readonly LINEAR_NEAREST: number;
  15392. /** Explicit coordinates mode */
  15393. static readonly EXPLICIT_MODE: number;
  15394. /** Spherical coordinates mode */
  15395. static readonly SPHERICAL_MODE: number;
  15396. /** Planar coordinates mode */
  15397. static readonly PLANAR_MODE: number;
  15398. /** Cubic coordinates mode */
  15399. static readonly CUBIC_MODE: number;
  15400. /** Projection coordinates mode */
  15401. static readonly PROJECTION_MODE: number;
  15402. /** Inverse Cubic coordinates mode */
  15403. static readonly SKYBOX_MODE: number;
  15404. /** Inverse Cubic coordinates mode */
  15405. static readonly INVCUBIC_MODE: number;
  15406. /** Equirectangular coordinates mode */
  15407. static readonly EQUIRECTANGULAR_MODE: number;
  15408. /** Equirectangular Fixed coordinates mode */
  15409. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15410. /** Equirectangular Fixed Mirrored coordinates mode */
  15411. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15412. /** Texture is not repeating outside of 0..1 UVs */
  15413. static readonly CLAMP_ADDRESSMODE: number;
  15414. /** Texture is repeating outside of 0..1 UVs */
  15415. static readonly WRAP_ADDRESSMODE: number;
  15416. /** Texture is repeating and mirrored */
  15417. static readonly MIRROR_ADDRESSMODE: number;
  15418. /**
  15419. * 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
  15420. */
  15421. static UseSerializedUrlIfAny: boolean;
  15422. /**
  15423. * Define the url of the texture.
  15424. */
  15425. url: Nullable<string>;
  15426. /**
  15427. * Define an offset on the texture to offset the u coordinates of the UVs
  15428. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15429. */
  15430. uOffset: number;
  15431. /**
  15432. * Define an offset on the texture to offset the v coordinates of the UVs
  15433. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15434. */
  15435. vOffset: number;
  15436. /**
  15437. * Define an offset on the texture to scale the u coordinates of the UVs
  15438. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15439. */
  15440. uScale: number;
  15441. /**
  15442. * Define an offset on the texture to scale the v coordinates of the UVs
  15443. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15444. */
  15445. vScale: number;
  15446. /**
  15447. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15448. * @see http://doc.babylonjs.com/how_to/more_materials
  15449. */
  15450. uAng: number;
  15451. /**
  15452. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15453. * @see http://doc.babylonjs.com/how_to/more_materials
  15454. */
  15455. vAng: number;
  15456. /**
  15457. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15458. * @see http://doc.babylonjs.com/how_to/more_materials
  15459. */
  15460. wAng: number;
  15461. /**
  15462. * Defines the center of rotation (U)
  15463. */
  15464. uRotationCenter: number;
  15465. /**
  15466. * Defines the center of rotation (V)
  15467. */
  15468. vRotationCenter: number;
  15469. /**
  15470. * Defines the center of rotation (W)
  15471. */
  15472. wRotationCenter: number;
  15473. /**
  15474. * Are mip maps generated for this texture or not.
  15475. */
  15476. readonly noMipmap: boolean;
  15477. /**
  15478. * List of inspectable custom properties (used by the Inspector)
  15479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15480. */
  15481. inspectableCustomProperties: Nullable<IInspectable[]>;
  15482. private _noMipmap;
  15483. /** @hidden */ private _invertY: boolean;
  15484. private _rowGenerationMatrix;
  15485. private _cachedTextureMatrix;
  15486. private _projectionModeMatrix;
  15487. private _t0;
  15488. private _t1;
  15489. private _t2;
  15490. private _cachedUOffset;
  15491. private _cachedVOffset;
  15492. private _cachedUScale;
  15493. private _cachedVScale;
  15494. private _cachedUAng;
  15495. private _cachedVAng;
  15496. private _cachedWAng;
  15497. private _cachedProjectionMatrixId;
  15498. private _cachedCoordinatesMode;
  15499. /** @hidden */
  15500. protected _initialSamplingMode: number;
  15501. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15502. private _deleteBuffer;
  15503. protected _format: Nullable<number>;
  15504. private _delayedOnLoad;
  15505. private _delayedOnError;
  15506. /**
  15507. * Observable triggered once the texture has been loaded.
  15508. */
  15509. onLoadObservable: Observable<Texture>;
  15510. protected _isBlocking: boolean;
  15511. /**
  15512. * Is the texture preventing material to render while loading.
  15513. * If false, a default texture will be used instead of the loading one during the preparation step.
  15514. */
  15515. isBlocking: boolean;
  15516. /**
  15517. * Get the current sampling mode associated with the texture.
  15518. */
  15519. readonly samplingMode: number;
  15520. /**
  15521. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15522. */
  15523. readonly invertY: boolean;
  15524. /**
  15525. * Instantiates a new texture.
  15526. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15527. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15528. * @param url define the url of the picture to load as a texture
  15529. * @param scene define the scene or engine the texture will belong to
  15530. * @param noMipmap define if the texture will require mip maps or not
  15531. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15532. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15533. * @param onLoad define a callback triggered when the texture has been loaded
  15534. * @param onError define a callback triggered when an error occurred during the loading session
  15535. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15536. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15537. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15538. */
  15539. 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);
  15540. /**
  15541. * Update the url (and optional buffer) of this texture if url was null during construction.
  15542. * @param url the url of the texture
  15543. * @param buffer the buffer of the texture (defaults to null)
  15544. * @param onLoad callback called when the texture is loaded (defaults to null)
  15545. */
  15546. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15547. /**
  15548. * Finish the loading sequence of a texture flagged as delayed load.
  15549. * @hidden
  15550. */
  15551. delayLoad(): void;
  15552. private _prepareRowForTextureGeneration;
  15553. /**
  15554. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15555. * @returns the transform matrix of the texture.
  15556. */
  15557. getTextureMatrix(): Matrix;
  15558. /**
  15559. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15560. * @returns The reflection texture transform
  15561. */
  15562. getReflectionTextureMatrix(): Matrix;
  15563. /**
  15564. * Clones the texture.
  15565. * @returns the cloned texture
  15566. */
  15567. clone(): Texture;
  15568. /**
  15569. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15570. * @returns The JSON representation of the texture
  15571. */
  15572. serialize(): any;
  15573. /**
  15574. * Get the current class name of the texture useful for serialization or dynamic coding.
  15575. * @returns "Texture"
  15576. */
  15577. getClassName(): string;
  15578. /**
  15579. * Dispose the texture and release its associated resources.
  15580. */
  15581. dispose(): void;
  15582. /**
  15583. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15584. * @param parsedTexture Define the JSON representation of the texture
  15585. * @param scene Define the scene the parsed texture should be instantiated in
  15586. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15587. * @returns The parsed texture if successful
  15588. */
  15589. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15590. /**
  15591. * Creates a texture from its base 64 representation.
  15592. * @param data Define the base64 payload without the data: prefix
  15593. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15594. * @param scene Define the scene the texture should belong to
  15595. * @param noMipmap Forces the texture to not create mip map information if true
  15596. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15597. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15598. * @param onLoad define a callback triggered when the texture has been loaded
  15599. * @param onError define a callback triggered when an error occurred during the loading session
  15600. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15601. * @returns the created texture
  15602. */
  15603. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15604. /**
  15605. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15606. * @param data Define the base64 payload without the data: prefix
  15607. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15608. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15609. * @param scene Define the scene the texture should belong to
  15610. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15611. * @param noMipmap Forces the texture to not create mip map information if true
  15612. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15613. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15614. * @param onLoad define a callback triggered when the texture has been loaded
  15615. * @param onError define a callback triggered when an error occurred during the loading session
  15616. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15617. * @returns the created texture
  15618. */
  15619. 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;
  15620. }
  15621. }
  15622. declare module BABYLON {
  15623. /**
  15624. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15625. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15626. */
  15627. export class PostProcessManager {
  15628. private _scene;
  15629. private _indexBuffer;
  15630. private _vertexBuffers;
  15631. /**
  15632. * Creates a new instance PostProcess
  15633. * @param scene The scene that the post process is associated with.
  15634. */
  15635. constructor(scene: Scene);
  15636. private _prepareBuffers;
  15637. private _buildIndexBuffer;
  15638. /**
  15639. * Rebuilds the vertex buffers of the manager.
  15640. * @hidden
  15641. */ private _rebuild(): void;
  15642. /**
  15643. * Prepares a frame to be run through a post process.
  15644. * @param sourceTexture The input texture to the post procesess. (default: null)
  15645. * @param postProcesses An array of post processes to be run. (default: null)
  15646. * @returns True if the post processes were able to be run.
  15647. * @hidden
  15648. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15649. /**
  15650. * Manually render a set of post processes to a texture.
  15651. * @param postProcesses An array of post processes to be run.
  15652. * @param targetTexture The target texture to render to.
  15653. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15654. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15655. * @param lodLevel defines which lod of the texture to render to
  15656. */
  15657. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15658. /**
  15659. * Finalize the result of the output of the postprocesses.
  15660. * @param doNotPresent If true the result will not be displayed to the screen.
  15661. * @param targetTexture The target texture to render to.
  15662. * @param faceIndex The index of the face to bind the target texture to.
  15663. * @param postProcesses The array of post processes to render.
  15664. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15665. * @hidden
  15666. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15667. /**
  15668. * Disposes of the post process manager.
  15669. */
  15670. dispose(): void;
  15671. }
  15672. }
  15673. declare module BABYLON {
  15674. /** Interface used by value gradients (color, factor, ...) */
  15675. export interface IValueGradient {
  15676. /**
  15677. * Gets or sets the gradient value (between 0 and 1)
  15678. */
  15679. gradient: number;
  15680. }
  15681. /** Class used to store color4 gradient */
  15682. export class ColorGradient implements IValueGradient {
  15683. /**
  15684. * Gets or sets the gradient value (between 0 and 1)
  15685. */
  15686. gradient: number;
  15687. /**
  15688. * Gets or sets first associated color
  15689. */
  15690. color1: Color4;
  15691. /**
  15692. * Gets or sets second associated color
  15693. */
  15694. color2?: Color4;
  15695. /**
  15696. * Will get a color picked randomly between color1 and color2.
  15697. * If color2 is undefined then color1 will be used
  15698. * @param result defines the target Color4 to store the result in
  15699. */
  15700. getColorToRef(result: Color4): void;
  15701. }
  15702. /** Class used to store color 3 gradient */
  15703. export class Color3Gradient implements IValueGradient {
  15704. /**
  15705. * Gets or sets the gradient value (between 0 and 1)
  15706. */
  15707. gradient: number;
  15708. /**
  15709. * Gets or sets the associated color
  15710. */
  15711. color: Color3;
  15712. }
  15713. /** Class used to store factor gradient */
  15714. export class FactorGradient implements IValueGradient {
  15715. /**
  15716. * Gets or sets the gradient value (between 0 and 1)
  15717. */
  15718. gradient: number;
  15719. /**
  15720. * Gets or sets first associated factor
  15721. */
  15722. factor1: number;
  15723. /**
  15724. * Gets or sets second associated factor
  15725. */
  15726. factor2?: number;
  15727. /**
  15728. * Will get a number picked randomly between factor1 and factor2.
  15729. * If factor2 is undefined then factor1 will be used
  15730. * @returns the picked number
  15731. */
  15732. getFactor(): number;
  15733. }
  15734. /**
  15735. * Helper used to simplify some generic gradient tasks
  15736. */
  15737. export class GradientHelper {
  15738. /**
  15739. * Gets the current gradient from an array of IValueGradient
  15740. * @param ratio defines the current ratio to get
  15741. * @param gradients defines the array of IValueGradient
  15742. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15743. */
  15744. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15745. }
  15746. }
  15747. declare module BABYLON {
  15748. interface AbstractScene {
  15749. /**
  15750. * The list of procedural textures added to the scene
  15751. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15752. */
  15753. proceduralTextures: Array<ProceduralTexture>;
  15754. }
  15755. /**
  15756. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15757. * in a given scene.
  15758. */
  15759. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15760. /**
  15761. * The component name helpfull to identify the component in the list of scene components.
  15762. */
  15763. readonly name: string;
  15764. /**
  15765. * The scene the component belongs to.
  15766. */
  15767. scene: Scene;
  15768. /**
  15769. * Creates a new instance of the component for the given scene
  15770. * @param scene Defines the scene to register the component in
  15771. */
  15772. constructor(scene: Scene);
  15773. /**
  15774. * Registers the component in a given scene
  15775. */
  15776. register(): void;
  15777. /**
  15778. * Rebuilds the elements related to this component in case of
  15779. * context lost for instance.
  15780. */
  15781. rebuild(): void;
  15782. /**
  15783. * Disposes the component and the associated ressources.
  15784. */
  15785. dispose(): void;
  15786. private _beforeClear;
  15787. }
  15788. }
  15789. declare module BABYLON {
  15790. interface Engine {
  15791. /**
  15792. * Creates a new render target cube texture
  15793. * @param size defines the size of the texture
  15794. * @param options defines the options used to create the texture
  15795. * @returns a new render target cube texture stored in an InternalTexture
  15796. */
  15797. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15798. }
  15799. }
  15800. declare module BABYLON {
  15801. /** @hidden */
  15802. export var proceduralVertexShader: {
  15803. name: string;
  15804. shader: string;
  15805. };
  15806. }
  15807. declare module BABYLON {
  15808. /**
  15809. * 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.
  15810. * This is the base class of any Procedural texture and contains most of the shareable code.
  15811. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15812. */
  15813. export class ProceduralTexture extends Texture {
  15814. isCube: boolean;
  15815. /**
  15816. * Define if the texture is enabled or not (disabled texture will not render)
  15817. */
  15818. isEnabled: boolean;
  15819. /**
  15820. * Define if the texture must be cleared before rendering (default is true)
  15821. */
  15822. autoClear: boolean;
  15823. /**
  15824. * Callback called when the texture is generated
  15825. */
  15826. onGenerated: () => void;
  15827. /**
  15828. * Event raised when the texture is generated
  15829. */
  15830. onGeneratedObservable: Observable<ProceduralTexture>;
  15831. /** @hidden */ private _generateMipMaps: boolean;
  15832. /** @hidden **/ private _effect: Effect;
  15833. /** @hidden */ private _textures: {
  15834. [key: string]: Texture;
  15835. };
  15836. private _size;
  15837. private _currentRefreshId;
  15838. private _refreshRate;
  15839. private _vertexBuffers;
  15840. private _indexBuffer;
  15841. private _uniforms;
  15842. private _samplers;
  15843. private _fragment;
  15844. private _floats;
  15845. private _ints;
  15846. private _floatsArrays;
  15847. private _colors3;
  15848. private _colors4;
  15849. private _vectors2;
  15850. private _vectors3;
  15851. private _matrices;
  15852. private _fallbackTexture;
  15853. private _fallbackTextureUsed;
  15854. private _engine;
  15855. private _cachedDefines;
  15856. private _contentUpdateId;
  15857. private _contentData;
  15858. /**
  15859. * Instantiates a new procedural texture.
  15860. * 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.
  15861. * This is the base class of any Procedural texture and contains most of the shareable code.
  15862. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15863. * @param name Define the name of the texture
  15864. * @param size Define the size of the texture to create
  15865. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15866. * @param scene Define the scene the texture belongs to
  15867. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15868. * @param generateMipMaps Define if the texture should creates mip maps or not
  15869. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15870. */
  15871. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15872. /**
  15873. * The effect that is created when initializing the post process.
  15874. * @returns The created effect corresponding the the postprocess.
  15875. */
  15876. getEffect(): Effect;
  15877. /**
  15878. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15879. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15880. */
  15881. getContent(): Nullable<ArrayBufferView>;
  15882. private _createIndexBuffer;
  15883. /** @hidden */ private _rebuild(): void;
  15884. /**
  15885. * Resets the texture in order to recreate its associated resources.
  15886. * This can be called in case of context loss
  15887. */
  15888. reset(): void;
  15889. protected _getDefines(): string;
  15890. /**
  15891. * Is the texture ready to be used ? (rendered at least once)
  15892. * @returns true if ready, otherwise, false.
  15893. */
  15894. isReady(): boolean;
  15895. /**
  15896. * Resets the refresh counter of the texture and start bak from scratch.
  15897. * Could be useful to regenerate the texture if it is setup to render only once.
  15898. */
  15899. resetRefreshCounter(): void;
  15900. /**
  15901. * Set the fragment shader to use in order to render the texture.
  15902. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15903. */
  15904. setFragment(fragment: any): void;
  15905. /**
  15906. * Define the refresh rate of the texture or the rendering frequency.
  15907. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15908. */
  15909. refreshRate: number;
  15910. /** @hidden */ private _shouldRender(): boolean;
  15911. /**
  15912. * Get the size the texture is rendering at.
  15913. * @returns the size (texture is always squared)
  15914. */
  15915. getRenderSize(): number;
  15916. /**
  15917. * Resize the texture to new value.
  15918. * @param size Define the new size the texture should have
  15919. * @param generateMipMaps Define whether the new texture should create mip maps
  15920. */
  15921. resize(size: number, generateMipMaps: boolean): void;
  15922. private _checkUniform;
  15923. /**
  15924. * Set a texture in the shader program used to render.
  15925. * @param name Define the name of the uniform samplers as defined in the shader
  15926. * @param texture Define the texture to bind to this sampler
  15927. * @return the texture itself allowing "fluent" like uniform updates
  15928. */
  15929. setTexture(name: string, texture: Texture): ProceduralTexture;
  15930. /**
  15931. * Set a float in the shader.
  15932. * @param name Define the name of the uniform as defined in the shader
  15933. * @param value Define the value to give to the uniform
  15934. * @return the texture itself allowing "fluent" like uniform updates
  15935. */
  15936. setFloat(name: string, value: number): ProceduralTexture;
  15937. /**
  15938. * Set a int in the shader.
  15939. * @param name Define the name of the uniform as defined in the shader
  15940. * @param value Define the value to give to the uniform
  15941. * @return the texture itself allowing "fluent" like uniform updates
  15942. */
  15943. setInt(name: string, value: number): ProceduralTexture;
  15944. /**
  15945. * Set an array of floats in the shader.
  15946. * @param name Define the name of the uniform as defined in the shader
  15947. * @param value Define the value to give to the uniform
  15948. * @return the texture itself allowing "fluent" like uniform updates
  15949. */
  15950. setFloats(name: string, value: number[]): ProceduralTexture;
  15951. /**
  15952. * Set a vec3 in the shader from a Color3.
  15953. * @param name Define the name of the uniform as defined in the shader
  15954. * @param value Define the value to give to the uniform
  15955. * @return the texture itself allowing "fluent" like uniform updates
  15956. */
  15957. setColor3(name: string, value: Color3): ProceduralTexture;
  15958. /**
  15959. * Set a vec4 in the shader from a Color4.
  15960. * @param name Define the name of the uniform as defined in the shader
  15961. * @param value Define the value to give to the uniform
  15962. * @return the texture itself allowing "fluent" like uniform updates
  15963. */
  15964. setColor4(name: string, value: Color4): ProceduralTexture;
  15965. /**
  15966. * Set a vec2 in the shader from a Vector2.
  15967. * @param name Define the name of the uniform as defined in the shader
  15968. * @param value Define the value to give to the uniform
  15969. * @return the texture itself allowing "fluent" like uniform updates
  15970. */
  15971. setVector2(name: string, value: Vector2): ProceduralTexture;
  15972. /**
  15973. * Set a vec3 in the shader from a Vector3.
  15974. * @param name Define the name of the uniform as defined in the shader
  15975. * @param value Define the value to give to the uniform
  15976. * @return the texture itself allowing "fluent" like uniform updates
  15977. */
  15978. setVector3(name: string, value: Vector3): ProceduralTexture;
  15979. /**
  15980. * Set a mat4 in the shader from a MAtrix.
  15981. * @param name Define the name of the uniform as defined in the shader
  15982. * @param value Define the value to give to the uniform
  15983. * @return the texture itself allowing "fluent" like uniform updates
  15984. */
  15985. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15986. /**
  15987. * Render the texture to its associated render target.
  15988. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15989. */
  15990. render(useCameraPostProcess?: boolean): void;
  15991. /**
  15992. * Clone the texture.
  15993. * @returns the cloned texture
  15994. */
  15995. clone(): ProceduralTexture;
  15996. /**
  15997. * Dispose the texture and release its asoociated resources.
  15998. */
  15999. dispose(): void;
  16000. }
  16001. }
  16002. declare module BABYLON {
  16003. /**
  16004. * This represents the base class for particle system in Babylon.
  16005. * 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.
  16006. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16007. * @example https://doc.babylonjs.com/babylon101/particles
  16008. */
  16009. export class BaseParticleSystem {
  16010. /**
  16011. * Source color is added to the destination color without alpha affecting the result
  16012. */
  16013. static BLENDMODE_ONEONE: number;
  16014. /**
  16015. * Blend current color and particle color using particle’s alpha
  16016. */
  16017. static BLENDMODE_STANDARD: number;
  16018. /**
  16019. * Add current color and particle color multiplied by particle’s alpha
  16020. */
  16021. static BLENDMODE_ADD: number;
  16022. /**
  16023. * Multiply current color with particle color
  16024. */
  16025. static BLENDMODE_MULTIPLY: number;
  16026. /**
  16027. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16028. */
  16029. static BLENDMODE_MULTIPLYADD: number;
  16030. /**
  16031. * List of animations used by the particle system.
  16032. */
  16033. animations: Animation[];
  16034. /**
  16035. * The id of the Particle system.
  16036. */
  16037. id: string;
  16038. /**
  16039. * The friendly name of the Particle system.
  16040. */
  16041. name: string;
  16042. /**
  16043. * The rendering group used by the Particle system to chose when to render.
  16044. */
  16045. renderingGroupId: number;
  16046. /**
  16047. * The emitter represents the Mesh or position we are attaching the particle system to.
  16048. */
  16049. emitter: Nullable<AbstractMesh | Vector3>;
  16050. /**
  16051. * The maximum number of particles to emit per frame
  16052. */
  16053. emitRate: number;
  16054. /**
  16055. * If you want to launch only a few particles at once, that can be done, as well.
  16056. */
  16057. manualEmitCount: number;
  16058. /**
  16059. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16060. */
  16061. updateSpeed: number;
  16062. /**
  16063. * The amount of time the particle system is running (depends of the overall update speed).
  16064. */
  16065. targetStopDuration: number;
  16066. /**
  16067. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16068. */
  16069. disposeOnStop: boolean;
  16070. /**
  16071. * Minimum power of emitting particles.
  16072. */
  16073. minEmitPower: number;
  16074. /**
  16075. * Maximum power of emitting particles.
  16076. */
  16077. maxEmitPower: number;
  16078. /**
  16079. * Minimum life time of emitting particles.
  16080. */
  16081. minLifeTime: number;
  16082. /**
  16083. * Maximum life time of emitting particles.
  16084. */
  16085. maxLifeTime: number;
  16086. /**
  16087. * Minimum Size of emitting particles.
  16088. */
  16089. minSize: number;
  16090. /**
  16091. * Maximum Size of emitting particles.
  16092. */
  16093. maxSize: number;
  16094. /**
  16095. * Minimum scale of emitting particles on X axis.
  16096. */
  16097. minScaleX: number;
  16098. /**
  16099. * Maximum scale of emitting particles on X axis.
  16100. */
  16101. maxScaleX: number;
  16102. /**
  16103. * Minimum scale of emitting particles on Y axis.
  16104. */
  16105. minScaleY: number;
  16106. /**
  16107. * Maximum scale of emitting particles on Y axis.
  16108. */
  16109. maxScaleY: number;
  16110. /**
  16111. * Gets or sets the minimal initial rotation in radians.
  16112. */
  16113. minInitialRotation: number;
  16114. /**
  16115. * Gets or sets the maximal initial rotation in radians.
  16116. */
  16117. maxInitialRotation: number;
  16118. /**
  16119. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16120. */
  16121. minAngularSpeed: number;
  16122. /**
  16123. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16124. */
  16125. maxAngularSpeed: number;
  16126. /**
  16127. * The texture used to render each particle. (this can be a spritesheet)
  16128. */
  16129. particleTexture: Nullable<Texture>;
  16130. /**
  16131. * The layer mask we are rendering the particles through.
  16132. */
  16133. layerMask: number;
  16134. /**
  16135. * This can help using your own shader to render the particle system.
  16136. * The according effect will be created
  16137. */
  16138. customShader: any;
  16139. /**
  16140. * By default particle system starts as soon as they are created. This prevents the
  16141. * automatic start to happen and let you decide when to start emitting particles.
  16142. */
  16143. preventAutoStart: boolean;
  16144. private _noiseTexture;
  16145. /**
  16146. * Gets or sets a texture used to add random noise to particle positions
  16147. */
  16148. noiseTexture: Nullable<ProceduralTexture>;
  16149. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16150. noiseStrength: Vector3;
  16151. /**
  16152. * Callback triggered when the particle animation is ending.
  16153. */
  16154. onAnimationEnd: Nullable<() => void>;
  16155. /**
  16156. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16157. */
  16158. blendMode: number;
  16159. /**
  16160. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16161. * to override the particles.
  16162. */
  16163. forceDepthWrite: boolean;
  16164. /** 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 */
  16165. preWarmCycles: number;
  16166. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16167. preWarmStepOffset: number;
  16168. /**
  16169. * 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)
  16170. */
  16171. spriteCellChangeSpeed: number;
  16172. /**
  16173. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16174. */
  16175. startSpriteCellID: number;
  16176. /**
  16177. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16178. */
  16179. endSpriteCellID: number;
  16180. /**
  16181. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16182. */
  16183. spriteCellWidth: number;
  16184. /**
  16185. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16186. */
  16187. spriteCellHeight: number;
  16188. /**
  16189. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16190. */
  16191. spriteRandomStartCell: boolean;
  16192. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16193. translationPivot: Vector2;
  16194. /** @hidden */
  16195. protected _isAnimationSheetEnabled: boolean;
  16196. /**
  16197. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16198. */
  16199. beginAnimationOnStart: boolean;
  16200. /**
  16201. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16202. */
  16203. beginAnimationFrom: number;
  16204. /**
  16205. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16206. */
  16207. beginAnimationTo: number;
  16208. /**
  16209. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16210. */
  16211. beginAnimationLoop: boolean;
  16212. /**
  16213. * Gets or sets a world offset applied to all particles
  16214. */
  16215. worldOffset: Vector3;
  16216. /**
  16217. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16218. */
  16219. isAnimationSheetEnabled: boolean;
  16220. /**
  16221. * Get hosting scene
  16222. * @returns the scene
  16223. */
  16224. getScene(): Scene;
  16225. /**
  16226. * You can use gravity if you want to give an orientation to your particles.
  16227. */
  16228. gravity: Vector3;
  16229. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16230. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16231. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16232. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16233. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16234. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16235. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16236. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16237. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16238. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16239. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16240. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16241. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16242. /**
  16243. * Defines the delay in milliseconds before starting the system (0 by default)
  16244. */
  16245. startDelay: number;
  16246. /**
  16247. * Gets the current list of drag gradients.
  16248. * You must use addDragGradient and removeDragGradient to udpate this list
  16249. * @returns the list of drag gradients
  16250. */
  16251. getDragGradients(): Nullable<Array<FactorGradient>>;
  16252. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16253. limitVelocityDamping: number;
  16254. /**
  16255. * Gets the current list of limit velocity gradients.
  16256. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16257. * @returns the list of limit velocity gradients
  16258. */
  16259. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16260. /**
  16261. * Gets the current list of color gradients.
  16262. * You must use addColorGradient and removeColorGradient to udpate this list
  16263. * @returns the list of color gradients
  16264. */
  16265. getColorGradients(): Nullable<Array<ColorGradient>>;
  16266. /**
  16267. * Gets the current list of size gradients.
  16268. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16269. * @returns the list of size gradients
  16270. */
  16271. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16272. /**
  16273. * Gets the current list of color remap gradients.
  16274. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16275. * @returns the list of color remap gradients
  16276. */
  16277. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16278. /**
  16279. * Gets the current list of alpha remap gradients.
  16280. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16281. * @returns the list of alpha remap gradients
  16282. */
  16283. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16284. /**
  16285. * Gets the current list of life time gradients.
  16286. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16287. * @returns the list of life time gradients
  16288. */
  16289. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16290. /**
  16291. * Gets the current list of angular speed gradients.
  16292. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16293. * @returns the list of angular speed gradients
  16294. */
  16295. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16296. /**
  16297. * Gets the current list of velocity gradients.
  16298. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16299. * @returns the list of velocity gradients
  16300. */
  16301. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16302. /**
  16303. * Gets the current list of start size gradients.
  16304. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16305. * @returns the list of start size gradients
  16306. */
  16307. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16308. /**
  16309. * Gets the current list of emit rate gradients.
  16310. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16311. * @returns the list of emit rate gradients
  16312. */
  16313. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16314. /**
  16315. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16316. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16317. */
  16318. direction1: Vector3;
  16319. /**
  16320. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16321. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16322. */
  16323. direction2: Vector3;
  16324. /**
  16325. * 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.
  16326. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16327. */
  16328. minEmitBox: Vector3;
  16329. /**
  16330. * 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.
  16331. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16332. */
  16333. maxEmitBox: Vector3;
  16334. /**
  16335. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16336. */
  16337. color1: Color4;
  16338. /**
  16339. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16340. */
  16341. color2: Color4;
  16342. /**
  16343. * Color the particle will have at the end of its lifetime
  16344. */
  16345. colorDead: Color4;
  16346. /**
  16347. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16348. */
  16349. textureMask: Color4;
  16350. /**
  16351. * The particle emitter type defines the emitter used by the particle system.
  16352. * It can be for example box, sphere, or cone...
  16353. */
  16354. particleEmitterType: IParticleEmitterType;
  16355. /** @hidden */ private _isSubEmitter: boolean;
  16356. /**
  16357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16359. */
  16360. billboardMode: number;
  16361. protected _isBillboardBased: boolean;
  16362. /**
  16363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16364. */
  16365. isBillboardBased: boolean;
  16366. /**
  16367. * The scene the particle system belongs to.
  16368. */
  16369. protected _scene: Scene;
  16370. /**
  16371. * Local cache of defines for image processing.
  16372. */
  16373. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16374. /**
  16375. * Default configuration related to image processing available in the standard Material.
  16376. */
  16377. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16378. /**
  16379. * Gets the image processing configuration used either in this material.
  16380. */
  16381. /**
  16382. * Sets the Default image processing configuration used either in the this material.
  16383. *
  16384. * If sets to null, the scene one is in use.
  16385. */
  16386. imageProcessingConfiguration: ImageProcessingConfiguration;
  16387. /**
  16388. * Attaches a new image processing configuration to the Standard Material.
  16389. * @param configuration
  16390. */
  16391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16392. /** @hidden */
  16393. protected _reset(): void;
  16394. /** @hidden */
  16395. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16396. /**
  16397. * Instantiates a particle system.
  16398. * 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.
  16399. * @param name The name of the particle system
  16400. */
  16401. constructor(name: string);
  16402. /**
  16403. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16406. * @returns the emitter
  16407. */
  16408. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16409. /**
  16410. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16411. * @param radius The radius of the hemisphere to emit from
  16412. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16413. * @returns the emitter
  16414. */
  16415. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16416. /**
  16417. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16418. * @param radius The radius of the sphere to emit from
  16419. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16420. * @returns the emitter
  16421. */
  16422. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16423. /**
  16424. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16425. * @param radius The radius of the sphere to emit from
  16426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16428. * @returns the emitter
  16429. */
  16430. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16431. /**
  16432. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16433. * @param radius The radius of the emission cylinder
  16434. * @param height The height of the emission cylinder
  16435. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16436. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16437. * @returns the emitter
  16438. */
  16439. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16440. /**
  16441. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16442. * @param radius The radius of the cylinder to emit from
  16443. * @param height The height of the emission cylinder
  16444. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16447. * @returns the emitter
  16448. */
  16449. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16450. /**
  16451. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16452. * @param radius The radius of the cone to emit from
  16453. * @param angle The base angle of the cone
  16454. * @returns the emitter
  16455. */
  16456. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16457. /**
  16458. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16461. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16462. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16463. * @returns the emitter
  16464. */
  16465. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16466. }
  16467. }
  16468. declare module BABYLON {
  16469. /**
  16470. * Type of sub emitter
  16471. */
  16472. export enum SubEmitterType {
  16473. /**
  16474. * Attached to the particle over it's lifetime
  16475. */
  16476. ATTACHED = 0,
  16477. /**
  16478. * Created when the particle dies
  16479. */
  16480. END = 1
  16481. }
  16482. /**
  16483. * Sub emitter class used to emit particles from an existing particle
  16484. */
  16485. export class SubEmitter {
  16486. /**
  16487. * the particle system to be used by the sub emitter
  16488. */
  16489. particleSystem: ParticleSystem;
  16490. /**
  16491. * Type of the submitter (Default: END)
  16492. */
  16493. type: SubEmitterType;
  16494. /**
  16495. * 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)
  16496. * Note: This only is supported when using an emitter of type Mesh
  16497. */
  16498. inheritDirection: boolean;
  16499. /**
  16500. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16501. */
  16502. inheritedVelocityAmount: number;
  16503. /**
  16504. * Creates a sub emitter
  16505. * @param particleSystem the particle system to be used by the sub emitter
  16506. */
  16507. constructor(
  16508. /**
  16509. * the particle system to be used by the sub emitter
  16510. */
  16511. particleSystem: ParticleSystem);
  16512. /**
  16513. * Clones the sub emitter
  16514. * @returns the cloned sub emitter
  16515. */
  16516. clone(): SubEmitter;
  16517. /**
  16518. * Serialize current object to a JSON object
  16519. * @returns the serialized object
  16520. */
  16521. serialize(): any;
  16522. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16523. /**
  16524. * Creates a new SubEmitter from a serialized JSON version
  16525. * @param serializationObject defines the JSON object to read from
  16526. * @param scene defines the hosting scene
  16527. * @param rootUrl defines the rootUrl for data loading
  16528. * @returns a new SubEmitter
  16529. */
  16530. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16531. /** Release associated resources */
  16532. dispose(): void;
  16533. }
  16534. }
  16535. declare module BABYLON {
  16536. /** @hidden */
  16537. export var clipPlaneFragmentDeclaration: {
  16538. name: string;
  16539. shader: string;
  16540. };
  16541. }
  16542. declare module BABYLON {
  16543. /** @hidden */
  16544. export var imageProcessingDeclaration: {
  16545. name: string;
  16546. shader: string;
  16547. };
  16548. }
  16549. declare module BABYLON {
  16550. /** @hidden */
  16551. export var imageProcessingFunctions: {
  16552. name: string;
  16553. shader: string;
  16554. };
  16555. }
  16556. declare module BABYLON {
  16557. /** @hidden */
  16558. export var clipPlaneFragment: {
  16559. name: string;
  16560. shader: string;
  16561. };
  16562. }
  16563. declare module BABYLON {
  16564. /** @hidden */
  16565. export var particlesPixelShader: {
  16566. name: string;
  16567. shader: string;
  16568. };
  16569. }
  16570. declare module BABYLON {
  16571. /** @hidden */
  16572. export var clipPlaneVertexDeclaration: {
  16573. name: string;
  16574. shader: string;
  16575. };
  16576. }
  16577. declare module BABYLON {
  16578. /** @hidden */
  16579. export var clipPlaneVertex: {
  16580. name: string;
  16581. shader: string;
  16582. };
  16583. }
  16584. declare module BABYLON {
  16585. /** @hidden */
  16586. export var particlesVertexShader: {
  16587. name: string;
  16588. shader: string;
  16589. };
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * This represents a particle system in Babylon.
  16594. * 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.
  16595. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16596. * @example https://doc.babylonjs.com/babylon101/particles
  16597. */
  16598. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16599. /**
  16600. * Billboard mode will only apply to Y axis
  16601. */
  16602. static readonly BILLBOARDMODE_Y: number;
  16603. /**
  16604. * Billboard mode will apply to all axes
  16605. */
  16606. static readonly BILLBOARDMODE_ALL: number;
  16607. /**
  16608. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16609. */
  16610. static readonly BILLBOARDMODE_STRETCHED: number;
  16611. /**
  16612. * This function can be defined to provide custom update for active particles.
  16613. * This function will be called instead of regular update (age, position, color, etc.).
  16614. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16615. */
  16616. updateFunction: (particles: Particle[]) => void;
  16617. private _emitterWorldMatrix;
  16618. /**
  16619. * This function can be defined to specify initial direction for every new particle.
  16620. * It by default use the emitterType defined function
  16621. */
  16622. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16623. /**
  16624. * This function can be defined to specify initial position for every new particle.
  16625. * It by default use the emitterType defined function
  16626. */
  16627. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16628. /**
  16629. * @hidden
  16630. */ private _inheritedVelocityOffset: Vector3;
  16631. /**
  16632. * An event triggered when the system is disposed
  16633. */
  16634. onDisposeObservable: Observable<ParticleSystem>;
  16635. private _onDisposeObserver;
  16636. /**
  16637. * Sets a callback that will be triggered when the system is disposed
  16638. */
  16639. onDispose: () => void;
  16640. private _particles;
  16641. private _epsilon;
  16642. private _capacity;
  16643. private _stockParticles;
  16644. private _newPartsExcess;
  16645. private _vertexData;
  16646. private _vertexBuffer;
  16647. private _vertexBuffers;
  16648. private _spriteBuffer;
  16649. private _indexBuffer;
  16650. private _effect;
  16651. private _customEffect;
  16652. private _cachedDefines;
  16653. private _scaledColorStep;
  16654. private _colorDiff;
  16655. private _scaledDirection;
  16656. private _scaledGravity;
  16657. private _currentRenderId;
  16658. private _alive;
  16659. private _useInstancing;
  16660. private _started;
  16661. private _stopped;
  16662. private _actualFrame;
  16663. private _scaledUpdateSpeed;
  16664. private _vertexBufferSize;
  16665. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16666. /** @hidden */ private _currentEmitRate1: number;
  16667. /** @hidden */ private _currentEmitRate2: number;
  16668. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16669. /** @hidden */ private _currentStartSize1: number;
  16670. /** @hidden */ private _currentStartSize2: number;
  16671. private readonly _rawTextureWidth;
  16672. private _rampGradientsTexture;
  16673. private _useRampGradients;
  16674. /** Gets or sets a boolean indicating that ramp gradients must be used
  16675. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16676. */
  16677. useRampGradients: boolean;
  16678. /**
  16679. * 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.
  16680. * 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: [])
  16681. */
  16682. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16683. private _subEmitters;
  16684. /**
  16685. * @hidden
  16686. * If the particle systems emitter should be disposed when the particle system is disposed
  16687. */ private _disposeEmitterOnDispose: boolean;
  16688. /**
  16689. * The current active Sub-systems, this property is used by the root particle system only.
  16690. */
  16691. activeSubSystems: Array<ParticleSystem>;
  16692. private _rootParticleSystem;
  16693. /**
  16694. * Gets the current list of active particles
  16695. */
  16696. readonly particles: Particle[];
  16697. /**
  16698. * Returns the string "ParticleSystem"
  16699. * @returns a string containing the class name
  16700. */
  16701. getClassName(): string;
  16702. /**
  16703. * Instantiates a particle system.
  16704. * 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.
  16705. * @param name The name of the particle system
  16706. * @param capacity The max number of particles alive at the same time
  16707. * @param scene The scene the particle system belongs to
  16708. * @param customEffect a custom effect used to change the way particles are rendered by default
  16709. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16710. * @param epsilon Offset used to render the particles
  16711. */
  16712. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16713. private _addFactorGradient;
  16714. private _removeFactorGradient;
  16715. /**
  16716. * Adds a new life time gradient
  16717. * @param gradient defines the gradient to use (between 0 and 1)
  16718. * @param factor defines the life time factor to affect to the specified gradient
  16719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16720. * @returns the current particle system
  16721. */
  16722. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16723. /**
  16724. * Remove a specific life time gradient
  16725. * @param gradient defines the gradient to remove
  16726. * @returns the current particle system
  16727. */
  16728. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16729. /**
  16730. * Adds a new size gradient
  16731. * @param gradient defines the gradient to use (between 0 and 1)
  16732. * @param factor defines the size factor to affect to the specified gradient
  16733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16734. * @returns the current particle system
  16735. */
  16736. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16737. /**
  16738. * Remove a specific size gradient
  16739. * @param gradient defines the gradient to remove
  16740. * @returns the current particle system
  16741. */
  16742. removeSizeGradient(gradient: number): IParticleSystem;
  16743. /**
  16744. * Adds a new color remap gradient
  16745. * @param gradient defines the gradient to use (between 0 and 1)
  16746. * @param min defines the color remap minimal range
  16747. * @param max defines the color remap maximal range
  16748. * @returns the current particle system
  16749. */
  16750. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16751. /**
  16752. * Remove a specific color remap gradient
  16753. * @param gradient defines the gradient to remove
  16754. * @returns the current particle system
  16755. */
  16756. removeColorRemapGradient(gradient: number): IParticleSystem;
  16757. /**
  16758. * Adds a new alpha remap gradient
  16759. * @param gradient defines the gradient to use (between 0 and 1)
  16760. * @param min defines the alpha remap minimal range
  16761. * @param max defines the alpha remap maximal range
  16762. * @returns the current particle system
  16763. */
  16764. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16765. /**
  16766. * Remove a specific alpha remap gradient
  16767. * @param gradient defines the gradient to remove
  16768. * @returns the current particle system
  16769. */
  16770. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16771. /**
  16772. * Adds a new angular speed gradient
  16773. * @param gradient defines the gradient to use (between 0 and 1)
  16774. * @param factor defines the angular speed to affect to the specified gradient
  16775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16776. * @returns the current particle system
  16777. */
  16778. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16779. /**
  16780. * Remove a specific angular speed gradient
  16781. * @param gradient defines the gradient to remove
  16782. * @returns the current particle system
  16783. */
  16784. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16785. /**
  16786. * Adds a new velocity gradient
  16787. * @param gradient defines the gradient to use (between 0 and 1)
  16788. * @param factor defines the velocity to affect to the specified gradient
  16789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16790. * @returns the current particle system
  16791. */
  16792. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16793. /**
  16794. * Remove a specific velocity gradient
  16795. * @param gradient defines the gradient to remove
  16796. * @returns the current particle system
  16797. */
  16798. removeVelocityGradient(gradient: number): IParticleSystem;
  16799. /**
  16800. * Adds a new limit velocity gradient
  16801. * @param gradient defines the gradient to use (between 0 and 1)
  16802. * @param factor defines the limit velocity value to affect to the specified gradient
  16803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16804. * @returns the current particle system
  16805. */
  16806. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16807. /**
  16808. * Remove a specific limit velocity gradient
  16809. * @param gradient defines the gradient to remove
  16810. * @returns the current particle system
  16811. */
  16812. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16813. /**
  16814. * Adds a new drag gradient
  16815. * @param gradient defines the gradient to use (between 0 and 1)
  16816. * @param factor defines the drag value to affect to the specified gradient
  16817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16818. * @returns the current particle system
  16819. */
  16820. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16821. /**
  16822. * Remove a specific drag gradient
  16823. * @param gradient defines the gradient to remove
  16824. * @returns the current particle system
  16825. */
  16826. removeDragGradient(gradient: number): IParticleSystem;
  16827. /**
  16828. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16829. * @param gradient defines the gradient to use (between 0 and 1)
  16830. * @param factor defines the emit rate value to affect to the specified gradient
  16831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16832. * @returns the current particle system
  16833. */
  16834. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16835. /**
  16836. * Remove a specific emit rate gradient
  16837. * @param gradient defines the gradient to remove
  16838. * @returns the current particle system
  16839. */
  16840. removeEmitRateGradient(gradient: number): IParticleSystem;
  16841. /**
  16842. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16843. * @param gradient defines the gradient to use (between 0 and 1)
  16844. * @param factor defines the start size value to affect to the specified gradient
  16845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16846. * @returns the current particle system
  16847. */
  16848. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16849. /**
  16850. * Remove a specific start size gradient
  16851. * @param gradient defines the gradient to remove
  16852. * @returns the current particle system
  16853. */
  16854. removeStartSizeGradient(gradient: number): IParticleSystem;
  16855. private _createRampGradientTexture;
  16856. /**
  16857. * Gets the current list of ramp gradients.
  16858. * You must use addRampGradient and removeRampGradient to udpate this list
  16859. * @returns the list of ramp gradients
  16860. */
  16861. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16862. /**
  16863. * Adds a new ramp gradient used to remap particle colors
  16864. * @param gradient defines the gradient to use (between 0 and 1)
  16865. * @param color defines the color to affect to the specified gradient
  16866. * @returns the current particle system
  16867. */
  16868. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16869. /**
  16870. * Remove a specific ramp gradient
  16871. * @param gradient defines the gradient to remove
  16872. * @returns the current particle system
  16873. */
  16874. removeRampGradient(gradient: number): ParticleSystem;
  16875. /**
  16876. * Adds a new color gradient
  16877. * @param gradient defines the gradient to use (between 0 and 1)
  16878. * @param color1 defines the color to affect to the specified gradient
  16879. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16880. * @returns this particle system
  16881. */
  16882. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16883. /**
  16884. * Remove a specific color gradient
  16885. * @param gradient defines the gradient to remove
  16886. * @returns this particle system
  16887. */
  16888. removeColorGradient(gradient: number): IParticleSystem;
  16889. private _fetchR;
  16890. protected _reset(): void;
  16891. private _resetEffect;
  16892. private _createVertexBuffers;
  16893. private _createIndexBuffer;
  16894. /**
  16895. * Gets the maximum number of particles active at the same time.
  16896. * @returns The max number of active particles.
  16897. */
  16898. getCapacity(): number;
  16899. /**
  16900. * Gets whether there are still active particles in the system.
  16901. * @returns True if it is alive, otherwise false.
  16902. */
  16903. isAlive(): boolean;
  16904. /**
  16905. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16906. * @returns True if it has been started, otherwise false.
  16907. */
  16908. isStarted(): boolean;
  16909. private _prepareSubEmitterInternalArray;
  16910. /**
  16911. * Starts the particle system and begins to emit
  16912. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16913. */
  16914. start(delay?: number): void;
  16915. /**
  16916. * Stops the particle system.
  16917. * @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.
  16918. */
  16919. stop(stopSubEmitters?: boolean): void;
  16920. /**
  16921. * Remove all active particles
  16922. */
  16923. reset(): void;
  16924. /**
  16925. * @hidden (for internal use only)
  16926. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16927. /**
  16928. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16929. * Its lifetime will start back at 0.
  16930. */
  16931. recycleParticle: (particle: Particle) => void;
  16932. private _stopSubEmitters;
  16933. private _createParticle;
  16934. private _removeFromRoot;
  16935. private _emitFromParticle;
  16936. private _update;
  16937. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16938. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16939. /** @hidden */
  16940. private _getEffect;
  16941. /**
  16942. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16943. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16944. */
  16945. animate(preWarmOnly?: boolean): void;
  16946. private _appendParticleVertices;
  16947. /**
  16948. * Rebuilds the particle system.
  16949. */
  16950. rebuild(): void;
  16951. /**
  16952. * Is this system ready to be used/rendered
  16953. * @return true if the system is ready
  16954. */
  16955. isReady(): boolean;
  16956. private _render;
  16957. /**
  16958. * Renders the particle system in its current state.
  16959. * @returns the current number of particles
  16960. */
  16961. render(): number;
  16962. /**
  16963. * Disposes the particle system and free the associated resources
  16964. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16965. */
  16966. dispose(disposeTexture?: boolean): void;
  16967. /**
  16968. * Clones the particle system.
  16969. * @param name The name of the cloned object
  16970. * @param newEmitter The new emitter to use
  16971. * @returns the cloned particle system
  16972. */
  16973. clone(name: string, newEmitter: any): ParticleSystem;
  16974. /**
  16975. * Serializes the particle system to a JSON object.
  16976. * @returns the JSON object
  16977. */
  16978. serialize(): any;
  16979. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  16980. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  16981. /**
  16982. * Parses a JSON object to create a particle system.
  16983. * @param parsedParticleSystem The JSON object to parse
  16984. * @param scene The scene to create the particle system in
  16985. * @param rootUrl The root url to use to load external dependencies like texture
  16986. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16987. * @returns the Parsed particle system
  16988. */
  16989. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16990. }
  16991. }
  16992. declare module BABYLON {
  16993. /**
  16994. * A particle represents one of the element emitted by a particle system.
  16995. * This is mainly define by its coordinates, direction, velocity and age.
  16996. */
  16997. export class Particle {
  16998. /**
  16999. * The particle system the particle belongs to.
  17000. */
  17001. particleSystem: ParticleSystem;
  17002. private static _Count;
  17003. /**
  17004. * Unique ID of the particle
  17005. */
  17006. id: number;
  17007. /**
  17008. * The world position of the particle in the scene.
  17009. */
  17010. position: Vector3;
  17011. /**
  17012. * The world direction of the particle in the scene.
  17013. */
  17014. direction: Vector3;
  17015. /**
  17016. * The color of the particle.
  17017. */
  17018. color: Color4;
  17019. /**
  17020. * The color change of the particle per step.
  17021. */
  17022. colorStep: Color4;
  17023. /**
  17024. * Defines how long will the life of the particle be.
  17025. */
  17026. lifeTime: number;
  17027. /**
  17028. * The current age of the particle.
  17029. */
  17030. age: number;
  17031. /**
  17032. * The current size of the particle.
  17033. */
  17034. size: number;
  17035. /**
  17036. * The current scale of the particle.
  17037. */
  17038. scale: Vector2;
  17039. /**
  17040. * The current angle of the particle.
  17041. */
  17042. angle: number;
  17043. /**
  17044. * Defines how fast is the angle changing.
  17045. */
  17046. angularSpeed: number;
  17047. /**
  17048. * Defines the cell index used by the particle to be rendered from a sprite.
  17049. */
  17050. cellIndex: number;
  17051. /**
  17052. * The information required to support color remapping
  17053. */
  17054. remapData: Vector4;
  17055. /** @hidden */ private _randomCellOffset?: number;
  17056. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17057. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17058. /** @hidden */ private _initialStartSpriteCellID: number;
  17059. /** @hidden */ private _initialEndSpriteCellID: number;
  17060. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17061. /** @hidden */ private _currentColor1: Color4;
  17062. /** @hidden */ private _currentColor2: Color4;
  17063. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17064. /** @hidden */ private _currentSize1: number;
  17065. /** @hidden */ private _currentSize2: number;
  17066. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17067. /** @hidden */ private _currentAngularSpeed1: number;
  17068. /** @hidden */ private _currentAngularSpeed2: number;
  17069. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17070. /** @hidden */ private _currentVelocity1: number;
  17071. /** @hidden */ private _currentVelocity2: number;
  17072. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17073. /** @hidden */ private _currentLimitVelocity1: number;
  17074. /** @hidden */ private _currentLimitVelocity2: number;
  17075. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17076. /** @hidden */ private _currentDrag1: number;
  17077. /** @hidden */ private _currentDrag2: number;
  17078. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17079. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17080. /**
  17081. * Creates a new instance Particle
  17082. * @param particleSystem the particle system the particle belongs to
  17083. */
  17084. constructor(
  17085. /**
  17086. * The particle system the particle belongs to.
  17087. */
  17088. particleSystem: ParticleSystem);
  17089. private updateCellInfoFromSystem;
  17090. /**
  17091. * Defines how the sprite cell index is updated for the particle
  17092. */
  17093. updateCellIndex(): void;
  17094. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17095. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17096. /** @hidden */ private _reset(): void;
  17097. /**
  17098. * Copy the properties of particle to another one.
  17099. * @param other the particle to copy the information to.
  17100. */
  17101. copyTo(other: Particle): void;
  17102. }
  17103. }
  17104. declare module BABYLON {
  17105. /**
  17106. * Particle emitter represents a volume emitting particles.
  17107. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17108. */
  17109. export interface IParticleEmitterType {
  17110. /**
  17111. * Called by the particle System when the direction is computed for the created particle.
  17112. * @param worldMatrix is the world matrix of the particle system
  17113. * @param directionToUpdate is the direction vector to update with the result
  17114. * @param particle is the particle we are computed the direction for
  17115. */
  17116. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17117. /**
  17118. * Called by the particle System when the position is computed for the created particle.
  17119. * @param worldMatrix is the world matrix of the particle system
  17120. * @param positionToUpdate is the position vector to update with the result
  17121. * @param particle is the particle we are computed the position for
  17122. */
  17123. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17124. /**
  17125. * Clones the current emitter and returns a copy of it
  17126. * @returns the new emitter
  17127. */
  17128. clone(): IParticleEmitterType;
  17129. /**
  17130. * Called by the GPUParticleSystem to setup the update shader
  17131. * @param effect defines the update shader
  17132. */
  17133. applyToShader(effect: Effect): void;
  17134. /**
  17135. * Returns a string to use to update the GPU particles update shader
  17136. * @returns the effect defines string
  17137. */
  17138. getEffectDefines(): string;
  17139. /**
  17140. * Returns a string representing the class name
  17141. * @returns a string containing the class name
  17142. */
  17143. getClassName(): string;
  17144. /**
  17145. * Serializes the particle system to a JSON object.
  17146. * @returns the JSON object
  17147. */
  17148. serialize(): any;
  17149. /**
  17150. * Parse properties from a JSON object
  17151. * @param serializationObject defines the JSON object
  17152. */
  17153. parse(serializationObject: any): void;
  17154. }
  17155. }
  17156. declare module BABYLON {
  17157. /**
  17158. * Particle emitter emitting particles from the inside of a box.
  17159. * It emits the particles randomly between 2 given directions.
  17160. */
  17161. export class BoxParticleEmitter implements IParticleEmitterType {
  17162. /**
  17163. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17164. */
  17165. direction1: Vector3;
  17166. /**
  17167. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17168. */
  17169. direction2: Vector3;
  17170. /**
  17171. * 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.
  17172. */
  17173. minEmitBox: Vector3;
  17174. /**
  17175. * 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.
  17176. */
  17177. maxEmitBox: Vector3;
  17178. /**
  17179. * Creates a new instance BoxParticleEmitter
  17180. */
  17181. constructor();
  17182. /**
  17183. * Called by the particle System when the direction is computed for the created particle.
  17184. * @param worldMatrix is the world matrix of the particle system
  17185. * @param directionToUpdate is the direction vector to update with the result
  17186. * @param particle is the particle we are computed the direction for
  17187. */
  17188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17189. /**
  17190. * Called by the particle System when the position is computed for the created particle.
  17191. * @param worldMatrix is the world matrix of the particle system
  17192. * @param positionToUpdate is the position vector to update with the result
  17193. * @param particle is the particle we are computed the position for
  17194. */
  17195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17196. /**
  17197. * Clones the current emitter and returns a copy of it
  17198. * @returns the new emitter
  17199. */
  17200. clone(): BoxParticleEmitter;
  17201. /**
  17202. * Called by the GPUParticleSystem to setup the update shader
  17203. * @param effect defines the update shader
  17204. */
  17205. applyToShader(effect: Effect): void;
  17206. /**
  17207. * Returns a string to use to update the GPU particles update shader
  17208. * @returns a string containng the defines string
  17209. */
  17210. getEffectDefines(): string;
  17211. /**
  17212. * Returns the string "BoxParticleEmitter"
  17213. * @returns a string containing the class name
  17214. */
  17215. getClassName(): string;
  17216. /**
  17217. * Serializes the particle system to a JSON object.
  17218. * @returns the JSON object
  17219. */
  17220. serialize(): any;
  17221. /**
  17222. * Parse properties from a JSON object
  17223. * @param serializationObject defines the JSON object
  17224. */
  17225. parse(serializationObject: any): void;
  17226. }
  17227. }
  17228. declare module BABYLON {
  17229. /**
  17230. * Particle emitter emitting particles from the inside of a cone.
  17231. * It emits the particles alongside the cone volume from the base to the particle.
  17232. * The emission direction might be randomized.
  17233. */
  17234. export class ConeParticleEmitter implements IParticleEmitterType {
  17235. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17236. directionRandomizer: number;
  17237. private _radius;
  17238. private _angle;
  17239. private _height;
  17240. /**
  17241. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17242. */
  17243. radiusRange: number;
  17244. /**
  17245. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17246. */
  17247. heightRange: number;
  17248. /**
  17249. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17250. */
  17251. emitFromSpawnPointOnly: boolean;
  17252. /**
  17253. * Gets or sets the radius of the emission cone
  17254. */
  17255. radius: number;
  17256. /**
  17257. * Gets or sets the angle of the emission cone
  17258. */
  17259. angle: number;
  17260. private _buildHeight;
  17261. /**
  17262. * Creates a new instance ConeParticleEmitter
  17263. * @param radius the radius of the emission cone (1 by default)
  17264. * @param angle the cone base angle (PI by default)
  17265. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17266. */
  17267. constructor(radius?: number, angle?: number,
  17268. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17269. directionRandomizer?: number);
  17270. /**
  17271. * Called by the particle System when the direction is computed for the created particle.
  17272. * @param worldMatrix is the world matrix of the particle system
  17273. * @param directionToUpdate is the direction vector to update with the result
  17274. * @param particle is the particle we are computed the direction for
  17275. */
  17276. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17277. /**
  17278. * Called by the particle System when the position is computed for the created particle.
  17279. * @param worldMatrix is the world matrix of the particle system
  17280. * @param positionToUpdate is the position vector to update with the result
  17281. * @param particle is the particle we are computed the position for
  17282. */
  17283. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17284. /**
  17285. * Clones the current emitter and returns a copy of it
  17286. * @returns the new emitter
  17287. */
  17288. clone(): ConeParticleEmitter;
  17289. /**
  17290. * Called by the GPUParticleSystem to setup the update shader
  17291. * @param effect defines the update shader
  17292. */
  17293. applyToShader(effect: Effect): void;
  17294. /**
  17295. * Returns a string to use to update the GPU particles update shader
  17296. * @returns a string containng the defines string
  17297. */
  17298. getEffectDefines(): string;
  17299. /**
  17300. * Returns the string "ConeParticleEmitter"
  17301. * @returns a string containing the class name
  17302. */
  17303. getClassName(): string;
  17304. /**
  17305. * Serializes the particle system to a JSON object.
  17306. * @returns the JSON object
  17307. */
  17308. serialize(): any;
  17309. /**
  17310. * Parse properties from a JSON object
  17311. * @param serializationObject defines the JSON object
  17312. */
  17313. parse(serializationObject: any): void;
  17314. }
  17315. }
  17316. declare module BABYLON {
  17317. /**
  17318. * Particle emitter emitting particles from the inside of a cylinder.
  17319. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17320. */
  17321. export class CylinderParticleEmitter implements IParticleEmitterType {
  17322. /**
  17323. * The radius of the emission cylinder.
  17324. */
  17325. radius: number;
  17326. /**
  17327. * The height of the emission cylinder.
  17328. */
  17329. height: number;
  17330. /**
  17331. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17332. */
  17333. radiusRange: number;
  17334. /**
  17335. * How much to randomize the particle direction [0-1].
  17336. */
  17337. directionRandomizer: number;
  17338. /**
  17339. * Creates a new instance CylinderParticleEmitter
  17340. * @param radius the radius of the emission cylinder (1 by default)
  17341. * @param height the height of the emission cylinder (1 by default)
  17342. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17343. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17344. */
  17345. constructor(
  17346. /**
  17347. * The radius of the emission cylinder.
  17348. */
  17349. radius?: number,
  17350. /**
  17351. * The height of the emission cylinder.
  17352. */
  17353. height?: number,
  17354. /**
  17355. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17356. */
  17357. radiusRange?: number,
  17358. /**
  17359. * How much to randomize the particle direction [0-1].
  17360. */
  17361. directionRandomizer?: number);
  17362. /**
  17363. * Called by the particle System when the direction is computed for the created particle.
  17364. * @param worldMatrix is the world matrix of the particle system
  17365. * @param directionToUpdate is the direction vector to update with the result
  17366. * @param particle is the particle we are computed the direction for
  17367. */
  17368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17369. /**
  17370. * Called by the particle System when the position is computed for the created particle.
  17371. * @param worldMatrix is the world matrix of the particle system
  17372. * @param positionToUpdate is the position vector to update with the result
  17373. * @param particle is the particle we are computed the position for
  17374. */
  17375. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17376. /**
  17377. * Clones the current emitter and returns a copy of it
  17378. * @returns the new emitter
  17379. */
  17380. clone(): CylinderParticleEmitter;
  17381. /**
  17382. * Called by the GPUParticleSystem to setup the update shader
  17383. * @param effect defines the update shader
  17384. */
  17385. applyToShader(effect: Effect): void;
  17386. /**
  17387. * Returns a string to use to update the GPU particles update shader
  17388. * @returns a string containng the defines string
  17389. */
  17390. getEffectDefines(): string;
  17391. /**
  17392. * Returns the string "CylinderParticleEmitter"
  17393. * @returns a string containing the class name
  17394. */
  17395. getClassName(): string;
  17396. /**
  17397. * Serializes the particle system to a JSON object.
  17398. * @returns the JSON object
  17399. */
  17400. serialize(): any;
  17401. /**
  17402. * Parse properties from a JSON object
  17403. * @param serializationObject defines the JSON object
  17404. */
  17405. parse(serializationObject: any): void;
  17406. }
  17407. /**
  17408. * Particle emitter emitting particles from the inside of a cylinder.
  17409. * It emits the particles randomly between two vectors.
  17410. */
  17411. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17412. /**
  17413. * The min limit of the emission direction.
  17414. */
  17415. direction1: Vector3;
  17416. /**
  17417. * The max limit of the emission direction.
  17418. */
  17419. direction2: Vector3;
  17420. /**
  17421. * Creates a new instance CylinderDirectedParticleEmitter
  17422. * @param radius the radius of the emission cylinder (1 by default)
  17423. * @param height the height of the emission cylinder (1 by default)
  17424. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17425. * @param direction1 the min limit of the emission direction (up vector by default)
  17426. * @param direction2 the max limit of the emission direction (up vector by default)
  17427. */
  17428. constructor(radius?: number, height?: number, radiusRange?: number,
  17429. /**
  17430. * The min limit of the emission direction.
  17431. */
  17432. direction1?: Vector3,
  17433. /**
  17434. * The max limit of the emission direction.
  17435. */
  17436. direction2?: Vector3);
  17437. /**
  17438. * Called by the particle System when the direction is computed for the created particle.
  17439. * @param worldMatrix is the world matrix of the particle system
  17440. * @param directionToUpdate is the direction vector to update with the result
  17441. * @param particle is the particle we are computed the direction for
  17442. */
  17443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17444. /**
  17445. * Clones the current emitter and returns a copy of it
  17446. * @returns the new emitter
  17447. */
  17448. clone(): CylinderDirectedParticleEmitter;
  17449. /**
  17450. * Called by the GPUParticleSystem to setup the update shader
  17451. * @param effect defines the update shader
  17452. */
  17453. applyToShader(effect: Effect): void;
  17454. /**
  17455. * Returns a string to use to update the GPU particles update shader
  17456. * @returns a string containng the defines string
  17457. */
  17458. getEffectDefines(): string;
  17459. /**
  17460. * Returns the string "CylinderDirectedParticleEmitter"
  17461. * @returns a string containing the class name
  17462. */
  17463. getClassName(): string;
  17464. /**
  17465. * Serializes the particle system to a JSON object.
  17466. * @returns the JSON object
  17467. */
  17468. serialize(): any;
  17469. /**
  17470. * Parse properties from a JSON object
  17471. * @param serializationObject defines the JSON object
  17472. */
  17473. parse(serializationObject: any): void;
  17474. }
  17475. }
  17476. declare module BABYLON {
  17477. /**
  17478. * Particle emitter emitting particles from the inside of a hemisphere.
  17479. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17480. */
  17481. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17482. /**
  17483. * The radius of the emission hemisphere.
  17484. */
  17485. radius: number;
  17486. /**
  17487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17488. */
  17489. radiusRange: number;
  17490. /**
  17491. * How much to randomize the particle direction [0-1].
  17492. */
  17493. directionRandomizer: number;
  17494. /**
  17495. * Creates a new instance HemisphericParticleEmitter
  17496. * @param radius the radius of the emission hemisphere (1 by default)
  17497. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17498. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17499. */
  17500. constructor(
  17501. /**
  17502. * The radius of the emission hemisphere.
  17503. */
  17504. radius?: number,
  17505. /**
  17506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17507. */
  17508. radiusRange?: number,
  17509. /**
  17510. * How much to randomize the particle direction [0-1].
  17511. */
  17512. directionRandomizer?: number);
  17513. /**
  17514. * Called by the particle System when the direction is computed for the created particle.
  17515. * @param worldMatrix is the world matrix of the particle system
  17516. * @param directionToUpdate is the direction vector to update with the result
  17517. * @param particle is the particle we are computed the direction for
  17518. */
  17519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17520. /**
  17521. * Called by the particle System when the position is computed for the created particle.
  17522. * @param worldMatrix is the world matrix of the particle system
  17523. * @param positionToUpdate is the position vector to update with the result
  17524. * @param particle is the particle we are computed the position for
  17525. */
  17526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17527. /**
  17528. * Clones the current emitter and returns a copy of it
  17529. * @returns the new emitter
  17530. */
  17531. clone(): HemisphericParticleEmitter;
  17532. /**
  17533. * Called by the GPUParticleSystem to setup the update shader
  17534. * @param effect defines the update shader
  17535. */
  17536. applyToShader(effect: Effect): void;
  17537. /**
  17538. * Returns a string to use to update the GPU particles update shader
  17539. * @returns a string containng the defines string
  17540. */
  17541. getEffectDefines(): string;
  17542. /**
  17543. * Returns the string "HemisphericParticleEmitter"
  17544. * @returns a string containing the class name
  17545. */
  17546. getClassName(): string;
  17547. /**
  17548. * Serializes the particle system to a JSON object.
  17549. * @returns the JSON object
  17550. */
  17551. serialize(): any;
  17552. /**
  17553. * Parse properties from a JSON object
  17554. * @param serializationObject defines the JSON object
  17555. */
  17556. parse(serializationObject: any): void;
  17557. }
  17558. }
  17559. declare module BABYLON {
  17560. /**
  17561. * Particle emitter emitting particles from a point.
  17562. * It emits the particles randomly between 2 given directions.
  17563. */
  17564. export class PointParticleEmitter implements IParticleEmitterType {
  17565. /**
  17566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17567. */
  17568. direction1: Vector3;
  17569. /**
  17570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17571. */
  17572. direction2: Vector3;
  17573. /**
  17574. * Creates a new instance PointParticleEmitter
  17575. */
  17576. constructor();
  17577. /**
  17578. * Called by the particle System when the direction is computed for the created particle.
  17579. * @param worldMatrix is the world matrix of the particle system
  17580. * @param directionToUpdate is the direction vector to update with the result
  17581. * @param particle is the particle we are computed the direction for
  17582. */
  17583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17584. /**
  17585. * Called by the particle System when the position is computed for the created particle.
  17586. * @param worldMatrix is the world matrix of the particle system
  17587. * @param positionToUpdate is the position vector to update with the result
  17588. * @param particle is the particle we are computed the position for
  17589. */
  17590. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17591. /**
  17592. * Clones the current emitter and returns a copy of it
  17593. * @returns the new emitter
  17594. */
  17595. clone(): PointParticleEmitter;
  17596. /**
  17597. * Called by the GPUParticleSystem to setup the update shader
  17598. * @param effect defines the update shader
  17599. */
  17600. applyToShader(effect: Effect): void;
  17601. /**
  17602. * Returns a string to use to update the GPU particles update shader
  17603. * @returns a string containng the defines string
  17604. */
  17605. getEffectDefines(): string;
  17606. /**
  17607. * Returns the string "PointParticleEmitter"
  17608. * @returns a string containing the class name
  17609. */
  17610. getClassName(): string;
  17611. /**
  17612. * Serializes the particle system to a JSON object.
  17613. * @returns the JSON object
  17614. */
  17615. serialize(): any;
  17616. /**
  17617. * Parse properties from a JSON object
  17618. * @param serializationObject defines the JSON object
  17619. */
  17620. parse(serializationObject: any): void;
  17621. }
  17622. }
  17623. declare module BABYLON {
  17624. /**
  17625. * Particle emitter emitting particles from the inside of a sphere.
  17626. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17627. */
  17628. export class SphereParticleEmitter implements IParticleEmitterType {
  17629. /**
  17630. * The radius of the emission sphere.
  17631. */
  17632. radius: number;
  17633. /**
  17634. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17635. */
  17636. radiusRange: number;
  17637. /**
  17638. * How much to randomize the particle direction [0-1].
  17639. */
  17640. directionRandomizer: number;
  17641. /**
  17642. * Creates a new instance SphereParticleEmitter
  17643. * @param radius the radius of the emission sphere (1 by default)
  17644. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17645. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17646. */
  17647. constructor(
  17648. /**
  17649. * The radius of the emission sphere.
  17650. */
  17651. radius?: number,
  17652. /**
  17653. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17654. */
  17655. radiusRange?: number,
  17656. /**
  17657. * How much to randomize the particle direction [0-1].
  17658. */
  17659. directionRandomizer?: number);
  17660. /**
  17661. * Called by the particle System when the direction is computed for the created particle.
  17662. * @param worldMatrix is the world matrix of the particle system
  17663. * @param directionToUpdate is the direction vector to update with the result
  17664. * @param particle is the particle we are computed the direction for
  17665. */
  17666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17667. /**
  17668. * Called by the particle System when the position is computed for the created particle.
  17669. * @param worldMatrix is the world matrix of the particle system
  17670. * @param positionToUpdate is the position vector to update with the result
  17671. * @param particle is the particle we are computed the position for
  17672. */
  17673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17674. /**
  17675. * Clones the current emitter and returns a copy of it
  17676. * @returns the new emitter
  17677. */
  17678. clone(): SphereParticleEmitter;
  17679. /**
  17680. * Called by the GPUParticleSystem to setup the update shader
  17681. * @param effect defines the update shader
  17682. */
  17683. applyToShader(effect: Effect): void;
  17684. /**
  17685. * Returns a string to use to update the GPU particles update shader
  17686. * @returns a string containng the defines string
  17687. */
  17688. getEffectDefines(): string;
  17689. /**
  17690. * Returns the string "SphereParticleEmitter"
  17691. * @returns a string containing the class name
  17692. */
  17693. getClassName(): string;
  17694. /**
  17695. * Serializes the particle system to a JSON object.
  17696. * @returns the JSON object
  17697. */
  17698. serialize(): any;
  17699. /**
  17700. * Parse properties from a JSON object
  17701. * @param serializationObject defines the JSON object
  17702. */
  17703. parse(serializationObject: any): void;
  17704. }
  17705. /**
  17706. * Particle emitter emitting particles from the inside of a sphere.
  17707. * It emits the particles randomly between two vectors.
  17708. */
  17709. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17710. /**
  17711. * The min limit of the emission direction.
  17712. */
  17713. direction1: Vector3;
  17714. /**
  17715. * The max limit of the emission direction.
  17716. */
  17717. direction2: Vector3;
  17718. /**
  17719. * Creates a new instance SphereDirectedParticleEmitter
  17720. * @param radius the radius of the emission sphere (1 by default)
  17721. * @param direction1 the min limit of the emission direction (up vector by default)
  17722. * @param direction2 the max limit of the emission direction (up vector by default)
  17723. */
  17724. constructor(radius?: number,
  17725. /**
  17726. * The min limit of the emission direction.
  17727. */
  17728. direction1?: Vector3,
  17729. /**
  17730. * The max limit of the emission direction.
  17731. */
  17732. direction2?: Vector3);
  17733. /**
  17734. * Called by the particle System when the direction is computed for the created particle.
  17735. * @param worldMatrix is the world matrix of the particle system
  17736. * @param directionToUpdate is the direction vector to update with the result
  17737. * @param particle is the particle we are computed the direction for
  17738. */
  17739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17740. /**
  17741. * Clones the current emitter and returns a copy of it
  17742. * @returns the new emitter
  17743. */
  17744. clone(): SphereDirectedParticleEmitter;
  17745. /**
  17746. * Called by the GPUParticleSystem to setup the update shader
  17747. * @param effect defines the update shader
  17748. */
  17749. applyToShader(effect: Effect): void;
  17750. /**
  17751. * Returns a string to use to update the GPU particles update shader
  17752. * @returns a string containng the defines string
  17753. */
  17754. getEffectDefines(): string;
  17755. /**
  17756. * Returns the string "SphereDirectedParticleEmitter"
  17757. * @returns a string containing the class name
  17758. */
  17759. getClassName(): string;
  17760. /**
  17761. * Serializes the particle system to a JSON object.
  17762. * @returns the JSON object
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Parse properties from a JSON object
  17767. * @param serializationObject defines the JSON object
  17768. */
  17769. parse(serializationObject: any): void;
  17770. }
  17771. }
  17772. declare module BABYLON {
  17773. /**
  17774. * Interface representing a particle system in Babylon.js.
  17775. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17776. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17777. */
  17778. export interface IParticleSystem {
  17779. /**
  17780. * List of animations used by the particle system.
  17781. */
  17782. animations: Animation[];
  17783. /**
  17784. * The id of the Particle system.
  17785. */
  17786. id: string;
  17787. /**
  17788. * The name of the Particle system.
  17789. */
  17790. name: string;
  17791. /**
  17792. * The emitter represents the Mesh or position we are attaching the particle system to.
  17793. */
  17794. emitter: Nullable<AbstractMesh | Vector3>;
  17795. /**
  17796. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17797. */
  17798. isBillboardBased: boolean;
  17799. /**
  17800. * The rendering group used by the Particle system to chose when to render.
  17801. */
  17802. renderingGroupId: number;
  17803. /**
  17804. * The layer mask we are rendering the particles through.
  17805. */
  17806. layerMask: number;
  17807. /**
  17808. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17809. */
  17810. updateSpeed: number;
  17811. /**
  17812. * The amount of time the particle system is running (depends of the overall update speed).
  17813. */
  17814. targetStopDuration: number;
  17815. /**
  17816. * The texture used to render each particle. (this can be a spritesheet)
  17817. */
  17818. particleTexture: Nullable<Texture>;
  17819. /**
  17820. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17821. */
  17822. blendMode: number;
  17823. /**
  17824. * Minimum life time of emitting particles.
  17825. */
  17826. minLifeTime: number;
  17827. /**
  17828. * Maximum life time of emitting particles.
  17829. */
  17830. maxLifeTime: number;
  17831. /**
  17832. * Minimum Size of emitting particles.
  17833. */
  17834. minSize: number;
  17835. /**
  17836. * Maximum Size of emitting particles.
  17837. */
  17838. maxSize: number;
  17839. /**
  17840. * Minimum scale of emitting particles on X axis.
  17841. */
  17842. minScaleX: number;
  17843. /**
  17844. * Maximum scale of emitting particles on X axis.
  17845. */
  17846. maxScaleX: number;
  17847. /**
  17848. * Minimum scale of emitting particles on Y axis.
  17849. */
  17850. minScaleY: number;
  17851. /**
  17852. * Maximum scale of emitting particles on Y axis.
  17853. */
  17854. maxScaleY: number;
  17855. /**
  17856. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17857. */
  17858. color1: Color4;
  17859. /**
  17860. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17861. */
  17862. color2: Color4;
  17863. /**
  17864. * Color the particle will have at the end of its lifetime.
  17865. */
  17866. colorDead: Color4;
  17867. /**
  17868. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17869. */
  17870. emitRate: number;
  17871. /**
  17872. * You can use gravity if you want to give an orientation to your particles.
  17873. */
  17874. gravity: Vector3;
  17875. /**
  17876. * Minimum power of emitting particles.
  17877. */
  17878. minEmitPower: number;
  17879. /**
  17880. * Maximum power of emitting particles.
  17881. */
  17882. maxEmitPower: number;
  17883. /**
  17884. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17885. */
  17886. minAngularSpeed: number;
  17887. /**
  17888. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17889. */
  17890. maxAngularSpeed: number;
  17891. /**
  17892. * Gets or sets the minimal initial rotation in radians.
  17893. */
  17894. minInitialRotation: number;
  17895. /**
  17896. * Gets or sets the maximal initial rotation in radians.
  17897. */
  17898. maxInitialRotation: number;
  17899. /**
  17900. * The particle emitter type defines the emitter used by the particle system.
  17901. * It can be for example box, sphere, or cone...
  17902. */
  17903. particleEmitterType: Nullable<IParticleEmitterType>;
  17904. /**
  17905. * Defines the delay in milliseconds before starting the system (0 by default)
  17906. */
  17907. startDelay: number;
  17908. /**
  17909. * 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
  17910. */
  17911. preWarmCycles: number;
  17912. /**
  17913. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17914. */
  17915. preWarmStepOffset: number;
  17916. /**
  17917. * 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)
  17918. */
  17919. spriteCellChangeSpeed: number;
  17920. /**
  17921. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17922. */
  17923. startSpriteCellID: number;
  17924. /**
  17925. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17926. */
  17927. endSpriteCellID: number;
  17928. /**
  17929. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17930. */
  17931. spriteCellWidth: number;
  17932. /**
  17933. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17934. */
  17935. spriteCellHeight: number;
  17936. /**
  17937. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17938. */
  17939. spriteRandomStartCell: boolean;
  17940. /**
  17941. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17942. */
  17943. isAnimationSheetEnabled: boolean;
  17944. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17945. translationPivot: Vector2;
  17946. /**
  17947. * Gets or sets a texture used to add random noise to particle positions
  17948. */
  17949. noiseTexture: Nullable<BaseTexture>;
  17950. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17951. noiseStrength: Vector3;
  17952. /**
  17953. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17954. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17955. */
  17956. billboardMode: number;
  17957. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17958. limitVelocityDamping: number;
  17959. /**
  17960. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17961. */
  17962. beginAnimationOnStart: boolean;
  17963. /**
  17964. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17965. */
  17966. beginAnimationFrom: number;
  17967. /**
  17968. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17969. */
  17970. beginAnimationTo: number;
  17971. /**
  17972. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17973. */
  17974. beginAnimationLoop: boolean;
  17975. /**
  17976. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17977. */
  17978. disposeOnStop: boolean;
  17979. /**
  17980. * Gets the maximum number of particles active at the same time.
  17981. * @returns The max number of active particles.
  17982. */
  17983. getCapacity(): number;
  17984. /**
  17985. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17986. * @returns True if it has been started, otherwise false.
  17987. */
  17988. isStarted(): boolean;
  17989. /**
  17990. * Animates the particle system for this frame.
  17991. */
  17992. animate(): void;
  17993. /**
  17994. * Renders the particle system in its current state.
  17995. * @returns the current number of particles
  17996. */
  17997. render(): number;
  17998. /**
  17999. * Dispose the particle system and frees its associated resources.
  18000. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18001. */
  18002. dispose(disposeTexture?: boolean): void;
  18003. /**
  18004. * Clones the particle system.
  18005. * @param name The name of the cloned object
  18006. * @param newEmitter The new emitter to use
  18007. * @returns the cloned particle system
  18008. */
  18009. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18010. /**
  18011. * Serializes the particle system to a JSON object.
  18012. * @returns the JSON object
  18013. */
  18014. serialize(): any;
  18015. /**
  18016. * Rebuild the particle system
  18017. */
  18018. rebuild(): void;
  18019. /**
  18020. * Starts the particle system and begins to emit
  18021. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18022. */
  18023. start(delay?: number): void;
  18024. /**
  18025. * Stops the particle system.
  18026. */
  18027. stop(): void;
  18028. /**
  18029. * Remove all active particles
  18030. */
  18031. reset(): void;
  18032. /**
  18033. * Is this system ready to be used/rendered
  18034. * @return true if the system is ready
  18035. */
  18036. isReady(): boolean;
  18037. /**
  18038. * Adds a new color gradient
  18039. * @param gradient defines the gradient to use (between 0 and 1)
  18040. * @param color1 defines the color to affect to the specified gradient
  18041. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18042. * @returns the current particle system
  18043. */
  18044. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18045. /**
  18046. * Remove a specific color gradient
  18047. * @param gradient defines the gradient to remove
  18048. * @returns the current particle system
  18049. */
  18050. removeColorGradient(gradient: number): IParticleSystem;
  18051. /**
  18052. * Adds a new size gradient
  18053. * @param gradient defines the gradient to use (between 0 and 1)
  18054. * @param factor defines the size factor to affect to the specified gradient
  18055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18056. * @returns the current particle system
  18057. */
  18058. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18059. /**
  18060. * Remove a specific size gradient
  18061. * @param gradient defines the gradient to remove
  18062. * @returns the current particle system
  18063. */
  18064. removeSizeGradient(gradient: number): IParticleSystem;
  18065. /**
  18066. * Gets the current list of color gradients.
  18067. * You must use addColorGradient and removeColorGradient to udpate this list
  18068. * @returns the list of color gradients
  18069. */
  18070. getColorGradients(): Nullable<Array<ColorGradient>>;
  18071. /**
  18072. * Gets the current list of size gradients.
  18073. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18074. * @returns the list of size gradients
  18075. */
  18076. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18077. /**
  18078. * Gets the current list of angular speed gradients.
  18079. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18080. * @returns the list of angular speed gradients
  18081. */
  18082. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18083. /**
  18084. * Adds a new angular speed gradient
  18085. * @param gradient defines the gradient to use (between 0 and 1)
  18086. * @param factor defines the angular speed to affect to the specified gradient
  18087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18088. * @returns the current particle system
  18089. */
  18090. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18091. /**
  18092. * Remove a specific angular speed gradient
  18093. * @param gradient defines the gradient to remove
  18094. * @returns the current particle system
  18095. */
  18096. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18097. /**
  18098. * Gets the current list of velocity gradients.
  18099. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18100. * @returns the list of velocity gradients
  18101. */
  18102. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18103. /**
  18104. * Adds a new velocity gradient
  18105. * @param gradient defines the gradient to use (between 0 and 1)
  18106. * @param factor defines the velocity to affect to the specified gradient
  18107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18108. * @returns the current particle system
  18109. */
  18110. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18111. /**
  18112. * Remove a specific velocity gradient
  18113. * @param gradient defines the gradient to remove
  18114. * @returns the current particle system
  18115. */
  18116. removeVelocityGradient(gradient: number): IParticleSystem;
  18117. /**
  18118. * Gets the current list of limit velocity gradients.
  18119. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18120. * @returns the list of limit velocity gradients
  18121. */
  18122. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18123. /**
  18124. * Adds a new limit velocity gradient
  18125. * @param gradient defines the gradient to use (between 0 and 1)
  18126. * @param factor defines the limit velocity to affect to the specified gradient
  18127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18128. * @returns the current particle system
  18129. */
  18130. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18131. /**
  18132. * Remove a specific limit velocity gradient
  18133. * @param gradient defines the gradient to remove
  18134. * @returns the current particle system
  18135. */
  18136. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18137. /**
  18138. * Adds a new drag gradient
  18139. * @param gradient defines the gradient to use (between 0 and 1)
  18140. * @param factor defines the drag to affect to the specified gradient
  18141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18142. * @returns the current particle system
  18143. */
  18144. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18145. /**
  18146. * Remove a specific drag gradient
  18147. * @param gradient defines the gradient to remove
  18148. * @returns the current particle system
  18149. */
  18150. removeDragGradient(gradient: number): IParticleSystem;
  18151. /**
  18152. * Gets the current list of drag gradients.
  18153. * You must use addDragGradient and removeDragGradient to udpate this list
  18154. * @returns the list of drag gradients
  18155. */
  18156. getDragGradients(): Nullable<Array<FactorGradient>>;
  18157. /**
  18158. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18159. * @param gradient defines the gradient to use (between 0 and 1)
  18160. * @param factor defines the emit rate to affect to the specified gradient
  18161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18162. * @returns the current particle system
  18163. */
  18164. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18165. /**
  18166. * Remove a specific emit rate gradient
  18167. * @param gradient defines the gradient to remove
  18168. * @returns the current particle system
  18169. */
  18170. removeEmitRateGradient(gradient: number): IParticleSystem;
  18171. /**
  18172. * Gets the current list of emit rate gradients.
  18173. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18174. * @returns the list of emit rate gradients
  18175. */
  18176. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18177. /**
  18178. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18179. * @param gradient defines the gradient to use (between 0 and 1)
  18180. * @param factor defines the start size to affect to the specified gradient
  18181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18182. * @returns the current particle system
  18183. */
  18184. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18185. /**
  18186. * Remove a specific start size gradient
  18187. * @param gradient defines the gradient to remove
  18188. * @returns the current particle system
  18189. */
  18190. removeStartSizeGradient(gradient: number): IParticleSystem;
  18191. /**
  18192. * Gets the current list of start size gradients.
  18193. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18194. * @returns the list of start size gradients
  18195. */
  18196. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18197. /**
  18198. * Adds a new life time gradient
  18199. * @param gradient defines the gradient to use (between 0 and 1)
  18200. * @param factor defines the life time factor to affect to the specified gradient
  18201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18202. * @returns the current particle system
  18203. */
  18204. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18205. /**
  18206. * Remove a specific life time gradient
  18207. * @param gradient defines the gradient to remove
  18208. * @returns the current particle system
  18209. */
  18210. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18211. /**
  18212. * Gets the current list of life time gradients.
  18213. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18214. * @returns the list of life time gradients
  18215. */
  18216. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18217. /**
  18218. * Gets the current list of color gradients.
  18219. * You must use addColorGradient and removeColorGradient to udpate this list
  18220. * @returns the list of color gradients
  18221. */
  18222. getColorGradients(): Nullable<Array<ColorGradient>>;
  18223. /**
  18224. * Adds a new ramp gradient used to remap particle colors
  18225. * @param gradient defines the gradient to use (between 0 and 1)
  18226. * @param color defines the color to affect to the specified gradient
  18227. * @returns the current particle system
  18228. */
  18229. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18230. /**
  18231. * Gets the current list of ramp gradients.
  18232. * You must use addRampGradient and removeRampGradient to udpate this list
  18233. * @returns the list of ramp gradients
  18234. */
  18235. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18236. /** Gets or sets a boolean indicating that ramp gradients must be used
  18237. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18238. */
  18239. useRampGradients: boolean;
  18240. /**
  18241. * Adds a new color remap gradient
  18242. * @param gradient defines the gradient to use (between 0 and 1)
  18243. * @param min defines the color remap minimal range
  18244. * @param max defines the color remap maximal range
  18245. * @returns the current particle system
  18246. */
  18247. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18248. /**
  18249. * Gets the current list of color remap gradients.
  18250. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18251. * @returns the list of color remap gradients
  18252. */
  18253. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18254. /**
  18255. * Adds a new alpha remap gradient
  18256. * @param gradient defines the gradient to use (between 0 and 1)
  18257. * @param min defines the alpha remap minimal range
  18258. * @param max defines the alpha remap maximal range
  18259. * @returns the current particle system
  18260. */
  18261. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18262. /**
  18263. * Gets the current list of alpha remap gradients.
  18264. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18265. * @returns the list of alpha remap gradients
  18266. */
  18267. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18268. /**
  18269. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18270. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18271. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18272. * @returns the emitter
  18273. */
  18274. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18275. /**
  18276. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18277. * @param radius The radius of the hemisphere to emit from
  18278. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18279. * @returns the emitter
  18280. */
  18281. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18282. /**
  18283. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18284. * @param radius The radius of the sphere to emit from
  18285. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18286. * @returns the emitter
  18287. */
  18288. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18289. /**
  18290. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18291. * @param radius The radius of the sphere to emit from
  18292. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18293. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18294. * @returns the emitter
  18295. */
  18296. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18297. /**
  18298. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18299. * @param radius The radius of the emission cylinder
  18300. * @param height The height of the emission cylinder
  18301. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18302. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18303. * @returns the emitter
  18304. */
  18305. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18306. /**
  18307. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18308. * @param radius The radius of the cylinder to emit from
  18309. * @param height The height of the emission cylinder
  18310. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18311. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18312. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18313. * @returns the emitter
  18314. */
  18315. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18316. /**
  18317. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18318. * @param radius The radius of the cone to emit from
  18319. * @param angle The base angle of the cone
  18320. * @returns the emitter
  18321. */
  18322. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18323. /**
  18324. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18327. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18328. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18329. * @returns the emitter
  18330. */
  18331. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18332. /**
  18333. * Get hosting scene
  18334. * @returns the scene
  18335. */
  18336. getScene(): Scene;
  18337. }
  18338. }
  18339. declare module BABYLON {
  18340. /**
  18341. * Creates an instance based on a source mesh.
  18342. */
  18343. export class InstancedMesh extends AbstractMesh {
  18344. private _sourceMesh;
  18345. private _currentLOD;
  18346. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18347. constructor(name: string, source: Mesh);
  18348. /**
  18349. * Returns the string "InstancedMesh".
  18350. */
  18351. getClassName(): string;
  18352. /** Gets the list of lights affecting that mesh */
  18353. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18354. /**
  18355. * If the source mesh receives shadows
  18356. */
  18357. readonly receiveShadows: boolean;
  18358. /**
  18359. * The material of the source mesh
  18360. */
  18361. readonly material: Nullable<Material>;
  18362. /**
  18363. * Visibility of the source mesh
  18364. */
  18365. readonly visibility: number;
  18366. /**
  18367. * Skeleton of the source mesh
  18368. */
  18369. readonly skeleton: Nullable<Skeleton>;
  18370. /**
  18371. * Rendering ground id of the source mesh
  18372. */
  18373. renderingGroupId: number;
  18374. /**
  18375. * Returns the total number of vertices (integer).
  18376. */
  18377. getTotalVertices(): number;
  18378. /**
  18379. * Returns a positive integer : the total number of indices in this mesh geometry.
  18380. * @returns the numner of indices or zero if the mesh has no geometry.
  18381. */
  18382. getTotalIndices(): number;
  18383. /**
  18384. * The source mesh of the instance
  18385. */
  18386. readonly sourceMesh: Mesh;
  18387. /**
  18388. * Is this node ready to be used/rendered
  18389. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18390. * @return {boolean} is it ready
  18391. */
  18392. isReady(completeCheck?: boolean): boolean;
  18393. /**
  18394. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18395. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18396. * @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.
  18397. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18398. */
  18399. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18400. /**
  18401. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18402. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18403. * The `data` are either a numeric array either a Float32Array.
  18404. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18405. * 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).
  18406. * Note that a new underlying VertexBuffer object is created each call.
  18407. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18408. *
  18409. * Possible `kind` values :
  18410. * - VertexBuffer.PositionKind
  18411. * - VertexBuffer.UVKind
  18412. * - VertexBuffer.UV2Kind
  18413. * - VertexBuffer.UV3Kind
  18414. * - VertexBuffer.UV4Kind
  18415. * - VertexBuffer.UV5Kind
  18416. * - VertexBuffer.UV6Kind
  18417. * - VertexBuffer.ColorKind
  18418. * - VertexBuffer.MatricesIndicesKind
  18419. * - VertexBuffer.MatricesIndicesExtraKind
  18420. * - VertexBuffer.MatricesWeightsKind
  18421. * - VertexBuffer.MatricesWeightsExtraKind
  18422. *
  18423. * Returns the Mesh.
  18424. */
  18425. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18426. /**
  18427. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18428. * If the mesh has no geometry, it is simply returned as it is.
  18429. * The `data` are either a numeric array either a Float32Array.
  18430. * No new underlying VertexBuffer object is created.
  18431. * 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.
  18432. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18433. *
  18434. * Possible `kind` values :
  18435. * - VertexBuffer.PositionKind
  18436. * - VertexBuffer.UVKind
  18437. * - VertexBuffer.UV2Kind
  18438. * - VertexBuffer.UV3Kind
  18439. * - VertexBuffer.UV4Kind
  18440. * - VertexBuffer.UV5Kind
  18441. * - VertexBuffer.UV6Kind
  18442. * - VertexBuffer.ColorKind
  18443. * - VertexBuffer.MatricesIndicesKind
  18444. * - VertexBuffer.MatricesIndicesExtraKind
  18445. * - VertexBuffer.MatricesWeightsKind
  18446. * - VertexBuffer.MatricesWeightsExtraKind
  18447. *
  18448. * Returns the Mesh.
  18449. */
  18450. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18451. /**
  18452. * Sets the mesh indices.
  18453. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18454. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18455. * This method creates a new index buffer each call.
  18456. * Returns the Mesh.
  18457. */
  18458. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18459. /**
  18460. * Boolean : True if the mesh owns the requested kind of data.
  18461. */
  18462. isVerticesDataPresent(kind: string): boolean;
  18463. /**
  18464. * Returns an array of indices (IndicesArray).
  18465. */
  18466. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18467. /**
  18468. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18469. * This means the mesh underlying bounding box and sphere are recomputed.
  18470. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18471. * @returns the current mesh
  18472. */
  18473. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18474. /** @hidden */ private _preActivate(): InstancedMesh;
  18475. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18476. /** @hidden */ private _postActivate(): void;
  18477. getWorldMatrix(): Matrix;
  18478. readonly isAnInstance: boolean;
  18479. /**
  18480. * Returns the current associated LOD AbstractMesh.
  18481. */
  18482. getLOD(camera: Camera): AbstractMesh;
  18483. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18484. /** @hidden */ private _generatePointsArray(): boolean;
  18485. /**
  18486. * Creates a new InstancedMesh from the current mesh.
  18487. * - name (string) : the cloned mesh name
  18488. * - newParent (optional Node) : the optional Node to parent the clone to.
  18489. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18490. *
  18491. * Returns the clone.
  18492. */
  18493. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18494. /**
  18495. * Disposes the InstancedMesh.
  18496. * Returns nothing.
  18497. */
  18498. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18499. }
  18500. }
  18501. declare module BABYLON {
  18502. /**
  18503. * Defines the options associated with the creation of a shader material.
  18504. */
  18505. export interface IShaderMaterialOptions {
  18506. /**
  18507. * Does the material work in alpha blend mode
  18508. */
  18509. needAlphaBlending: boolean;
  18510. /**
  18511. * Does the material work in alpha test mode
  18512. */
  18513. needAlphaTesting: boolean;
  18514. /**
  18515. * The list of attribute names used in the shader
  18516. */
  18517. attributes: string[];
  18518. /**
  18519. * The list of unifrom names used in the shader
  18520. */
  18521. uniforms: string[];
  18522. /**
  18523. * The list of UBO names used in the shader
  18524. */
  18525. uniformBuffers: string[];
  18526. /**
  18527. * The list of sampler names used in the shader
  18528. */
  18529. samplers: string[];
  18530. /**
  18531. * The list of defines used in the shader
  18532. */
  18533. defines: string[];
  18534. }
  18535. /**
  18536. * 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.
  18537. *
  18538. * This returned material effects how the mesh will look based on the code in the shaders.
  18539. *
  18540. * @see http://doc.babylonjs.com/how_to/shader_material
  18541. */
  18542. export class ShaderMaterial extends Material {
  18543. private _shaderPath;
  18544. private _options;
  18545. private _textures;
  18546. private _textureArrays;
  18547. private _floats;
  18548. private _ints;
  18549. private _floatsArrays;
  18550. private _colors3;
  18551. private _colors3Arrays;
  18552. private _colors4;
  18553. private _colors4Arrays;
  18554. private _vectors2;
  18555. private _vectors3;
  18556. private _vectors4;
  18557. private _matrices;
  18558. private _matrices3x3;
  18559. private _matrices2x2;
  18560. private _vectors2Arrays;
  18561. private _vectors3Arrays;
  18562. private _vectors4Arrays;
  18563. private _cachedWorldViewMatrix;
  18564. private _cachedWorldViewProjectionMatrix;
  18565. private _renderId;
  18566. /**
  18567. * Instantiate a new shader material.
  18568. * 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.
  18569. * This returned material effects how the mesh will look based on the code in the shaders.
  18570. * @see http://doc.babylonjs.com/how_to/shader_material
  18571. * @param name Define the name of the material in the scene
  18572. * @param scene Define the scene the material belongs to
  18573. * @param shaderPath Defines the route to the shader code in one of three ways:
  18574. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18575. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18576. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18577. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18578. * @param options Define the options used to create the shader
  18579. */
  18580. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18581. /**
  18582. * Gets the options used to compile the shader.
  18583. * They can be modified to trigger a new compilation
  18584. */
  18585. readonly options: IShaderMaterialOptions;
  18586. /**
  18587. * Gets the current class name of the material e.g. "ShaderMaterial"
  18588. * Mainly use in serialization.
  18589. * @returns the class name
  18590. */
  18591. getClassName(): string;
  18592. /**
  18593. * Specifies if the material will require alpha blending
  18594. * @returns a boolean specifying if alpha blending is needed
  18595. */
  18596. needAlphaBlending(): boolean;
  18597. /**
  18598. * Specifies if this material should be rendered in alpha test mode
  18599. * @returns a boolean specifying if an alpha test is needed.
  18600. */
  18601. needAlphaTesting(): boolean;
  18602. private _checkUniform;
  18603. /**
  18604. * Set a texture in the shader.
  18605. * @param name Define the name of the uniform samplers as defined in the shader
  18606. * @param texture Define the texture to bind to this sampler
  18607. * @return the material itself allowing "fluent" like uniform updates
  18608. */
  18609. setTexture(name: string, texture: Texture): ShaderMaterial;
  18610. /**
  18611. * Set a texture array in the shader.
  18612. * @param name Define the name of the uniform sampler array as defined in the shader
  18613. * @param textures Define the list of textures to bind to this sampler
  18614. * @return the material itself allowing "fluent" like uniform updates
  18615. */
  18616. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18617. /**
  18618. * Set a float in the shader.
  18619. * @param name Define the name of the uniform as defined in the shader
  18620. * @param value Define the value to give to the uniform
  18621. * @return the material itself allowing "fluent" like uniform updates
  18622. */
  18623. setFloat(name: string, value: number): ShaderMaterial;
  18624. /**
  18625. * Set a int in the shader.
  18626. * @param name Define the name of the uniform as defined in the shader
  18627. * @param value Define the value to give to the uniform
  18628. * @return the material itself allowing "fluent" like uniform updates
  18629. */
  18630. setInt(name: string, value: number): ShaderMaterial;
  18631. /**
  18632. * Set an array of floats in the shader.
  18633. * @param name Define the name of the uniform as defined in the shader
  18634. * @param value Define the value to give to the uniform
  18635. * @return the material itself allowing "fluent" like uniform updates
  18636. */
  18637. setFloats(name: string, value: number[]): ShaderMaterial;
  18638. /**
  18639. * Set a vec3 in the shader from a Color3.
  18640. * @param name Define the name of the uniform as defined in the shader
  18641. * @param value Define the value to give to the uniform
  18642. * @return the material itself allowing "fluent" like uniform updates
  18643. */
  18644. setColor3(name: string, value: Color3): ShaderMaterial;
  18645. /**
  18646. * Set a vec3 array in the shader from a Color3 array.
  18647. * @param name Define the name of the uniform as defined in the shader
  18648. * @param value Define the value to give to the uniform
  18649. * @return the material itself allowing "fluent" like uniform updates
  18650. */
  18651. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18652. /**
  18653. * Set a vec4 in the shader from a Color4.
  18654. * @param name Define the name of the uniform as defined in the shader
  18655. * @param value Define the value to give to the uniform
  18656. * @return the material itself allowing "fluent" like uniform updates
  18657. */
  18658. setColor4(name: string, value: Color4): ShaderMaterial;
  18659. /**
  18660. * Set a vec4 array in the shader from a Color4 array.
  18661. * @param name Define the name of the uniform as defined in the shader
  18662. * @param value Define the value to give to the uniform
  18663. * @return the material itself allowing "fluent" like uniform updates
  18664. */
  18665. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18666. /**
  18667. * Set a vec2 in the shader from a Vector2.
  18668. * @param name Define the name of the uniform as defined in the shader
  18669. * @param value Define the value to give to the uniform
  18670. * @return the material itself allowing "fluent" like uniform updates
  18671. */
  18672. setVector2(name: string, value: Vector2): ShaderMaterial;
  18673. /**
  18674. * Set a vec3 in the shader from a Vector3.
  18675. * @param name Define the name of the uniform as defined in the shader
  18676. * @param value Define the value to give to the uniform
  18677. * @return the material itself allowing "fluent" like uniform updates
  18678. */
  18679. setVector3(name: string, value: Vector3): ShaderMaterial;
  18680. /**
  18681. * Set a vec4 in the shader from a Vector4.
  18682. * @param name Define the name of the uniform as defined in the shader
  18683. * @param value Define the value to give to the uniform
  18684. * @return the material itself allowing "fluent" like uniform updates
  18685. */
  18686. setVector4(name: string, value: Vector4): ShaderMaterial;
  18687. /**
  18688. * Set a mat4 in the shader from a Matrix.
  18689. * @param name Define the name of the uniform as defined in the shader
  18690. * @param value Define the value to give to the uniform
  18691. * @return the material itself allowing "fluent" like uniform updates
  18692. */
  18693. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18694. /**
  18695. * Set a mat3 in the shader from a Float32Array.
  18696. * @param name Define the name of the uniform as defined in the shader
  18697. * @param value Define the value to give to the uniform
  18698. * @return the material itself allowing "fluent" like uniform updates
  18699. */
  18700. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18701. /**
  18702. * Set a mat2 in the shader from a Float32Array.
  18703. * @param name Define the name of the uniform as defined in the shader
  18704. * @param value Define the value to give to the uniform
  18705. * @return the material itself allowing "fluent" like uniform updates
  18706. */
  18707. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18708. /**
  18709. * Set a vec2 array in the shader from a number array.
  18710. * @param name Define the name of the uniform as defined in the shader
  18711. * @param value Define the value to give to the uniform
  18712. * @return the material itself allowing "fluent" like uniform updates
  18713. */
  18714. setArray2(name: string, value: number[]): ShaderMaterial;
  18715. /**
  18716. * Set a vec3 array in the shader from a number array.
  18717. * @param name Define the name of the uniform as defined in the shader
  18718. * @param value Define the value to give to the uniform
  18719. * @return the material itself allowing "fluent" like uniform updates
  18720. */
  18721. setArray3(name: string, value: number[]): ShaderMaterial;
  18722. /**
  18723. * Set a vec4 array in the shader from a number array.
  18724. * @param name Define the name of the uniform as defined in the shader
  18725. * @param value Define the value to give to the uniform
  18726. * @return the material itself allowing "fluent" like uniform updates
  18727. */
  18728. setArray4(name: string, value: number[]): ShaderMaterial;
  18729. private _checkCache;
  18730. /**
  18731. * Specifies that the submesh is ready to be used
  18732. * @param mesh defines the mesh to check
  18733. * @param subMesh defines which submesh to check
  18734. * @param useInstances specifies that instances should be used
  18735. * @returns a boolean indicating that the submesh is ready or not
  18736. */
  18737. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18738. /**
  18739. * Checks if the material is ready to render the requested mesh
  18740. * @param mesh Define the mesh to render
  18741. * @param useInstances Define whether or not the material is used with instances
  18742. * @returns true if ready, otherwise false
  18743. */
  18744. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18745. /**
  18746. * Binds the world matrix to the material
  18747. * @param world defines the world transformation matrix
  18748. */
  18749. bindOnlyWorldMatrix(world: Matrix): void;
  18750. /**
  18751. * Binds the material to the mesh
  18752. * @param world defines the world transformation matrix
  18753. * @param mesh defines the mesh to bind the material to
  18754. */
  18755. bind(world: Matrix, mesh?: Mesh): void;
  18756. /**
  18757. * Gets the active textures from the material
  18758. * @returns an array of textures
  18759. */
  18760. getActiveTextures(): BaseTexture[];
  18761. /**
  18762. * Specifies if the material uses a texture
  18763. * @param texture defines the texture to check against the material
  18764. * @returns a boolean specifying if the material uses the texture
  18765. */
  18766. hasTexture(texture: BaseTexture): boolean;
  18767. /**
  18768. * Makes a duplicate of the material, and gives it a new name
  18769. * @param name defines the new name for the duplicated material
  18770. * @returns the cloned material
  18771. */
  18772. clone(name: string): ShaderMaterial;
  18773. /**
  18774. * Disposes the material
  18775. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18776. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18777. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18778. */
  18779. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18780. /**
  18781. * Serializes this material in a JSON representation
  18782. * @returns the serialized material object
  18783. */
  18784. serialize(): any;
  18785. /**
  18786. * Creates a shader material from parsed shader material data
  18787. * @param source defines the JSON represnetation of the material
  18788. * @param scene defines the hosting scene
  18789. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18790. * @returns a new material
  18791. */
  18792. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18793. }
  18794. }
  18795. declare module BABYLON {
  18796. /** @hidden */
  18797. export var colorPixelShader: {
  18798. name: string;
  18799. shader: string;
  18800. };
  18801. }
  18802. declare module BABYLON {
  18803. /** @hidden */
  18804. export var colorVertexShader: {
  18805. name: string;
  18806. shader: string;
  18807. };
  18808. }
  18809. declare module BABYLON {
  18810. /**
  18811. * Line mesh
  18812. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18813. */
  18814. export class LinesMesh extends Mesh {
  18815. /**
  18816. * If vertex color should be applied to the mesh
  18817. */
  18818. readonly useVertexColor?: boolean | undefined;
  18819. /**
  18820. * If vertex alpha should be applied to the mesh
  18821. */
  18822. readonly useVertexAlpha?: boolean | undefined;
  18823. /**
  18824. * Color of the line (Default: White)
  18825. */
  18826. color: Color3;
  18827. /**
  18828. * Alpha of the line (Default: 1)
  18829. */
  18830. alpha: number;
  18831. /**
  18832. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18833. * This margin is expressed in world space coordinates, so its value may vary.
  18834. * Default value is 0.1
  18835. */
  18836. intersectionThreshold: number;
  18837. private _colorShader;
  18838. private color4;
  18839. /**
  18840. * Creates a new LinesMesh
  18841. * @param name defines the name
  18842. * @param scene defines the hosting scene
  18843. * @param parent defines the parent mesh if any
  18844. * @param source defines the optional source LinesMesh used to clone data from
  18845. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18846. * When false, achieved by calling a clone(), also passing False.
  18847. * This will make creation of children, recursive.
  18848. * @param useVertexColor defines if this LinesMesh supports vertex color
  18849. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18850. */
  18851. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  18852. /**
  18853. * If vertex color should be applied to the mesh
  18854. */
  18855. useVertexColor?: boolean | undefined,
  18856. /**
  18857. * If vertex alpha should be applied to the mesh
  18858. */
  18859. useVertexAlpha?: boolean | undefined);
  18860. private _addClipPlaneDefine;
  18861. private _removeClipPlaneDefine;
  18862. isReady(): boolean;
  18863. /**
  18864. * Returns the string "LineMesh"
  18865. */
  18866. getClassName(): string;
  18867. /**
  18868. * @hidden
  18869. */
  18870. /**
  18871. * @hidden
  18872. */
  18873. material: Material;
  18874. /**
  18875. * @hidden
  18876. */
  18877. readonly checkCollisions: boolean;
  18878. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  18879. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  18880. /**
  18881. * Disposes of the line mesh
  18882. * @param doNotRecurse If children should be disposed
  18883. */
  18884. dispose(doNotRecurse?: boolean): void;
  18885. /**
  18886. * Returns a new LineMesh object cloned from the current one.
  18887. */
  18888. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18889. /**
  18890. * Creates a new InstancedLinesMesh object from the mesh model.
  18891. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18892. * @param name defines the name of the new instance
  18893. * @returns a new InstancedLinesMesh
  18894. */
  18895. createInstance(name: string): InstancedLinesMesh;
  18896. }
  18897. /**
  18898. * Creates an instance based on a source LinesMesh
  18899. */
  18900. export class InstancedLinesMesh extends InstancedMesh {
  18901. /**
  18902. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18903. * This margin is expressed in world space coordinates, so its value may vary.
  18904. * Initilized with the intersectionThreshold value of the source LinesMesh
  18905. */
  18906. intersectionThreshold: number;
  18907. constructor(name: string, source: LinesMesh);
  18908. /**
  18909. * Returns the string "InstancedLinesMesh".
  18910. */
  18911. getClassName(): string;
  18912. }
  18913. }
  18914. declare module BABYLON {
  18915. /** @hidden */
  18916. export var linePixelShader: {
  18917. name: string;
  18918. shader: string;
  18919. };
  18920. }
  18921. declare module BABYLON {
  18922. /** @hidden */
  18923. export var lineVertexShader: {
  18924. name: string;
  18925. shader: string;
  18926. };
  18927. }
  18928. declare module BABYLON {
  18929. interface AbstractMesh {
  18930. /**
  18931. * Gets the edgesRenderer associated with the mesh
  18932. */
  18933. edgesRenderer: Nullable<EdgesRenderer>;
  18934. }
  18935. interface LinesMesh {
  18936. /**
  18937. * Enables the edge rendering mode on the mesh.
  18938. * This mode makes the mesh edges visible
  18939. * @param epsilon defines the maximal distance between two angles to detect a face
  18940. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18941. * @returns the currentAbstractMesh
  18942. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18943. */
  18944. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18945. }
  18946. interface InstancedLinesMesh {
  18947. /**
  18948. * Enables the edge rendering mode on the mesh.
  18949. * This mode makes the mesh edges visible
  18950. * @param epsilon defines the maximal distance between two angles to detect a face
  18951. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18952. * @returns the current InstancedLinesMesh
  18953. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18954. */
  18955. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  18956. }
  18957. /**
  18958. * Defines the minimum contract an Edges renderer should follow.
  18959. */
  18960. export interface IEdgesRenderer extends IDisposable {
  18961. /**
  18962. * Gets or sets a boolean indicating if the edgesRenderer is active
  18963. */
  18964. isEnabled: boolean;
  18965. /**
  18966. * Renders the edges of the attached mesh,
  18967. */
  18968. render(): void;
  18969. /**
  18970. * Checks wether or not the edges renderer is ready to render.
  18971. * @return true if ready, otherwise false.
  18972. */
  18973. isReady(): boolean;
  18974. }
  18975. /**
  18976. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  18977. */
  18978. export class EdgesRenderer implements IEdgesRenderer {
  18979. /**
  18980. * Define the size of the edges with an orthographic camera
  18981. */
  18982. edgesWidthScalerForOrthographic: number;
  18983. /**
  18984. * Define the size of the edges with a perspective camera
  18985. */
  18986. edgesWidthScalerForPerspective: number;
  18987. protected _source: AbstractMesh;
  18988. protected _linesPositions: number[];
  18989. protected _linesNormals: number[];
  18990. protected _linesIndices: number[];
  18991. protected _epsilon: number;
  18992. protected _indicesCount: number;
  18993. protected _lineShader: ShaderMaterial;
  18994. protected _ib: DataBuffer;
  18995. protected _buffers: {
  18996. [key: string]: Nullable<VertexBuffer>;
  18997. };
  18998. protected _checkVerticesInsteadOfIndices: boolean;
  18999. private _meshRebuildObserver;
  19000. private _meshDisposeObserver;
  19001. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19002. isEnabled: boolean;
  19003. /**
  19004. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19005. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19006. * @param source Mesh used to create edges
  19007. * @param epsilon sum of angles in adjacency to check for edge
  19008. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19009. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19010. */
  19011. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19012. protected _prepareRessources(): void;
  19013. /** @hidden */ private _rebuild(): void;
  19014. /**
  19015. * Releases the required resources for the edges renderer
  19016. */
  19017. dispose(): void;
  19018. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19019. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19020. /**
  19021. * Checks if the pair of p0 and p1 is en edge
  19022. * @param faceIndex
  19023. * @param edge
  19024. * @param faceNormals
  19025. * @param p0
  19026. * @param p1
  19027. * @private
  19028. */
  19029. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19030. /**
  19031. * push line into the position, normal and index buffer
  19032. * @protected
  19033. */
  19034. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19035. /**
  19036. * Generates lines edges from adjacencjes
  19037. * @private
  19038. */ private _generateEdgesLines(): void;
  19039. /**
  19040. * Checks wether or not the edges renderer is ready to render.
  19041. * @return true if ready, otherwise false.
  19042. */
  19043. isReady(): boolean;
  19044. /**
  19045. * Renders the edges of the attached mesh,
  19046. */
  19047. render(): void;
  19048. }
  19049. /**
  19050. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19051. */
  19052. export class LineEdgesRenderer extends EdgesRenderer {
  19053. /**
  19054. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19055. * @param source LineMesh used to generate edges
  19056. * @param epsilon not important (specified angle for edge detection)
  19057. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19058. */
  19059. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19060. /**
  19061. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19062. */ private _generateEdgesLines(): void;
  19063. }
  19064. }
  19065. declare module BABYLON {
  19066. /**
  19067. * This represents the object necessary to create a rendering group.
  19068. * This is exclusively used and created by the rendering manager.
  19069. * To modify the behavior, you use the available helpers in your scene or meshes.
  19070. * @hidden
  19071. */
  19072. export class RenderingGroup {
  19073. index: number;
  19074. private static _zeroVector;
  19075. private _scene;
  19076. private _opaqueSubMeshes;
  19077. private _transparentSubMeshes;
  19078. private _alphaTestSubMeshes;
  19079. private _depthOnlySubMeshes;
  19080. private _particleSystems;
  19081. private _spriteManagers;
  19082. private _opaqueSortCompareFn;
  19083. private _alphaTestSortCompareFn;
  19084. private _transparentSortCompareFn;
  19085. private _renderOpaque;
  19086. private _renderAlphaTest;
  19087. private _renderTransparent;
  19088. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19089. onBeforeTransparentRendering: () => void;
  19090. /**
  19091. * Set the opaque sort comparison function.
  19092. * If null the sub meshes will be render in the order they were created
  19093. */
  19094. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19095. /**
  19096. * Set the alpha test sort comparison function.
  19097. * If null the sub meshes will be render in the order they were created
  19098. */
  19099. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19100. /**
  19101. * Set the transparent sort comparison function.
  19102. * If null the sub meshes will be render in the order they were created
  19103. */
  19104. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19105. /**
  19106. * Creates a new rendering group.
  19107. * @param index The rendering group index
  19108. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19109. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19110. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19111. */
  19112. 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>);
  19113. /**
  19114. * Render all the sub meshes contained in the group.
  19115. * @param customRenderFunction Used to override the default render behaviour of the group.
  19116. * @returns true if rendered some submeshes.
  19117. */
  19118. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19119. /**
  19120. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19121. * @param subMeshes The submeshes to render
  19122. */
  19123. private renderOpaqueSorted;
  19124. /**
  19125. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19126. * @param subMeshes The submeshes to render
  19127. */
  19128. private renderAlphaTestSorted;
  19129. /**
  19130. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19131. * @param subMeshes The submeshes to render
  19132. */
  19133. private renderTransparentSorted;
  19134. /**
  19135. * Renders the submeshes in a specified order.
  19136. * @param subMeshes The submeshes to sort before render
  19137. * @param sortCompareFn The comparison function use to sort
  19138. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19139. * @param transparent Specifies to activate blending if true
  19140. */
  19141. private static renderSorted;
  19142. /**
  19143. * Renders the submeshes in the order they were dispatched (no sort applied).
  19144. * @param subMeshes The submeshes to render
  19145. */
  19146. private static renderUnsorted;
  19147. /**
  19148. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19149. * are rendered back to front if in the same alpha index.
  19150. *
  19151. * @param a The first submesh
  19152. * @param b The second submesh
  19153. * @returns The result of the comparison
  19154. */
  19155. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19156. /**
  19157. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19158. * are rendered back to front.
  19159. *
  19160. * @param a The first submesh
  19161. * @param b The second submesh
  19162. * @returns The result of the comparison
  19163. */
  19164. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19165. /**
  19166. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19167. * are rendered front to back (prevent overdraw).
  19168. *
  19169. * @param a The first submesh
  19170. * @param b The second submesh
  19171. * @returns The result of the comparison
  19172. */
  19173. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19174. /**
  19175. * Resets the different lists of submeshes to prepare a new frame.
  19176. */
  19177. prepare(): void;
  19178. dispose(): void;
  19179. /**
  19180. * Inserts the submesh in its correct queue depending on its material.
  19181. * @param subMesh The submesh to dispatch
  19182. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19183. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19184. */
  19185. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19186. dispatchSprites(spriteManager: ISpriteManager): void;
  19187. dispatchParticles(particleSystem: IParticleSystem): void;
  19188. private _renderParticles;
  19189. private _renderSprites;
  19190. }
  19191. }
  19192. declare module BABYLON {
  19193. /**
  19194. * Interface describing the different options available in the rendering manager
  19195. * regarding Auto Clear between groups.
  19196. */
  19197. export interface IRenderingManagerAutoClearSetup {
  19198. /**
  19199. * Defines whether or not autoclear is enable.
  19200. */
  19201. autoClear: boolean;
  19202. /**
  19203. * Defines whether or not to autoclear the depth buffer.
  19204. */
  19205. depth: boolean;
  19206. /**
  19207. * Defines whether or not to autoclear the stencil buffer.
  19208. */
  19209. stencil: boolean;
  19210. }
  19211. /**
  19212. * This class is used by the onRenderingGroupObservable
  19213. */
  19214. export class RenderingGroupInfo {
  19215. /**
  19216. * The Scene that being rendered
  19217. */
  19218. scene: Scene;
  19219. /**
  19220. * The camera currently used for the rendering pass
  19221. */
  19222. camera: Nullable<Camera>;
  19223. /**
  19224. * The ID of the renderingGroup being processed
  19225. */
  19226. renderingGroupId: number;
  19227. }
  19228. /**
  19229. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19230. * It is enable to manage the different groups as well as the different necessary sort functions.
  19231. * This should not be used directly aside of the few static configurations
  19232. */
  19233. export class RenderingManager {
  19234. /**
  19235. * The max id used for rendering groups (not included)
  19236. */
  19237. static MAX_RENDERINGGROUPS: number;
  19238. /**
  19239. * The min id used for rendering groups (included)
  19240. */
  19241. static MIN_RENDERINGGROUPS: number;
  19242. /**
  19243. * Used to globally prevent autoclearing scenes.
  19244. */
  19245. static AUTOCLEAR: boolean;
  19246. /**
  19247. * @hidden
  19248. */ private _useSceneAutoClearSetup: boolean;
  19249. private _scene;
  19250. private _renderingGroups;
  19251. private _depthStencilBufferAlreadyCleaned;
  19252. private _autoClearDepthStencil;
  19253. private _customOpaqueSortCompareFn;
  19254. private _customAlphaTestSortCompareFn;
  19255. private _customTransparentSortCompareFn;
  19256. private _renderingGroupInfo;
  19257. /**
  19258. * Instantiates a new rendering group for a particular scene
  19259. * @param scene Defines the scene the groups belongs to
  19260. */
  19261. constructor(scene: Scene);
  19262. private _clearDepthStencilBuffer;
  19263. /**
  19264. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19265. * @hidden
  19266. */
  19267. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19268. /**
  19269. * Resets the different information of the group to prepare a new frame
  19270. * @hidden
  19271. */
  19272. reset(): void;
  19273. /**
  19274. * Dispose and release the group and its associated resources.
  19275. * @hidden
  19276. */
  19277. dispose(): void;
  19278. /**
  19279. * Clear the info related to rendering groups preventing retention points during dispose.
  19280. */
  19281. freeRenderingGroups(): void;
  19282. private _prepareRenderingGroup;
  19283. /**
  19284. * Add a sprite manager to the rendering manager in order to render it this frame.
  19285. * @param spriteManager Define the sprite manager to render
  19286. */
  19287. dispatchSprites(spriteManager: ISpriteManager): void;
  19288. /**
  19289. * Add a particle system to the rendering manager in order to render it this frame.
  19290. * @param particleSystem Define the particle system to render
  19291. */
  19292. dispatchParticles(particleSystem: IParticleSystem): void;
  19293. /**
  19294. * Add a submesh to the manager in order to render it this frame
  19295. * @param subMesh The submesh to dispatch
  19296. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19297. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19298. */
  19299. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19300. /**
  19301. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19302. * This allowed control for front to back rendering or reversly depending of the special needs.
  19303. *
  19304. * @param renderingGroupId The rendering group id corresponding to its index
  19305. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19306. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19307. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19308. */
  19309. 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;
  19310. /**
  19311. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19312. *
  19313. * @param renderingGroupId The rendering group id corresponding to its index
  19314. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19315. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19316. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19317. */
  19318. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19319. /**
  19320. * Gets the current auto clear configuration for one rendering group of the rendering
  19321. * manager.
  19322. * @param index the rendering group index to get the information for
  19323. * @returns The auto clear setup for the requested rendering group
  19324. */
  19325. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19326. }
  19327. }
  19328. declare module BABYLON {
  19329. /**
  19330. * This Helps creating a texture that will be created from a camera in your scene.
  19331. * It is basically a dynamic texture that could be used to create special effects for instance.
  19332. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19333. */
  19334. export class RenderTargetTexture extends Texture {
  19335. isCube: boolean;
  19336. /**
  19337. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19338. */
  19339. static readonly REFRESHRATE_RENDER_ONCE: number;
  19340. /**
  19341. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19342. */
  19343. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19344. /**
  19345. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19346. * the central point of your effect and can save a lot of performances.
  19347. */
  19348. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19349. /**
  19350. * Use this predicate to dynamically define the list of mesh you want to render.
  19351. * If set, the renderList property will be overwritten.
  19352. */
  19353. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19354. private _renderList;
  19355. /**
  19356. * Use this list to define the list of mesh you want to render.
  19357. */
  19358. renderList: Nullable<Array<AbstractMesh>>;
  19359. private _hookArray;
  19360. /**
  19361. * Define if particles should be rendered in your texture.
  19362. */
  19363. renderParticles: boolean;
  19364. /**
  19365. * Define if sprites should be rendered in your texture.
  19366. */
  19367. renderSprites: boolean;
  19368. /**
  19369. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19370. */
  19371. coordinatesMode: number;
  19372. /**
  19373. * Define the camera used to render the texture.
  19374. */
  19375. activeCamera: Nullable<Camera>;
  19376. /**
  19377. * Override the render function of the texture with your own one.
  19378. */
  19379. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19380. /**
  19381. * Define if camera post processes should be use while rendering the texture.
  19382. */
  19383. useCameraPostProcesses: boolean;
  19384. /**
  19385. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19386. */
  19387. ignoreCameraViewport: boolean;
  19388. private _postProcessManager;
  19389. private _postProcesses;
  19390. private _resizeObserver;
  19391. /**
  19392. * An event triggered when the texture is unbind.
  19393. */
  19394. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19395. /**
  19396. * An event triggered when the texture is unbind.
  19397. */
  19398. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19399. private _onAfterUnbindObserver;
  19400. /**
  19401. * Set a after unbind callback in the texture.
  19402. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19403. */
  19404. onAfterUnbind: () => void;
  19405. /**
  19406. * An event triggered before rendering the texture
  19407. */
  19408. onBeforeRenderObservable: Observable<number>;
  19409. private _onBeforeRenderObserver;
  19410. /**
  19411. * Set a before render callback in the texture.
  19412. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19413. */
  19414. onBeforeRender: (faceIndex: number) => void;
  19415. /**
  19416. * An event triggered after rendering the texture
  19417. */
  19418. onAfterRenderObservable: Observable<number>;
  19419. private _onAfterRenderObserver;
  19420. /**
  19421. * Set a after render callback in the texture.
  19422. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19423. */
  19424. onAfterRender: (faceIndex: number) => void;
  19425. /**
  19426. * An event triggered after the texture clear
  19427. */
  19428. onClearObservable: Observable<Engine>;
  19429. private _onClearObserver;
  19430. /**
  19431. * Set a clear callback in the texture.
  19432. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19433. */
  19434. onClear: (Engine: Engine) => void;
  19435. /**
  19436. * An event triggered when the texture is resized.
  19437. */
  19438. onResizeObservable: Observable<RenderTargetTexture>;
  19439. /**
  19440. * Define the clear color of the Render Target if it should be different from the scene.
  19441. */
  19442. clearColor: Color4;
  19443. protected _size: number | {
  19444. width: number;
  19445. height: number;
  19446. };
  19447. protected _initialSizeParameter: number | {
  19448. width: number;
  19449. height: number;
  19450. } | {
  19451. ratio: number;
  19452. };
  19453. protected _sizeRatio: Nullable<number>;
  19454. /** @hidden */ private _generateMipMaps: boolean;
  19455. protected _renderingManager: RenderingManager;
  19456. /** @hidden */ private _waitingRenderList: string[];
  19457. protected _doNotChangeAspectRatio: boolean;
  19458. protected _currentRefreshId: number;
  19459. protected _refreshRate: number;
  19460. protected _textureMatrix: Matrix;
  19461. protected _samples: number;
  19462. protected _renderTargetOptions: RenderTargetCreationOptions;
  19463. /**
  19464. * Gets render target creation options that were used.
  19465. */
  19466. readonly renderTargetOptions: RenderTargetCreationOptions;
  19467. protected _engine: Engine;
  19468. protected _onRatioRescale(): void;
  19469. /**
  19470. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19471. * It must define where the camera used to render the texture is set
  19472. */
  19473. boundingBoxPosition: Vector3;
  19474. private _boundingBoxSize;
  19475. /**
  19476. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19477. * When defined, the cubemap will switch to local mode
  19478. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19479. * @example https://www.babylonjs-playground.com/#RNASML
  19480. */
  19481. boundingBoxSize: Vector3;
  19482. /**
  19483. * In case the RTT has been created with a depth texture, get the associated
  19484. * depth texture.
  19485. * Otherwise, return null.
  19486. */
  19487. depthStencilTexture: Nullable<InternalTexture>;
  19488. /**
  19489. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19490. * or used a shadow, depth texture...
  19491. * @param name The friendly name of the texture
  19492. * @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)
  19493. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19494. * @param generateMipMaps True if mip maps need to be generated after render.
  19495. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19496. * @param type The type of the buffer in the RTT (int, half float, float...)
  19497. * @param isCube True if a cube texture needs to be created
  19498. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19499. * @param generateDepthBuffer True to generate a depth buffer
  19500. * @param generateStencilBuffer True to generate a stencil buffer
  19501. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19502. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19504. */
  19505. constructor(name: string, size: number | {
  19506. width: number;
  19507. height: number;
  19508. } | {
  19509. ratio: number;
  19510. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19511. /**
  19512. * Creates a depth stencil texture.
  19513. * This is only available in WebGL 2 or with the depth texture extension available.
  19514. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19515. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19516. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19517. */
  19518. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19519. private _processSizeParameter;
  19520. /**
  19521. * Define the number of samples to use in case of MSAA.
  19522. * It defaults to one meaning no MSAA has been enabled.
  19523. */
  19524. samples: number;
  19525. /**
  19526. * Resets the refresh counter of the texture and start bak from scratch.
  19527. * Could be useful to regenerate the texture if it is setup to render only once.
  19528. */
  19529. resetRefreshCounter(): void;
  19530. /**
  19531. * Define the refresh rate of the texture or the rendering frequency.
  19532. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19533. */
  19534. refreshRate: number;
  19535. /**
  19536. * Adds a post process to the render target rendering passes.
  19537. * @param postProcess define the post process to add
  19538. */
  19539. addPostProcess(postProcess: PostProcess): void;
  19540. /**
  19541. * Clear all the post processes attached to the render target
  19542. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19543. */
  19544. clearPostProcesses(dispose?: boolean): void;
  19545. /**
  19546. * Remove one of the post process from the list of attached post processes to the texture
  19547. * @param postProcess define the post process to remove from the list
  19548. */
  19549. removePostProcess(postProcess: PostProcess): void;
  19550. /** @hidden */ private _shouldRender(): boolean;
  19551. /**
  19552. * Gets the actual render size of the texture.
  19553. * @returns the width of the render size
  19554. */
  19555. getRenderSize(): number;
  19556. /**
  19557. * Gets the actual render width of the texture.
  19558. * @returns the width of the render size
  19559. */
  19560. getRenderWidth(): number;
  19561. /**
  19562. * Gets the actual render height of the texture.
  19563. * @returns the height of the render size
  19564. */
  19565. getRenderHeight(): number;
  19566. /**
  19567. * Get if the texture can be rescaled or not.
  19568. */
  19569. readonly canRescale: boolean;
  19570. /**
  19571. * Resize the texture using a ratio.
  19572. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19573. */
  19574. scale(ratio: number): void;
  19575. /**
  19576. * Get the texture reflection matrix used to rotate/transform the reflection.
  19577. * @returns the reflection matrix
  19578. */
  19579. getReflectionTextureMatrix(): Matrix;
  19580. /**
  19581. * Resize the texture to a new desired size.
  19582. * Be carrefull as it will recreate all the data in the new texture.
  19583. * @param size Define the new size. It can be:
  19584. * - a number for squared texture,
  19585. * - an object containing { width: number, height: number }
  19586. * - or an object containing a ratio { ratio: number }
  19587. */
  19588. resize(size: number | {
  19589. width: number;
  19590. height: number;
  19591. } | {
  19592. ratio: number;
  19593. }): void;
  19594. /**
  19595. * Renders all the objects from the render list into the texture.
  19596. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19597. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19598. */
  19599. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19600. private _bestReflectionRenderTargetDimension;
  19601. /**
  19602. * @hidden
  19603. * @param faceIndex face index to bind to if this is a cubetexture
  19604. */ private _bindFrameBuffer(faceIndex?: number): void;
  19605. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19606. private renderToTarget;
  19607. /**
  19608. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19609. * This allowed control for front to back rendering or reversly depending of the special needs.
  19610. *
  19611. * @param renderingGroupId The rendering group id corresponding to its index
  19612. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19613. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19614. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19615. */
  19616. 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;
  19617. /**
  19618. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19619. *
  19620. * @param renderingGroupId The rendering group id corresponding to its index
  19621. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19622. */
  19623. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19624. /**
  19625. * Clones the texture.
  19626. * @returns the cloned texture
  19627. */
  19628. clone(): RenderTargetTexture;
  19629. /**
  19630. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19631. * @returns The JSON representation of the texture
  19632. */
  19633. serialize(): any;
  19634. /**
  19635. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19636. */
  19637. disposeFramebufferObjects(): void;
  19638. /**
  19639. * Dispose the texture and release its associated resources.
  19640. */
  19641. dispose(): void;
  19642. /** @hidden */ private _rebuild(): void;
  19643. /**
  19644. * Clear the info related to rendering groups preventing retention point in material dispose.
  19645. */
  19646. freeRenderingGroups(): void;
  19647. /**
  19648. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19649. * @returns the view count
  19650. */
  19651. getViewCount(): number;
  19652. }
  19653. }
  19654. declare module BABYLON {
  19655. /**
  19656. * Base class for the main features of a material in Babylon.js
  19657. */
  19658. export class Material implements IAnimatable {
  19659. /**
  19660. * Returns the triangle fill mode
  19661. */
  19662. static readonly TriangleFillMode: number;
  19663. /**
  19664. * Returns the wireframe mode
  19665. */
  19666. static readonly WireFrameFillMode: number;
  19667. /**
  19668. * Returns the point fill mode
  19669. */
  19670. static readonly PointFillMode: number;
  19671. /**
  19672. * Returns the point list draw mode
  19673. */
  19674. static readonly PointListDrawMode: number;
  19675. /**
  19676. * Returns the line list draw mode
  19677. */
  19678. static readonly LineListDrawMode: number;
  19679. /**
  19680. * Returns the line loop draw mode
  19681. */
  19682. static readonly LineLoopDrawMode: number;
  19683. /**
  19684. * Returns the line strip draw mode
  19685. */
  19686. static readonly LineStripDrawMode: number;
  19687. /**
  19688. * Returns the triangle strip draw mode
  19689. */
  19690. static readonly TriangleStripDrawMode: number;
  19691. /**
  19692. * Returns the triangle fan draw mode
  19693. */
  19694. static readonly TriangleFanDrawMode: number;
  19695. /**
  19696. * Stores the clock-wise side orientation
  19697. */
  19698. static readonly ClockWiseSideOrientation: number;
  19699. /**
  19700. * Stores the counter clock-wise side orientation
  19701. */
  19702. static readonly CounterClockWiseSideOrientation: number;
  19703. /**
  19704. * The dirty texture flag value
  19705. */
  19706. static readonly TextureDirtyFlag: number;
  19707. /**
  19708. * The dirty light flag value
  19709. */
  19710. static readonly LightDirtyFlag: number;
  19711. /**
  19712. * The dirty fresnel flag value
  19713. */
  19714. static readonly FresnelDirtyFlag: number;
  19715. /**
  19716. * The dirty attribute flag value
  19717. */
  19718. static readonly AttributesDirtyFlag: number;
  19719. /**
  19720. * The dirty misc flag value
  19721. */
  19722. static readonly MiscDirtyFlag: number;
  19723. /**
  19724. * The all dirty flag value
  19725. */
  19726. static readonly AllDirtyFlag: number;
  19727. /**
  19728. * The ID of the material
  19729. */
  19730. id: string;
  19731. /**
  19732. * Gets or sets the unique id of the material
  19733. */
  19734. uniqueId: number;
  19735. /**
  19736. * The name of the material
  19737. */
  19738. name: string;
  19739. /**
  19740. * Gets or sets user defined metadata
  19741. */
  19742. metadata: any;
  19743. /**
  19744. * For internal use only. Please do not use.
  19745. */
  19746. reservedDataStore: any;
  19747. /**
  19748. * Specifies if the ready state should be checked on each call
  19749. */
  19750. checkReadyOnEveryCall: boolean;
  19751. /**
  19752. * Specifies if the ready state should be checked once
  19753. */
  19754. checkReadyOnlyOnce: boolean;
  19755. /**
  19756. * The state of the material
  19757. */
  19758. state: string;
  19759. /**
  19760. * The alpha value of the material
  19761. */
  19762. protected _alpha: number;
  19763. /**
  19764. * List of inspectable custom properties (used by the Inspector)
  19765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19766. */
  19767. inspectableCustomProperties: IInspectable[];
  19768. /**
  19769. * Sets the alpha value of the material
  19770. */
  19771. /**
  19772. * Gets the alpha value of the material
  19773. */
  19774. alpha: number;
  19775. /**
  19776. * Specifies if back face culling is enabled
  19777. */
  19778. protected _backFaceCulling: boolean;
  19779. /**
  19780. * Sets the back-face culling state
  19781. */
  19782. /**
  19783. * Gets the back-face culling state
  19784. */
  19785. backFaceCulling: boolean;
  19786. /**
  19787. * Stores the value for side orientation
  19788. */
  19789. sideOrientation: number;
  19790. /**
  19791. * Callback triggered when the material is compiled
  19792. */
  19793. onCompiled: Nullable<(effect: Effect) => void>;
  19794. /**
  19795. * Callback triggered when an error occurs
  19796. */
  19797. onError: Nullable<(effect: Effect, errors: string) => void>;
  19798. /**
  19799. * Callback triggered to get the render target textures
  19800. */
  19801. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19802. /**
  19803. * Gets a boolean indicating that current material needs to register RTT
  19804. */
  19805. readonly hasRenderTargetTextures: boolean;
  19806. /**
  19807. * Specifies if the material should be serialized
  19808. */
  19809. doNotSerialize: boolean;
  19810. /**
  19811. * @hidden
  19812. */ private _storeEffectOnSubMeshes: boolean;
  19813. /**
  19814. * Stores the animations for the material
  19815. */
  19816. animations: Nullable<Array<Animation>>;
  19817. /**
  19818. * An event triggered when the material is disposed
  19819. */
  19820. onDisposeObservable: Observable<Material>;
  19821. /**
  19822. * An observer which watches for dispose events
  19823. */
  19824. private _onDisposeObserver;
  19825. private _onUnBindObservable;
  19826. /**
  19827. * Called during a dispose event
  19828. */
  19829. onDispose: () => void;
  19830. private _onBindObservable;
  19831. /**
  19832. * An event triggered when the material is bound
  19833. */
  19834. readonly onBindObservable: Observable<AbstractMesh>;
  19835. /**
  19836. * An observer which watches for bind events
  19837. */
  19838. private _onBindObserver;
  19839. /**
  19840. * Called during a bind event
  19841. */
  19842. onBind: (Mesh: AbstractMesh) => void;
  19843. /**
  19844. * An event triggered when the material is unbound
  19845. */
  19846. readonly onUnBindObservable: Observable<Material>;
  19847. /**
  19848. * Stores the value of the alpha mode
  19849. */
  19850. private _alphaMode;
  19851. /**
  19852. * Sets the value of the alpha mode.
  19853. *
  19854. * | Value | Type | Description |
  19855. * | --- | --- | --- |
  19856. * | 0 | ALPHA_DISABLE | |
  19857. * | 1 | ALPHA_ADD | |
  19858. * | 2 | ALPHA_COMBINE | |
  19859. * | 3 | ALPHA_SUBTRACT | |
  19860. * | 4 | ALPHA_MULTIPLY | |
  19861. * | 5 | ALPHA_MAXIMIZED | |
  19862. * | 6 | ALPHA_ONEONE | |
  19863. * | 7 | ALPHA_PREMULTIPLIED | |
  19864. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19865. * | 9 | ALPHA_INTERPOLATE | |
  19866. * | 10 | ALPHA_SCREENMODE | |
  19867. *
  19868. */
  19869. /**
  19870. * Gets the value of the alpha mode
  19871. */
  19872. alphaMode: number;
  19873. /**
  19874. * Stores the state of the need depth pre-pass value
  19875. */
  19876. private _needDepthPrePass;
  19877. /**
  19878. * Sets the need depth pre-pass value
  19879. */
  19880. /**
  19881. * Gets the depth pre-pass value
  19882. */
  19883. needDepthPrePass: boolean;
  19884. /**
  19885. * Specifies if depth writing should be disabled
  19886. */
  19887. disableDepthWrite: boolean;
  19888. /**
  19889. * Specifies if depth writing should be forced
  19890. */
  19891. forceDepthWrite: boolean;
  19892. /**
  19893. * Specifies if there should be a separate pass for culling
  19894. */
  19895. separateCullingPass: boolean;
  19896. /**
  19897. * Stores the state specifing if fog should be enabled
  19898. */
  19899. private _fogEnabled;
  19900. /**
  19901. * Sets the state for enabling fog
  19902. */
  19903. /**
  19904. * Gets the value of the fog enabled state
  19905. */
  19906. fogEnabled: boolean;
  19907. /**
  19908. * Stores the size of points
  19909. */
  19910. pointSize: number;
  19911. /**
  19912. * Stores the z offset value
  19913. */
  19914. zOffset: number;
  19915. /**
  19916. * Gets a value specifying if wireframe mode is enabled
  19917. */
  19918. /**
  19919. * Sets the state of wireframe mode
  19920. */
  19921. wireframe: boolean;
  19922. /**
  19923. * Gets the value specifying if point clouds are enabled
  19924. */
  19925. /**
  19926. * Sets the state of point cloud mode
  19927. */
  19928. pointsCloud: boolean;
  19929. /**
  19930. * Gets the material fill mode
  19931. */
  19932. /**
  19933. * Sets the material fill mode
  19934. */
  19935. fillMode: number;
  19936. /**
  19937. * @hidden
  19938. * Stores the effects for the material
  19939. */ private _effect: Nullable<Effect>;
  19940. /**
  19941. * @hidden
  19942. * Specifies if the material was previously ready
  19943. */ private _wasPreviouslyReady: boolean;
  19944. /**
  19945. * Specifies if uniform buffers should be used
  19946. */
  19947. private _useUBO;
  19948. /**
  19949. * Stores a reference to the scene
  19950. */
  19951. private _scene;
  19952. /**
  19953. * Stores the fill mode state
  19954. */
  19955. private _fillMode;
  19956. /**
  19957. * Specifies if the depth write state should be cached
  19958. */
  19959. private _cachedDepthWriteState;
  19960. /**
  19961. * Stores the uniform buffer
  19962. */
  19963. protected _uniformBuffer: UniformBuffer;
  19964. /** @hidden */ private _indexInSceneMaterialArray: number;
  19965. /** @hidden */
  19966. meshMap: Nullable<{
  19967. [id: string]: AbstractMesh | undefined;
  19968. }>;
  19969. /**
  19970. * Creates a material instance
  19971. * @param name defines the name of the material
  19972. * @param scene defines the scene to reference
  19973. * @param doNotAdd specifies if the material should be added to the scene
  19974. */
  19975. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  19976. /**
  19977. * Returns a string representation of the current material
  19978. * @param fullDetails defines a boolean indicating which levels of logging is desired
  19979. * @returns a string with material information
  19980. */
  19981. toString(fullDetails?: boolean): string;
  19982. /**
  19983. * Gets the class name of the material
  19984. * @returns a string with the class name of the material
  19985. */
  19986. getClassName(): string;
  19987. /**
  19988. * Specifies if updates for the material been locked
  19989. */
  19990. readonly isFrozen: boolean;
  19991. /**
  19992. * Locks updates for the material
  19993. */
  19994. freeze(): void;
  19995. /**
  19996. * Unlocks updates for the material
  19997. */
  19998. unfreeze(): void;
  19999. /**
  20000. * Specifies if the material is ready to be used
  20001. * @param mesh defines the mesh to check
  20002. * @param useInstances specifies if instances should be used
  20003. * @returns a boolean indicating if the material is ready to be used
  20004. */
  20005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20006. /**
  20007. * Specifies that the submesh is ready to be used
  20008. * @param mesh defines the mesh to check
  20009. * @param subMesh defines which submesh to check
  20010. * @param useInstances specifies that instances should be used
  20011. * @returns a boolean indicating that the submesh is ready or not
  20012. */
  20013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20014. /**
  20015. * Returns the material effect
  20016. * @returns the effect associated with the material
  20017. */
  20018. getEffect(): Nullable<Effect>;
  20019. /**
  20020. * Returns the current scene
  20021. * @returns a Scene
  20022. */
  20023. getScene(): Scene;
  20024. /**
  20025. * Specifies if the material will require alpha blending
  20026. * @returns a boolean specifying if alpha blending is needed
  20027. */
  20028. needAlphaBlending(): boolean;
  20029. /**
  20030. * Specifies if the mesh will require alpha blending
  20031. * @param mesh defines the mesh to check
  20032. * @returns a boolean specifying if alpha blending is needed for the mesh
  20033. */
  20034. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20035. /**
  20036. * Specifies if this material should be rendered in alpha test mode
  20037. * @returns a boolean specifying if an alpha test is needed.
  20038. */
  20039. needAlphaTesting(): boolean;
  20040. /**
  20041. * Gets the texture used for the alpha test
  20042. * @returns the texture to use for alpha testing
  20043. */
  20044. getAlphaTestTexture(): Nullable<BaseTexture>;
  20045. /**
  20046. * Marks the material to indicate that it needs to be re-calculated
  20047. */
  20048. markDirty(): void;
  20049. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20050. /**
  20051. * Binds the material to the mesh
  20052. * @param world defines the world transformation matrix
  20053. * @param mesh defines the mesh to bind the material to
  20054. */
  20055. bind(world: Matrix, mesh?: Mesh): void;
  20056. /**
  20057. * Binds the submesh to the material
  20058. * @param world defines the world transformation matrix
  20059. * @param mesh defines the mesh containing the submesh
  20060. * @param subMesh defines the submesh to bind the material to
  20061. */
  20062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20063. /**
  20064. * Binds the world matrix to the material
  20065. * @param world defines the world transformation matrix
  20066. */
  20067. bindOnlyWorldMatrix(world: Matrix): void;
  20068. /**
  20069. * Binds the scene's uniform buffer to the effect.
  20070. * @param effect defines the effect to bind to the scene uniform buffer
  20071. * @param sceneUbo defines the uniform buffer storing scene data
  20072. */
  20073. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20074. /**
  20075. * Binds the view matrix to the effect
  20076. * @param effect defines the effect to bind the view matrix to
  20077. */
  20078. bindView(effect: Effect): void;
  20079. /**
  20080. * Binds the view projection matrix to the effect
  20081. * @param effect defines the effect to bind the view projection matrix to
  20082. */
  20083. bindViewProjection(effect: Effect): void;
  20084. /**
  20085. * Specifies if material alpha testing should be turned on for the mesh
  20086. * @param mesh defines the mesh to check
  20087. */
  20088. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20089. /**
  20090. * Processes to execute after binding the material to a mesh
  20091. * @param mesh defines the rendered mesh
  20092. */
  20093. protected _afterBind(mesh?: Mesh): void;
  20094. /**
  20095. * Unbinds the material from the mesh
  20096. */
  20097. unbind(): void;
  20098. /**
  20099. * Gets the active textures from the material
  20100. * @returns an array of textures
  20101. */
  20102. getActiveTextures(): BaseTexture[];
  20103. /**
  20104. * Specifies if the material uses a texture
  20105. * @param texture defines the texture to check against the material
  20106. * @returns a boolean specifying if the material uses the texture
  20107. */
  20108. hasTexture(texture: BaseTexture): boolean;
  20109. /**
  20110. * Makes a duplicate of the material, and gives it a new name
  20111. * @param name defines the new name for the duplicated material
  20112. * @returns the cloned material
  20113. */
  20114. clone(name: string): Nullable<Material>;
  20115. /**
  20116. * Gets the meshes bound to the material
  20117. * @returns an array of meshes bound to the material
  20118. */
  20119. getBindedMeshes(): AbstractMesh[];
  20120. /**
  20121. * Force shader compilation
  20122. * @param mesh defines the mesh associated with this material
  20123. * @param onCompiled defines a function to execute once the material is compiled
  20124. * @param options defines the options to configure the compilation
  20125. */
  20126. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20127. clipPlane: boolean;
  20128. }>): void;
  20129. /**
  20130. * Force shader compilation
  20131. * @param mesh defines the mesh that will use this material
  20132. * @param options defines additional options for compiling the shaders
  20133. * @returns a promise that resolves when the compilation completes
  20134. */
  20135. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20136. clipPlane: boolean;
  20137. }>): Promise<void>;
  20138. private static readonly _AllDirtyCallBack;
  20139. private static readonly _ImageProcessingDirtyCallBack;
  20140. private static readonly _TextureDirtyCallBack;
  20141. private static readonly _FresnelDirtyCallBack;
  20142. private static readonly _MiscDirtyCallBack;
  20143. private static readonly _LightsDirtyCallBack;
  20144. private static readonly _AttributeDirtyCallBack;
  20145. private static _FresnelAndMiscDirtyCallBack;
  20146. private static _TextureAndMiscDirtyCallBack;
  20147. private static readonly _DirtyCallbackArray;
  20148. private static readonly _RunDirtyCallBacks;
  20149. /**
  20150. * Marks a define in the material to indicate that it needs to be re-computed
  20151. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20152. */
  20153. markAsDirty(flag: number): void;
  20154. /**
  20155. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20156. * @param func defines a function which checks material defines against the submeshes
  20157. */
  20158. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20159. /**
  20160. * Indicates that we need to re-calculated for all submeshes
  20161. */
  20162. protected _markAllSubMeshesAsAllDirty(): void;
  20163. /**
  20164. * Indicates that image processing needs to be re-calculated for all submeshes
  20165. */
  20166. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20167. /**
  20168. * Indicates that textures need to be re-calculated for all submeshes
  20169. */
  20170. protected _markAllSubMeshesAsTexturesDirty(): void;
  20171. /**
  20172. * Indicates that fresnel needs to be re-calculated for all submeshes
  20173. */
  20174. protected _markAllSubMeshesAsFresnelDirty(): void;
  20175. /**
  20176. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20177. */
  20178. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20179. /**
  20180. * Indicates that lights need to be re-calculated for all submeshes
  20181. */
  20182. protected _markAllSubMeshesAsLightsDirty(): void;
  20183. /**
  20184. * Indicates that attributes need to be re-calculated for all submeshes
  20185. */
  20186. protected _markAllSubMeshesAsAttributesDirty(): void;
  20187. /**
  20188. * Indicates that misc needs to be re-calculated for all submeshes
  20189. */
  20190. protected _markAllSubMeshesAsMiscDirty(): void;
  20191. /**
  20192. * Indicates that textures and misc need to be re-calculated for all submeshes
  20193. */
  20194. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20195. /**
  20196. * Disposes the material
  20197. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20198. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20199. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20200. */
  20201. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20202. /** @hidden */
  20203. private releaseVertexArrayObject;
  20204. /**
  20205. * Serializes this material
  20206. * @returns the serialized material object
  20207. */
  20208. serialize(): any;
  20209. /**
  20210. * Creates a material from parsed material data
  20211. * @param parsedMaterial defines parsed material data
  20212. * @param scene defines the hosting scene
  20213. * @param rootUrl defines the root URL to use to load textures
  20214. * @returns a new material
  20215. */
  20216. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20217. }
  20218. }
  20219. declare module BABYLON {
  20220. /**
  20221. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20222. * separate meshes. This can be use to improve performances.
  20223. * @see http://doc.babylonjs.com/how_to/multi_materials
  20224. */
  20225. export class MultiMaterial extends Material {
  20226. private _subMaterials;
  20227. /**
  20228. * Gets or Sets the list of Materials used within the multi material.
  20229. * They need to be ordered according to the submeshes order in the associated mesh
  20230. */
  20231. subMaterials: Nullable<Material>[];
  20232. /**
  20233. * Function used to align with Node.getChildren()
  20234. * @returns the list of Materials used within the multi material
  20235. */
  20236. getChildren(): Nullable<Material>[];
  20237. /**
  20238. * Instantiates a new Multi Material
  20239. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20240. * separate meshes. This can be use to improve performances.
  20241. * @see http://doc.babylonjs.com/how_to/multi_materials
  20242. * @param name Define the name in the scene
  20243. * @param scene Define the scene the material belongs to
  20244. */
  20245. constructor(name: string, scene: Scene);
  20246. private _hookArray;
  20247. /**
  20248. * Get one of the submaterial by its index in the submaterials array
  20249. * @param index The index to look the sub material at
  20250. * @returns The Material if the index has been defined
  20251. */
  20252. getSubMaterial(index: number): Nullable<Material>;
  20253. /**
  20254. * Get the list of active textures for the whole sub materials list.
  20255. * @returns All the textures that will be used during the rendering
  20256. */
  20257. getActiveTextures(): BaseTexture[];
  20258. /**
  20259. * Gets the current class name of the material e.g. "MultiMaterial"
  20260. * Mainly use in serialization.
  20261. * @returns the class name
  20262. */
  20263. getClassName(): string;
  20264. /**
  20265. * Checks if the material is ready to render the requested sub mesh
  20266. * @param mesh Define the mesh the submesh belongs to
  20267. * @param subMesh Define the sub mesh to look readyness for
  20268. * @param useInstances Define whether or not the material is used with instances
  20269. * @returns true if ready, otherwise false
  20270. */
  20271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20272. /**
  20273. * Clones the current material and its related sub materials
  20274. * @param name Define the name of the newly cloned material
  20275. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20276. * @returns the cloned material
  20277. */
  20278. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20279. /**
  20280. * Serializes the materials into a JSON representation.
  20281. * @returns the JSON representation
  20282. */
  20283. serialize(): any;
  20284. /**
  20285. * Dispose the material and release its associated resources
  20286. * @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)
  20287. * @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)
  20288. * @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)
  20289. */
  20290. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20291. /**
  20292. * Creates a MultiMaterial from parsed MultiMaterial data.
  20293. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20294. * @param scene defines the hosting scene
  20295. * @returns a new MultiMaterial
  20296. */
  20297. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20298. }
  20299. }
  20300. declare module BABYLON {
  20301. /**
  20302. * Base class for submeshes
  20303. */
  20304. export class BaseSubMesh {
  20305. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20306. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20307. /**
  20308. * Gets associated effect
  20309. */
  20310. readonly effect: Nullable<Effect>;
  20311. /**
  20312. * Sets associated effect (effect used to render this submesh)
  20313. * @param effect defines the effect to associate with
  20314. * @param defines defines the set of defines used to compile this effect
  20315. */
  20316. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20317. }
  20318. /**
  20319. * Defines a subdivision inside a mesh
  20320. */
  20321. export class SubMesh extends BaseSubMesh implements ICullable {
  20322. /** the material index to use */
  20323. materialIndex: number;
  20324. /** vertex index start */
  20325. verticesStart: number;
  20326. /** vertices count */
  20327. verticesCount: number;
  20328. /** index start */
  20329. indexStart: number;
  20330. /** indices count */
  20331. indexCount: number;
  20332. /** @hidden */ private _linesIndexCount: number;
  20333. private _mesh;
  20334. private _renderingMesh;
  20335. private _boundingInfo;
  20336. private _linesIndexBuffer;
  20337. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20338. /** @hidden */ private _trianglePlanes: Plane[];
  20339. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20340. /** @hidden */ private _renderId: number;
  20341. /** @hidden */ private _alphaIndex: number;
  20342. /** @hidden */ private _distanceToCamera: number;
  20343. /** @hidden */ private _id: number;
  20344. private _currentMaterial;
  20345. /**
  20346. * Add a new submesh to a mesh
  20347. * @param materialIndex defines the material index to use
  20348. * @param verticesStart defines vertex index start
  20349. * @param verticesCount defines vertices count
  20350. * @param indexStart defines index start
  20351. * @param indexCount defines indices count
  20352. * @param mesh defines the parent mesh
  20353. * @param renderingMesh defines an optional rendering mesh
  20354. * @param createBoundingBox defines if bounding box should be created for this submesh
  20355. * @returns the new submesh
  20356. */
  20357. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20358. /**
  20359. * Creates a new submesh
  20360. * @param materialIndex defines the material index to use
  20361. * @param verticesStart defines vertex index start
  20362. * @param verticesCount defines vertices count
  20363. * @param indexStart defines index start
  20364. * @param indexCount defines indices count
  20365. * @param mesh defines the parent mesh
  20366. * @param renderingMesh defines an optional rendering mesh
  20367. * @param createBoundingBox defines if bounding box should be created for this submesh
  20368. */
  20369. constructor(
  20370. /** the material index to use */
  20371. materialIndex: number,
  20372. /** vertex index start */
  20373. verticesStart: number,
  20374. /** vertices count */
  20375. verticesCount: number,
  20376. /** index start */
  20377. indexStart: number,
  20378. /** indices count */
  20379. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20380. /**
  20381. * Returns true if this submesh covers the entire parent mesh
  20382. * @ignorenaming
  20383. */
  20384. readonly IsGlobal: boolean;
  20385. /**
  20386. * Returns the submesh BoudingInfo object
  20387. * @returns current bounding info (or mesh's one if the submesh is global)
  20388. */
  20389. getBoundingInfo(): BoundingInfo;
  20390. /**
  20391. * Sets the submesh BoundingInfo
  20392. * @param boundingInfo defines the new bounding info to use
  20393. * @returns the SubMesh
  20394. */
  20395. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20396. /**
  20397. * Returns the mesh of the current submesh
  20398. * @return the parent mesh
  20399. */
  20400. getMesh(): AbstractMesh;
  20401. /**
  20402. * Returns the rendering mesh of the submesh
  20403. * @returns the rendering mesh (could be different from parent mesh)
  20404. */
  20405. getRenderingMesh(): Mesh;
  20406. /**
  20407. * Returns the submesh material
  20408. * @returns null or the current material
  20409. */
  20410. getMaterial(): Nullable<Material>;
  20411. /**
  20412. * Sets a new updated BoundingInfo object to the submesh
  20413. * @param data defines an optional position array to use to determine the bounding info
  20414. * @returns the SubMesh
  20415. */
  20416. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20417. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20418. /**
  20419. * Updates the submesh BoundingInfo
  20420. * @param world defines the world matrix to use to update the bounding info
  20421. * @returns the submesh
  20422. */
  20423. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20424. /**
  20425. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20426. * @param frustumPlanes defines the frustum planes
  20427. * @returns true if the submesh is intersecting with the frustum
  20428. */
  20429. isInFrustum(frustumPlanes: Plane[]): boolean;
  20430. /**
  20431. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20432. * @param frustumPlanes defines the frustum planes
  20433. * @returns true if the submesh is inside the frustum
  20434. */
  20435. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20436. /**
  20437. * Renders the submesh
  20438. * @param enableAlphaMode defines if alpha needs to be used
  20439. * @returns the submesh
  20440. */
  20441. render(enableAlphaMode: boolean): SubMesh;
  20442. /**
  20443. * @hidden
  20444. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20445. /**
  20446. * Checks if the submesh intersects with a ray
  20447. * @param ray defines the ray to test
  20448. * @returns true is the passed ray intersects the submesh bounding box
  20449. */
  20450. canIntersects(ray: Ray): boolean;
  20451. /**
  20452. * Intersects current submesh with a ray
  20453. * @param ray defines the ray to test
  20454. * @param positions defines mesh's positions array
  20455. * @param indices defines mesh's indices array
  20456. * @param fastCheck defines if only bounding info should be used
  20457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20458. * @returns intersection info or null if no intersection
  20459. */
  20460. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20461. /** @hidden */
  20462. private _intersectLines;
  20463. /** @hidden */
  20464. private _intersectUnIndexedLines;
  20465. /** @hidden */
  20466. private _intersectTriangles;
  20467. /** @hidden */
  20468. private _intersectUnIndexedTriangles;
  20469. /** @hidden */ private _rebuild(): void;
  20470. /**
  20471. * Creates a new submesh from the passed mesh
  20472. * @param newMesh defines the new hosting mesh
  20473. * @param newRenderingMesh defines an optional rendering mesh
  20474. * @returns the new submesh
  20475. */
  20476. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20477. /**
  20478. * Release associated resources
  20479. */
  20480. dispose(): void;
  20481. /**
  20482. * Gets the class name
  20483. * @returns the string "SubMesh".
  20484. */
  20485. getClassName(): string;
  20486. /**
  20487. * Creates a new submesh from indices data
  20488. * @param materialIndex the index of the main mesh material
  20489. * @param startIndex the index where to start the copy in the mesh indices array
  20490. * @param indexCount the number of indices to copy then from the startIndex
  20491. * @param mesh the main mesh to create the submesh from
  20492. * @param renderingMesh the optional rendering mesh
  20493. * @returns a new submesh
  20494. */
  20495. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20496. }
  20497. }
  20498. declare module BABYLON {
  20499. /**
  20500. * Class used to represent data loading progression
  20501. */
  20502. export class SceneLoaderFlags {
  20503. private static _ForceFullSceneLoadingForIncremental;
  20504. private static _ShowLoadingScreen;
  20505. private static _CleanBoneMatrixWeights;
  20506. private static _loggingLevel;
  20507. /**
  20508. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20509. */
  20510. static ForceFullSceneLoadingForIncremental: boolean;
  20511. /**
  20512. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20513. */
  20514. static ShowLoadingScreen: boolean;
  20515. /**
  20516. * Defines the current logging level (while loading the scene)
  20517. * @ignorenaming
  20518. */
  20519. static loggingLevel: number;
  20520. /**
  20521. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20522. */
  20523. static CleanBoneMatrixWeights: boolean;
  20524. }
  20525. }
  20526. declare module BABYLON {
  20527. /**
  20528. * Class used to store geometry data (vertex buffers + index buffer)
  20529. */
  20530. export class Geometry implements IGetSetVerticesData {
  20531. /**
  20532. * Gets or sets the ID of the geometry
  20533. */
  20534. id: string;
  20535. /**
  20536. * Gets or sets the unique ID of the geometry
  20537. */
  20538. uniqueId: number;
  20539. /**
  20540. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20541. */
  20542. delayLoadState: number;
  20543. /**
  20544. * Gets the file containing the data to load when running in delay load state
  20545. */
  20546. delayLoadingFile: Nullable<string>;
  20547. /**
  20548. * Callback called when the geometry is updated
  20549. */
  20550. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20551. private _scene;
  20552. private _engine;
  20553. private _meshes;
  20554. private _totalVertices;
  20555. /** @hidden */ private _indices: IndicesArray;
  20556. /** @hidden */ private _vertexBuffers: {
  20557. [key: string]: VertexBuffer;
  20558. };
  20559. private _isDisposed;
  20560. private _extend;
  20561. private _boundingBias;
  20562. /** @hidden */ private _delayInfo: Array<string>;
  20563. private _indexBuffer;
  20564. private _indexBufferIsUpdatable;
  20565. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20566. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20567. /** @hidden */ private _softwareSkinningFrameId: number;
  20568. private _vertexArrayObjects;
  20569. private _updatable;
  20570. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20571. /**
  20572. * 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
  20573. */
  20574. /**
  20575. * 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
  20576. */
  20577. boundingBias: Vector2;
  20578. /**
  20579. * Static function used to attach a new empty geometry to a mesh
  20580. * @param mesh defines the mesh to attach the geometry to
  20581. * @returns the new Geometry
  20582. */
  20583. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20584. /**
  20585. * Creates a new geometry
  20586. * @param id defines the unique ID
  20587. * @param scene defines the hosting scene
  20588. * @param vertexData defines the VertexData used to get geometry data
  20589. * @param updatable defines if geometry must be updatable (false by default)
  20590. * @param mesh defines the mesh that will be associated with the geometry
  20591. */
  20592. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20593. /**
  20594. * Gets the current extend of the geometry
  20595. */
  20596. readonly extend: {
  20597. minimum: Vector3;
  20598. maximum: Vector3;
  20599. };
  20600. /**
  20601. * Gets the hosting scene
  20602. * @returns the hosting Scene
  20603. */
  20604. getScene(): Scene;
  20605. /**
  20606. * Gets the hosting engine
  20607. * @returns the hosting Engine
  20608. */
  20609. getEngine(): Engine;
  20610. /**
  20611. * Defines if the geometry is ready to use
  20612. * @returns true if the geometry is ready to be used
  20613. */
  20614. isReady(): boolean;
  20615. /**
  20616. * Gets a value indicating that the geometry should not be serialized
  20617. */
  20618. readonly doNotSerialize: boolean;
  20619. /** @hidden */ private _rebuild(): void;
  20620. /**
  20621. * Affects all geometry data in one call
  20622. * @param vertexData defines the geometry data
  20623. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20624. */
  20625. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20626. /**
  20627. * Set specific vertex data
  20628. * @param kind defines the data kind (Position, normal, etc...)
  20629. * @param data defines the vertex data to use
  20630. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20631. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20632. */
  20633. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20634. /**
  20635. * Removes a specific vertex data
  20636. * @param kind defines the data kind (Position, normal, etc...)
  20637. */
  20638. removeVerticesData(kind: string): void;
  20639. /**
  20640. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20641. * @param buffer defines the vertex buffer to use
  20642. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20643. */
  20644. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20645. /**
  20646. * Update a specific vertex buffer
  20647. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20648. * It will do nothing if the buffer is not updatable
  20649. * @param kind defines the data kind (Position, normal, etc...)
  20650. * @param data defines the data to use
  20651. * @param offset defines the offset in the target buffer where to store the data
  20652. * @param useBytes set to true if the offset is in bytes
  20653. */
  20654. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20655. /**
  20656. * Update a specific vertex buffer
  20657. * This function will create a new buffer if the current one is not updatable
  20658. * @param kind defines the data kind (Position, normal, etc...)
  20659. * @param data defines the data to use
  20660. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20661. */
  20662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20663. private _updateBoundingInfo;
  20664. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20665. /**
  20666. * Gets total number of vertices
  20667. * @returns the total number of vertices
  20668. */
  20669. getTotalVertices(): number;
  20670. /**
  20671. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20672. * @param kind defines the data kind (Position, normal, etc...)
  20673. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20674. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20675. * @returns a float array containing vertex data
  20676. */
  20677. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20678. /**
  20679. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20680. * @param kind defines the data kind (Position, normal, etc...)
  20681. * @returns true if the vertex buffer with the specified kind is updatable
  20682. */
  20683. isVertexBufferUpdatable(kind: string): boolean;
  20684. /**
  20685. * Gets a specific vertex buffer
  20686. * @param kind defines the data kind (Position, normal, etc...)
  20687. * @returns a VertexBuffer
  20688. */
  20689. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20690. /**
  20691. * Returns all vertex buffers
  20692. * @return an object holding all vertex buffers indexed by kind
  20693. */
  20694. getVertexBuffers(): Nullable<{
  20695. [key: string]: VertexBuffer;
  20696. }>;
  20697. /**
  20698. * Gets a boolean indicating if specific vertex buffer is present
  20699. * @param kind defines the data kind (Position, normal, etc...)
  20700. * @returns true if data is present
  20701. */
  20702. isVerticesDataPresent(kind: string): boolean;
  20703. /**
  20704. * Gets a list of all attached data kinds (Position, normal, etc...)
  20705. * @returns a list of string containing all kinds
  20706. */
  20707. getVerticesDataKinds(): string[];
  20708. /**
  20709. * Update index buffer
  20710. * @param indices defines the indices to store in the index buffer
  20711. * @param offset defines the offset in the target buffer where to store the data
  20712. * @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)
  20713. */
  20714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20715. /**
  20716. * Creates a new index buffer
  20717. * @param indices defines the indices to store in the index buffer
  20718. * @param totalVertices defines the total number of vertices (could be null)
  20719. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20720. */
  20721. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20722. /**
  20723. * Return the total number of indices
  20724. * @returns the total number of indices
  20725. */
  20726. getTotalIndices(): number;
  20727. /**
  20728. * Gets the index buffer array
  20729. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20731. * @returns the index buffer array
  20732. */
  20733. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20734. /**
  20735. * Gets the index buffer
  20736. * @return the index buffer
  20737. */
  20738. getIndexBuffer(): Nullable<DataBuffer>;
  20739. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20740. /**
  20741. * Release the associated resources for a specific mesh
  20742. * @param mesh defines the source mesh
  20743. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20744. */
  20745. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20746. /**
  20747. * Apply current geometry to a given mesh
  20748. * @param mesh defines the mesh to apply geometry to
  20749. */
  20750. applyToMesh(mesh: Mesh): void;
  20751. private _updateExtend;
  20752. private _applyToMesh;
  20753. private notifyUpdate;
  20754. /**
  20755. * Load the geometry if it was flagged as delay loaded
  20756. * @param scene defines the hosting scene
  20757. * @param onLoaded defines a callback called when the geometry is loaded
  20758. */
  20759. load(scene: Scene, onLoaded?: () => void): void;
  20760. private _queueLoad;
  20761. /**
  20762. * Invert the geometry to move from a right handed system to a left handed one.
  20763. */
  20764. toLeftHanded(): void;
  20765. /** @hidden */ private _resetPointsArrayCache(): void;
  20766. /** @hidden */ private _generatePointsArray(): boolean;
  20767. /**
  20768. * Gets a value indicating if the geometry is disposed
  20769. * @returns true if the geometry was disposed
  20770. */
  20771. isDisposed(): boolean;
  20772. private _disposeVertexArrayObjects;
  20773. /**
  20774. * Free all associated resources
  20775. */
  20776. dispose(): void;
  20777. /**
  20778. * Clone the current geometry into a new geometry
  20779. * @param id defines the unique ID of the new geometry
  20780. * @returns a new geometry object
  20781. */
  20782. copy(id: string): Geometry;
  20783. /**
  20784. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20785. * @return a JSON representation of the current geometry data (without the vertices data)
  20786. */
  20787. serialize(): any;
  20788. private toNumberArray;
  20789. /**
  20790. * Serialize all vertices data into a JSON oject
  20791. * @returns a JSON representation of the current geometry data
  20792. */
  20793. serializeVerticeData(): any;
  20794. /**
  20795. * Extracts a clone of a mesh geometry
  20796. * @param mesh defines the source mesh
  20797. * @param id defines the unique ID of the new geometry object
  20798. * @returns the new geometry object
  20799. */
  20800. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20801. /**
  20802. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20803. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20804. * Be aware Math.random() could cause collisions, but:
  20805. * "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"
  20806. * @returns a string containing a new GUID
  20807. */
  20808. static RandomId(): string;
  20809. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20810. private static _CleanMatricesWeights;
  20811. /**
  20812. * Create a new geometry from persisted data (Using .babylon file format)
  20813. * @param parsedVertexData defines the persisted data
  20814. * @param scene defines the hosting scene
  20815. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20816. * @returns the new geometry object
  20817. */
  20818. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20819. }
  20820. }
  20821. declare module BABYLON {
  20822. /**
  20823. * Define an interface for all classes that will get and set the data on vertices
  20824. */
  20825. export interface IGetSetVerticesData {
  20826. /**
  20827. * Gets a boolean indicating if specific vertex data is present
  20828. * @param kind defines the vertex data kind to use
  20829. * @returns true is data kind is present
  20830. */
  20831. isVerticesDataPresent(kind: string): boolean;
  20832. /**
  20833. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20834. * @param kind defines the data kind (Position, normal, etc...)
  20835. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20836. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20837. * @returns a float array containing vertex data
  20838. */
  20839. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20840. /**
  20841. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20842. * @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.
  20843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20844. * @returns the indices array or an empty array if the mesh has no geometry
  20845. */
  20846. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20847. /**
  20848. * Set specific vertex data
  20849. * @param kind defines the data kind (Position, normal, etc...)
  20850. * @param data defines the vertex data to use
  20851. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20852. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20853. */
  20854. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20855. /**
  20856. * Update a specific associated vertex buffer
  20857. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20858. * - VertexBuffer.PositionKind
  20859. * - VertexBuffer.UVKind
  20860. * - VertexBuffer.UV2Kind
  20861. * - VertexBuffer.UV3Kind
  20862. * - VertexBuffer.UV4Kind
  20863. * - VertexBuffer.UV5Kind
  20864. * - VertexBuffer.UV6Kind
  20865. * - VertexBuffer.ColorKind
  20866. * - VertexBuffer.MatricesIndicesKind
  20867. * - VertexBuffer.MatricesIndicesExtraKind
  20868. * - VertexBuffer.MatricesWeightsKind
  20869. * - VertexBuffer.MatricesWeightsExtraKind
  20870. * @param data defines the data source
  20871. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20872. * @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)
  20873. */
  20874. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20875. /**
  20876. * Creates a new index buffer
  20877. * @param indices defines the indices to store in the index buffer
  20878. * @param totalVertices defines the total number of vertices (could be null)
  20879. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20880. */
  20881. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20882. }
  20883. /**
  20884. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20885. */
  20886. export class VertexData {
  20887. /**
  20888. * Mesh side orientation : usually the external or front surface
  20889. */
  20890. static readonly FRONTSIDE: number;
  20891. /**
  20892. * Mesh side orientation : usually the internal or back surface
  20893. */
  20894. static readonly BACKSIDE: number;
  20895. /**
  20896. * Mesh side orientation : both internal and external or front and back surfaces
  20897. */
  20898. static readonly DOUBLESIDE: number;
  20899. /**
  20900. * Mesh side orientation : by default, `FRONTSIDE`
  20901. */
  20902. static readonly DEFAULTSIDE: number;
  20903. /**
  20904. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20905. */
  20906. positions: Nullable<FloatArray>;
  20907. /**
  20908. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20909. */
  20910. normals: Nullable<FloatArray>;
  20911. /**
  20912. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20913. */
  20914. tangents: Nullable<FloatArray>;
  20915. /**
  20916. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20917. */
  20918. uvs: Nullable<FloatArray>;
  20919. /**
  20920. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20921. */
  20922. uvs2: Nullable<FloatArray>;
  20923. /**
  20924. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20925. */
  20926. uvs3: Nullable<FloatArray>;
  20927. /**
  20928. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20929. */
  20930. uvs4: Nullable<FloatArray>;
  20931. /**
  20932. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20933. */
  20934. uvs5: Nullable<FloatArray>;
  20935. /**
  20936. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20937. */
  20938. uvs6: Nullable<FloatArray>;
  20939. /**
  20940. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20941. */
  20942. colors: Nullable<FloatArray>;
  20943. /**
  20944. * 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).
  20945. */
  20946. matricesIndices: Nullable<FloatArray>;
  20947. /**
  20948. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20949. */
  20950. matricesWeights: Nullable<FloatArray>;
  20951. /**
  20952. * An array extending the number of possible indices
  20953. */
  20954. matricesIndicesExtra: Nullable<FloatArray>;
  20955. /**
  20956. * An array extending the number of possible weights when the number of indices is extended
  20957. */
  20958. matricesWeightsExtra: Nullable<FloatArray>;
  20959. /**
  20960. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20961. */
  20962. indices: Nullable<IndicesArray>;
  20963. /**
  20964. * Uses the passed data array to set the set the values for the specified kind of data
  20965. * @param data a linear array of floating numbers
  20966. * @param kind the type of data that is being set, eg positions, colors etc
  20967. */
  20968. set(data: FloatArray, kind: string): void;
  20969. /**
  20970. * Associates the vertexData to the passed Mesh.
  20971. * Sets it as updatable or not (default `false`)
  20972. * @param mesh the mesh the vertexData is applied to
  20973. * @param updatable when used and having the value true allows new data to update the vertexData
  20974. * @returns the VertexData
  20975. */
  20976. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20977. /**
  20978. * Associates the vertexData to the passed Geometry.
  20979. * Sets it as updatable or not (default `false`)
  20980. * @param geometry the geometry the vertexData is applied to
  20981. * @param updatable when used and having the value true allows new data to update the vertexData
  20982. * @returns VertexData
  20983. */
  20984. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20985. /**
  20986. * Updates the associated mesh
  20987. * @param mesh the mesh to be updated
  20988. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20989. * @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
  20990. * @returns VertexData
  20991. */
  20992. updateMesh(mesh: Mesh): VertexData;
  20993. /**
  20994. * Updates the associated geometry
  20995. * @param geometry the geometry to be updated
  20996. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20997. * @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
  20998. * @returns VertexData.
  20999. */
  21000. updateGeometry(geometry: Geometry): VertexData;
  21001. private _applyTo;
  21002. private _update;
  21003. /**
  21004. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21005. * @param matrix the transforming matrix
  21006. * @returns the VertexData
  21007. */
  21008. transform(matrix: Matrix): VertexData;
  21009. /**
  21010. * Merges the passed VertexData into the current one
  21011. * @param other the VertexData to be merged into the current one
  21012. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21013. * @returns the modified VertexData
  21014. */
  21015. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21016. private _mergeElement;
  21017. private _validate;
  21018. /**
  21019. * Serializes the VertexData
  21020. * @returns a serialized object
  21021. */
  21022. serialize(): any;
  21023. /**
  21024. * Extracts the vertexData from a mesh
  21025. * @param mesh the mesh from which to extract the VertexData
  21026. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21027. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21028. * @returns the object VertexData associated to the passed mesh
  21029. */
  21030. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21031. /**
  21032. * Extracts the vertexData from the geometry
  21033. * @param geometry the geometry from which to extract the VertexData
  21034. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21035. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21036. * @returns the object VertexData associated to the passed mesh
  21037. */
  21038. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21039. private static _ExtractFrom;
  21040. /**
  21041. * Creates the VertexData for a Ribbon
  21042. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21043. * * pathArray array of paths, each of which an array of successive Vector3
  21044. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21045. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21046. * * 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
  21047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21048. * * 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)
  21049. * * 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)
  21050. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21051. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21052. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21053. * @returns the VertexData of the ribbon
  21054. */
  21055. static CreateRibbon(options: {
  21056. pathArray: Vector3[][];
  21057. closeArray?: boolean;
  21058. closePath?: boolean;
  21059. offset?: number;
  21060. sideOrientation?: number;
  21061. frontUVs?: Vector4;
  21062. backUVs?: Vector4;
  21063. invertUV?: boolean;
  21064. uvs?: Vector2[];
  21065. colors?: Color4[];
  21066. }): VertexData;
  21067. /**
  21068. * Creates the VertexData for a box
  21069. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21070. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21071. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21072. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21073. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21074. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21075. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21077. * * 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)
  21078. * * 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)
  21079. * @returns the VertexData of the box
  21080. */
  21081. static CreateBox(options: {
  21082. size?: number;
  21083. width?: number;
  21084. height?: number;
  21085. depth?: number;
  21086. faceUV?: Vector4[];
  21087. faceColors?: Color4[];
  21088. sideOrientation?: number;
  21089. frontUVs?: Vector4;
  21090. backUVs?: Vector4;
  21091. }): VertexData;
  21092. /**
  21093. * Creates the VertexData for a tiled box
  21094. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21095. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21096. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21097. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21099. * @returns the VertexData of the box
  21100. */
  21101. static CreateTiledBox(options: {
  21102. pattern?: number;
  21103. width?: number;
  21104. height?: number;
  21105. depth?: number;
  21106. tileSize?: number;
  21107. tileWidth?: number;
  21108. tileHeight?: number;
  21109. alignHorizontal?: number;
  21110. alignVertical?: number;
  21111. faceUV?: Vector4[];
  21112. faceColors?: Color4[];
  21113. sideOrientation?: number;
  21114. }): VertexData;
  21115. /**
  21116. * Creates the VertexData for a tiled plane
  21117. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21118. * * pattern a limited pattern arrangement depending on the number
  21119. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21120. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21121. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21123. * * 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)
  21124. * * 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)
  21125. * @returns the VertexData of the tiled plane
  21126. */
  21127. static CreateTiledPlane(options: {
  21128. pattern?: number;
  21129. tileSize?: number;
  21130. tileWidth?: number;
  21131. tileHeight?: number;
  21132. size?: number;
  21133. width?: number;
  21134. height?: number;
  21135. alignHorizontal?: number;
  21136. alignVertical?: number;
  21137. sideOrientation?: number;
  21138. frontUVs?: Vector4;
  21139. backUVs?: Vector4;
  21140. }): VertexData;
  21141. /**
  21142. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21143. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21144. * * segments sets the number of horizontal strips optional, default 32
  21145. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21146. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21147. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21148. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21149. * * 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
  21150. * * 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
  21151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21152. * * 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)
  21153. * * 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)
  21154. * @returns the VertexData of the ellipsoid
  21155. */
  21156. static CreateSphere(options: {
  21157. segments?: number;
  21158. diameter?: number;
  21159. diameterX?: number;
  21160. diameterY?: number;
  21161. diameterZ?: number;
  21162. arc?: number;
  21163. slice?: number;
  21164. sideOrientation?: number;
  21165. frontUVs?: Vector4;
  21166. backUVs?: Vector4;
  21167. }): VertexData;
  21168. /**
  21169. * Creates the VertexData for a cylinder, cone or prism
  21170. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21171. * * height sets the height (y direction) of the cylinder, optional, default 2
  21172. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21173. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21174. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21175. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21176. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21177. * * 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
  21178. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21179. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21180. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21181. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21183. * * 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)
  21184. * * 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)
  21185. * @returns the VertexData of the cylinder, cone or prism
  21186. */
  21187. static CreateCylinder(options: {
  21188. height?: number;
  21189. diameterTop?: number;
  21190. diameterBottom?: number;
  21191. diameter?: number;
  21192. tessellation?: number;
  21193. subdivisions?: number;
  21194. arc?: number;
  21195. faceColors?: Color4[];
  21196. faceUV?: Vector4[];
  21197. hasRings?: boolean;
  21198. enclose?: boolean;
  21199. sideOrientation?: number;
  21200. frontUVs?: Vector4;
  21201. backUVs?: Vector4;
  21202. }): VertexData;
  21203. /**
  21204. * Creates the VertexData for a torus
  21205. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21206. * * diameter the diameter of the torus, optional default 1
  21207. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21208. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21210. * * 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)
  21211. * * 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)
  21212. * @returns the VertexData of the torus
  21213. */
  21214. static CreateTorus(options: {
  21215. diameter?: number;
  21216. thickness?: number;
  21217. tessellation?: number;
  21218. sideOrientation?: number;
  21219. frontUVs?: Vector4;
  21220. backUVs?: Vector4;
  21221. }): VertexData;
  21222. /**
  21223. * Creates the VertexData of the LineSystem
  21224. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21225. * - lines an array of lines, each line being an array of successive Vector3
  21226. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21227. * @returns the VertexData of the LineSystem
  21228. */
  21229. static CreateLineSystem(options: {
  21230. lines: Vector3[][];
  21231. colors?: Nullable<Color4[][]>;
  21232. }): VertexData;
  21233. /**
  21234. * Create the VertexData for a DashedLines
  21235. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21236. * - points an array successive Vector3
  21237. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21238. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21239. * - dashNb the intended total number of dashes, optional, default 200
  21240. * @returns the VertexData for the DashedLines
  21241. */
  21242. static CreateDashedLines(options: {
  21243. points: Vector3[];
  21244. dashSize?: number;
  21245. gapSize?: number;
  21246. dashNb?: number;
  21247. }): VertexData;
  21248. /**
  21249. * Creates the VertexData for a Ground
  21250. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21251. * - width the width (x direction) of the ground, optional, default 1
  21252. * - height the height (z direction) of the ground, optional, default 1
  21253. * - subdivisions the number of subdivisions per side, optional, default 1
  21254. * @returns the VertexData of the Ground
  21255. */
  21256. static CreateGround(options: {
  21257. width?: number;
  21258. height?: number;
  21259. subdivisions?: number;
  21260. subdivisionsX?: number;
  21261. subdivisionsY?: number;
  21262. }): VertexData;
  21263. /**
  21264. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21265. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21266. * * xmin the ground minimum X coordinate, optional, default -1
  21267. * * zmin the ground minimum Z coordinate, optional, default -1
  21268. * * xmax the ground maximum X coordinate, optional, default 1
  21269. * * zmax the ground maximum Z coordinate, optional, default 1
  21270. * * 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}
  21271. * * 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}
  21272. * @returns the VertexData of the TiledGround
  21273. */
  21274. static CreateTiledGround(options: {
  21275. xmin: number;
  21276. zmin: number;
  21277. xmax: number;
  21278. zmax: number;
  21279. subdivisions?: {
  21280. w: number;
  21281. h: number;
  21282. };
  21283. precision?: {
  21284. w: number;
  21285. h: number;
  21286. };
  21287. }): VertexData;
  21288. /**
  21289. * Creates the VertexData of the Ground designed from a heightmap
  21290. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21291. * * width the width (x direction) of the ground
  21292. * * height the height (z direction) of the ground
  21293. * * subdivisions the number of subdivisions per side
  21294. * * minHeight the minimum altitude on the ground, optional, default 0
  21295. * * maxHeight the maximum altitude on the ground, optional default 1
  21296. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21297. * * buffer the array holding the image color data
  21298. * * bufferWidth the width of image
  21299. * * bufferHeight the height of image
  21300. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21301. * @returns the VertexData of the Ground designed from a heightmap
  21302. */
  21303. static CreateGroundFromHeightMap(options: {
  21304. width: number;
  21305. height: number;
  21306. subdivisions: number;
  21307. minHeight: number;
  21308. maxHeight: number;
  21309. colorFilter: Color3;
  21310. buffer: Uint8Array;
  21311. bufferWidth: number;
  21312. bufferHeight: number;
  21313. alphaFilter: number;
  21314. }): VertexData;
  21315. /**
  21316. * Creates the VertexData for a Plane
  21317. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21318. * * size sets the width and height of the plane to the value of size, optional default 1
  21319. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21320. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21322. * * 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)
  21323. * * 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)
  21324. * @returns the VertexData of the box
  21325. */
  21326. static CreatePlane(options: {
  21327. size?: number;
  21328. width?: number;
  21329. height?: number;
  21330. sideOrientation?: number;
  21331. frontUVs?: Vector4;
  21332. backUVs?: Vector4;
  21333. }): VertexData;
  21334. /**
  21335. * Creates the VertexData of the Disc or regular Polygon
  21336. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21337. * * radius the radius of the disc, optional default 0.5
  21338. * * tessellation the number of polygon sides, optional, default 64
  21339. * * 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
  21340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21341. * * 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)
  21342. * * 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)
  21343. * @returns the VertexData of the box
  21344. */
  21345. static CreateDisc(options: {
  21346. radius?: number;
  21347. tessellation?: number;
  21348. arc?: number;
  21349. sideOrientation?: number;
  21350. frontUVs?: Vector4;
  21351. backUVs?: Vector4;
  21352. }): VertexData;
  21353. /**
  21354. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21355. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21356. * @param polygon a mesh built from polygonTriangulation.build()
  21357. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21358. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21359. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21360. * @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)
  21361. * @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)
  21362. * @returns the VertexData of the Polygon
  21363. */
  21364. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21365. /**
  21366. * Creates the VertexData of the IcoSphere
  21367. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21368. * * radius the radius of the IcoSphere, optional default 1
  21369. * * radiusX allows stretching in the x direction, optional, default radius
  21370. * * radiusY allows stretching in the y direction, optional, default radius
  21371. * * radiusZ allows stretching in the z direction, optional, default radius
  21372. * * flat when true creates a flat shaded mesh, optional, default true
  21373. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21375. * * 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)
  21376. * * 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)
  21377. * @returns the VertexData of the IcoSphere
  21378. */
  21379. static CreateIcoSphere(options: {
  21380. radius?: number;
  21381. radiusX?: number;
  21382. radiusY?: number;
  21383. radiusZ?: number;
  21384. flat?: boolean;
  21385. subdivisions?: number;
  21386. sideOrientation?: number;
  21387. frontUVs?: Vector4;
  21388. backUVs?: Vector4;
  21389. }): VertexData;
  21390. /**
  21391. * Creates the VertexData for a Polyhedron
  21392. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21393. * * type provided types are:
  21394. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21395. * * 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)
  21396. * * size the size of the IcoSphere, optional default 1
  21397. * * sizeX allows stretching in the x direction, optional, default size
  21398. * * sizeY allows stretching in the y direction, optional, default size
  21399. * * sizeZ allows stretching in the z direction, optional, default size
  21400. * * 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
  21401. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21402. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21403. * * flat when true creates a flat shaded mesh, optional, default true
  21404. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21406. * * 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)
  21407. * * 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)
  21408. * @returns the VertexData of the Polyhedron
  21409. */
  21410. static CreatePolyhedron(options: {
  21411. type?: number;
  21412. size?: number;
  21413. sizeX?: number;
  21414. sizeY?: number;
  21415. sizeZ?: number;
  21416. custom?: any;
  21417. faceUV?: Vector4[];
  21418. faceColors?: Color4[];
  21419. flat?: boolean;
  21420. sideOrientation?: number;
  21421. frontUVs?: Vector4;
  21422. backUVs?: Vector4;
  21423. }): VertexData;
  21424. /**
  21425. * Creates the VertexData for a TorusKnot
  21426. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21427. * * radius the radius of the torus knot, optional, default 2
  21428. * * tube the thickness of the tube, optional, default 0.5
  21429. * * radialSegments the number of sides on each tube segments, optional, default 32
  21430. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21431. * * p the number of windings around the z axis, optional, default 2
  21432. * * q the number of windings around the x axis, optional, default 3
  21433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21434. * * 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)
  21435. * * 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)
  21436. * @returns the VertexData of the Torus Knot
  21437. */
  21438. static CreateTorusKnot(options: {
  21439. radius?: number;
  21440. tube?: number;
  21441. radialSegments?: number;
  21442. tubularSegments?: number;
  21443. p?: number;
  21444. q?: number;
  21445. sideOrientation?: number;
  21446. frontUVs?: Vector4;
  21447. backUVs?: Vector4;
  21448. }): VertexData;
  21449. /**
  21450. * Compute normals for given positions and indices
  21451. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21452. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21453. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21454. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21455. * * facetNormals : optional array of facet normals (vector3)
  21456. * * facetPositions : optional array of facet positions (vector3)
  21457. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21458. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21459. * * bInfo : optional bounding info, required for facetPartitioning computation
  21460. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21461. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21462. * * useRightHandedSystem: optional boolean to for right handed system computation
  21463. * * depthSort : optional boolean to enable the facet depth sort computation
  21464. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21465. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21466. */
  21467. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21468. facetNormals?: any;
  21469. facetPositions?: any;
  21470. facetPartitioning?: any;
  21471. ratio?: number;
  21472. bInfo?: any;
  21473. bbSize?: Vector3;
  21474. subDiv?: any;
  21475. useRightHandedSystem?: boolean;
  21476. depthSort?: boolean;
  21477. distanceTo?: Vector3;
  21478. depthSortedFacets?: any;
  21479. }): void;
  21480. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21481. /**
  21482. * Applies VertexData created from the imported parameters to the geometry
  21483. * @param parsedVertexData the parsed data from an imported file
  21484. * @param geometry the geometry to apply the VertexData to
  21485. */
  21486. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21487. }
  21488. }
  21489. declare module BABYLON {
  21490. /**
  21491. * Defines a target to use with MorphTargetManager
  21492. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21493. */
  21494. export class MorphTarget implements IAnimatable {
  21495. /** defines the name of the target */
  21496. name: string;
  21497. /**
  21498. * Gets or sets the list of animations
  21499. */
  21500. animations: Animation[];
  21501. private _scene;
  21502. private _positions;
  21503. private _normals;
  21504. private _tangents;
  21505. private _uvs;
  21506. private _influence;
  21507. /**
  21508. * Observable raised when the influence changes
  21509. */
  21510. onInfluenceChanged: Observable<boolean>;
  21511. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21512. /**
  21513. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21514. */
  21515. influence: number;
  21516. /**
  21517. * Gets or sets the id of the morph Target
  21518. */
  21519. id: string;
  21520. private _animationPropertiesOverride;
  21521. /**
  21522. * Gets or sets the animation properties override
  21523. */
  21524. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21525. /**
  21526. * Creates a new MorphTarget
  21527. * @param name defines the name of the target
  21528. * @param influence defines the influence to use
  21529. * @param scene defines the scene the morphtarget belongs to
  21530. */
  21531. constructor(
  21532. /** defines the name of the target */
  21533. name: string, influence?: number, scene?: Nullable<Scene>);
  21534. /**
  21535. * Gets a boolean defining if the target contains position data
  21536. */
  21537. readonly hasPositions: boolean;
  21538. /**
  21539. * Gets a boolean defining if the target contains normal data
  21540. */
  21541. readonly hasNormals: boolean;
  21542. /**
  21543. * Gets a boolean defining if the target contains tangent data
  21544. */
  21545. readonly hasTangents: boolean;
  21546. /**
  21547. * Gets a boolean defining if the target contains texture coordinates data
  21548. */
  21549. readonly hasUVs: boolean;
  21550. /**
  21551. * Affects position data to this target
  21552. * @param data defines the position data to use
  21553. */
  21554. setPositions(data: Nullable<FloatArray>): void;
  21555. /**
  21556. * Gets the position data stored in this target
  21557. * @returns a FloatArray containing the position data (or null if not present)
  21558. */
  21559. getPositions(): Nullable<FloatArray>;
  21560. /**
  21561. * Affects normal data to this target
  21562. * @param data defines the normal data to use
  21563. */
  21564. setNormals(data: Nullable<FloatArray>): void;
  21565. /**
  21566. * Gets the normal data stored in this target
  21567. * @returns a FloatArray containing the normal data (or null if not present)
  21568. */
  21569. getNormals(): Nullable<FloatArray>;
  21570. /**
  21571. * Affects tangent data to this target
  21572. * @param data defines the tangent data to use
  21573. */
  21574. setTangents(data: Nullable<FloatArray>): void;
  21575. /**
  21576. * Gets the tangent data stored in this target
  21577. * @returns a FloatArray containing the tangent data (or null if not present)
  21578. */
  21579. getTangents(): Nullable<FloatArray>;
  21580. /**
  21581. * Affects texture coordinates data to this target
  21582. * @param data defines the texture coordinates data to use
  21583. */
  21584. setUVs(data: Nullable<FloatArray>): void;
  21585. /**
  21586. * Gets the texture coordinates data stored in this target
  21587. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21588. */
  21589. getUVs(): Nullable<FloatArray>;
  21590. /**
  21591. * Serializes the current target into a Serialization object
  21592. * @returns the serialized object
  21593. */
  21594. serialize(): any;
  21595. /**
  21596. * Returns the string "MorphTarget"
  21597. * @returns "MorphTarget"
  21598. */
  21599. getClassName(): string;
  21600. /**
  21601. * Creates a new target from serialized data
  21602. * @param serializationObject defines the serialized data to use
  21603. * @returns a new MorphTarget
  21604. */
  21605. static Parse(serializationObject: any): MorphTarget;
  21606. /**
  21607. * Creates a MorphTarget from mesh data
  21608. * @param mesh defines the source mesh
  21609. * @param name defines the name to use for the new target
  21610. * @param influence defines the influence to attach to the target
  21611. * @returns a new MorphTarget
  21612. */
  21613. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21614. }
  21615. }
  21616. declare module BABYLON {
  21617. /**
  21618. * This class is used to deform meshes using morphing between different targets
  21619. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21620. */
  21621. export class MorphTargetManager {
  21622. private _targets;
  21623. private _targetInfluenceChangedObservers;
  21624. private _targetDataLayoutChangedObservers;
  21625. private _activeTargets;
  21626. private _scene;
  21627. private _influences;
  21628. private _supportsNormals;
  21629. private _supportsTangents;
  21630. private _supportsUVs;
  21631. private _vertexCount;
  21632. private _uniqueId;
  21633. private _tempInfluences;
  21634. /**
  21635. * Gets or sets a boolean indicating if normals must be morphed
  21636. */
  21637. enableNormalMorphing: boolean;
  21638. /**
  21639. * Gets or sets a boolean indicating if tangents must be morphed
  21640. */
  21641. enableTangentMorphing: boolean;
  21642. /**
  21643. * Gets or sets a boolean indicating if UV must be morphed
  21644. */
  21645. enableUVMorphing: boolean;
  21646. /**
  21647. * Creates a new MorphTargetManager
  21648. * @param scene defines the current scene
  21649. */
  21650. constructor(scene?: Nullable<Scene>);
  21651. /**
  21652. * Gets the unique ID of this manager
  21653. */
  21654. readonly uniqueId: number;
  21655. /**
  21656. * Gets the number of vertices handled by this manager
  21657. */
  21658. readonly vertexCount: number;
  21659. /**
  21660. * Gets a boolean indicating if this manager supports morphing of normals
  21661. */
  21662. readonly supportsNormals: boolean;
  21663. /**
  21664. * Gets a boolean indicating if this manager supports morphing of tangents
  21665. */
  21666. readonly supportsTangents: boolean;
  21667. /**
  21668. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21669. */
  21670. readonly supportsUVs: boolean;
  21671. /**
  21672. * Gets the number of targets stored in this manager
  21673. */
  21674. readonly numTargets: number;
  21675. /**
  21676. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21677. */
  21678. readonly numInfluencers: number;
  21679. /**
  21680. * Gets the list of influences (one per target)
  21681. */
  21682. readonly influences: Float32Array;
  21683. /**
  21684. * Gets the active target at specified index. An active target is a target with an influence > 0
  21685. * @param index defines the index to check
  21686. * @returns the requested target
  21687. */
  21688. getActiveTarget(index: number): MorphTarget;
  21689. /**
  21690. * Gets the target at specified index
  21691. * @param index defines the index to check
  21692. * @returns the requested target
  21693. */
  21694. getTarget(index: number): MorphTarget;
  21695. /**
  21696. * Add a new target to this manager
  21697. * @param target defines the target to add
  21698. */
  21699. addTarget(target: MorphTarget): void;
  21700. /**
  21701. * Removes a target from the manager
  21702. * @param target defines the target to remove
  21703. */
  21704. removeTarget(target: MorphTarget): void;
  21705. /**
  21706. * Serializes the current manager into a Serialization object
  21707. * @returns the serialized object
  21708. */
  21709. serialize(): any;
  21710. private _syncActiveTargets;
  21711. /**
  21712. * Syncrhonize the targets with all the meshes using this morph target manager
  21713. */
  21714. synchronize(): void;
  21715. /**
  21716. * Creates a new MorphTargetManager from serialized data
  21717. * @param serializationObject defines the serialized data
  21718. * @param scene defines the hosting scene
  21719. * @returns the new MorphTargetManager
  21720. */
  21721. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21722. }
  21723. }
  21724. declare module BABYLON {
  21725. /**
  21726. * Class used to represent a specific level of detail of a mesh
  21727. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21728. */
  21729. export class MeshLODLevel {
  21730. /** Defines the distance where this level should star being displayed */
  21731. distance: number;
  21732. /** Defines the mesh to use to render this level */
  21733. mesh: Nullable<Mesh>;
  21734. /**
  21735. * Creates a new LOD level
  21736. * @param distance defines the distance where this level should star being displayed
  21737. * @param mesh defines the mesh to use to render this level
  21738. */
  21739. constructor(
  21740. /** Defines the distance where this level should star being displayed */
  21741. distance: number,
  21742. /** Defines the mesh to use to render this level */
  21743. mesh: Nullable<Mesh>);
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * Mesh representing the gorund
  21749. */
  21750. export class GroundMesh extends Mesh {
  21751. /** If octree should be generated */
  21752. generateOctree: boolean;
  21753. private _heightQuads;
  21754. /** @hidden */ private _subdivisionsX: number;
  21755. /** @hidden */ private _subdivisionsY: number;
  21756. /** @hidden */ private _width: number;
  21757. /** @hidden */ private _height: number;
  21758. /** @hidden */ private _minX: number;
  21759. /** @hidden */ private _maxX: number;
  21760. /** @hidden */ private _minZ: number;
  21761. /** @hidden */ private _maxZ: number;
  21762. constructor(name: string, scene: Scene);
  21763. /**
  21764. * "GroundMesh"
  21765. * @returns "GroundMesh"
  21766. */
  21767. getClassName(): string;
  21768. /**
  21769. * The minimum of x and y subdivisions
  21770. */
  21771. readonly subdivisions: number;
  21772. /**
  21773. * X subdivisions
  21774. */
  21775. readonly subdivisionsX: number;
  21776. /**
  21777. * Y subdivisions
  21778. */
  21779. readonly subdivisionsY: number;
  21780. /**
  21781. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21782. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21783. * @param chunksCount the number of subdivisions for x and y
  21784. * @param octreeBlocksSize (Default: 32)
  21785. */
  21786. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21787. /**
  21788. * Returns a height (y) value in the Worl system :
  21789. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21790. * @param x x coordinate
  21791. * @param z z coordinate
  21792. * @returns the ground y position if (x, z) are outside the ground surface.
  21793. */
  21794. getHeightAtCoordinates(x: number, z: number): number;
  21795. /**
  21796. * Returns a normalized vector (Vector3) orthogonal to the ground
  21797. * at the ground coordinates (x, z) expressed in the World system.
  21798. * @param x x coordinate
  21799. * @param z z coordinate
  21800. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21801. */
  21802. getNormalAtCoordinates(x: number, z: number): Vector3;
  21803. /**
  21804. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21805. * at the ground coordinates (x, z) expressed in the World system.
  21806. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21807. * @param x x coordinate
  21808. * @param z z coordinate
  21809. * @param ref vector to store the result
  21810. * @returns the GroundMesh.
  21811. */
  21812. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21813. /**
  21814. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21815. * if the ground has been updated.
  21816. * This can be used in the render loop.
  21817. * @returns the GroundMesh.
  21818. */
  21819. updateCoordinateHeights(): GroundMesh;
  21820. private _getFacetAt;
  21821. private _initHeightQuads;
  21822. private _computeHeightQuads;
  21823. /**
  21824. * Serializes this ground mesh
  21825. * @param serializationObject object to write serialization to
  21826. */
  21827. serialize(serializationObject: any): void;
  21828. /**
  21829. * Parses a serialized ground mesh
  21830. * @param parsedMesh the serialized mesh
  21831. * @param scene the scene to create the ground mesh in
  21832. * @returns the created ground mesh
  21833. */
  21834. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21835. }
  21836. }
  21837. declare module BABYLON {
  21838. /**
  21839. * Interface for Physics-Joint data
  21840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21841. */
  21842. export interface PhysicsJointData {
  21843. /**
  21844. * The main pivot of the joint
  21845. */
  21846. mainPivot?: Vector3;
  21847. /**
  21848. * The connected pivot of the joint
  21849. */
  21850. connectedPivot?: Vector3;
  21851. /**
  21852. * The main axis of the joint
  21853. */
  21854. mainAxis?: Vector3;
  21855. /**
  21856. * The connected axis of the joint
  21857. */
  21858. connectedAxis?: Vector3;
  21859. /**
  21860. * The collision of the joint
  21861. */
  21862. collision?: boolean;
  21863. /**
  21864. * Native Oimo/Cannon/Energy data
  21865. */
  21866. nativeParams?: any;
  21867. }
  21868. /**
  21869. * This is a holder class for the physics joint created by the physics plugin
  21870. * It holds a set of functions to control the underlying joint
  21871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21872. */
  21873. export class PhysicsJoint {
  21874. /**
  21875. * The type of the physics joint
  21876. */
  21877. type: number;
  21878. /**
  21879. * The data for the physics joint
  21880. */
  21881. jointData: PhysicsJointData;
  21882. private _physicsJoint;
  21883. protected _physicsPlugin: IPhysicsEnginePlugin;
  21884. /**
  21885. * Initializes the physics joint
  21886. * @param type The type of the physics joint
  21887. * @param jointData The data for the physics joint
  21888. */
  21889. constructor(
  21890. /**
  21891. * The type of the physics joint
  21892. */
  21893. type: number,
  21894. /**
  21895. * The data for the physics joint
  21896. */
  21897. jointData: PhysicsJointData);
  21898. /**
  21899. * Gets the physics joint
  21900. */
  21901. /**
  21902. * Sets the physics joint
  21903. */
  21904. physicsJoint: any;
  21905. /**
  21906. * Sets the physics plugin
  21907. */
  21908. physicsPlugin: IPhysicsEnginePlugin;
  21909. /**
  21910. * Execute a function that is physics-plugin specific.
  21911. * @param {Function} func the function that will be executed.
  21912. * It accepts two parameters: the physics world and the physics joint
  21913. */
  21914. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  21915. /**
  21916. * Distance-Joint type
  21917. */
  21918. static DistanceJoint: number;
  21919. /**
  21920. * Hinge-Joint type
  21921. */
  21922. static HingeJoint: number;
  21923. /**
  21924. * Ball-and-Socket joint type
  21925. */
  21926. static BallAndSocketJoint: number;
  21927. /**
  21928. * Wheel-Joint type
  21929. */
  21930. static WheelJoint: number;
  21931. /**
  21932. * Slider-Joint type
  21933. */
  21934. static SliderJoint: number;
  21935. /**
  21936. * Prismatic-Joint type
  21937. */
  21938. static PrismaticJoint: number;
  21939. /**
  21940. * Universal-Joint type
  21941. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  21942. */
  21943. static UniversalJoint: number;
  21944. /**
  21945. * Hinge-Joint 2 type
  21946. */
  21947. static Hinge2Joint: number;
  21948. /**
  21949. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  21950. */
  21951. static PointToPointJoint: number;
  21952. /**
  21953. * Spring-Joint type
  21954. */
  21955. static SpringJoint: number;
  21956. /**
  21957. * Lock-Joint type
  21958. */
  21959. static LockJoint: number;
  21960. }
  21961. /**
  21962. * A class representing a physics distance joint
  21963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21964. */
  21965. export class DistanceJoint extends PhysicsJoint {
  21966. /**
  21967. *
  21968. * @param jointData The data for the Distance-Joint
  21969. */
  21970. constructor(jointData: DistanceJointData);
  21971. /**
  21972. * Update the predefined distance.
  21973. * @param maxDistance The maximum preferred distance
  21974. * @param minDistance The minimum preferred distance
  21975. */
  21976. updateDistance(maxDistance: number, minDistance?: number): void;
  21977. }
  21978. /**
  21979. * Represents a Motor-Enabled Joint
  21980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21981. */
  21982. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  21983. /**
  21984. * Initializes the Motor-Enabled Joint
  21985. * @param type The type of the joint
  21986. * @param jointData The physica joint data for the joint
  21987. */
  21988. constructor(type: number, jointData: PhysicsJointData);
  21989. /**
  21990. * Set the motor values.
  21991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21992. * @param force the force to apply
  21993. * @param maxForce max force for this motor.
  21994. */
  21995. setMotor(force?: number, maxForce?: number): void;
  21996. /**
  21997. * Set the motor's limits.
  21998. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21999. * @param upperLimit The upper limit of the motor
  22000. * @param lowerLimit The lower limit of the motor
  22001. */
  22002. setLimit(upperLimit: number, lowerLimit?: number): void;
  22003. }
  22004. /**
  22005. * This class represents a single physics Hinge-Joint
  22006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22007. */
  22008. export class HingeJoint extends MotorEnabledJoint {
  22009. /**
  22010. * Initializes the Hinge-Joint
  22011. * @param jointData The joint data for the Hinge-Joint
  22012. */
  22013. constructor(jointData: PhysicsJointData);
  22014. /**
  22015. * Set the motor values.
  22016. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22017. * @param {number} force the force to apply
  22018. * @param {number} maxForce max force for this motor.
  22019. */
  22020. setMotor(force?: number, maxForce?: number): void;
  22021. /**
  22022. * Set the motor's limits.
  22023. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22024. * @param upperLimit The upper limit of the motor
  22025. * @param lowerLimit The lower limit of the motor
  22026. */
  22027. setLimit(upperLimit: number, lowerLimit?: number): void;
  22028. }
  22029. /**
  22030. * This class represents a dual hinge physics joint (same as wheel joint)
  22031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22032. */
  22033. export class Hinge2Joint extends MotorEnabledJoint {
  22034. /**
  22035. * Initializes the Hinge2-Joint
  22036. * @param jointData The joint data for the Hinge2-Joint
  22037. */
  22038. constructor(jointData: PhysicsJointData);
  22039. /**
  22040. * Set the motor values.
  22041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22042. * @param {number} targetSpeed the speed the motor is to reach
  22043. * @param {number} maxForce max force for this motor.
  22044. * @param {motorIndex} the motor's index, 0 or 1.
  22045. */
  22046. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22047. /**
  22048. * Set the motor limits.
  22049. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22050. * @param {number} upperLimit the upper limit
  22051. * @param {number} lowerLimit lower limit
  22052. * @param {motorIndex} the motor's index, 0 or 1.
  22053. */
  22054. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22055. }
  22056. /**
  22057. * Interface for a motor enabled joint
  22058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22059. */
  22060. export interface IMotorEnabledJoint {
  22061. /**
  22062. * Physics joint
  22063. */
  22064. physicsJoint: any;
  22065. /**
  22066. * Sets the motor of the motor-enabled joint
  22067. * @param force The force of the motor
  22068. * @param maxForce The maximum force of the motor
  22069. * @param motorIndex The index of the motor
  22070. */
  22071. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22072. /**
  22073. * Sets the limit of the motor
  22074. * @param upperLimit The upper limit of the motor
  22075. * @param lowerLimit The lower limit of the motor
  22076. * @param motorIndex The index of the motor
  22077. */
  22078. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22079. }
  22080. /**
  22081. * Joint data for a Distance-Joint
  22082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22083. */
  22084. export interface DistanceJointData extends PhysicsJointData {
  22085. /**
  22086. * Max distance the 2 joint objects can be apart
  22087. */
  22088. maxDistance: number;
  22089. }
  22090. /**
  22091. * Joint data from a spring joint
  22092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22093. */
  22094. export interface SpringJointData extends PhysicsJointData {
  22095. /**
  22096. * Length of the spring
  22097. */
  22098. length: number;
  22099. /**
  22100. * Stiffness of the spring
  22101. */
  22102. stiffness: number;
  22103. /**
  22104. * Damping of the spring
  22105. */
  22106. damping: number;
  22107. /** this callback will be called when applying the force to the impostors. */
  22108. forceApplicationCallback: () => void;
  22109. }
  22110. }
  22111. declare module BABYLON {
  22112. /**
  22113. * Holds the data for the raycast result
  22114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22115. */
  22116. export class PhysicsRaycastResult {
  22117. private _hasHit;
  22118. private _hitDistance;
  22119. private _hitNormalWorld;
  22120. private _hitPointWorld;
  22121. private _rayFromWorld;
  22122. private _rayToWorld;
  22123. /**
  22124. * Gets if there was a hit
  22125. */
  22126. readonly hasHit: boolean;
  22127. /**
  22128. * Gets the distance from the hit
  22129. */
  22130. readonly hitDistance: number;
  22131. /**
  22132. * Gets the hit normal/direction in the world
  22133. */
  22134. readonly hitNormalWorld: Vector3;
  22135. /**
  22136. * Gets the hit point in the world
  22137. */
  22138. readonly hitPointWorld: Vector3;
  22139. /**
  22140. * Gets the ray "start point" of the ray in the world
  22141. */
  22142. readonly rayFromWorld: Vector3;
  22143. /**
  22144. * Gets the ray "end point" of the ray in the world
  22145. */
  22146. readonly rayToWorld: Vector3;
  22147. /**
  22148. * Sets the hit data (normal & point in world space)
  22149. * @param hitNormalWorld defines the normal in world space
  22150. * @param hitPointWorld defines the point in world space
  22151. */
  22152. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22153. /**
  22154. * Sets the distance from the start point to the hit point
  22155. * @param distance
  22156. */
  22157. setHitDistance(distance: number): void;
  22158. /**
  22159. * Calculates the distance manually
  22160. */
  22161. calculateHitDistance(): void;
  22162. /**
  22163. * Resets all the values to default
  22164. * @param from The from point on world space
  22165. * @param to The to point on world space
  22166. */
  22167. reset(from?: Vector3, to?: Vector3): void;
  22168. }
  22169. /**
  22170. * Interface for the size containing width and height
  22171. */
  22172. interface IXYZ {
  22173. /**
  22174. * X
  22175. */
  22176. x: number;
  22177. /**
  22178. * Y
  22179. */
  22180. y: number;
  22181. /**
  22182. * Z
  22183. */
  22184. z: number;
  22185. }
  22186. }
  22187. declare module BABYLON {
  22188. /**
  22189. * Interface used to describe a physics joint
  22190. */
  22191. export interface PhysicsImpostorJoint {
  22192. /** Defines the main impostor to which the joint is linked */
  22193. mainImpostor: PhysicsImpostor;
  22194. /** Defines the impostor that is connected to the main impostor using this joint */
  22195. connectedImpostor: PhysicsImpostor;
  22196. /** Defines the joint itself */
  22197. joint: PhysicsJoint;
  22198. }
  22199. /** @hidden */
  22200. export interface IPhysicsEnginePlugin {
  22201. world: any;
  22202. name: string;
  22203. setGravity(gravity: Vector3): void;
  22204. setTimeStep(timeStep: number): void;
  22205. getTimeStep(): number;
  22206. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22207. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22208. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22209. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22210. removePhysicsBody(impostor: PhysicsImpostor): void;
  22211. generateJoint(joint: PhysicsImpostorJoint): void;
  22212. removeJoint(joint: PhysicsImpostorJoint): void;
  22213. isSupported(): boolean;
  22214. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22215. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22216. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22217. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22218. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22219. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22220. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22221. getBodyMass(impostor: PhysicsImpostor): number;
  22222. getBodyFriction(impostor: PhysicsImpostor): number;
  22223. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22224. getBodyRestitution(impostor: PhysicsImpostor): number;
  22225. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22226. getBodyPressure?(impostor: PhysicsImpostor): number;
  22227. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22228. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22229. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22230. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22231. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22232. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22233. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22234. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22235. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22236. sleepBody(impostor: PhysicsImpostor): void;
  22237. wakeUpBody(impostor: PhysicsImpostor): void;
  22238. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22239. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22240. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22241. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22242. getRadius(impostor: PhysicsImpostor): number;
  22243. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22244. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22245. dispose(): void;
  22246. }
  22247. /**
  22248. * Interface used to define a physics engine
  22249. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22250. */
  22251. export interface IPhysicsEngine {
  22252. /**
  22253. * Gets the gravity vector used by the simulation
  22254. */
  22255. gravity: Vector3;
  22256. /**
  22257. * Sets the gravity vector used by the simulation
  22258. * @param gravity defines the gravity vector to use
  22259. */
  22260. setGravity(gravity: Vector3): void;
  22261. /**
  22262. * Set the time step of the physics engine.
  22263. * Default is 1/60.
  22264. * To slow it down, enter 1/600 for example.
  22265. * To speed it up, 1/30
  22266. * @param newTimeStep the new timestep to apply to this world.
  22267. */
  22268. setTimeStep(newTimeStep: number): void;
  22269. /**
  22270. * Get the time step of the physics engine.
  22271. * @returns the current time step
  22272. */
  22273. getTimeStep(): number;
  22274. /**
  22275. * Release all resources
  22276. */
  22277. dispose(): void;
  22278. /**
  22279. * Gets the name of the current physics plugin
  22280. * @returns the name of the plugin
  22281. */
  22282. getPhysicsPluginName(): string;
  22283. /**
  22284. * Adding a new impostor for the impostor tracking.
  22285. * This will be done by the impostor itself.
  22286. * @param impostor the impostor to add
  22287. */
  22288. addImpostor(impostor: PhysicsImpostor): void;
  22289. /**
  22290. * Remove an impostor from the engine.
  22291. * This impostor and its mesh will not longer be updated by the physics engine.
  22292. * @param impostor the impostor to remove
  22293. */
  22294. removeImpostor(impostor: PhysicsImpostor): void;
  22295. /**
  22296. * Add a joint to the physics engine
  22297. * @param mainImpostor defines the main impostor to which the joint is added.
  22298. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22299. * @param joint defines the joint that will connect both impostors.
  22300. */
  22301. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22302. /**
  22303. * Removes a joint from the simulation
  22304. * @param mainImpostor defines the impostor used with the joint
  22305. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22306. * @param joint defines the joint to remove
  22307. */
  22308. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22309. /**
  22310. * Gets the current plugin used to run the simulation
  22311. * @returns current plugin
  22312. */
  22313. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22314. /**
  22315. * Gets the list of physic impostors
  22316. * @returns an array of PhysicsImpostor
  22317. */
  22318. getImpostors(): Array<PhysicsImpostor>;
  22319. /**
  22320. * Gets the impostor for a physics enabled object
  22321. * @param object defines the object impersonated by the impostor
  22322. * @returns the PhysicsImpostor or null if not found
  22323. */
  22324. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22325. /**
  22326. * Gets the impostor for a physics body object
  22327. * @param body defines physics body used by the impostor
  22328. * @returns the PhysicsImpostor or null if not found
  22329. */
  22330. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22331. /**
  22332. * Does a raycast in the physics world
  22333. * @param from when should the ray start?
  22334. * @param to when should the ray end?
  22335. * @returns PhysicsRaycastResult
  22336. */
  22337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22338. /**
  22339. * Called by the scene. No need to call it.
  22340. * @param delta defines the timespam between frames
  22341. */ private _step(delta: number): void;
  22342. }
  22343. }
  22344. declare module BABYLON {
  22345. /**
  22346. * The interface for the physics imposter parameters
  22347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22348. */
  22349. export interface PhysicsImpostorParameters {
  22350. /**
  22351. * The mass of the physics imposter
  22352. */
  22353. mass: number;
  22354. /**
  22355. * The friction of the physics imposter
  22356. */
  22357. friction?: number;
  22358. /**
  22359. * The coefficient of restitution of the physics imposter
  22360. */
  22361. restitution?: number;
  22362. /**
  22363. * The native options of the physics imposter
  22364. */
  22365. nativeOptions?: any;
  22366. /**
  22367. * Specifies if the parent should be ignored
  22368. */
  22369. ignoreParent?: boolean;
  22370. /**
  22371. * Specifies if bi-directional transformations should be disabled
  22372. */
  22373. disableBidirectionalTransformation?: boolean;
  22374. /**
  22375. * The pressure inside the physics imposter, soft object only
  22376. */
  22377. pressure?: number;
  22378. /**
  22379. * The stiffness the physics imposter, soft object only
  22380. */
  22381. stiffness?: number;
  22382. /**
  22383. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22384. */
  22385. velocityIterations?: number;
  22386. /**
  22387. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22388. */
  22389. positionIterations?: number;
  22390. /**
  22391. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22392. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22393. * Add to fix multiple points
  22394. */
  22395. fixedPoints?: number;
  22396. /**
  22397. * The collision margin around a soft object
  22398. */
  22399. margin?: number;
  22400. /**
  22401. * The collision margin around a soft object
  22402. */
  22403. damping?: number;
  22404. /**
  22405. * The path for a rope based on an extrusion
  22406. */
  22407. path?: any;
  22408. /**
  22409. * The shape of an extrusion used for a rope based on an extrusion
  22410. */
  22411. shape?: any;
  22412. }
  22413. /**
  22414. * Interface for a physics-enabled object
  22415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22416. */
  22417. export interface IPhysicsEnabledObject {
  22418. /**
  22419. * The position of the physics-enabled object
  22420. */
  22421. position: Vector3;
  22422. /**
  22423. * The rotation of the physics-enabled object
  22424. */
  22425. rotationQuaternion: Nullable<Quaternion>;
  22426. /**
  22427. * The scale of the physics-enabled object
  22428. */
  22429. scaling: Vector3;
  22430. /**
  22431. * The rotation of the physics-enabled object
  22432. */
  22433. rotation?: Vector3;
  22434. /**
  22435. * The parent of the physics-enabled object
  22436. */
  22437. parent?: any;
  22438. /**
  22439. * The bounding info of the physics-enabled object
  22440. * @returns The bounding info of the physics-enabled object
  22441. */
  22442. getBoundingInfo(): BoundingInfo;
  22443. /**
  22444. * Computes the world matrix
  22445. * @param force Specifies if the world matrix should be computed by force
  22446. * @returns A world matrix
  22447. */
  22448. computeWorldMatrix(force: boolean): Matrix;
  22449. /**
  22450. * Gets the world matrix
  22451. * @returns A world matrix
  22452. */
  22453. getWorldMatrix?(): Matrix;
  22454. /**
  22455. * Gets the child meshes
  22456. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22457. * @returns An array of abstract meshes
  22458. */
  22459. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22460. /**
  22461. * Gets the vertex data
  22462. * @param kind The type of vertex data
  22463. * @returns A nullable array of numbers, or a float32 array
  22464. */
  22465. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22466. /**
  22467. * Gets the indices from the mesh
  22468. * @returns A nullable array of index arrays
  22469. */
  22470. getIndices?(): Nullable<IndicesArray>;
  22471. /**
  22472. * Gets the scene from the mesh
  22473. * @returns the indices array or null
  22474. */
  22475. getScene?(): Scene;
  22476. /**
  22477. * Gets the absolute position from the mesh
  22478. * @returns the absolute position
  22479. */
  22480. getAbsolutePosition(): Vector3;
  22481. /**
  22482. * Gets the absolute pivot point from the mesh
  22483. * @returns the absolute pivot point
  22484. */
  22485. getAbsolutePivotPoint(): Vector3;
  22486. /**
  22487. * Rotates the mesh
  22488. * @param axis The axis of rotation
  22489. * @param amount The amount of rotation
  22490. * @param space The space of the rotation
  22491. * @returns The rotation transform node
  22492. */
  22493. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22494. /**
  22495. * Translates the mesh
  22496. * @param axis The axis of translation
  22497. * @param distance The distance of translation
  22498. * @param space The space of the translation
  22499. * @returns The transform node
  22500. */
  22501. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22502. /**
  22503. * Sets the absolute position of the mesh
  22504. * @param absolutePosition The absolute position of the mesh
  22505. * @returns The transform node
  22506. */
  22507. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22508. /**
  22509. * Gets the class name of the mesh
  22510. * @returns The class name
  22511. */
  22512. getClassName(): string;
  22513. }
  22514. /**
  22515. * Represents a physics imposter
  22516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22517. */
  22518. export class PhysicsImpostor {
  22519. /**
  22520. * The physics-enabled object used as the physics imposter
  22521. */
  22522. object: IPhysicsEnabledObject;
  22523. /**
  22524. * The type of the physics imposter
  22525. */
  22526. type: number;
  22527. private _options;
  22528. private _scene?;
  22529. /**
  22530. * The default object size of the imposter
  22531. */
  22532. static DEFAULT_OBJECT_SIZE: Vector3;
  22533. /**
  22534. * The identity quaternion of the imposter
  22535. */
  22536. static IDENTITY_QUATERNION: Quaternion;
  22537. /** @hidden */ private _pluginData: any;
  22538. private _physicsEngine;
  22539. private _physicsBody;
  22540. private _bodyUpdateRequired;
  22541. private _onBeforePhysicsStepCallbacks;
  22542. private _onAfterPhysicsStepCallbacks;
  22543. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22544. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22545. otherImpostors: Array<PhysicsImpostor>;
  22546. }>;
  22547. private _deltaPosition;
  22548. private _deltaRotation;
  22549. private _deltaRotationConjugated;
  22550. /** @hidden */ private _isFromLine: boolean;
  22551. private _parent;
  22552. private _isDisposed;
  22553. private static _tmpVecs;
  22554. private static _tmpQuat;
  22555. /**
  22556. * Specifies if the physics imposter is disposed
  22557. */
  22558. readonly isDisposed: boolean;
  22559. /**
  22560. * Gets the mass of the physics imposter
  22561. */
  22562. mass: number;
  22563. /**
  22564. * Gets the coefficient of friction
  22565. */
  22566. /**
  22567. * Sets the coefficient of friction
  22568. */
  22569. friction: number;
  22570. /**
  22571. * Gets the coefficient of restitution
  22572. */
  22573. /**
  22574. * Sets the coefficient of restitution
  22575. */
  22576. restitution: number;
  22577. /**
  22578. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22579. */
  22580. /**
  22581. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22582. */
  22583. pressure: number;
  22584. /**
  22585. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22586. */
  22587. /**
  22588. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22589. */
  22590. stiffness: number;
  22591. /**
  22592. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22593. */
  22594. /**
  22595. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22596. */
  22597. velocityIterations: number;
  22598. /**
  22599. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22600. */
  22601. /**
  22602. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22603. */
  22604. positionIterations: number;
  22605. /**
  22606. * The unique id of the physics imposter
  22607. * set by the physics engine when adding this impostor to the array
  22608. */
  22609. uniqueId: number;
  22610. /**
  22611. * @hidden
  22612. */
  22613. soft: boolean;
  22614. /**
  22615. * @hidden
  22616. */
  22617. segments: number;
  22618. private _joints;
  22619. /**
  22620. * Initializes the physics imposter
  22621. * @param object The physics-enabled object used as the physics imposter
  22622. * @param type The type of the physics imposter
  22623. * @param _options The options for the physics imposter
  22624. * @param _scene The Babylon scene
  22625. */
  22626. constructor(
  22627. /**
  22628. * The physics-enabled object used as the physics imposter
  22629. */
  22630. object: IPhysicsEnabledObject,
  22631. /**
  22632. * The type of the physics imposter
  22633. */
  22634. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22635. /**
  22636. * This function will completly initialize this impostor.
  22637. * It will create a new body - but only if this mesh has no parent.
  22638. * If it has, this impostor will not be used other than to define the impostor
  22639. * of the child mesh.
  22640. * @hidden
  22641. */ private _init(): void;
  22642. private _getPhysicsParent;
  22643. /**
  22644. * Should a new body be generated.
  22645. * @returns boolean specifying if body initialization is required
  22646. */
  22647. isBodyInitRequired(): boolean;
  22648. /**
  22649. * Sets the updated scaling
  22650. * @param updated Specifies if the scaling is updated
  22651. */
  22652. setScalingUpdated(): void;
  22653. /**
  22654. * Force a regeneration of this or the parent's impostor's body.
  22655. * Use under cautious - This will remove all joints already implemented.
  22656. */
  22657. forceUpdate(): void;
  22658. /**
  22659. * Gets the body that holds this impostor. Either its own, or its parent.
  22660. */
  22661. /**
  22662. * Set the physics body. Used mainly by the physics engine/plugin
  22663. */
  22664. physicsBody: any;
  22665. /**
  22666. * Get the parent of the physics imposter
  22667. * @returns Physics imposter or null
  22668. */
  22669. /**
  22670. * Sets the parent of the physics imposter
  22671. */
  22672. parent: Nullable<PhysicsImpostor>;
  22673. /**
  22674. * Resets the update flags
  22675. */
  22676. resetUpdateFlags(): void;
  22677. /**
  22678. * Gets the object extend size
  22679. * @returns the object extend size
  22680. */
  22681. getObjectExtendSize(): Vector3;
  22682. /**
  22683. * Gets the object center
  22684. * @returns The object center
  22685. */
  22686. getObjectCenter(): Vector3;
  22687. /**
  22688. * Get a specific parametes from the options parameter
  22689. * @param paramName The object parameter name
  22690. * @returns The object parameter
  22691. */
  22692. getParam(paramName: string): any;
  22693. /**
  22694. * Sets a specific parameter in the options given to the physics plugin
  22695. * @param paramName The parameter name
  22696. * @param value The value of the parameter
  22697. */
  22698. setParam(paramName: string, value: number): void;
  22699. /**
  22700. * Specifically change the body's mass option. Won't recreate the physics body object
  22701. * @param mass The mass of the physics imposter
  22702. */
  22703. setMass(mass: number): void;
  22704. /**
  22705. * Gets the linear velocity
  22706. * @returns linear velocity or null
  22707. */
  22708. getLinearVelocity(): Nullable<Vector3>;
  22709. /**
  22710. * Sets the linear velocity
  22711. * @param velocity linear velocity or null
  22712. */
  22713. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22714. /**
  22715. * Gets the angular velocity
  22716. * @returns angular velocity or null
  22717. */
  22718. getAngularVelocity(): Nullable<Vector3>;
  22719. /**
  22720. * Sets the angular velocity
  22721. * @param velocity The velocity or null
  22722. */
  22723. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22724. /**
  22725. * Execute a function with the physics plugin native code
  22726. * Provide a function the will have two variables - the world object and the physics body object
  22727. * @param func The function to execute with the physics plugin native code
  22728. */
  22729. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22730. /**
  22731. * Register a function that will be executed before the physics world is stepping forward
  22732. * @param func The function to execute before the physics world is stepped forward
  22733. */
  22734. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22735. /**
  22736. * Unregister a function that will be executed before the physics world is stepping forward
  22737. * @param func The function to execute before the physics world is stepped forward
  22738. */
  22739. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22740. /**
  22741. * Register a function that will be executed after the physics step
  22742. * @param func The function to execute after physics step
  22743. */
  22744. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22745. /**
  22746. * Unregisters a function that will be executed after the physics step
  22747. * @param func The function to execute after physics step
  22748. */
  22749. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22750. /**
  22751. * register a function that will be executed when this impostor collides against a different body
  22752. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22753. * @param func Callback that is executed on collision
  22754. */
  22755. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22756. /**
  22757. * Unregisters the physics imposter on contact
  22758. * @param collideAgainst The physics object to collide against
  22759. * @param func Callback to execute on collision
  22760. */
  22761. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22762. private _tmpQuat;
  22763. private _tmpQuat2;
  22764. /**
  22765. * Get the parent rotation
  22766. * @returns The parent rotation
  22767. */
  22768. getParentsRotation(): Quaternion;
  22769. /**
  22770. * this function is executed by the physics engine.
  22771. */
  22772. beforeStep: () => void;
  22773. /**
  22774. * this function is executed by the physics engine
  22775. */
  22776. afterStep: () => void;
  22777. /**
  22778. * Legacy collision detection event support
  22779. */
  22780. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22781. /**
  22782. * event and body object due to cannon's event-based architecture.
  22783. */
  22784. onCollide: (e: {
  22785. body: any;
  22786. }) => void;
  22787. /**
  22788. * Apply a force
  22789. * @param force The force to apply
  22790. * @param contactPoint The contact point for the force
  22791. * @returns The physics imposter
  22792. */
  22793. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22794. /**
  22795. * Apply an impulse
  22796. * @param force The impulse force
  22797. * @param contactPoint The contact point for the impulse force
  22798. * @returns The physics imposter
  22799. */
  22800. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22801. /**
  22802. * A help function to create a joint
  22803. * @param otherImpostor A physics imposter used to create a joint
  22804. * @param jointType The type of joint
  22805. * @param jointData The data for the joint
  22806. * @returns The physics imposter
  22807. */
  22808. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22809. /**
  22810. * Add a joint to this impostor with a different impostor
  22811. * @param otherImpostor A physics imposter used to add a joint
  22812. * @param joint The joint to add
  22813. * @returns The physics imposter
  22814. */
  22815. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22816. /**
  22817. * Add an anchor to a cloth impostor
  22818. * @param otherImpostor rigid impostor to anchor to
  22819. * @param width ratio across width from 0 to 1
  22820. * @param height ratio up height from 0 to 1
  22821. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22822. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22823. * @returns impostor the soft imposter
  22824. */
  22825. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22826. /**
  22827. * Add a hook to a rope impostor
  22828. * @param otherImpostor rigid impostor to anchor to
  22829. * @param length ratio across rope from 0 to 1
  22830. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22831. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22832. * @returns impostor the rope imposter
  22833. */
  22834. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22835. /**
  22836. * Will keep this body still, in a sleep mode.
  22837. * @returns the physics imposter
  22838. */
  22839. sleep(): PhysicsImpostor;
  22840. /**
  22841. * Wake the body up.
  22842. * @returns The physics imposter
  22843. */
  22844. wakeUp(): PhysicsImpostor;
  22845. /**
  22846. * Clones the physics imposter
  22847. * @param newObject The physics imposter clones to this physics-enabled object
  22848. * @returns A nullable physics imposter
  22849. */
  22850. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22851. /**
  22852. * Disposes the physics imposter
  22853. */
  22854. dispose(): void;
  22855. /**
  22856. * Sets the delta position
  22857. * @param position The delta position amount
  22858. */
  22859. setDeltaPosition(position: Vector3): void;
  22860. /**
  22861. * Sets the delta rotation
  22862. * @param rotation The delta rotation amount
  22863. */
  22864. setDeltaRotation(rotation: Quaternion): void;
  22865. /**
  22866. * Gets the box size of the physics imposter and stores the result in the input parameter
  22867. * @param result Stores the box size
  22868. * @returns The physics imposter
  22869. */
  22870. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22871. /**
  22872. * Gets the radius of the physics imposter
  22873. * @returns Radius of the physics imposter
  22874. */
  22875. getRadius(): number;
  22876. /**
  22877. * Sync a bone with this impostor
  22878. * @param bone The bone to sync to the impostor.
  22879. * @param boneMesh The mesh that the bone is influencing.
  22880. * @param jointPivot The pivot of the joint / bone in local space.
  22881. * @param distToJoint Optional distance from the impostor to the joint.
  22882. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22883. */
  22884. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22885. /**
  22886. * Sync impostor to a bone
  22887. * @param bone The bone that the impostor will be synced to.
  22888. * @param boneMesh The mesh that the bone is influencing.
  22889. * @param jointPivot The pivot of the joint / bone in local space.
  22890. * @param distToJoint Optional distance from the impostor to the joint.
  22891. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22892. * @param boneAxis Optional vector3 axis the bone is aligned with
  22893. */
  22894. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22895. /**
  22896. * No-Imposter type
  22897. */
  22898. static NoImpostor: number;
  22899. /**
  22900. * Sphere-Imposter type
  22901. */
  22902. static SphereImpostor: number;
  22903. /**
  22904. * Box-Imposter type
  22905. */
  22906. static BoxImpostor: number;
  22907. /**
  22908. * Plane-Imposter type
  22909. */
  22910. static PlaneImpostor: number;
  22911. /**
  22912. * Mesh-imposter type
  22913. */
  22914. static MeshImpostor: number;
  22915. /**
  22916. * Capsule-Impostor type (Ammo.js plugin only)
  22917. */
  22918. static CapsuleImpostor: number;
  22919. /**
  22920. * Cylinder-Imposter type
  22921. */
  22922. static CylinderImpostor: number;
  22923. /**
  22924. * Particle-Imposter type
  22925. */
  22926. static ParticleImpostor: number;
  22927. /**
  22928. * Heightmap-Imposter type
  22929. */
  22930. static HeightmapImpostor: number;
  22931. /**
  22932. * ConvexHull-Impostor type (Ammo.js plugin only)
  22933. */
  22934. static ConvexHullImpostor: number;
  22935. /**
  22936. * Rope-Imposter type
  22937. */
  22938. static RopeImpostor: number;
  22939. /**
  22940. * Cloth-Imposter type
  22941. */
  22942. static ClothImpostor: number;
  22943. /**
  22944. * Softbody-Imposter type
  22945. */
  22946. static SoftbodyImpostor: number;
  22947. }
  22948. }
  22949. declare module BABYLON {
  22950. /**
  22951. * @hidden
  22952. **/
  22953. export class _CreationDataStorage {
  22954. closePath?: boolean;
  22955. closeArray?: boolean;
  22956. idx: number[];
  22957. dashSize: number;
  22958. gapSize: number;
  22959. path3D: Path3D;
  22960. pathArray: Vector3[][];
  22961. arc: number;
  22962. radius: number;
  22963. cap: number;
  22964. tessellation: number;
  22965. }
  22966. /**
  22967. * @hidden
  22968. **/ private class _InstanceDataStorage {
  22969. visibleInstances: any;
  22970. batchCache: _InstancesBatch;
  22971. instancesBufferSize: number;
  22972. instancesBuffer: Nullable<Buffer>;
  22973. instancesData: Float32Array;
  22974. overridenInstanceCount: number;
  22975. isFrozen: boolean;
  22976. previousBatch: Nullable<_InstancesBatch>;
  22977. hardwareInstancedRendering: boolean;
  22978. sideOrientation: number;
  22979. }
  22980. /**
  22981. * @hidden
  22982. **/
  22983. export class _InstancesBatch {
  22984. mustReturn: boolean;
  22985. visibleInstances: Nullable<InstancedMesh[]>[];
  22986. renderSelf: boolean[];
  22987. hardwareInstancedRendering: boolean[];
  22988. }
  22989. /**
  22990. * Class used to represent renderable models
  22991. */
  22992. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22993. /**
  22994. * Mesh side orientation : usually the external or front surface
  22995. */
  22996. static readonly FRONTSIDE: number;
  22997. /**
  22998. * Mesh side orientation : usually the internal or back surface
  22999. */
  23000. static readonly BACKSIDE: number;
  23001. /**
  23002. * Mesh side orientation : both internal and external or front and back surfaces
  23003. */
  23004. static readonly DOUBLESIDE: number;
  23005. /**
  23006. * Mesh side orientation : by default, `FRONTSIDE`
  23007. */
  23008. static readonly DEFAULTSIDE: number;
  23009. /**
  23010. * Mesh cap setting : no cap
  23011. */
  23012. static readonly NO_CAP: number;
  23013. /**
  23014. * Mesh cap setting : one cap at the beginning of the mesh
  23015. */
  23016. static readonly CAP_START: number;
  23017. /**
  23018. * Mesh cap setting : one cap at the end of the mesh
  23019. */
  23020. static readonly CAP_END: number;
  23021. /**
  23022. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23023. */
  23024. static readonly CAP_ALL: number;
  23025. /**
  23026. * Mesh pattern setting : no flip or rotate
  23027. */
  23028. static readonly NO_FLIP: number;
  23029. /**
  23030. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23031. */
  23032. static readonly FLIP_TILE: number;
  23033. /**
  23034. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23035. */
  23036. static readonly ROTATE_TILE: number;
  23037. /**
  23038. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23039. */
  23040. static readonly FLIP_ROW: number;
  23041. /**
  23042. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23043. */
  23044. static readonly ROTATE_ROW: number;
  23045. /**
  23046. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23047. */
  23048. static readonly FLIP_N_ROTATE_TILE: number;
  23049. /**
  23050. * Mesh pattern setting : rotate pattern and rotate
  23051. */
  23052. static readonly FLIP_N_ROTATE_ROW: number;
  23053. /**
  23054. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23055. */
  23056. static readonly CENTER: number;
  23057. /**
  23058. * Mesh tile positioning : part tiles on left
  23059. */
  23060. static readonly LEFT: number;
  23061. /**
  23062. * Mesh tile positioning : part tiles on right
  23063. */
  23064. static readonly RIGHT: number;
  23065. /**
  23066. * Mesh tile positioning : part tiles on top
  23067. */
  23068. static readonly TOP: number;
  23069. /**
  23070. * Mesh tile positioning : part tiles on bottom
  23071. */
  23072. static readonly BOTTOM: number;
  23073. /**
  23074. * Gets the default side orientation.
  23075. * @param orientation the orientation to value to attempt to get
  23076. * @returns the default orientation
  23077. * @hidden
  23078. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23079. private _internalMeshDataInfo;
  23080. /**
  23081. * An event triggered before rendering the mesh
  23082. */
  23083. readonly onBeforeRenderObservable: Observable<Mesh>;
  23084. /**
  23085. * An event triggered before binding the mesh
  23086. */
  23087. readonly onBeforeBindObservable: Observable<Mesh>;
  23088. /**
  23089. * An event triggered after rendering the mesh
  23090. */
  23091. readonly onAfterRenderObservable: Observable<Mesh>;
  23092. /**
  23093. * An event triggered before drawing the mesh
  23094. */
  23095. readonly onBeforeDrawObservable: Observable<Mesh>;
  23096. private _onBeforeDrawObserver;
  23097. /**
  23098. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23099. */
  23100. onBeforeDraw: () => void;
  23101. readonly hasInstances: boolean;
  23102. /**
  23103. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23104. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23105. */
  23106. delayLoadState: number;
  23107. /**
  23108. * Gets the list of instances created from this mesh
  23109. * it is not supposed to be modified manually.
  23110. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23111. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23112. */
  23113. instances: InstancedMesh[];
  23114. /**
  23115. * Gets the file containing delay loading data for this mesh
  23116. */
  23117. delayLoadingFile: string;
  23118. /** @hidden */ private _binaryInfo: any;
  23119. /**
  23120. * User defined function used to change how LOD level selection is done
  23121. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23122. */
  23123. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23124. /**
  23125. * Gets or sets the morph target manager
  23126. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23127. */
  23128. morphTargetManager: Nullable<MorphTargetManager>;
  23129. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23130. /** @hidden */ private _geometry: Nullable<Geometry>;
  23131. /** @hidden */ private _delayInfo: Array<string>;
  23132. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23133. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23134. private _effectiveMaterial;
  23135. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23136. /** @hidden */ private _originalBuilderSideOrientation: number;
  23137. /**
  23138. * Use this property to change the original side orientation defined at construction time
  23139. */
  23140. overrideMaterialSideOrientation: Nullable<number>;
  23141. /**
  23142. * Gets the source mesh (the one used to clone this one from)
  23143. */
  23144. readonly source: Nullable<Mesh>;
  23145. /**
  23146. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23147. */
  23148. isUnIndexed: boolean;
  23149. /**
  23150. * @constructor
  23151. * @param name The value used by scene.getMeshByName() to do a lookup.
  23152. * @param scene The scene to add this mesh to.
  23153. * @param parent The parent of this mesh, if it has one
  23154. * @param source An optional Mesh from which geometry is shared, cloned.
  23155. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23156. * When false, achieved by calling a clone(), also passing False.
  23157. * This will make creation of children, recursive.
  23158. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23159. */
  23160. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23161. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23162. /**
  23163. * Gets the class name
  23164. * @returns the string "Mesh".
  23165. */
  23166. getClassName(): string;
  23167. /** @hidden */ protected readonly _isMesh: boolean;
  23168. /**
  23169. * Returns a description of this mesh
  23170. * @param fullDetails define if full details about this mesh must be used
  23171. * @returns a descriptive string representing this mesh
  23172. */
  23173. toString(fullDetails?: boolean): string;
  23174. /** @hidden */ private _unBindEffect(): void;
  23175. /**
  23176. * Gets a boolean indicating if this mesh has LOD
  23177. */
  23178. readonly hasLODLevels: boolean;
  23179. /**
  23180. * Gets the list of MeshLODLevel associated with the current mesh
  23181. * @returns an array of MeshLODLevel
  23182. */
  23183. getLODLevels(): MeshLODLevel[];
  23184. private _sortLODLevels;
  23185. /**
  23186. * Add a mesh as LOD level triggered at the given distance.
  23187. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23188. * @param distance The distance from the center of the object to show this level
  23189. * @param mesh The mesh to be added as LOD level (can be null)
  23190. * @return This mesh (for chaining)
  23191. */
  23192. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23193. /**
  23194. * Returns the LOD level mesh at the passed distance or null if not found.
  23195. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23196. * @param distance The distance from the center of the object to show this level
  23197. * @returns a Mesh or `null`
  23198. */
  23199. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23200. /**
  23201. * Remove a mesh from the LOD array
  23202. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23203. * @param mesh defines the mesh to be removed
  23204. * @return This mesh (for chaining)
  23205. */
  23206. removeLODLevel(mesh: Mesh): Mesh;
  23207. /**
  23208. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23209. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23210. * @param camera defines the camera to use to compute distance
  23211. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23212. * @return This mesh (for chaining)
  23213. */
  23214. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23215. /**
  23216. * Gets the mesh internal Geometry object
  23217. */
  23218. readonly geometry: Nullable<Geometry>;
  23219. /**
  23220. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23221. * @returns the total number of vertices
  23222. */
  23223. getTotalVertices(): number;
  23224. /**
  23225. * Returns the content of an associated vertex buffer
  23226. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23227. * - VertexBuffer.PositionKind
  23228. * - VertexBuffer.UVKind
  23229. * - VertexBuffer.UV2Kind
  23230. * - VertexBuffer.UV3Kind
  23231. * - VertexBuffer.UV4Kind
  23232. * - VertexBuffer.UV5Kind
  23233. * - VertexBuffer.UV6Kind
  23234. * - VertexBuffer.ColorKind
  23235. * - VertexBuffer.MatricesIndicesKind
  23236. * - VertexBuffer.MatricesIndicesExtraKind
  23237. * - VertexBuffer.MatricesWeightsKind
  23238. * - VertexBuffer.MatricesWeightsExtraKind
  23239. * @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
  23240. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23241. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23242. */
  23243. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23244. /**
  23245. * Returns the mesh VertexBuffer object from the requested `kind`
  23246. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23247. * - VertexBuffer.PositionKind
  23248. * - VertexBuffer.NormalKind
  23249. * - VertexBuffer.UVKind
  23250. * - VertexBuffer.UV2Kind
  23251. * - VertexBuffer.UV3Kind
  23252. * - VertexBuffer.UV4Kind
  23253. * - VertexBuffer.UV5Kind
  23254. * - VertexBuffer.UV6Kind
  23255. * - VertexBuffer.ColorKind
  23256. * - VertexBuffer.MatricesIndicesKind
  23257. * - VertexBuffer.MatricesIndicesExtraKind
  23258. * - VertexBuffer.MatricesWeightsKind
  23259. * - VertexBuffer.MatricesWeightsExtraKind
  23260. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23261. */
  23262. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23263. /**
  23264. * Tests if a specific vertex buffer is associated with this mesh
  23265. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23266. * - VertexBuffer.PositionKind
  23267. * - VertexBuffer.NormalKind
  23268. * - VertexBuffer.UVKind
  23269. * - VertexBuffer.UV2Kind
  23270. * - VertexBuffer.UV3Kind
  23271. * - VertexBuffer.UV4Kind
  23272. * - VertexBuffer.UV5Kind
  23273. * - VertexBuffer.UV6Kind
  23274. * - VertexBuffer.ColorKind
  23275. * - VertexBuffer.MatricesIndicesKind
  23276. * - VertexBuffer.MatricesIndicesExtraKind
  23277. * - VertexBuffer.MatricesWeightsKind
  23278. * - VertexBuffer.MatricesWeightsExtraKind
  23279. * @returns a boolean
  23280. */
  23281. isVerticesDataPresent(kind: string): boolean;
  23282. /**
  23283. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23284. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23285. * - VertexBuffer.PositionKind
  23286. * - VertexBuffer.UVKind
  23287. * - VertexBuffer.UV2Kind
  23288. * - VertexBuffer.UV3Kind
  23289. * - VertexBuffer.UV4Kind
  23290. * - VertexBuffer.UV5Kind
  23291. * - VertexBuffer.UV6Kind
  23292. * - VertexBuffer.ColorKind
  23293. * - VertexBuffer.MatricesIndicesKind
  23294. * - VertexBuffer.MatricesIndicesExtraKind
  23295. * - VertexBuffer.MatricesWeightsKind
  23296. * - VertexBuffer.MatricesWeightsExtraKind
  23297. * @returns a boolean
  23298. */
  23299. isVertexBufferUpdatable(kind: string): boolean;
  23300. /**
  23301. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23302. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23303. * - VertexBuffer.PositionKind
  23304. * - VertexBuffer.NormalKind
  23305. * - VertexBuffer.UVKind
  23306. * - VertexBuffer.UV2Kind
  23307. * - VertexBuffer.UV3Kind
  23308. * - VertexBuffer.UV4Kind
  23309. * - VertexBuffer.UV5Kind
  23310. * - VertexBuffer.UV6Kind
  23311. * - VertexBuffer.ColorKind
  23312. * - VertexBuffer.MatricesIndicesKind
  23313. * - VertexBuffer.MatricesIndicesExtraKind
  23314. * - VertexBuffer.MatricesWeightsKind
  23315. * - VertexBuffer.MatricesWeightsExtraKind
  23316. * @returns an array of strings
  23317. */
  23318. getVerticesDataKinds(): string[];
  23319. /**
  23320. * Returns a positive integer : the total number of indices in this mesh geometry.
  23321. * @returns the numner of indices or zero if the mesh has no geometry.
  23322. */
  23323. getTotalIndices(): number;
  23324. /**
  23325. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23326. * @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.
  23327. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23328. * @returns the indices array or an empty array if the mesh has no geometry
  23329. */
  23330. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23331. readonly isBlocked: boolean;
  23332. /**
  23333. * Determine if the current mesh is ready to be rendered
  23334. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23335. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23336. * @returns true if all associated assets are ready (material, textures, shaders)
  23337. */
  23338. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23339. /**
  23340. * 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.
  23341. */
  23342. readonly areNormalsFrozen: boolean;
  23343. /**
  23344. * 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.
  23345. * @returns the current mesh
  23346. */
  23347. freezeNormals(): Mesh;
  23348. /**
  23349. * 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
  23350. * @returns the current mesh
  23351. */
  23352. unfreezeNormals(): Mesh;
  23353. /**
  23354. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23355. */
  23356. overridenInstanceCount: number;
  23357. /** @hidden */ private _preActivate(): Mesh;
  23358. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23359. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23360. /**
  23361. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23362. * This means the mesh underlying bounding box and sphere are recomputed.
  23363. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23364. * @returns the current mesh
  23365. */
  23366. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23367. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23368. /**
  23369. * This function will subdivide the mesh into multiple submeshes
  23370. * @param count defines the expected number of submeshes
  23371. */
  23372. subdivide(count: number): void;
  23373. /**
  23374. * Copy a FloatArray into a specific associated vertex buffer
  23375. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23376. * - VertexBuffer.PositionKind
  23377. * - VertexBuffer.UVKind
  23378. * - VertexBuffer.UV2Kind
  23379. * - VertexBuffer.UV3Kind
  23380. * - VertexBuffer.UV4Kind
  23381. * - VertexBuffer.UV5Kind
  23382. * - VertexBuffer.UV6Kind
  23383. * - VertexBuffer.ColorKind
  23384. * - VertexBuffer.MatricesIndicesKind
  23385. * - VertexBuffer.MatricesIndicesExtraKind
  23386. * - VertexBuffer.MatricesWeightsKind
  23387. * - VertexBuffer.MatricesWeightsExtraKind
  23388. * @param data defines the data source
  23389. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23390. * @param stride defines the data stride size (can be null)
  23391. * @returns the current mesh
  23392. */
  23393. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23394. /**
  23395. * Flags an associated vertex buffer as updatable
  23396. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23397. * - VertexBuffer.PositionKind
  23398. * - VertexBuffer.UVKind
  23399. * - VertexBuffer.UV2Kind
  23400. * - VertexBuffer.UV3Kind
  23401. * - VertexBuffer.UV4Kind
  23402. * - VertexBuffer.UV5Kind
  23403. * - VertexBuffer.UV6Kind
  23404. * - VertexBuffer.ColorKind
  23405. * - VertexBuffer.MatricesIndicesKind
  23406. * - VertexBuffer.MatricesIndicesExtraKind
  23407. * - VertexBuffer.MatricesWeightsKind
  23408. * - VertexBuffer.MatricesWeightsExtraKind
  23409. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23410. */
  23411. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23412. /**
  23413. * Sets the mesh global Vertex Buffer
  23414. * @param buffer defines the buffer to use
  23415. * @returns the current mesh
  23416. */
  23417. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23418. /**
  23419. * Update a specific associated vertex buffer
  23420. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23421. * - VertexBuffer.PositionKind
  23422. * - VertexBuffer.UVKind
  23423. * - VertexBuffer.UV2Kind
  23424. * - VertexBuffer.UV3Kind
  23425. * - VertexBuffer.UV4Kind
  23426. * - VertexBuffer.UV5Kind
  23427. * - VertexBuffer.UV6Kind
  23428. * - VertexBuffer.ColorKind
  23429. * - VertexBuffer.MatricesIndicesKind
  23430. * - VertexBuffer.MatricesIndicesExtraKind
  23431. * - VertexBuffer.MatricesWeightsKind
  23432. * - VertexBuffer.MatricesWeightsExtraKind
  23433. * @param data defines the data source
  23434. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23435. * @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)
  23436. * @returns the current mesh
  23437. */
  23438. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23439. /**
  23440. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23441. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23442. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23443. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23444. * @returns the current mesh
  23445. */
  23446. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23447. /**
  23448. * Creates a un-shared specific occurence of the geometry for the mesh.
  23449. * @returns the current mesh
  23450. */
  23451. makeGeometryUnique(): Mesh;
  23452. /**
  23453. * Set the index buffer of this mesh
  23454. * @param indices defines the source data
  23455. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23456. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23457. * @returns the current mesh
  23458. */
  23459. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23460. /**
  23461. * Update the current index buffer
  23462. * @param indices defines the source data
  23463. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23464. * @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)
  23465. * @returns the current mesh
  23466. */
  23467. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23468. /**
  23469. * Invert the geometry to move from a right handed system to a left handed one.
  23470. * @returns the current mesh
  23471. */
  23472. toLeftHanded(): Mesh;
  23473. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23474. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23475. /**
  23476. * Registers for this mesh a javascript function called just before the rendering process
  23477. * @param func defines the function to call before rendering this mesh
  23478. * @returns the current mesh
  23479. */
  23480. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23481. /**
  23482. * Disposes a previously registered javascript function called before the rendering
  23483. * @param func defines the function to remove
  23484. * @returns the current mesh
  23485. */
  23486. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23487. /**
  23488. * Registers for this mesh a javascript function called just after the rendering is complete
  23489. * @param func defines the function to call after rendering this mesh
  23490. * @returns the current mesh
  23491. */
  23492. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23493. /**
  23494. * Disposes a previously registered javascript function called after the rendering.
  23495. * @param func defines the function to remove
  23496. * @returns the current mesh
  23497. */
  23498. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23499. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23500. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23501. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23502. /** @hidden */ private _rebuild(): void;
  23503. /** @hidden */ private _freeze(): void;
  23504. /** @hidden */ private _unFreeze(): void;
  23505. /**
  23506. * 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
  23507. * @param subMesh defines the subMesh to render
  23508. * @param enableAlphaMode defines if alpha mode can be changed
  23509. * @returns the current mesh
  23510. */
  23511. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23512. private _onBeforeDraw;
  23513. /**
  23514. * Renormalize the mesh and patch it up if there are no weights
  23515. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23516. * However in the case of zero weights then we set just a single influence to 1.
  23517. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23518. */
  23519. cleanMatrixWeights(): void;
  23520. private normalizeSkinFourWeights;
  23521. private normalizeSkinWeightsAndExtra;
  23522. /**
  23523. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23524. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23525. * the user know there was an issue with importing the mesh
  23526. * @returns a validation object with skinned, valid and report string
  23527. */
  23528. validateSkinning(): {
  23529. skinned: boolean;
  23530. valid: boolean;
  23531. report: string;
  23532. };
  23533. /** @hidden */ private _checkDelayState(): Mesh;
  23534. private _queueLoad;
  23535. /**
  23536. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23537. * A mesh is in the frustum if its bounding box intersects the frustum
  23538. * @param frustumPlanes defines the frustum to test
  23539. * @returns true if the mesh is in the frustum planes
  23540. */
  23541. isInFrustum(frustumPlanes: Plane[]): boolean;
  23542. /**
  23543. * Sets the mesh material by the material or multiMaterial `id` property
  23544. * @param id is a string identifying the material or the multiMaterial
  23545. * @returns the current mesh
  23546. */
  23547. setMaterialByID(id: string): Mesh;
  23548. /**
  23549. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23550. * @returns an array of IAnimatable
  23551. */
  23552. getAnimatables(): IAnimatable[];
  23553. /**
  23554. * Modifies the mesh geometry according to the passed transformation matrix.
  23555. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23556. * The mesh normals are modified using the same transformation.
  23557. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23558. * @param transform defines the transform matrix to use
  23559. * @see http://doc.babylonjs.com/resources/baking_transformations
  23560. * @returns the current mesh
  23561. */
  23562. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23563. /**
  23564. * Modifies the mesh geometry according to its own current World Matrix.
  23565. * The mesh World Matrix is then reset.
  23566. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23567. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23568. * @see http://doc.babylonjs.com/resources/baking_transformations
  23569. * @returns the current mesh
  23570. */
  23571. bakeCurrentTransformIntoVertices(): Mesh;
  23572. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23573. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23574. /** @hidden */ private _generatePointsArray(): boolean;
  23575. /**
  23576. * Returns a new Mesh object generated from the current mesh properties.
  23577. * This method must not get confused with createInstance()
  23578. * @param name is a string, the name given to the new mesh
  23579. * @param newParent can be any Node object (default `null`)
  23580. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23581. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23582. * @returns a new mesh
  23583. */
  23584. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23585. /**
  23586. * Releases resources associated with this mesh.
  23587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23589. */
  23590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23591. /**
  23592. * Modifies the mesh geometry according to a displacement map.
  23593. * 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.
  23594. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23595. * @param url is a string, the URL from the image file is to be downloaded.
  23596. * @param minHeight is the lower limit of the displacement.
  23597. * @param maxHeight is the upper limit of the displacement.
  23598. * @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.
  23599. * @param uvOffset is an optional vector2 used to offset UV.
  23600. * @param uvScale is an optional vector2 used to scale UV.
  23601. * @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.
  23602. * @returns the Mesh.
  23603. */
  23604. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23605. /**
  23606. * Modifies the mesh geometry according to a displacementMap buffer.
  23607. * 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.
  23608. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23609. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23610. * @param heightMapWidth is the width of the buffer image.
  23611. * @param heightMapHeight is the height of the buffer image.
  23612. * @param minHeight is the lower limit of the displacement.
  23613. * @param maxHeight is the upper limit of the displacement.
  23614. * @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.
  23615. * @param uvOffset is an optional vector2 used to offset UV.
  23616. * @param uvScale is an optional vector2 used to scale UV.
  23617. * @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.
  23618. * @returns the Mesh.
  23619. */
  23620. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23621. /**
  23622. * Modify the mesh to get a flat shading rendering.
  23623. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23624. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23625. * @returns current mesh
  23626. */
  23627. convertToFlatShadedMesh(): Mesh;
  23628. /**
  23629. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23630. * In other words, more vertices, no more indices and a single bigger VBO.
  23631. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23632. * @returns current mesh
  23633. */
  23634. convertToUnIndexedMesh(): Mesh;
  23635. /**
  23636. * Inverses facet orientations.
  23637. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23638. * @param flipNormals will also inverts the normals
  23639. * @returns current mesh
  23640. */
  23641. flipFaces(flipNormals?: boolean): Mesh;
  23642. /**
  23643. * Increase the number of facets and hence vertices in a mesh
  23644. * Vertex normals are interpolated from existing vertex normals
  23645. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23646. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23647. */
  23648. increaseVertices(numberPerEdge: number): void;
  23649. /**
  23650. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23651. * This will undo any application of covertToFlatShadedMesh
  23652. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23653. */
  23654. forceSharedVertices(): void;
  23655. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23656. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23657. /**
  23658. * Creates a new InstancedMesh object from the mesh model.
  23659. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23660. * @param name defines the name of the new instance
  23661. * @returns a new InstancedMesh
  23662. */
  23663. createInstance(name: string): InstancedMesh;
  23664. /**
  23665. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23666. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23667. * @returns the current mesh
  23668. */
  23669. synchronizeInstances(): Mesh;
  23670. /**
  23671. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23672. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23673. * This should be used together with the simplification to avoid disappearing triangles.
  23674. * @param successCallback an optional success callback to be called after the optimization finished.
  23675. * @returns the current mesh
  23676. */
  23677. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23678. /**
  23679. * Serialize current mesh
  23680. * @param serializationObject defines the object which will receive the serialization data
  23681. */
  23682. serialize(serializationObject: any): void;
  23683. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23684. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23685. /**
  23686. * Returns a new Mesh object parsed from the source provided.
  23687. * @param parsedMesh is the source
  23688. * @param scene defines the hosting scene
  23689. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23690. * @returns a new Mesh
  23691. */
  23692. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23693. /**
  23694. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23695. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23696. * @param name defines the name of the mesh to create
  23697. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23698. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23699. * @param closePath creates a seam between the first and the last points of each path of the path array
  23700. * @param offset is taken in account only if the `pathArray` is containing a single path
  23701. * @param scene defines the hosting scene
  23702. * @param updatable defines if the mesh must be flagged as updatable
  23703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23704. * @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)
  23705. * @returns a new Mesh
  23706. */
  23707. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23708. /**
  23709. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23710. * @param name defines the name of the mesh to create
  23711. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23712. * @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
  23713. * @param scene defines the hosting scene
  23714. * @param updatable defines if the mesh must be flagged as updatable
  23715. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23716. * @returns a new Mesh
  23717. */
  23718. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23719. /**
  23720. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23721. * @param name defines the name of the mesh to create
  23722. * @param size sets the size (float) of each box side (default 1)
  23723. * @param scene defines the hosting scene
  23724. * @param updatable defines if the mesh must be flagged as updatable
  23725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23726. * @returns a new Mesh
  23727. */
  23728. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23729. /**
  23730. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23731. * @param name defines the name of the mesh to create
  23732. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23733. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23734. * @param scene defines the hosting scene
  23735. * @param updatable defines if the mesh must be flagged as updatable
  23736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23737. * @returns a new Mesh
  23738. */
  23739. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23740. /**
  23741. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23742. * @param name defines the name of the mesh to create
  23743. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23744. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23745. * @param scene defines the hosting scene
  23746. * @returns a new Mesh
  23747. */
  23748. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23749. /**
  23750. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23751. * @param name defines the name of the mesh to create
  23752. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23753. * @param diameterTop set the top cap diameter (floats, default 1)
  23754. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23755. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23756. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23757. * @param scene defines the hosting scene
  23758. * @param updatable defines if the mesh must be flagged as updatable
  23759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23760. * @returns a new Mesh
  23761. */
  23762. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23763. /**
  23764. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23765. * @param name defines the name of the mesh to create
  23766. * @param diameter sets the diameter size (float) of the torus (default 1)
  23767. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23768. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23769. * @param scene defines the hosting scene
  23770. * @param updatable defines if the mesh must be flagged as updatable
  23771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23772. * @returns a new Mesh
  23773. */
  23774. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23775. /**
  23776. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23777. * @param name defines the name of the mesh to create
  23778. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23779. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23780. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23781. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23782. * @param p the number of windings on X axis (positive integers, default 2)
  23783. * @param q the number of windings on Y axis (positive integers, default 3)
  23784. * @param scene defines the hosting scene
  23785. * @param updatable defines if the mesh must be flagged as updatable
  23786. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23787. * @returns a new Mesh
  23788. */
  23789. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23790. /**
  23791. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23792. * @param name defines the name of the mesh to create
  23793. * @param points is an array successive Vector3
  23794. * @param scene defines the hosting scene
  23795. * @param updatable defines if the mesh must be flagged as updatable
  23796. * @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).
  23797. * @returns a new Mesh
  23798. */
  23799. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23800. /**
  23801. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23802. * @param name defines the name of the mesh to create
  23803. * @param points is an array successive Vector3
  23804. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23805. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23806. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23807. * @param scene defines the hosting scene
  23808. * @param updatable defines if the mesh must be flagged as updatable
  23809. * @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)
  23810. * @returns a new Mesh
  23811. */
  23812. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23813. /**
  23814. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23815. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23816. * 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.
  23817. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23818. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23819. * Remember you can only change the shape positions, not their number when updating a polygon.
  23820. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23821. * @param name defines the name of the mesh to create
  23822. * @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
  23823. * @param scene defines the hosting scene
  23824. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23825. * @param updatable defines if the mesh must be flagged as updatable
  23826. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23827. * @param earcutInjection can be used to inject your own earcut reference
  23828. * @returns a new Mesh
  23829. */
  23830. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23831. /**
  23832. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23833. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23834. * @param name defines the name of the mesh to create
  23835. * @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
  23836. * @param depth defines the height of extrusion
  23837. * @param scene defines the hosting scene
  23838. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23839. * @param updatable defines if the mesh must be flagged as updatable
  23840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23841. * @param earcutInjection can be used to inject your own earcut reference
  23842. * @returns a new Mesh
  23843. */
  23844. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23845. /**
  23846. * Creates an extruded shape mesh.
  23847. * 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
  23848. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23849. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23850. * @param name defines the name of the mesh to create
  23851. * @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
  23852. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23853. * @param scale is the value to scale the shape
  23854. * @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
  23855. * @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
  23856. * @param scene defines the hosting scene
  23857. * @param updatable defines if the mesh must be flagged as updatable
  23858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23859. * @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)
  23860. * @returns a new Mesh
  23861. */
  23862. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23863. /**
  23864. * Creates an custom extruded shape mesh.
  23865. * The custom extrusion is a parametric shape.
  23866. * It has no predefined shape. Its final shape will depend on the input parameters.
  23867. * Please consider using the same method from the MeshBuilder class instead
  23868. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23869. * @param name defines the name of the mesh to create
  23870. * @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
  23871. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23872. * @param scaleFunction is a custom Javascript function called on each path point
  23873. * @param rotationFunction is a custom Javascript function called on each path point
  23874. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23875. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  23876. * @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
  23877. * @param scene defines the hosting scene
  23878. * @param updatable defines if the mesh must be flagged as updatable
  23879. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23880. * @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)
  23881. * @returns a new Mesh
  23882. */
  23883. 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;
  23884. /**
  23885. * Creates lathe mesh.
  23886. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23887. * Please consider using the same method from the MeshBuilder class instead
  23888. * @param name defines the name of the mesh to create
  23889. * @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
  23890. * @param radius is the radius value of the lathe
  23891. * @param tessellation is the side number of the lathe.
  23892. * @param scene defines the hosting scene
  23893. * @param updatable defines if the mesh must be flagged as updatable
  23894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23895. * @returns a new Mesh
  23896. */
  23897. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23898. /**
  23899. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  23900. * @param name defines the name of the mesh to create
  23901. * @param size sets the size (float) of both sides of the plane at once (default 1)
  23902. * @param scene defines the hosting scene
  23903. * @param updatable defines if the mesh must be flagged as updatable
  23904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23905. * @returns a new Mesh
  23906. */
  23907. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23908. /**
  23909. * Creates a ground mesh.
  23910. * Please consider using the same method from the MeshBuilder class instead
  23911. * @param name defines the name of the mesh to create
  23912. * @param width set the width of the ground
  23913. * @param height set the height of the ground
  23914. * @param subdivisions sets the number of subdivisions per side
  23915. * @param scene defines the hosting scene
  23916. * @param updatable defines if the mesh must be flagged as updatable
  23917. * @returns a new Mesh
  23918. */
  23919. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23920. /**
  23921. * Creates a tiled ground mesh.
  23922. * Please consider using the same method from the MeshBuilder class instead
  23923. * @param name defines the name of the mesh to create
  23924. * @param xmin set the ground minimum X coordinate
  23925. * @param zmin set the ground minimum Y coordinate
  23926. * @param xmax set the ground maximum X coordinate
  23927. * @param zmax set the ground maximum Z coordinate
  23928. * @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
  23929. * @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
  23930. * @param scene defines the hosting scene
  23931. * @param updatable defines if the mesh must be flagged as updatable
  23932. * @returns a new Mesh
  23933. */
  23934. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23935. w: number;
  23936. h: number;
  23937. }, precision: {
  23938. w: number;
  23939. h: number;
  23940. }, scene: Scene, updatable?: boolean): Mesh;
  23941. /**
  23942. * Creates a ground mesh from a height map.
  23943. * Please consider using the same method from the MeshBuilder class instead
  23944. * @see http://doc.babylonjs.com/babylon101/height_map
  23945. * @param name defines the name of the mesh to create
  23946. * @param url sets the URL of the height map image resource
  23947. * @param width set the ground width size
  23948. * @param height set the ground height size
  23949. * @param subdivisions sets the number of subdivision per side
  23950. * @param minHeight is the minimum altitude on the ground
  23951. * @param maxHeight is the maximum altitude on the ground
  23952. * @param scene defines the hosting scene
  23953. * @param updatable defines if the mesh must be flagged as updatable
  23954. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  23955. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23956. * @returns a new Mesh
  23957. */
  23958. 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;
  23959. /**
  23960. * Creates a tube mesh.
  23961. * The tube is a parametric shape.
  23962. * It has no predefined shape. Its final shape will depend on the input parameters.
  23963. * Please consider using the same method from the MeshBuilder class instead
  23964. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23965. * @param name defines the name of the mesh to create
  23966. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  23967. * @param radius sets the tube radius size
  23968. * @param tessellation is the number of sides on the tubular surface
  23969. * @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
  23970. * @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
  23971. * @param scene defines the hosting scene
  23972. * @param updatable defines if the mesh must be flagged as updatable
  23973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23974. * @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)
  23975. * @returns a new Mesh
  23976. */
  23977. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23978. (i: number, distance: number): number;
  23979. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23980. /**
  23981. * Creates a polyhedron mesh.
  23982. * Please consider using the same method from the MeshBuilder class instead.
  23983. * * 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
  23984. * * The parameter `size` (positive float, default 1) sets the polygon size
  23985. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23986. * * 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`
  23987. * * 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
  23988. * * 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)`)
  23989. * * 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
  23990. * * 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
  23991. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23992. * * 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
  23993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23994. * @param name defines the name of the mesh to create
  23995. * @param options defines the options used to create the mesh
  23996. * @param scene defines the hosting scene
  23997. * @returns a new Mesh
  23998. */
  23999. static CreatePolyhedron(name: string, options: {
  24000. type?: number;
  24001. size?: number;
  24002. sizeX?: number;
  24003. sizeY?: number;
  24004. sizeZ?: number;
  24005. custom?: any;
  24006. faceUV?: Vector4[];
  24007. faceColors?: Color4[];
  24008. updatable?: boolean;
  24009. sideOrientation?: number;
  24010. }, scene: Scene): Mesh;
  24011. /**
  24012. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24013. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24014. * * 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`)
  24015. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24016. * * 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
  24017. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24018. * * 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
  24019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24020. * @param name defines the name of the mesh
  24021. * @param options defines the options used to create the mesh
  24022. * @param scene defines the hosting scene
  24023. * @returns a new Mesh
  24024. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24025. */
  24026. static CreateIcoSphere(name: string, options: {
  24027. radius?: number;
  24028. flat?: boolean;
  24029. subdivisions?: number;
  24030. sideOrientation?: number;
  24031. updatable?: boolean;
  24032. }, scene: Scene): Mesh;
  24033. /**
  24034. * Creates a decal mesh.
  24035. * Please consider using the same method from the MeshBuilder class instead.
  24036. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24037. * @param name defines the name of the mesh
  24038. * @param sourceMesh defines the mesh receiving the decal
  24039. * @param position sets the position of the decal in world coordinates
  24040. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24041. * @param size sets the decal scaling
  24042. * @param angle sets the angle to rotate the decal
  24043. * @returns a new Mesh
  24044. */
  24045. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24046. /**
  24047. * Prepare internal position array for software CPU skinning
  24048. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24049. */
  24050. setPositionsForCPUSkinning(): Float32Array;
  24051. /**
  24052. * Prepare internal normal array for software CPU skinning
  24053. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24054. */
  24055. setNormalsForCPUSkinning(): Float32Array;
  24056. /**
  24057. * Updates the vertex buffer by applying transformation from the bones
  24058. * @param skeleton defines the skeleton to apply to current mesh
  24059. * @returns the current mesh
  24060. */
  24061. applySkeleton(skeleton: Skeleton): Mesh;
  24062. /**
  24063. * 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
  24064. * @param meshes defines the list of meshes to scan
  24065. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24066. */
  24067. static MinMax(meshes: AbstractMesh[]): {
  24068. min: Vector3;
  24069. max: Vector3;
  24070. };
  24071. /**
  24072. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24073. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24074. * @returns a vector3
  24075. */
  24076. static Center(meshesOrMinMaxVector: {
  24077. min: Vector3;
  24078. max: Vector3;
  24079. } | AbstractMesh[]): Vector3;
  24080. /**
  24081. * Merge the array of meshes into a single mesh for performance reasons.
  24082. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24083. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24084. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24085. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24086. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24087. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24088. * @returns a new mesh
  24089. */
  24090. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24091. /** @hidden */
  24092. addInstance(instance: InstancedMesh): void;
  24093. /** @hidden */
  24094. removeInstance(instance: InstancedMesh): void;
  24095. }
  24096. }
  24097. declare module BABYLON {
  24098. /**
  24099. * This is the base class of all the camera used in the application.
  24100. * @see http://doc.babylonjs.com/features/cameras
  24101. */
  24102. export class Camera extends Node {
  24103. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24104. /**
  24105. * This is the default projection mode used by the cameras.
  24106. * It helps recreating a feeling of perspective and better appreciate depth.
  24107. * This is the best way to simulate real life cameras.
  24108. */
  24109. static readonly PERSPECTIVE_CAMERA: number;
  24110. /**
  24111. * This helps creating camera with an orthographic mode.
  24112. * 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.
  24113. */
  24114. static readonly ORTHOGRAPHIC_CAMERA: number;
  24115. /**
  24116. * This is the default FOV mode for perspective cameras.
  24117. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24118. */
  24119. static readonly FOVMODE_VERTICAL_FIXED: number;
  24120. /**
  24121. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24122. */
  24123. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24124. /**
  24125. * This specifies ther is no need for a camera rig.
  24126. * Basically only one eye is rendered corresponding to the camera.
  24127. */
  24128. static readonly RIG_MODE_NONE: number;
  24129. /**
  24130. * Simulates a camera Rig with one blue eye and one red eye.
  24131. * This can be use with 3d blue and red glasses.
  24132. */
  24133. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24134. /**
  24135. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24136. */
  24137. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24138. /**
  24139. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24140. */
  24141. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24142. /**
  24143. * Defines that both eyes of the camera will be rendered over under each other.
  24144. */
  24145. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24146. /**
  24147. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24148. */
  24149. static readonly RIG_MODE_VR: number;
  24150. /**
  24151. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24152. */
  24153. static readonly RIG_MODE_WEBVR: number;
  24154. /**
  24155. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24156. */
  24157. static readonly RIG_MODE_CUSTOM: number;
  24158. /**
  24159. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24160. */
  24161. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24162. /**
  24163. * Define the input manager associated with the camera.
  24164. */
  24165. inputs: CameraInputsManager<Camera>;
  24166. /** @hidden */ private _position: Vector3;
  24167. /**
  24168. * Define the current local position of the camera in the scene
  24169. */
  24170. position: Vector3;
  24171. /**
  24172. * The vector the camera should consider as up.
  24173. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24174. */
  24175. upVector: Vector3;
  24176. /**
  24177. * Define the current limit on the left side for an orthographic camera
  24178. * In scene unit
  24179. */
  24180. orthoLeft: Nullable<number>;
  24181. /**
  24182. * Define the current limit on the right side for an orthographic camera
  24183. * In scene unit
  24184. */
  24185. orthoRight: Nullable<number>;
  24186. /**
  24187. * Define the current limit on the bottom side for an orthographic camera
  24188. * In scene unit
  24189. */
  24190. orthoBottom: Nullable<number>;
  24191. /**
  24192. * Define the current limit on the top side for an orthographic camera
  24193. * In scene unit
  24194. */
  24195. orthoTop: Nullable<number>;
  24196. /**
  24197. * Field Of View is set in Radians. (default is 0.8)
  24198. */
  24199. fov: number;
  24200. /**
  24201. * Define the minimum distance the camera can see from.
  24202. * This is important to note that the depth buffer are not infinite and the closer it starts
  24203. * the more your scene might encounter depth fighting issue.
  24204. */
  24205. minZ: number;
  24206. /**
  24207. * Define the maximum distance the camera can see to.
  24208. * This is important to note that the depth buffer are not infinite and the further it end
  24209. * the more your scene might encounter depth fighting issue.
  24210. */
  24211. maxZ: number;
  24212. /**
  24213. * Define the default inertia of the camera.
  24214. * This helps giving a smooth feeling to the camera movement.
  24215. */
  24216. inertia: number;
  24217. /**
  24218. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24219. */
  24220. mode: number;
  24221. /**
  24222. * Define wether the camera is intermediate.
  24223. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24224. */
  24225. isIntermediate: boolean;
  24226. /**
  24227. * Define the viewport of the camera.
  24228. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24229. */
  24230. viewport: Viewport;
  24231. /**
  24232. * Restricts the camera to viewing objects with the same layerMask.
  24233. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24234. */
  24235. layerMask: number;
  24236. /**
  24237. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24238. */
  24239. fovMode: number;
  24240. /**
  24241. * Rig mode of the camera.
  24242. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24243. * This is normally controlled byt the camera themselves as internal use.
  24244. */
  24245. cameraRigMode: number;
  24246. /**
  24247. * Defines the distance between both "eyes" in case of a RIG
  24248. */
  24249. interaxialDistance: number;
  24250. /**
  24251. * Defines if stereoscopic rendering is done side by side or over under.
  24252. */
  24253. isStereoscopicSideBySide: boolean;
  24254. /**
  24255. * 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
  24256. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24257. * else in the scene. (Eg. security camera)
  24258. *
  24259. * 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)
  24260. */
  24261. customRenderTargets: RenderTargetTexture[];
  24262. /**
  24263. * When set, the camera will render to this render target instead of the default canvas
  24264. *
  24265. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24266. */
  24267. outputRenderTarget: Nullable<RenderTargetTexture>;
  24268. /**
  24269. * Observable triggered when the camera view matrix has changed.
  24270. */
  24271. onViewMatrixChangedObservable: Observable<Camera>;
  24272. /**
  24273. * Observable triggered when the camera Projection matrix has changed.
  24274. */
  24275. onProjectionMatrixChangedObservable: Observable<Camera>;
  24276. /**
  24277. * Observable triggered when the inputs have been processed.
  24278. */
  24279. onAfterCheckInputsObservable: Observable<Camera>;
  24280. /**
  24281. * Observable triggered when reset has been called and applied to the camera.
  24282. */
  24283. onRestoreStateObservable: Observable<Camera>;
  24284. /** @hidden */ private _cameraRigParams: any;
  24285. /** @hidden */ private _rigCameras: Camera[];
  24286. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24287. protected _webvrViewMatrix: Matrix;
  24288. /** @hidden */ private _skipRendering: boolean;
  24289. /** @hidden */ private _projectionMatrix: Matrix;
  24290. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24291. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24292. protected _globalPosition: Vector3;
  24293. /** @hidden */ private _computedViewMatrix: Matrix;
  24294. private _doNotComputeProjectionMatrix;
  24295. private _transformMatrix;
  24296. private _frustumPlanes;
  24297. private _refreshFrustumPlanes;
  24298. private _storedFov;
  24299. private _stateStored;
  24300. /**
  24301. * Instantiates a new camera object.
  24302. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24303. * @see http://doc.babylonjs.com/features/cameras
  24304. * @param name Defines the name of the camera in the scene
  24305. * @param position Defines the position of the camera
  24306. * @param scene Defines the scene the camera belongs too
  24307. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24308. */
  24309. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24310. /**
  24311. * Store current camera state (fov, position, etc..)
  24312. * @returns the camera
  24313. */
  24314. storeState(): Camera;
  24315. /**
  24316. * Restores the camera state values if it has been stored. You must call storeState() first
  24317. */
  24318. protected _restoreStateValues(): boolean;
  24319. /**
  24320. * Restored camera state. You must call storeState() first.
  24321. * @returns true if restored and false otherwise
  24322. */
  24323. restoreState(): boolean;
  24324. /**
  24325. * Gets the class name of the camera.
  24326. * @returns the class name
  24327. */
  24328. getClassName(): string;
  24329. /** @hidden */ protected readonly _isCamera: boolean;
  24330. /**
  24331. * Gets a string representation of the camera useful for debug purpose.
  24332. * @param fullDetails Defines that a more verboe level of logging is required
  24333. * @returns the string representation
  24334. */
  24335. toString(fullDetails?: boolean): string;
  24336. /**
  24337. * Gets the current world space position of the camera.
  24338. */
  24339. readonly globalPosition: Vector3;
  24340. /**
  24341. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24342. * @returns the active meshe list
  24343. */
  24344. getActiveMeshes(): SmartArray<AbstractMesh>;
  24345. /**
  24346. * Check wether a mesh is part of the current active mesh list of the camera
  24347. * @param mesh Defines the mesh to check
  24348. * @returns true if active, false otherwise
  24349. */
  24350. isActiveMesh(mesh: Mesh): boolean;
  24351. /**
  24352. * Is this camera ready to be used/rendered
  24353. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24354. * @return true if the camera is ready
  24355. */
  24356. isReady(completeCheck?: boolean): boolean;
  24357. /** @hidden */ private _initCache(): void;
  24358. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24359. /** @hidden */ private _isSynchronized(): boolean;
  24360. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24361. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24362. /**
  24363. * Attach the input controls to a specific dom element to get the input from.
  24364. * @param element Defines the element the controls should be listened from
  24365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24366. */
  24367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24368. /**
  24369. * Detach the current controls from the specified dom element.
  24370. * @param element Defines the element to stop listening the inputs from
  24371. */
  24372. detachControl(element: HTMLElement): void;
  24373. /**
  24374. * Update the camera state according to the different inputs gathered during the frame.
  24375. */
  24376. update(): void;
  24377. /** @hidden */ private _checkInputs(): void;
  24378. /** @hidden */
  24379. readonly rigCameras: Camera[];
  24380. /**
  24381. * Gets the post process used by the rig cameras
  24382. */
  24383. readonly rigPostProcess: Nullable<PostProcess>;
  24384. /**
  24385. * Internal, gets the first post proces.
  24386. * @returns the first post process to be run on this camera.
  24387. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24388. private _cascadePostProcessesToRigCams;
  24389. /**
  24390. * Attach a post process to the camera.
  24391. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24392. * @param postProcess The post process to attach to the camera
  24393. * @param insertAt The position of the post process in case several of them are in use in the scene
  24394. * @returns the position the post process has been inserted at
  24395. */
  24396. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24397. /**
  24398. * Detach a post process to the camera.
  24399. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24400. * @param postProcess The post process to detach from the camera
  24401. */
  24402. detachPostProcess(postProcess: PostProcess): void;
  24403. /**
  24404. * Gets the current world matrix of the camera
  24405. */
  24406. getWorldMatrix(): Matrix;
  24407. /** @hidden */ private _getViewMatrix(): Matrix;
  24408. /**
  24409. * Gets the current view matrix of the camera.
  24410. * @param force forces the camera to recompute the matrix without looking at the cached state
  24411. * @returns the view matrix
  24412. */
  24413. getViewMatrix(force?: boolean): Matrix;
  24414. /**
  24415. * Freeze the projection matrix.
  24416. * It will prevent the cache check of the camera projection compute and can speed up perf
  24417. * if no parameter of the camera are meant to change
  24418. * @param projection Defines manually a projection if necessary
  24419. */
  24420. freezeProjectionMatrix(projection?: Matrix): void;
  24421. /**
  24422. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24423. */
  24424. unfreezeProjectionMatrix(): void;
  24425. /**
  24426. * Gets the current projection matrix of the camera.
  24427. * @param force forces the camera to recompute the matrix without looking at the cached state
  24428. * @returns the projection matrix
  24429. */
  24430. getProjectionMatrix(force?: boolean): Matrix;
  24431. /**
  24432. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24433. * @returns a Matrix
  24434. */
  24435. getTransformationMatrix(): Matrix;
  24436. private _updateFrustumPlanes;
  24437. /**
  24438. * Checks if a cullable object (mesh...) is in the camera frustum
  24439. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24440. * @param target The object to check
  24441. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24442. * @returns true if the object is in frustum otherwise false
  24443. */
  24444. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24445. /**
  24446. * Checks if a cullable object (mesh...) is in the camera frustum
  24447. * Unlike isInFrustum this cheks the full bounding box
  24448. * @param target The object to check
  24449. * @returns true if the object is in frustum otherwise false
  24450. */
  24451. isCompletelyInFrustum(target: ICullable): boolean;
  24452. /**
  24453. * Gets a ray in the forward direction from the camera.
  24454. * @param length Defines the length of the ray to create
  24455. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24456. * @param origin Defines the start point of the ray which defaults to the camera position
  24457. * @returns the forward ray
  24458. */
  24459. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24460. /**
  24461. * Releases resources associated with this node.
  24462. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24463. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24464. */
  24465. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24466. /** @hidden */ private _isLeftCamera: boolean;
  24467. /**
  24468. * Gets the left camera of a rig setup in case of Rigged Camera
  24469. */
  24470. readonly isLeftCamera: boolean;
  24471. /** @hidden */ private _isRightCamera: boolean;
  24472. /**
  24473. * Gets the right camera of a rig setup in case of Rigged Camera
  24474. */
  24475. readonly isRightCamera: boolean;
  24476. /**
  24477. * Gets the left camera of a rig setup in case of Rigged Camera
  24478. */
  24479. readonly leftCamera: Nullable<FreeCamera>;
  24480. /**
  24481. * Gets the right camera of a rig setup in case of Rigged Camera
  24482. */
  24483. readonly rightCamera: Nullable<FreeCamera>;
  24484. /**
  24485. * Gets the left camera target of a rig setup in case of Rigged Camera
  24486. * @returns the target position
  24487. */
  24488. getLeftTarget(): Nullable<Vector3>;
  24489. /**
  24490. * Gets the right camera target of a rig setup in case of Rigged Camera
  24491. * @returns the target position
  24492. */
  24493. getRightTarget(): Nullable<Vector3>;
  24494. /**
  24495. * @hidden
  24496. */
  24497. setCameraRigMode(mode: number, rigParams: any): void;
  24498. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24499. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24500. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24501. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24502. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24503. protected _updateCameraRotationMatrix(): void;
  24504. protected _updateWebVRCameraRotationMatrix(): void;
  24505. /**
  24506. * This function MUST be overwritten by the different WebVR cameras available.
  24507. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24508. * @hidden
  24509. */ private _getWebVRProjectionMatrix(): Matrix;
  24510. /**
  24511. * This function MUST be overwritten by the different WebVR cameras available.
  24512. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24513. * @hidden
  24514. */ private _getWebVRViewMatrix(): Matrix;
  24515. /** @hidden */
  24516. setCameraRigParameter(name: string, value: any): void;
  24517. /**
  24518. * needs to be overridden by children so sub has required properties to be copied
  24519. * @hidden
  24520. */
  24521. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24522. /**
  24523. * May need to be overridden by children
  24524. * @hidden
  24525. */ private _updateRigCameras(): void;
  24526. /** @hidden */ private _setupInputs(): void;
  24527. /**
  24528. * Serialiaze the camera setup to a json represention
  24529. * @returns the JSON representation
  24530. */
  24531. serialize(): any;
  24532. /**
  24533. * Clones the current camera.
  24534. * @param name The cloned camera name
  24535. * @returns the cloned camera
  24536. */
  24537. clone(name: string): Camera;
  24538. /**
  24539. * Gets the direction of the camera relative to a given local axis.
  24540. * @param localAxis Defines the reference axis to provide a relative direction.
  24541. * @return the direction
  24542. */
  24543. getDirection(localAxis: Vector3): Vector3;
  24544. /**
  24545. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24546. * @param localAxis Defines the reference axis to provide a relative direction.
  24547. * @param result Defines the vector to store the result in
  24548. */
  24549. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24550. /**
  24551. * Gets a camera constructor for a given camera type
  24552. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24553. * @param name The name of the camera the result will be able to instantiate
  24554. * @param scene The scene the result will construct the camera in
  24555. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24556. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24557. * @returns a factory method to construc the camera
  24558. */
  24559. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24560. /**
  24561. * Compute the world matrix of the camera.
  24562. * @returns the camera workd matrix
  24563. */
  24564. computeWorldMatrix(): Matrix;
  24565. /**
  24566. * Parse a JSON and creates the camera from the parsed information
  24567. * @param parsedCamera The JSON to parse
  24568. * @param scene The scene to instantiate the camera in
  24569. * @returns the newly constructed camera
  24570. */
  24571. static Parse(parsedCamera: any, scene: Scene): Camera;
  24572. }
  24573. }
  24574. declare module BABYLON {
  24575. /**
  24576. * Class containing static functions to help procedurally build meshes
  24577. */
  24578. export class DiscBuilder {
  24579. /**
  24580. * Creates a plane polygonal mesh. By default, this is a disc
  24581. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24582. * * 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
  24583. * * 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
  24584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24585. * * 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
  24586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24587. * @param name defines the name of the mesh
  24588. * @param options defines the options used to create the mesh
  24589. * @param scene defines the hosting scene
  24590. * @returns the plane polygonal mesh
  24591. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24592. */
  24593. static CreateDisc(name: string, options: {
  24594. radius?: number;
  24595. tessellation?: number;
  24596. arc?: number;
  24597. updatable?: boolean;
  24598. sideOrientation?: number;
  24599. frontUVs?: Vector4;
  24600. backUVs?: Vector4;
  24601. }, scene?: Nullable<Scene>): Mesh;
  24602. }
  24603. }
  24604. declare module BABYLON {
  24605. /**
  24606. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24607. *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.
  24608. * The SPS is also a particle system. It provides some methods to manage the particles.
  24609. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24610. *
  24611. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24612. */
  24613. export class SolidParticleSystem implements IDisposable {
  24614. /**
  24615. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24616. * Example : var p = SPS.particles[i];
  24617. */
  24618. particles: SolidParticle[];
  24619. /**
  24620. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24621. */
  24622. nbParticles: number;
  24623. /**
  24624. * If the particles must ever face the camera (default false). Useful for planar particles.
  24625. */
  24626. billboard: boolean;
  24627. /**
  24628. * Recompute normals when adding a shape
  24629. */
  24630. recomputeNormals: boolean;
  24631. /**
  24632. * This a counter ofr your own usage. It's not set by any SPS functions.
  24633. */
  24634. counter: number;
  24635. /**
  24636. * The SPS name. This name is also given to the underlying mesh.
  24637. */
  24638. name: string;
  24639. /**
  24640. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24641. */
  24642. mesh: Mesh;
  24643. /**
  24644. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24645. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24646. */
  24647. vars: any;
  24648. /**
  24649. * This array is populated when the SPS is set as 'pickable'.
  24650. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24651. * Each element of this array is an object `{idx: int, faceId: int}`.
  24652. * `idx` is the picked particle index in the `SPS.particles` array
  24653. * `faceId` is the picked face index counted within this particle.
  24654. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24655. */
  24656. pickedParticles: {
  24657. idx: number;
  24658. faceId: number;
  24659. }[];
  24660. /**
  24661. * This array is populated when `enableDepthSort` is set to true.
  24662. * Each element of this array is an instance of the class DepthSortedParticle.
  24663. */
  24664. depthSortedParticles: DepthSortedParticle[];
  24665. /**
  24666. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24667. * @hidden
  24668. */ private _bSphereOnly: boolean;
  24669. /**
  24670. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24671. * @hidden
  24672. */ private _bSphereRadiusFactor: number;
  24673. private _scene;
  24674. private _positions;
  24675. private _indices;
  24676. private _normals;
  24677. private _colors;
  24678. private _uvs;
  24679. private _indices32;
  24680. private _positions32;
  24681. private _normals32;
  24682. private _fixedNormal32;
  24683. private _colors32;
  24684. private _uvs32;
  24685. private _index;
  24686. private _updatable;
  24687. private _pickable;
  24688. private _isVisibilityBoxLocked;
  24689. private _alwaysVisible;
  24690. private _depthSort;
  24691. private _shapeCounter;
  24692. private _copy;
  24693. private _color;
  24694. private _computeParticleColor;
  24695. private _computeParticleTexture;
  24696. private _computeParticleRotation;
  24697. private _computeParticleVertex;
  24698. private _computeBoundingBox;
  24699. private _depthSortParticles;
  24700. private _camera;
  24701. private _mustUnrotateFixedNormals;
  24702. private _particlesIntersect;
  24703. private _needs32Bits;
  24704. /**
  24705. * Creates a SPS (Solid Particle System) object.
  24706. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24707. * @param scene (Scene) is the scene in which the SPS is added.
  24708. * @param options defines the options of the sps e.g.
  24709. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24710. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24711. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24712. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24713. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24714. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24715. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24716. */
  24717. constructor(name: string, scene: Scene, options?: {
  24718. updatable?: boolean;
  24719. isPickable?: boolean;
  24720. enableDepthSort?: boolean;
  24721. particleIntersection?: boolean;
  24722. boundingSphereOnly?: boolean;
  24723. bSphereRadiusFactor?: number;
  24724. });
  24725. /**
  24726. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24727. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24728. * @returns the created mesh
  24729. */
  24730. buildMesh(): Mesh;
  24731. /**
  24732. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24733. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24734. * Thus the particles generated from `digest()` have their property `position` set yet.
  24735. * @param mesh ( Mesh ) is the mesh to be digested
  24736. * @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
  24737. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24738. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24739. * @returns the current SPS
  24740. */
  24741. digest(mesh: Mesh, options?: {
  24742. facetNb?: number;
  24743. number?: number;
  24744. delta?: number;
  24745. }): SolidParticleSystem;
  24746. private _unrotateFixedNormals;
  24747. private _resetCopy;
  24748. private _meshBuilder;
  24749. private _posToShape;
  24750. private _uvsToShapeUV;
  24751. private _addParticle;
  24752. /**
  24753. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24754. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24755. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24756. * @param nb (positive integer) the number of particles to be created from this model
  24757. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24758. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24759. * @returns the number of shapes in the system
  24760. */
  24761. addShape(mesh: Mesh, nb: number, options?: {
  24762. positionFunction?: any;
  24763. vertexFunction?: any;
  24764. }): number;
  24765. private _rebuildParticle;
  24766. /**
  24767. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24768. * @returns the SPS.
  24769. */
  24770. rebuildMesh(): SolidParticleSystem;
  24771. /**
  24772. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24773. * This method calls `updateParticle()` for each particle of the SPS.
  24774. * For an animated SPS, it is usually called within the render loop.
  24775. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24776. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24777. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24778. * @returns the SPS.
  24779. */
  24780. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24781. /**
  24782. * Disposes the SPS.
  24783. */
  24784. dispose(): void;
  24785. /**
  24786. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24787. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24788. * @returns the SPS.
  24789. */
  24790. refreshVisibleSize(): SolidParticleSystem;
  24791. /**
  24792. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24793. * @param size the size (float) of the visibility box
  24794. * note : this doesn't lock the SPS mesh bounding box.
  24795. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24796. */
  24797. setVisibilityBox(size: number): void;
  24798. /**
  24799. * Gets whether the SPS as always visible or not
  24800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24801. */
  24802. /**
  24803. * Sets the SPS as always visible or not
  24804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24805. */
  24806. isAlwaysVisible: boolean;
  24807. /**
  24808. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24810. */
  24811. /**
  24812. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24813. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24814. */
  24815. isVisibilityBoxLocked: boolean;
  24816. /**
  24817. * Tells to `setParticles()` to compute the particle rotations or not.
  24818. * Default value : true. The SPS is faster when it's set to false.
  24819. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24820. */
  24821. /**
  24822. * Gets if `setParticles()` computes the particle rotations or not.
  24823. * Default value : true. The SPS is faster when it's set to false.
  24824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24825. */
  24826. computeParticleRotation: boolean;
  24827. /**
  24828. * Tells to `setParticles()` to compute the particle colors or not.
  24829. * Default value : true. The SPS is faster when it's set to false.
  24830. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24831. */
  24832. /**
  24833. * Gets if `setParticles()` computes the particle colors or not.
  24834. * Default value : true. The SPS is faster when it's set to false.
  24835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24836. */
  24837. computeParticleColor: boolean;
  24838. /**
  24839. * Gets if `setParticles()` computes the particle textures or not.
  24840. * Default value : true. The SPS is faster when it's set to false.
  24841. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24842. */
  24843. computeParticleTexture: boolean;
  24844. /**
  24845. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24846. * Default value : false. The SPS is faster when it's set to false.
  24847. * Note : the particle custom vertex positions aren't stored values.
  24848. */
  24849. /**
  24850. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24851. * Default value : false. The SPS is faster when it's set to false.
  24852. * Note : the particle custom vertex positions aren't stored values.
  24853. */
  24854. computeParticleVertex: boolean;
  24855. /**
  24856. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24857. */
  24858. /**
  24859. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24860. */
  24861. computeBoundingBox: boolean;
  24862. /**
  24863. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24864. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24865. * Default : `true`
  24866. */
  24867. /**
  24868. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24870. * Default : `true`
  24871. */
  24872. depthSortParticles: boolean;
  24873. /**
  24874. * This function does nothing. It may be overwritten to set all the particle first values.
  24875. * The SPS doesn't call this function, you may have to call it by your own.
  24876. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24877. */
  24878. initParticles(): void;
  24879. /**
  24880. * This function does nothing. It may be overwritten to recycle a particle.
  24881. * The SPS doesn't call this function, you may have to call it by your own.
  24882. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24883. * @param particle The particle to recycle
  24884. * @returns the recycled particle
  24885. */
  24886. recycleParticle(particle: SolidParticle): SolidParticle;
  24887. /**
  24888. * Updates a particle : this function should be overwritten by the user.
  24889. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24890. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24891. * @example : just set a particle position or velocity and recycle conditions
  24892. * @param particle The particle to update
  24893. * @returns the updated particle
  24894. */
  24895. updateParticle(particle: SolidParticle): SolidParticle;
  24896. /**
  24897. * Updates a vertex of a particle : it can be overwritten by the user.
  24898. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24899. * @param particle the current particle
  24900. * @param vertex the current index of the current particle
  24901. * @param pt the index of the current vertex in the particle shape
  24902. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  24903. * @example : just set a vertex particle position
  24904. * @returns the updated vertex
  24905. */
  24906. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24907. /**
  24908. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24909. * This does nothing and may be overwritten by the user.
  24910. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24912. * @param update the boolean update value actually passed to setParticles()
  24913. */
  24914. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24915. /**
  24916. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24917. * This will be passed three parameters.
  24918. * This does nothing and may be overwritten by the user.
  24919. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24920. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24921. * @param update the boolean update value actually passed to setParticles()
  24922. */
  24923. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24924. }
  24925. }
  24926. declare module BABYLON {
  24927. /**
  24928. * Represents one particle of a solid particle system.
  24929. */
  24930. export class SolidParticle {
  24931. /**
  24932. * particle global index
  24933. */
  24934. idx: number;
  24935. /**
  24936. * The color of the particle
  24937. */
  24938. color: Nullable<Color4>;
  24939. /**
  24940. * The world space position of the particle.
  24941. */
  24942. position: Vector3;
  24943. /**
  24944. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24945. */
  24946. rotation: Vector3;
  24947. /**
  24948. * The world space rotation quaternion of the particle.
  24949. */
  24950. rotationQuaternion: Nullable<Quaternion>;
  24951. /**
  24952. * The scaling of the particle.
  24953. */
  24954. scaling: Vector3;
  24955. /**
  24956. * The uvs of the particle.
  24957. */
  24958. uvs: Vector4;
  24959. /**
  24960. * The current speed of the particle.
  24961. */
  24962. velocity: Vector3;
  24963. /**
  24964. * The pivot point in the particle local space.
  24965. */
  24966. pivot: Vector3;
  24967. /**
  24968. * Must the particle be translated from its pivot point in its local space ?
  24969. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24970. * Default : false
  24971. */
  24972. translateFromPivot: boolean;
  24973. /**
  24974. * Is the particle active or not ?
  24975. */
  24976. alive: boolean;
  24977. /**
  24978. * Is the particle visible or not ?
  24979. */
  24980. isVisible: boolean;
  24981. /**
  24982. * Index of this particle in the global "positions" array (Internal use)
  24983. * @hidden
  24984. */ private _pos: number;
  24985. /**
  24986. * @hidden Index of this particle in the global "indices" array (Internal use)
  24987. */ private _ind: number;
  24988. /**
  24989. * @hidden ModelShape of this particle (Internal use)
  24990. */ private _model: ModelShape;
  24991. /**
  24992. * ModelShape id of this particle
  24993. */
  24994. shapeId: number;
  24995. /**
  24996. * Index of the particle in its shape id
  24997. */
  24998. idxInShape: number;
  24999. /**
  25000. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25001. */ private _modelBoundingInfo: BoundingInfo;
  25002. /**
  25003. * @hidden Particle BoundingInfo object (Internal use)
  25004. */ private _boundingInfo: BoundingInfo;
  25005. /**
  25006. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25007. */ private _sps: SolidParticleSystem;
  25008. /**
  25009. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25010. */ private _stillInvisible: boolean;
  25011. /**
  25012. * @hidden Last computed particle rotation matrix
  25013. */ private _rotationMatrix: number[];
  25014. /**
  25015. * Parent particle Id, if any.
  25016. * Default null.
  25017. */
  25018. parentId: Nullable<number>;
  25019. /**
  25020. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25021. * The possible values are :
  25022. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25023. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25024. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25025. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25026. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25027. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25028. * */
  25029. cullingStrategy: number;
  25030. /**
  25031. * @hidden Internal global position in the SPS.
  25032. */ private _globalPosition: Vector3;
  25033. /**
  25034. * Creates a Solid Particle object.
  25035. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25036. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25037. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25038. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25039. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25040. * @param shapeId (integer) is the model shape identifier in the SPS.
  25041. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25042. * @param sps defines the sps it is associated to
  25043. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25044. */
  25045. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25046. /**
  25047. * Legacy support, changed scale to scaling
  25048. */
  25049. /**
  25050. * Legacy support, changed scale to scaling
  25051. */
  25052. scale: Vector3;
  25053. /**
  25054. * Legacy support, changed quaternion to rotationQuaternion
  25055. */
  25056. /**
  25057. * Legacy support, changed quaternion to rotationQuaternion
  25058. */
  25059. quaternion: Nullable<Quaternion>;
  25060. /**
  25061. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25062. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25063. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25064. * @returns true if it intersects
  25065. */
  25066. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25067. /**
  25068. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25069. * A particle is in the frustum if its bounding box intersects the frustum
  25070. * @param frustumPlanes defines the frustum to test
  25071. * @returns true if the particle is in the frustum planes
  25072. */
  25073. isInFrustum(frustumPlanes: Plane[]): boolean;
  25074. /**
  25075. * get the rotation matrix of the particle
  25076. * @hidden
  25077. */
  25078. getRotationMatrix(m: Matrix): void;
  25079. }
  25080. /**
  25081. * Represents the shape of the model used by one particle of a solid particle system.
  25082. * SPS internal tool, don't use it manually.
  25083. */
  25084. export class ModelShape {
  25085. /**
  25086. * The shape id
  25087. * @hidden
  25088. */
  25089. shapeID: number;
  25090. /**
  25091. * flat array of model positions (internal use)
  25092. * @hidden
  25093. */ private _shape: Vector3[];
  25094. /**
  25095. * flat array of model UVs (internal use)
  25096. * @hidden
  25097. */ private _shapeUV: number[];
  25098. /**
  25099. * length of the shape in the model indices array (internal use)
  25100. * @hidden
  25101. */ private _indicesLength: number;
  25102. /**
  25103. * Custom position function (internal use)
  25104. * @hidden
  25105. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25106. /**
  25107. * Custom vertex function (internal use)
  25108. * @hidden
  25109. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25110. /**
  25111. * 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.
  25112. * SPS internal tool, don't use it manually.
  25113. * @hidden
  25114. */
  25115. 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>);
  25116. }
  25117. /**
  25118. * Represents a Depth Sorted Particle in the solid particle system.
  25119. */
  25120. export class DepthSortedParticle {
  25121. /**
  25122. * Index of the particle in the "indices" array
  25123. */
  25124. ind: number;
  25125. /**
  25126. * Length of the particle shape in the "indices" array
  25127. */
  25128. indicesLength: number;
  25129. /**
  25130. * Squared distance from the particle to the camera
  25131. */
  25132. sqDistance: number;
  25133. }
  25134. }
  25135. declare module BABYLON {
  25136. /**
  25137. * @hidden
  25138. */
  25139. 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>>;
  25140. }
  25141. }
  25142. declare module BABYLON {
  25143. /** @hidden */ private class _FacetDataStorage {
  25144. facetPositions: Vector3[];
  25145. facetNormals: Vector3[];
  25146. facetPartitioning: number[][];
  25147. facetNb: number;
  25148. partitioningSubdivisions: number;
  25149. partitioningBBoxRatio: number;
  25150. facetDataEnabled: boolean;
  25151. facetParameters: any;
  25152. bbSize: Vector3;
  25153. subDiv: {
  25154. max: number;
  25155. X: number;
  25156. Y: number;
  25157. Z: number;
  25158. };
  25159. facetDepthSort: boolean;
  25160. facetDepthSortEnabled: boolean;
  25161. depthSortedIndices: IndicesArray;
  25162. depthSortedFacets: {
  25163. ind: number;
  25164. sqDistance: number;
  25165. }[];
  25166. facetDepthSortFunction: (f1: {
  25167. ind: number;
  25168. sqDistance: number;
  25169. }, f2: {
  25170. ind: number;
  25171. sqDistance: number;
  25172. }) => number;
  25173. facetDepthSortFrom: Vector3;
  25174. facetDepthSortOrigin: Vector3;
  25175. invertedMatrix: Matrix;
  25176. }
  25177. /**
  25178. * @hidden
  25179. **/ 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;
  25180. }
  25181. /**
  25182. * Class used to store all common mesh properties
  25183. */
  25184. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25185. /** No occlusion */
  25186. static OCCLUSION_TYPE_NONE: number;
  25187. /** Occlusion set to optimisitic */
  25188. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25189. /** Occlusion set to strict */
  25190. static OCCLUSION_TYPE_STRICT: number;
  25191. /** Use an accurante occlusion algorithm */
  25192. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25193. /** Use a conservative occlusion algorithm */
  25194. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25195. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25196. * Test order :
  25197. * Is the bounding sphere outside the frustum ?
  25198. * If not, are the bounding box vertices outside the frustum ?
  25199. * It not, then the cullable object is in the frustum.
  25200. */
  25201. static readonly CULLINGSTRATEGY_STANDARD: number;
  25202. /** Culling strategy : Bounding Sphere Only.
  25203. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25204. * It's also less accurate than the standard because some not visible objects can still be selected.
  25205. * Test : is the bounding sphere outside the frustum ?
  25206. * If not, then the cullable object is in the frustum.
  25207. */
  25208. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25209. /** Culling strategy : Optimistic Inclusion.
  25210. * This in an inclusion test first, then the standard exclusion test.
  25211. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25212. * 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.
  25213. * Anyway, it's as accurate as the standard strategy.
  25214. * Test :
  25215. * Is the cullable object bounding sphere center in the frustum ?
  25216. * If not, apply the default culling strategy.
  25217. */
  25218. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25219. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25220. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25221. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25222. * 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.
  25223. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25224. * Test :
  25225. * Is the cullable object bounding sphere center in the frustum ?
  25226. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25227. */
  25228. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25229. /**
  25230. * No billboard
  25231. */
  25232. static readonly BILLBOARDMODE_NONE: number;
  25233. /** Billboard on X axis */
  25234. static readonly BILLBOARDMODE_X: number;
  25235. /** Billboard on Y axis */
  25236. static readonly BILLBOARDMODE_Y: number;
  25237. /** Billboard on Z axis */
  25238. static readonly BILLBOARDMODE_Z: number;
  25239. /** Billboard on all axes */
  25240. static readonly BILLBOARDMODE_ALL: number;
  25241. /** Billboard on using position instead of orientation */
  25242. static readonly BILLBOARDMODE_USE_POSITION: number;
  25243. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25244. /**
  25245. * The culling strategy to use to check whether the mesh must be rendered or not.
  25246. * This value can be changed at any time and will be used on the next render mesh selection.
  25247. * The possible values are :
  25248. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25249. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25250. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25251. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25252. * Please read each static variable documentation to get details about the culling process.
  25253. * */
  25254. cullingStrategy: number;
  25255. /**
  25256. * Gets the number of facets in the mesh
  25257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25258. */
  25259. readonly facetNb: number;
  25260. /**
  25261. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25263. */
  25264. partitioningSubdivisions: number;
  25265. /**
  25266. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25267. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25269. */
  25270. partitioningBBoxRatio: number;
  25271. /**
  25272. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25273. * Works only for updatable meshes.
  25274. * Doesn't work with multi-materials
  25275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25276. */
  25277. mustDepthSortFacets: boolean;
  25278. /**
  25279. * The location (Vector3) where the facet depth sort must be computed from.
  25280. * By default, the active camera position.
  25281. * Used only when facet depth sort is enabled
  25282. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25283. */
  25284. facetDepthSortFrom: Vector3;
  25285. /**
  25286. * gets a boolean indicating if facetData is enabled
  25287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25288. */
  25289. readonly isFacetDataEnabled: boolean;
  25290. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25291. /**
  25292. * An event triggered when this mesh collides with another one
  25293. */
  25294. onCollideObservable: Observable<AbstractMesh>;
  25295. /** Set a function to call when this mesh collides with another one */
  25296. onCollide: () => void;
  25297. /**
  25298. * An event triggered when the collision's position changes
  25299. */
  25300. onCollisionPositionChangeObservable: Observable<Vector3>;
  25301. /** Set a function to call when the collision's position changes */
  25302. onCollisionPositionChange: () => void;
  25303. /**
  25304. * An event triggered when material is changed
  25305. */
  25306. onMaterialChangedObservable: Observable<AbstractMesh>;
  25307. /**
  25308. * Gets or sets the orientation for POV movement & rotation
  25309. */
  25310. definedFacingForward: boolean;
  25311. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25312. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25313. /**
  25314. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25315. */
  25316. /**
  25317. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25318. */
  25319. visibility: number;
  25320. /** Gets or sets the alpha index used to sort transparent meshes
  25321. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25322. */
  25323. alphaIndex: number;
  25324. /**
  25325. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25326. */
  25327. isVisible: boolean;
  25328. /**
  25329. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25330. */
  25331. isPickable: boolean;
  25332. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25333. showSubMeshesBoundingBox: boolean;
  25334. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25335. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25336. */
  25337. isBlocker: boolean;
  25338. /**
  25339. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25340. */
  25341. enablePointerMoveEvents: boolean;
  25342. /**
  25343. * Specifies the rendering group id for this mesh (0 by default)
  25344. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25345. */
  25346. renderingGroupId: number;
  25347. private _material;
  25348. /** Gets or sets current material */
  25349. material: Nullable<Material>;
  25350. /**
  25351. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25352. * @see http://doc.babylonjs.com/babylon101/shadows
  25353. */
  25354. receiveShadows: boolean;
  25355. /** Defines color to use when rendering outline */
  25356. outlineColor: Color3;
  25357. /** Define width to use when rendering outline */
  25358. outlineWidth: number;
  25359. /** Defines color to use when rendering overlay */
  25360. overlayColor: Color3;
  25361. /** Defines alpha to use when rendering overlay */
  25362. overlayAlpha: number;
  25363. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25364. hasVertexAlpha: boolean;
  25365. /** 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) */
  25366. useVertexColors: boolean;
  25367. /**
  25368. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25369. */
  25370. computeBonesUsingShaders: boolean;
  25371. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25372. numBoneInfluencers: number;
  25373. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25374. applyFog: boolean;
  25375. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25376. useOctreeForRenderingSelection: boolean;
  25377. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25378. useOctreeForPicking: boolean;
  25379. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25380. useOctreeForCollisions: boolean;
  25381. /**
  25382. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25383. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25384. */
  25385. layerMask: number;
  25386. /**
  25387. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25388. */
  25389. alwaysSelectAsActiveMesh: boolean;
  25390. /**
  25391. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25392. */
  25393. doNotSyncBoundingInfo: boolean;
  25394. /**
  25395. * Gets or sets the current action manager
  25396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25397. */
  25398. actionManager: Nullable<AbstractActionManager>;
  25399. private _meshCollisionData;
  25400. /**
  25401. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25403. */
  25404. ellipsoid: Vector3;
  25405. /**
  25406. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25408. */
  25409. ellipsoidOffset: Vector3;
  25410. /**
  25411. * Gets or sets a collision mask used to mask collisions (default is -1).
  25412. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25413. */
  25414. collisionMask: number;
  25415. /**
  25416. * Gets or sets the current collision group mask (-1 by default).
  25417. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25418. */
  25419. collisionGroup: number;
  25420. /**
  25421. * Defines edge width used when edgesRenderer is enabled
  25422. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25423. */
  25424. edgesWidth: number;
  25425. /**
  25426. * Defines edge color used when edgesRenderer is enabled
  25427. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25428. */
  25429. edgesColor: Color4;
  25430. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25431. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25432. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25433. /** @hidden */ private _renderId: number;
  25434. /**
  25435. * Gets or sets the list of subMeshes
  25436. * @see http://doc.babylonjs.com/how_to/multi_materials
  25437. */
  25438. subMeshes: SubMesh[];
  25439. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25440. /** @hidden */ private _unIndexed: boolean;
  25441. /** @hidden */ private _lightSources: Light[];
  25442. /** Gets the list of lights affecting that mesh */
  25443. readonly lightSources: Light[];
  25444. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25445. /** @hidden */ private _waitingData: {
  25446. lods: Nullable<any>;
  25447. actions: Nullable<any>;
  25448. freezeWorldMatrix: Nullable<boolean>;
  25449. };
  25450. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25451. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25452. /**
  25453. * Gets or sets a skeleton to apply skining transformations
  25454. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25455. */
  25456. skeleton: Nullable<Skeleton>;
  25457. /**
  25458. * An event triggered when the mesh is rebuilt.
  25459. */
  25460. onRebuildObservable: Observable<AbstractMesh>;
  25461. /**
  25462. * Creates a new AbstractMesh
  25463. * @param name defines the name of the mesh
  25464. * @param scene defines the hosting scene
  25465. */
  25466. constructor(name: string, scene?: Nullable<Scene>);
  25467. /**
  25468. * Returns the string "AbstractMesh"
  25469. * @returns "AbstractMesh"
  25470. */
  25471. getClassName(): string;
  25472. /**
  25473. * Gets a string representation of the current mesh
  25474. * @param fullDetails defines a boolean indicating if full details must be included
  25475. * @returns a string representation of the current mesh
  25476. */
  25477. toString(fullDetails?: boolean): string;
  25478. /**
  25479. * @hidden
  25480. */
  25481. protected _getEffectiveParent(): Nullable<Node>;
  25482. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25483. /** @hidden */ private _rebuild(): void;
  25484. /** @hidden */ private _resyncLightSources(): void;
  25485. /** @hidden */ private _resyncLighSource(light: Light): void;
  25486. /** @hidden */ private _unBindEffect(): void;
  25487. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25488. private _markSubMeshesAsDirty;
  25489. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25490. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25491. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25492. /**
  25493. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25494. */
  25495. scaling: Vector3;
  25496. /**
  25497. * Returns true if the mesh is blocked. Implemented by child classes
  25498. */
  25499. readonly isBlocked: boolean;
  25500. /**
  25501. * Returns the mesh itself by default. Implemented by child classes
  25502. * @param camera defines the camera to use to pick the right LOD level
  25503. * @returns the currentAbstractMesh
  25504. */
  25505. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25506. /**
  25507. * Returns 0 by default. Implemented by child classes
  25508. * @returns an integer
  25509. */
  25510. getTotalVertices(): number;
  25511. /**
  25512. * Returns a positive integer : the total number of indices in this mesh geometry.
  25513. * @returns the numner of indices or zero if the mesh has no geometry.
  25514. */
  25515. getTotalIndices(): number;
  25516. /**
  25517. * Returns null by default. Implemented by child classes
  25518. * @returns null
  25519. */
  25520. getIndices(): Nullable<IndicesArray>;
  25521. /**
  25522. * Returns the array of the requested vertex data kind. Implemented by child classes
  25523. * @param kind defines the vertex data kind to use
  25524. * @returns null
  25525. */
  25526. getVerticesData(kind: string): Nullable<FloatArray>;
  25527. /**
  25528. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25529. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25530. * Note that a new underlying VertexBuffer object is created each call.
  25531. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25532. * @param kind defines vertex data kind:
  25533. * * VertexBuffer.PositionKind
  25534. * * VertexBuffer.UVKind
  25535. * * VertexBuffer.UV2Kind
  25536. * * VertexBuffer.UV3Kind
  25537. * * VertexBuffer.UV4Kind
  25538. * * VertexBuffer.UV5Kind
  25539. * * VertexBuffer.UV6Kind
  25540. * * VertexBuffer.ColorKind
  25541. * * VertexBuffer.MatricesIndicesKind
  25542. * * VertexBuffer.MatricesIndicesExtraKind
  25543. * * VertexBuffer.MatricesWeightsKind
  25544. * * VertexBuffer.MatricesWeightsExtraKind
  25545. * @param data defines the data source
  25546. * @param updatable defines if the data must be flagged as updatable (or static)
  25547. * @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
  25548. * @returns the current mesh
  25549. */
  25550. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25551. /**
  25552. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25553. * If the mesh has no geometry, it is simply returned as it is.
  25554. * @param kind defines vertex data kind:
  25555. * * VertexBuffer.PositionKind
  25556. * * VertexBuffer.UVKind
  25557. * * VertexBuffer.UV2Kind
  25558. * * VertexBuffer.UV3Kind
  25559. * * VertexBuffer.UV4Kind
  25560. * * VertexBuffer.UV5Kind
  25561. * * VertexBuffer.UV6Kind
  25562. * * VertexBuffer.ColorKind
  25563. * * VertexBuffer.MatricesIndicesKind
  25564. * * VertexBuffer.MatricesIndicesExtraKind
  25565. * * VertexBuffer.MatricesWeightsKind
  25566. * * VertexBuffer.MatricesWeightsExtraKind
  25567. * @param data defines the data source
  25568. * @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
  25569. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25570. * @returns the current mesh
  25571. */
  25572. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25573. /**
  25574. * Sets the mesh indices,
  25575. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25576. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25577. * @param totalVertices Defines the total number of vertices
  25578. * @returns the current mesh
  25579. */
  25580. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25581. /**
  25582. * Gets a boolean indicating if specific vertex data is present
  25583. * @param kind defines the vertex data kind to use
  25584. * @returns true is data kind is present
  25585. */
  25586. isVerticesDataPresent(kind: string): boolean;
  25587. /**
  25588. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25589. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25590. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25591. * @returns a BoundingInfo
  25592. */
  25593. getBoundingInfo(): BoundingInfo;
  25594. /**
  25595. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25596. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25597. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25598. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25599. * @returns the current mesh
  25600. */
  25601. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25602. /**
  25603. * Overwrite the current bounding info
  25604. * @param boundingInfo defines the new bounding info
  25605. * @returns the current mesh
  25606. */
  25607. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25608. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25609. readonly useBones: boolean;
  25610. /** @hidden */ private _preActivate(): void;
  25611. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25612. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25613. /** @hidden */ private _postActivate(): void;
  25614. /** @hidden */ private _freeze(): void;
  25615. /** @hidden */ private _unFreeze(): void;
  25616. /**
  25617. * Gets the current world matrix
  25618. * @returns a Matrix
  25619. */
  25620. getWorldMatrix(): Matrix;
  25621. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25622. /**
  25623. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25624. */
  25625. readonly isAnInstance: boolean;
  25626. /**
  25627. * Gets a boolean indicating if this mesh has instances
  25628. */
  25629. readonly hasInstances: boolean;
  25630. /**
  25631. * Perform relative position change from the point of view of behind the front of the mesh.
  25632. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25633. * Supports definition of mesh facing forward or backward
  25634. * @param amountRight defines the distance on the right axis
  25635. * @param amountUp defines the distance on the up axis
  25636. * @param amountForward defines the distance on the forward axis
  25637. * @returns the current mesh
  25638. */
  25639. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25640. /**
  25641. * Calculate relative position change from the point of view of behind the front of the mesh.
  25642. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25643. * Supports definition of mesh facing forward or backward
  25644. * @param amountRight defines the distance on the right axis
  25645. * @param amountUp defines the distance on the up axis
  25646. * @param amountForward defines the distance on the forward axis
  25647. * @returns the new displacement vector
  25648. */
  25649. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25650. /**
  25651. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25652. * Supports definition of mesh facing forward or backward
  25653. * @param flipBack defines the flip
  25654. * @param twirlClockwise defines the twirl
  25655. * @param tiltRight defines the tilt
  25656. * @returns the current mesh
  25657. */
  25658. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25659. /**
  25660. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25661. * Supports definition of mesh facing forward or backward.
  25662. * @param flipBack defines the flip
  25663. * @param twirlClockwise defines the twirl
  25664. * @param tiltRight defines the tilt
  25665. * @returns the new rotation vector
  25666. */
  25667. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25668. /**
  25669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25670. * This means the mesh underlying bounding box and sphere are recomputed.
  25671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25672. * @returns the current mesh
  25673. */
  25674. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25675. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25676. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25677. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25678. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25679. /** @hidden */
  25680. protected _afterComputeWorldMatrix(): void;
  25681. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25682. /**
  25683. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25684. * A mesh is in the frustum if its bounding box intersects the frustum
  25685. * @param frustumPlanes defines the frustum to test
  25686. * @returns true if the mesh is in the frustum planes
  25687. */
  25688. isInFrustum(frustumPlanes: Plane[]): boolean;
  25689. /**
  25690. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25691. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25692. * @param frustumPlanes defines the frustum to test
  25693. * @returns true if the mesh is completely in the frustum planes
  25694. */
  25695. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25696. /**
  25697. * True if the mesh intersects another mesh or a SolidParticle object
  25698. * @param mesh defines a target mesh or SolidParticle to test
  25699. * @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)
  25700. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25701. * @returns true if there is an intersection
  25702. */
  25703. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25704. /**
  25705. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25706. * @param point defines the point to test
  25707. * @returns true if there is an intersection
  25708. */
  25709. intersectsPoint(point: Vector3): boolean;
  25710. /**
  25711. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25713. */
  25714. checkCollisions: boolean;
  25715. /**
  25716. * Gets Collider object used to compute collisions (not physics)
  25717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25718. */
  25719. readonly collider: Nullable<Collider>;
  25720. /**
  25721. * Move the mesh using collision engine
  25722. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25723. * @param displacement defines the requested displacement vector
  25724. * @returns the current mesh
  25725. */
  25726. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25727. private _onCollisionPositionChange;
  25728. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25729. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25730. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25731. /** @hidden */ private _generatePointsArray(): boolean;
  25732. /**
  25733. * Checks if the passed Ray intersects with the mesh
  25734. * @param ray defines the ray to use
  25735. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25736. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25737. * @returns the picking info
  25738. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25739. */
  25740. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25741. /**
  25742. * Clones the current mesh
  25743. * @param name defines the mesh name
  25744. * @param newParent defines the new mesh parent
  25745. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25746. * @returns the new mesh
  25747. */
  25748. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25749. /**
  25750. * Disposes all the submeshes of the current meshnp
  25751. * @returns the current mesh
  25752. */
  25753. releaseSubMeshes(): AbstractMesh;
  25754. /**
  25755. * Releases resources associated with this abstract mesh.
  25756. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25757. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25758. */
  25759. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25760. /**
  25761. * Adds the passed mesh as a child to the current mesh
  25762. * @param mesh defines the child mesh
  25763. * @returns the current mesh
  25764. */
  25765. addChild(mesh: AbstractMesh): AbstractMesh;
  25766. /**
  25767. * Removes the passed mesh from the current mesh children list
  25768. * @param mesh defines the child mesh
  25769. * @returns the current mesh
  25770. */
  25771. removeChild(mesh: AbstractMesh): AbstractMesh;
  25772. /** @hidden */
  25773. private _initFacetData;
  25774. /**
  25775. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25776. * This method can be called within the render loop.
  25777. * 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
  25778. * @returns the current mesh
  25779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25780. */
  25781. updateFacetData(): AbstractMesh;
  25782. /**
  25783. * Returns the facetLocalNormals array.
  25784. * The normals are expressed in the mesh local spac
  25785. * @returns an array of Vector3
  25786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25787. */
  25788. getFacetLocalNormals(): Vector3[];
  25789. /**
  25790. * Returns the facetLocalPositions array.
  25791. * The facet positions are expressed in the mesh local space
  25792. * @returns an array of Vector3
  25793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25794. */
  25795. getFacetLocalPositions(): Vector3[];
  25796. /**
  25797. * Returns the facetLocalPartioning array
  25798. * @returns an array of array of numbers
  25799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25800. */
  25801. getFacetLocalPartitioning(): number[][];
  25802. /**
  25803. * Returns the i-th facet position in the world system.
  25804. * This method allocates a new Vector3 per call
  25805. * @param i defines the facet index
  25806. * @returns a new Vector3
  25807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25808. */
  25809. getFacetPosition(i: number): Vector3;
  25810. /**
  25811. * Sets the reference Vector3 with the i-th facet position in the world system
  25812. * @param i defines the facet index
  25813. * @param ref defines the target vector
  25814. * @returns the current mesh
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25816. */
  25817. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25818. /**
  25819. * Returns the i-th facet normal in the world system.
  25820. * This method allocates a new Vector3 per call
  25821. * @param i defines the facet index
  25822. * @returns a new Vector3
  25823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25824. */
  25825. getFacetNormal(i: number): Vector3;
  25826. /**
  25827. * Sets the reference Vector3 with the i-th facet normal in the world system
  25828. * @param i defines the facet index
  25829. * @param ref defines the target vector
  25830. * @returns the current mesh
  25831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25832. */
  25833. getFacetNormalToRef(i: number, ref: Vector3): this;
  25834. /**
  25835. * 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)
  25836. * @param x defines x coordinate
  25837. * @param y defines y coordinate
  25838. * @param z defines z coordinate
  25839. * @returns the array of facet indexes
  25840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25841. */
  25842. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25843. /**
  25844. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25845. * @param projected sets as the (x,y,z) world projection on the facet
  25846. * @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
  25847. * @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
  25848. * @param x defines x coordinate
  25849. * @param y defines y coordinate
  25850. * @param z defines z coordinate
  25851. * @returns the face index if found (or null instead)
  25852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25853. */
  25854. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25855. /**
  25856. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25857. * @param projected sets as the (x,y,z) local projection on the facet
  25858. * @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
  25859. * @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
  25860. * @param x defines x coordinate
  25861. * @param y defines y coordinate
  25862. * @param z defines z coordinate
  25863. * @returns the face index if found (or null instead)
  25864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25865. */
  25866. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25867. /**
  25868. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25869. * @returns the parameters
  25870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25871. */
  25872. getFacetDataParameters(): any;
  25873. /**
  25874. * Disables the feature FacetData and frees the related memory
  25875. * @returns the current mesh
  25876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25877. */
  25878. disableFacetData(): AbstractMesh;
  25879. /**
  25880. * Updates the AbstractMesh indices array
  25881. * @param indices defines the data source
  25882. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25883. * @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)
  25884. * @returns the current mesh
  25885. */
  25886. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25887. /**
  25888. * Creates new normals data for the mesh
  25889. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25890. * @returns the current mesh
  25891. */
  25892. createNormals(updatable: boolean): AbstractMesh;
  25893. /**
  25894. * Align the mesh with a normal
  25895. * @param normal defines the normal to use
  25896. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25897. * @returns the current mesh
  25898. */
  25899. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25900. /** @hidden */ private _checkOcclusionQuery(): boolean;
  25901. /**
  25902. * Disables the mesh edge rendering mode
  25903. * @returns the currentAbstractMesh
  25904. */
  25905. disableEdgesRendering(): AbstractMesh;
  25906. /**
  25907. * Enables the edge rendering mode on the mesh.
  25908. * This mode makes the mesh edges visible
  25909. * @param epsilon defines the maximal distance between two angles to detect a face
  25910. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25911. * @returns the currentAbstractMesh
  25912. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25913. */
  25914. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25915. }
  25916. }
  25917. declare module BABYLON {
  25918. /**
  25919. * Interface used to define ActionEvent
  25920. */
  25921. export interface IActionEvent {
  25922. /** The mesh or sprite that triggered the action */
  25923. source: any;
  25924. /** The X mouse cursor position at the time of the event */
  25925. pointerX: number;
  25926. /** The Y mouse cursor position at the time of the event */
  25927. pointerY: number;
  25928. /** The mesh that is currently pointed at (can be null) */
  25929. meshUnderPointer: Nullable<AbstractMesh>;
  25930. /** the original (browser) event that triggered the ActionEvent */
  25931. sourceEvent?: any;
  25932. /** additional data for the event */
  25933. additionalData?: any;
  25934. }
  25935. /**
  25936. * ActionEvent is the event being sent when an action is triggered.
  25937. */
  25938. export class ActionEvent implements IActionEvent {
  25939. /** The mesh or sprite that triggered the action */
  25940. source: any;
  25941. /** The X mouse cursor position at the time of the event */
  25942. pointerX: number;
  25943. /** The Y mouse cursor position at the time of the event */
  25944. pointerY: number;
  25945. /** The mesh that is currently pointed at (can be null) */
  25946. meshUnderPointer: Nullable<AbstractMesh>;
  25947. /** the original (browser) event that triggered the ActionEvent */
  25948. sourceEvent?: any;
  25949. /** additional data for the event */
  25950. additionalData?: any;
  25951. /**
  25952. * Creates a new ActionEvent
  25953. * @param source The mesh or sprite that triggered the action
  25954. * @param pointerX The X mouse cursor position at the time of the event
  25955. * @param pointerY The Y mouse cursor position at the time of the event
  25956. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25957. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25958. * @param additionalData additional data for the event
  25959. */
  25960. constructor(
  25961. /** The mesh or sprite that triggered the action */
  25962. source: any,
  25963. /** The X mouse cursor position at the time of the event */
  25964. pointerX: number,
  25965. /** The Y mouse cursor position at the time of the event */
  25966. pointerY: number,
  25967. /** The mesh that is currently pointed at (can be null) */
  25968. meshUnderPointer: Nullable<AbstractMesh>,
  25969. /** the original (browser) event that triggered the ActionEvent */
  25970. sourceEvent?: any,
  25971. /** additional data for the event */
  25972. additionalData?: any);
  25973. /**
  25974. * Helper function to auto-create an ActionEvent from a source mesh.
  25975. * @param source The source mesh that triggered the event
  25976. * @param evt The original (browser) event
  25977. * @param additionalData additional data for the event
  25978. * @returns the new ActionEvent
  25979. */
  25980. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25981. /**
  25982. * Helper function to auto-create an ActionEvent from a source sprite
  25983. * @param source The source sprite that triggered the event
  25984. * @param scene Scene associated with the sprite
  25985. * @param evt The original (browser) event
  25986. * @param additionalData additional data for the event
  25987. * @returns the new ActionEvent
  25988. */
  25989. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25990. /**
  25991. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25992. * @param scene the scene where the event occurred
  25993. * @param evt The original (browser) event
  25994. * @returns the new ActionEvent
  25995. */
  25996. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25997. /**
  25998. * Helper function to auto-create an ActionEvent from a primitive
  25999. * @param prim defines the target primitive
  26000. * @param pointerPos defines the pointer position
  26001. * @param evt The original (browser) event
  26002. * @param additionalData additional data for the event
  26003. * @returns the new ActionEvent
  26004. */
  26005. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26006. }
  26007. }
  26008. declare module BABYLON {
  26009. /**
  26010. * Abstract class used to decouple action Manager from scene and meshes.
  26011. * Do not instantiate.
  26012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26013. */
  26014. export abstract class AbstractActionManager implements IDisposable {
  26015. /** Gets the list of active triggers */
  26016. static Triggers: {
  26017. [key: string]: number;
  26018. };
  26019. /** Gets the cursor to use when hovering items */
  26020. hoverCursor: string;
  26021. /** Gets the list of actions */
  26022. actions: IAction[];
  26023. /**
  26024. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26025. */
  26026. isRecursive: boolean;
  26027. /**
  26028. * Releases all associated resources
  26029. */
  26030. abstract dispose(): void;
  26031. /**
  26032. * Does this action manager has pointer triggers
  26033. */
  26034. abstract readonly hasPointerTriggers: boolean;
  26035. /**
  26036. * Does this action manager has pick triggers
  26037. */
  26038. abstract readonly hasPickTriggers: boolean;
  26039. /**
  26040. * Process a specific trigger
  26041. * @param trigger defines the trigger to process
  26042. * @param evt defines the event details to be processed
  26043. */
  26044. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26045. /**
  26046. * Does this action manager handles actions of any of the given triggers
  26047. * @param triggers defines the triggers to be tested
  26048. * @return a boolean indicating whether one (or more) of the triggers is handled
  26049. */
  26050. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26051. /**
  26052. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26053. * speed.
  26054. * @param triggerA defines the trigger to be tested
  26055. * @param triggerB defines the trigger to be tested
  26056. * @return a boolean indicating whether one (or more) of the triggers is handled
  26057. */
  26058. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26059. /**
  26060. * Does this action manager handles actions of a given trigger
  26061. * @param trigger defines the trigger to be tested
  26062. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26063. * @return whether the trigger is handled
  26064. */
  26065. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26066. /**
  26067. * Serialize this manager to a JSON object
  26068. * @param name defines the property name to store this manager
  26069. * @returns a JSON representation of this manager
  26070. */
  26071. abstract serialize(name: string): any;
  26072. /**
  26073. * Registers an action to this action manager
  26074. * @param action defines the action to be registered
  26075. * @return the action amended (prepared) after registration
  26076. */
  26077. abstract registerAction(action: IAction): Nullable<IAction>;
  26078. /**
  26079. * Unregisters an action to this action manager
  26080. * @param action defines the action to be unregistered
  26081. * @return a boolean indicating whether the action has been unregistered
  26082. */
  26083. abstract unregisterAction(action: IAction): Boolean;
  26084. /**
  26085. * Does exist one action manager with at least one trigger
  26086. **/
  26087. static readonly HasTriggers: boolean;
  26088. /**
  26089. * Does exist one action manager with at least one pick trigger
  26090. **/
  26091. static readonly HasPickTriggers: boolean;
  26092. /**
  26093. * Does exist one action manager that handles actions of a given trigger
  26094. * @param trigger defines the trigger to be tested
  26095. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26096. **/
  26097. static HasSpecificTrigger(trigger: number): boolean;
  26098. }
  26099. }
  26100. declare module BABYLON {
  26101. /**
  26102. * Defines how a node can be built from a string name.
  26103. */
  26104. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26105. /**
  26106. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26107. */
  26108. export class Node implements IBehaviorAware<Node> {
  26109. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26110. private static _NodeConstructors;
  26111. /**
  26112. * Add a new node constructor
  26113. * @param type defines the type name of the node to construct
  26114. * @param constructorFunc defines the constructor function
  26115. */
  26116. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26117. /**
  26118. * Returns a node constructor based on type name
  26119. * @param type defines the type name
  26120. * @param name defines the new node name
  26121. * @param scene defines the hosting scene
  26122. * @param options defines optional options to transmit to constructors
  26123. * @returns the new constructor or null
  26124. */
  26125. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26126. /**
  26127. * Gets or sets the name of the node
  26128. */
  26129. name: string;
  26130. /**
  26131. * Gets or sets the id of the node
  26132. */
  26133. id: string;
  26134. /**
  26135. * Gets or sets the unique id of the node
  26136. */
  26137. uniqueId: number;
  26138. /**
  26139. * Gets or sets a string used to store user defined state for the node
  26140. */
  26141. state: string;
  26142. /**
  26143. * Gets or sets an object used to store user defined information for the node
  26144. */
  26145. metadata: any;
  26146. /**
  26147. * For internal use only. Please do not use.
  26148. */
  26149. reservedDataStore: any;
  26150. /**
  26151. * List of inspectable custom properties (used by the Inspector)
  26152. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26153. */
  26154. inspectableCustomProperties: IInspectable[];
  26155. /**
  26156. * Gets or sets a boolean used to define if the node must be serialized
  26157. */
  26158. doNotSerialize: boolean;
  26159. /** @hidden */ private _isDisposed: boolean;
  26160. /**
  26161. * Gets a list of Animations associated with the node
  26162. */
  26163. animations: Animation[];
  26164. protected _ranges: {
  26165. [name: string]: Nullable<AnimationRange>;
  26166. };
  26167. /**
  26168. * Callback raised when the node is ready to be used
  26169. */
  26170. onReady: Nullable<(node: Node) => void>;
  26171. private _isEnabled;
  26172. private _isParentEnabled;
  26173. private _isReady;
  26174. /** @hidden */ private _currentRenderId: number;
  26175. private _parentUpdateId;
  26176. /** @hidden */ private _childUpdateId: number;
  26177. /** @hidden */ private _waitingParentId: Nullable<string>;
  26178. /** @hidden */ private _scene: Scene;
  26179. /** @hidden */ private _cache: any;
  26180. private _parentNode;
  26181. private _children;
  26182. /** @hidden */ private _worldMatrix: Matrix;
  26183. /** @hidden */ private _worldMatrixDeterminant: number;
  26184. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26185. /** @hidden */
  26186. private _sceneRootNodesIndex;
  26187. /**
  26188. * Gets a boolean indicating if the node has been disposed
  26189. * @returns true if the node was disposed
  26190. */
  26191. isDisposed(): boolean;
  26192. /**
  26193. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26194. * @see https://doc.babylonjs.com/how_to/parenting
  26195. */
  26196. parent: Nullable<Node>;
  26197. private addToSceneRootNodes;
  26198. private removeFromSceneRootNodes;
  26199. private _animationPropertiesOverride;
  26200. /**
  26201. * Gets or sets the animation properties override
  26202. */
  26203. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26204. /**
  26205. * Gets a string idenfifying the name of the class
  26206. * @returns "Node" string
  26207. */
  26208. getClassName(): string;
  26209. /** @hidden */ protected readonly _isNode: boolean;
  26210. /**
  26211. * An event triggered when the mesh is disposed
  26212. */
  26213. onDisposeObservable: Observable<Node>;
  26214. private _onDisposeObserver;
  26215. /**
  26216. * Sets a callback that will be raised when the node will be disposed
  26217. */
  26218. onDispose: () => void;
  26219. /**
  26220. * Creates a new Node
  26221. * @param name the name and id to be given to this node
  26222. * @param scene the scene this node will be added to
  26223. * @param addToRootNodes the node will be added to scene.rootNodes
  26224. */
  26225. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26226. /**
  26227. * Gets the scene of the node
  26228. * @returns a scene
  26229. */
  26230. getScene(): Scene;
  26231. /**
  26232. * Gets the engine of the node
  26233. * @returns a Engine
  26234. */
  26235. getEngine(): Engine;
  26236. private _behaviors;
  26237. /**
  26238. * Attach a behavior to the node
  26239. * @see http://doc.babylonjs.com/features/behaviour
  26240. * @param behavior defines the behavior to attach
  26241. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26242. * @returns the current Node
  26243. */
  26244. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26245. /**
  26246. * Remove an attached behavior
  26247. * @see http://doc.babylonjs.com/features/behaviour
  26248. * @param behavior defines the behavior to attach
  26249. * @returns the current Node
  26250. */
  26251. removeBehavior(behavior: Behavior<Node>): Node;
  26252. /**
  26253. * Gets the list of attached behaviors
  26254. * @see http://doc.babylonjs.com/features/behaviour
  26255. */
  26256. readonly behaviors: Behavior<Node>[];
  26257. /**
  26258. * Gets an attached behavior by name
  26259. * @param name defines the name of the behavior to look for
  26260. * @see http://doc.babylonjs.com/features/behaviour
  26261. * @returns null if behavior was not found else the requested behavior
  26262. */
  26263. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26264. /**
  26265. * Returns the latest update of the World matrix
  26266. * @returns a Matrix
  26267. */
  26268. getWorldMatrix(): Matrix;
  26269. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26270. /**
  26271. * Returns directly the latest state of the mesh World matrix.
  26272. * A Matrix is returned.
  26273. */
  26274. readonly worldMatrixFromCache: Matrix;
  26275. /** @hidden */ private _initCache(): void;
  26276. /** @hidden */
  26277. updateCache(force?: boolean): void;
  26278. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26279. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26280. /** @hidden */ private _isSynchronized(): boolean;
  26281. /** @hidden */ private _markSyncedWithParent(): void;
  26282. /** @hidden */
  26283. isSynchronizedWithParent(): boolean;
  26284. /** @hidden */
  26285. isSynchronized(): boolean;
  26286. /**
  26287. * Is this node ready to be used/rendered
  26288. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26289. * @return true if the node is ready
  26290. */
  26291. isReady(completeCheck?: boolean): boolean;
  26292. /**
  26293. * Is this node enabled?
  26294. * 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
  26295. * @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
  26296. * @return whether this node (and its parent) is enabled
  26297. */
  26298. isEnabled(checkAncestors?: boolean): boolean;
  26299. /** @hidden */
  26300. protected _syncParentEnabledState(): void;
  26301. /**
  26302. * Set the enabled state of this node
  26303. * @param value defines the new enabled state
  26304. */
  26305. setEnabled(value: boolean): void;
  26306. /**
  26307. * Is this node a descendant of the given node?
  26308. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26309. * @param ancestor defines the parent node to inspect
  26310. * @returns a boolean indicating if this node is a descendant of the given node
  26311. */
  26312. isDescendantOf(ancestor: Node): boolean;
  26313. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26314. /**
  26315. * Will return all nodes that have this node as ascendant
  26316. * @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
  26317. * @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
  26318. * @return all children nodes of all types
  26319. */
  26320. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26321. /**
  26322. * Get all child-meshes of this node
  26323. * @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)
  26324. * @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
  26325. * @returns an array of AbstractMesh
  26326. */
  26327. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26328. /**
  26329. * Get all direct children of this node
  26330. * @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
  26331. * @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)
  26332. * @returns an array of Node
  26333. */
  26334. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26335. /** @hidden */ private _setReady(state: boolean): void;
  26336. /**
  26337. * Get an animation by name
  26338. * @param name defines the name of the animation to look for
  26339. * @returns null if not found else the requested animation
  26340. */
  26341. getAnimationByName(name: string): Nullable<Animation>;
  26342. /**
  26343. * Creates an animation range for this node
  26344. * @param name defines the name of the range
  26345. * @param from defines the starting key
  26346. * @param to defines the end key
  26347. */
  26348. createAnimationRange(name: string, from: number, to: number): void;
  26349. /**
  26350. * Delete a specific animation range
  26351. * @param name defines the name of the range to delete
  26352. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26353. */
  26354. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26355. /**
  26356. * Get an animation range by name
  26357. * @param name defines the name of the animation range to look for
  26358. * @returns null if not found else the requested animation range
  26359. */
  26360. getAnimationRange(name: string): Nullable<AnimationRange>;
  26361. /**
  26362. * Gets the list of all animation ranges defined on this node
  26363. * @returns an array
  26364. */
  26365. getAnimationRanges(): Nullable<AnimationRange>[];
  26366. /**
  26367. * Will start the animation sequence
  26368. * @param name defines the range frames for animation sequence
  26369. * @param loop defines if the animation should loop (false by default)
  26370. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26371. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26372. * @returns the object created for this animation. If range does not exist, it will return null
  26373. */
  26374. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26375. /**
  26376. * Serialize animation ranges into a JSON compatible object
  26377. * @returns serialization object
  26378. */
  26379. serializeAnimationRanges(): any;
  26380. /**
  26381. * Computes the world matrix of the node
  26382. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26383. * @returns the world matrix
  26384. */
  26385. computeWorldMatrix(force?: boolean): Matrix;
  26386. /**
  26387. * Releases resources associated with this node.
  26388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26390. */
  26391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26392. /**
  26393. * Parse animation range data from a serialization object and store them into a given node
  26394. * @param node defines where to store the animation ranges
  26395. * @param parsedNode defines the serialization object to read data from
  26396. * @param scene defines the hosting scene
  26397. */
  26398. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26399. /**
  26400. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26401. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26402. * @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
  26403. * @returns the new bounding vectors
  26404. */
  26405. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26406. min: Vector3;
  26407. max: Vector3;
  26408. };
  26409. }
  26410. }
  26411. declare module BABYLON {
  26412. /**
  26413. * @hidden
  26414. */
  26415. export class _IAnimationState {
  26416. key: number;
  26417. repeatCount: number;
  26418. workValue?: any;
  26419. loopMode?: number;
  26420. offsetValue?: any;
  26421. highLimitValue?: any;
  26422. }
  26423. /**
  26424. * Class used to store any kind of animation
  26425. */
  26426. export class Animation {
  26427. /**Name of the animation */
  26428. name: string;
  26429. /**Property to animate */
  26430. targetProperty: string;
  26431. /**The frames per second of the animation */
  26432. framePerSecond: number;
  26433. /**The data type of the animation */
  26434. dataType: number;
  26435. /**The loop mode of the animation */
  26436. loopMode?: number | undefined;
  26437. /**Specifies if blending should be enabled */
  26438. enableBlending?: boolean | undefined;
  26439. /**
  26440. * Use matrix interpolation instead of using direct key value when animating matrices
  26441. */
  26442. static AllowMatricesInterpolation: boolean;
  26443. /**
  26444. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26445. */
  26446. static AllowMatrixDecomposeForInterpolation: boolean;
  26447. /**
  26448. * Stores the key frames of the animation
  26449. */
  26450. private _keys;
  26451. /**
  26452. * Stores the easing function of the animation
  26453. */
  26454. private _easingFunction;
  26455. /**
  26456. * @hidden Internal use only
  26457. */ private _runtimeAnimations: RuntimeAnimation[];
  26458. /**
  26459. * The set of event that will be linked to this animation
  26460. */
  26461. private _events;
  26462. /**
  26463. * Stores an array of target property paths
  26464. */
  26465. targetPropertyPath: string[];
  26466. /**
  26467. * Stores the blending speed of the animation
  26468. */
  26469. blendingSpeed: number;
  26470. /**
  26471. * Stores the animation ranges for the animation
  26472. */
  26473. private _ranges;
  26474. /**
  26475. * @hidden Internal use
  26476. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26477. /**
  26478. * Sets up an animation
  26479. * @param property The property to animate
  26480. * @param animationType The animation type to apply
  26481. * @param framePerSecond The frames per second of the animation
  26482. * @param easingFunction The easing function used in the animation
  26483. * @returns The created animation
  26484. */
  26485. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26486. /**
  26487. * Create and start an animation on a node
  26488. * @param name defines the name of the global animation that will be run on all nodes
  26489. * @param node defines the root node where the animation will take place
  26490. * @param targetProperty defines property to animate
  26491. * @param framePerSecond defines the number of frame per second yo use
  26492. * @param totalFrame defines the number of frames in total
  26493. * @param from defines the initial value
  26494. * @param to defines the final value
  26495. * @param loopMode defines which loop mode you want to use (off by default)
  26496. * @param easingFunction defines the easing function to use (linear by default)
  26497. * @param onAnimationEnd defines the callback to call when animation end
  26498. * @returns the animatable created for this animation
  26499. */
  26500. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26501. /**
  26502. * Create and start an animation on a node and its descendants
  26503. * @param name defines the name of the global animation that will be run on all nodes
  26504. * @param node defines the root node where the animation will take place
  26505. * @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
  26506. * @param targetProperty defines property to animate
  26507. * @param framePerSecond defines the number of frame per second to use
  26508. * @param totalFrame defines the number of frames in total
  26509. * @param from defines the initial value
  26510. * @param to defines the final value
  26511. * @param loopMode defines which loop mode you want to use (off by default)
  26512. * @param easingFunction defines the easing function to use (linear by default)
  26513. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26514. * @returns the list of animatables created for all nodes
  26515. * @example https://www.babylonjs-playground.com/#MH0VLI
  26516. */
  26517. 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[]>;
  26518. /**
  26519. * Creates a new animation, merges it with the existing animations and starts it
  26520. * @param name Name of the animation
  26521. * @param node Node which contains the scene that begins the animations
  26522. * @param targetProperty Specifies which property to animate
  26523. * @param framePerSecond The frames per second of the animation
  26524. * @param totalFrame The total number of frames
  26525. * @param from The frame at the beginning of the animation
  26526. * @param to The frame at the end of the animation
  26527. * @param loopMode Specifies the loop mode of the animation
  26528. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26529. * @param onAnimationEnd Callback to run once the animation is complete
  26530. * @returns Nullable animation
  26531. */
  26532. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26533. /**
  26534. * Transition property of an host to the target Value
  26535. * @param property The property to transition
  26536. * @param targetValue The target Value of the property
  26537. * @param host The object where the property to animate belongs
  26538. * @param scene Scene used to run the animation
  26539. * @param frameRate Framerate (in frame/s) to use
  26540. * @param transition The transition type we want to use
  26541. * @param duration The duration of the animation, in milliseconds
  26542. * @param onAnimationEnd Callback trigger at the end of the animation
  26543. * @returns Nullable animation
  26544. */
  26545. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26546. /**
  26547. * Return the array of runtime animations currently using this animation
  26548. */
  26549. readonly runtimeAnimations: RuntimeAnimation[];
  26550. /**
  26551. * Specifies if any of the runtime animations are currently running
  26552. */
  26553. readonly hasRunningRuntimeAnimations: boolean;
  26554. /**
  26555. * Initializes the animation
  26556. * @param name Name of the animation
  26557. * @param targetProperty Property to animate
  26558. * @param framePerSecond The frames per second of the animation
  26559. * @param dataType The data type of the animation
  26560. * @param loopMode The loop mode of the animation
  26561. * @param enableBlending Specifies if blending should be enabled
  26562. */
  26563. constructor(
  26564. /**Name of the animation */
  26565. name: string,
  26566. /**Property to animate */
  26567. targetProperty: string,
  26568. /**The frames per second of the animation */
  26569. framePerSecond: number,
  26570. /**The data type of the animation */
  26571. dataType: number,
  26572. /**The loop mode of the animation */
  26573. loopMode?: number | undefined,
  26574. /**Specifies if blending should be enabled */
  26575. enableBlending?: boolean | undefined);
  26576. /**
  26577. * Converts the animation to a string
  26578. * @param fullDetails support for multiple levels of logging within scene loading
  26579. * @returns String form of the animation
  26580. */
  26581. toString(fullDetails?: boolean): string;
  26582. /**
  26583. * Add an event to this animation
  26584. * @param event Event to add
  26585. */
  26586. addEvent(event: AnimationEvent): void;
  26587. /**
  26588. * Remove all events found at the given frame
  26589. * @param frame The frame to remove events from
  26590. */
  26591. removeEvents(frame: number): void;
  26592. /**
  26593. * Retrieves all the events from the animation
  26594. * @returns Events from the animation
  26595. */
  26596. getEvents(): AnimationEvent[];
  26597. /**
  26598. * Creates an animation range
  26599. * @param name Name of the animation range
  26600. * @param from Starting frame of the animation range
  26601. * @param to Ending frame of the animation
  26602. */
  26603. createRange(name: string, from: number, to: number): void;
  26604. /**
  26605. * Deletes an animation range by name
  26606. * @param name Name of the animation range to delete
  26607. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26608. */
  26609. deleteRange(name: string, deleteFrames?: boolean): void;
  26610. /**
  26611. * Gets the animation range by name, or null if not defined
  26612. * @param name Name of the animation range
  26613. * @returns Nullable animation range
  26614. */
  26615. getRange(name: string): Nullable<AnimationRange>;
  26616. /**
  26617. * Gets the key frames from the animation
  26618. * @returns The key frames of the animation
  26619. */
  26620. getKeys(): Array<IAnimationKey>;
  26621. /**
  26622. * Gets the highest frame rate of the animation
  26623. * @returns Highest frame rate of the animation
  26624. */
  26625. getHighestFrame(): number;
  26626. /**
  26627. * Gets the easing function of the animation
  26628. * @returns Easing function of the animation
  26629. */
  26630. getEasingFunction(): IEasingFunction;
  26631. /**
  26632. * Sets the easing function of the animation
  26633. * @param easingFunction A custom mathematical formula for animation
  26634. */
  26635. setEasingFunction(easingFunction: EasingFunction): void;
  26636. /**
  26637. * Interpolates a scalar linearly
  26638. * @param startValue Start value of the animation curve
  26639. * @param endValue End value of the animation curve
  26640. * @param gradient Scalar amount to interpolate
  26641. * @returns Interpolated scalar value
  26642. */
  26643. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26644. /**
  26645. * Interpolates a scalar cubically
  26646. * @param startValue Start value of the animation curve
  26647. * @param outTangent End tangent of the animation
  26648. * @param endValue End value of the animation curve
  26649. * @param inTangent Start tangent of the animation curve
  26650. * @param gradient Scalar amount to interpolate
  26651. * @returns Interpolated scalar value
  26652. */
  26653. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26654. /**
  26655. * Interpolates a quaternion using a spherical linear interpolation
  26656. * @param startValue Start value of the animation curve
  26657. * @param endValue End value of the animation curve
  26658. * @param gradient Scalar amount to interpolate
  26659. * @returns Interpolated quaternion value
  26660. */
  26661. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26662. /**
  26663. * Interpolates a quaternion cubically
  26664. * @param startValue Start value of the animation curve
  26665. * @param outTangent End tangent of the animation curve
  26666. * @param endValue End value of the animation curve
  26667. * @param inTangent Start tangent of the animation curve
  26668. * @param gradient Scalar amount to interpolate
  26669. * @returns Interpolated quaternion value
  26670. */
  26671. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26672. /**
  26673. * Interpolates a Vector3 linearl
  26674. * @param startValue Start value of the animation curve
  26675. * @param endValue End value of the animation curve
  26676. * @param gradient Scalar amount to interpolate
  26677. * @returns Interpolated scalar value
  26678. */
  26679. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26680. /**
  26681. * Interpolates a Vector3 cubically
  26682. * @param startValue Start value of the animation curve
  26683. * @param outTangent End tangent of the animation
  26684. * @param endValue End value of the animation curve
  26685. * @param inTangent Start tangent of the animation curve
  26686. * @param gradient Scalar amount to interpolate
  26687. * @returns InterpolatedVector3 value
  26688. */
  26689. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26690. /**
  26691. * Interpolates a Vector2 linearly
  26692. * @param startValue Start value of the animation curve
  26693. * @param endValue End value of the animation curve
  26694. * @param gradient Scalar amount to interpolate
  26695. * @returns Interpolated Vector2 value
  26696. */
  26697. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26698. /**
  26699. * Interpolates a Vector2 cubically
  26700. * @param startValue Start value of the animation curve
  26701. * @param outTangent End tangent of the animation
  26702. * @param endValue End value of the animation curve
  26703. * @param inTangent Start tangent of the animation curve
  26704. * @param gradient Scalar amount to interpolate
  26705. * @returns Interpolated Vector2 value
  26706. */
  26707. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26708. /**
  26709. * Interpolates a size linearly
  26710. * @param startValue Start value of the animation curve
  26711. * @param endValue End value of the animation curve
  26712. * @param gradient Scalar amount to interpolate
  26713. * @returns Interpolated Size value
  26714. */
  26715. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26716. /**
  26717. * Interpolates a Color3 linearly
  26718. * @param startValue Start value of the animation curve
  26719. * @param endValue End value of the animation curve
  26720. * @param gradient Scalar amount to interpolate
  26721. * @returns Interpolated Color3 value
  26722. */
  26723. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26724. /**
  26725. * @hidden Internal use only
  26726. */ private _getKeyValue(value: any): any;
  26727. /**
  26728. * @hidden Internal use only
  26729. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26730. /**
  26731. * Defines the function to use to interpolate matrices
  26732. * @param startValue defines the start matrix
  26733. * @param endValue defines the end matrix
  26734. * @param gradient defines the gradient between both matrices
  26735. * @param result defines an optional target matrix where to store the interpolation
  26736. * @returns the interpolated matrix
  26737. */
  26738. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26739. /**
  26740. * Makes a copy of the animation
  26741. * @returns Cloned animation
  26742. */
  26743. clone(): Animation;
  26744. /**
  26745. * Sets the key frames of the animation
  26746. * @param values The animation key frames to set
  26747. */
  26748. setKeys(values: Array<IAnimationKey>): void;
  26749. /**
  26750. * Serializes the animation to an object
  26751. * @returns Serialized object
  26752. */
  26753. serialize(): any;
  26754. /**
  26755. * Float animation type
  26756. */
  26757. private static _ANIMATIONTYPE_FLOAT;
  26758. /**
  26759. * Vector3 animation type
  26760. */
  26761. private static _ANIMATIONTYPE_VECTOR3;
  26762. /**
  26763. * Quaternion animation type
  26764. */
  26765. private static _ANIMATIONTYPE_QUATERNION;
  26766. /**
  26767. * Matrix animation type
  26768. */
  26769. private static _ANIMATIONTYPE_MATRIX;
  26770. /**
  26771. * Color3 animation type
  26772. */
  26773. private static _ANIMATIONTYPE_COLOR3;
  26774. /**
  26775. * Vector2 animation type
  26776. */
  26777. private static _ANIMATIONTYPE_VECTOR2;
  26778. /**
  26779. * Size animation type
  26780. */
  26781. private static _ANIMATIONTYPE_SIZE;
  26782. /**
  26783. * Relative Loop Mode
  26784. */
  26785. private static _ANIMATIONLOOPMODE_RELATIVE;
  26786. /**
  26787. * Cycle Loop Mode
  26788. */
  26789. private static _ANIMATIONLOOPMODE_CYCLE;
  26790. /**
  26791. * Constant Loop Mode
  26792. */
  26793. private static _ANIMATIONLOOPMODE_CONSTANT;
  26794. /**
  26795. * Get the float animation type
  26796. */
  26797. static readonly ANIMATIONTYPE_FLOAT: number;
  26798. /**
  26799. * Get the Vector3 animation type
  26800. */
  26801. static readonly ANIMATIONTYPE_VECTOR3: number;
  26802. /**
  26803. * Get the Vector2 animation type
  26804. */
  26805. static readonly ANIMATIONTYPE_VECTOR2: number;
  26806. /**
  26807. * Get the Size animation type
  26808. */
  26809. static readonly ANIMATIONTYPE_SIZE: number;
  26810. /**
  26811. * Get the Quaternion animation type
  26812. */
  26813. static readonly ANIMATIONTYPE_QUATERNION: number;
  26814. /**
  26815. * Get the Matrix animation type
  26816. */
  26817. static readonly ANIMATIONTYPE_MATRIX: number;
  26818. /**
  26819. * Get the Color3 animation type
  26820. */
  26821. static readonly ANIMATIONTYPE_COLOR3: number;
  26822. /**
  26823. * Get the Relative Loop Mode
  26824. */
  26825. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26826. /**
  26827. * Get the Cycle Loop Mode
  26828. */
  26829. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26830. /**
  26831. * Get the Constant Loop Mode
  26832. */
  26833. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26834. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26835. /**
  26836. * Parses an animation object and creates an animation
  26837. * @param parsedAnimation Parsed animation object
  26838. * @returns Animation object
  26839. */
  26840. static Parse(parsedAnimation: any): Animation;
  26841. /**
  26842. * Appends the serialized animations from the source animations
  26843. * @param source Source containing the animations
  26844. * @param destination Target to store the animations
  26845. */
  26846. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26847. }
  26848. }
  26849. declare module BABYLON {
  26850. /**
  26851. * Interface containing an array of animations
  26852. */
  26853. export interface IAnimatable {
  26854. /**
  26855. * Array of animations
  26856. */
  26857. animations: Nullable<Array<Animation>>;
  26858. }
  26859. }
  26860. declare module BABYLON {
  26861. /**
  26862. * This represents all the required information to add a fresnel effect on a material:
  26863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26864. */
  26865. export class FresnelParameters {
  26866. private _isEnabled;
  26867. /**
  26868. * Define if the fresnel effect is enable or not.
  26869. */
  26870. isEnabled: boolean;
  26871. /**
  26872. * Define the color used on edges (grazing angle)
  26873. */
  26874. leftColor: Color3;
  26875. /**
  26876. * Define the color used on center
  26877. */
  26878. rightColor: Color3;
  26879. /**
  26880. * Define bias applied to computed fresnel term
  26881. */
  26882. bias: number;
  26883. /**
  26884. * Defined the power exponent applied to fresnel term
  26885. */
  26886. power: number;
  26887. /**
  26888. * Clones the current fresnel and its valuues
  26889. * @returns a clone fresnel configuration
  26890. */
  26891. clone(): FresnelParameters;
  26892. /**
  26893. * Serializes the current fresnel parameters to a JSON representation.
  26894. * @return the JSON serialization
  26895. */
  26896. serialize(): any;
  26897. /**
  26898. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26899. * @param parsedFresnelParameters Define the JSON representation
  26900. * @returns the parsed parameters
  26901. */
  26902. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26903. }
  26904. }
  26905. declare module BABYLON {
  26906. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26907. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26908. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26909. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26910. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26911. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26912. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26913. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26914. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26915. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26916. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26917. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26918. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26919. /**
  26920. * Decorator used to define property that can be serialized as reference to a camera
  26921. * @param sourceName defines the name of the property to decorate
  26922. */
  26923. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26924. /**
  26925. * Class used to help serialization objects
  26926. */
  26927. export class SerializationHelper {
  26928. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  26929. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  26930. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  26931. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  26932. /**
  26933. * Appends the serialized animations from the source animations
  26934. * @param source Source containing the animations
  26935. * @param destination Target to store the animations
  26936. */
  26937. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26938. /**
  26939. * Static function used to serialized a specific entity
  26940. * @param entity defines the entity to serialize
  26941. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  26942. * @returns a JSON compatible object representing the serialization of the entity
  26943. */
  26944. static Serialize<T>(entity: T, serializationObject?: any): any;
  26945. /**
  26946. * Creates a new entity from a serialization data object
  26947. * @param creationFunction defines a function used to instanciated the new entity
  26948. * @param source defines the source serialization data
  26949. * @param scene defines the hosting scene
  26950. * @param rootUrl defines the root url for resources
  26951. * @returns a new entity
  26952. */
  26953. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26954. /**
  26955. * Clones an object
  26956. * @param creationFunction defines the function used to instanciate the new object
  26957. * @param source defines the source object
  26958. * @returns the cloned object
  26959. */
  26960. static Clone<T>(creationFunction: () => T, source: T): T;
  26961. /**
  26962. * Instanciates a new object based on a source one (some data will be shared between both object)
  26963. * @param creationFunction defines the function used to instanciate the new object
  26964. * @param source defines the source object
  26965. * @returns the new object
  26966. */
  26967. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26968. }
  26969. }
  26970. declare module BABYLON {
  26971. /**
  26972. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26973. */
  26974. export interface CubeMapInfo {
  26975. /**
  26976. * The pixel array for the front face.
  26977. * This is stored in format, left to right, up to down format.
  26978. */
  26979. front: Nullable<ArrayBufferView>;
  26980. /**
  26981. * The pixel array for the back face.
  26982. * This is stored in format, left to right, up to down format.
  26983. */
  26984. back: Nullable<ArrayBufferView>;
  26985. /**
  26986. * The pixel array for the left face.
  26987. * This is stored in format, left to right, up to down format.
  26988. */
  26989. left: Nullable<ArrayBufferView>;
  26990. /**
  26991. * The pixel array for the right face.
  26992. * This is stored in format, left to right, up to down format.
  26993. */
  26994. right: Nullable<ArrayBufferView>;
  26995. /**
  26996. * The pixel array for the up face.
  26997. * This is stored in format, left to right, up to down format.
  26998. */
  26999. up: Nullable<ArrayBufferView>;
  27000. /**
  27001. * The pixel array for the down face.
  27002. * This is stored in format, left to right, up to down format.
  27003. */
  27004. down: Nullable<ArrayBufferView>;
  27005. /**
  27006. * The size of the cubemap stored.
  27007. *
  27008. * Each faces will be size * size pixels.
  27009. */
  27010. size: number;
  27011. /**
  27012. * The format of the texture.
  27013. *
  27014. * RGBA, RGB.
  27015. */
  27016. format: number;
  27017. /**
  27018. * The type of the texture data.
  27019. *
  27020. * UNSIGNED_INT, FLOAT.
  27021. */
  27022. type: number;
  27023. /**
  27024. * Specifies whether the texture is in gamma space.
  27025. */
  27026. gammaSpace: boolean;
  27027. }
  27028. /**
  27029. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27030. */
  27031. export class PanoramaToCubeMapTools {
  27032. private static FACE_FRONT;
  27033. private static FACE_BACK;
  27034. private static FACE_RIGHT;
  27035. private static FACE_LEFT;
  27036. private static FACE_DOWN;
  27037. private static FACE_UP;
  27038. /**
  27039. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27040. *
  27041. * @param float32Array The source data.
  27042. * @param inputWidth The width of the input panorama.
  27043. * @param inputHeight The height of the input panorama.
  27044. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27045. * @return The cubemap data
  27046. */
  27047. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27048. private static CreateCubemapTexture;
  27049. private static CalcProjectionSpherical;
  27050. }
  27051. }
  27052. declare module BABYLON {
  27053. /**
  27054. * Helper class dealing with the extraction of spherical polynomial dataArray
  27055. * from a cube map.
  27056. */
  27057. export class CubeMapToSphericalPolynomialTools {
  27058. private static FileFaces;
  27059. /**
  27060. * Converts a texture to the according Spherical Polynomial data.
  27061. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27062. *
  27063. * @param texture The texture to extract the information from.
  27064. * @return The Spherical Polynomial data.
  27065. */
  27066. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27067. /**
  27068. * Converts a cubemap to the according Spherical Polynomial data.
  27069. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27070. *
  27071. * @param cubeInfo The Cube map to extract the information from.
  27072. * @return The Spherical Polynomial data.
  27073. */
  27074. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27075. }
  27076. }
  27077. declare module BABYLON {
  27078. /**
  27079. * Class used to manipulate GUIDs
  27080. */
  27081. export class GUID {
  27082. /**
  27083. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27084. * Be aware Math.random() could cause collisions, but:
  27085. * "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"
  27086. * @returns a pseudo random id
  27087. */
  27088. static RandomId(): string;
  27089. }
  27090. }
  27091. declare module BABYLON {
  27092. /**
  27093. * Base class of all the textures in babylon.
  27094. * It groups all the common properties the materials, post process, lights... might need
  27095. * in order to make a correct use of the texture.
  27096. */
  27097. export class BaseTexture implements IAnimatable {
  27098. /**
  27099. * Default anisotropic filtering level for the application.
  27100. * It is set to 4 as a good tradeoff between perf and quality.
  27101. */
  27102. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27103. /**
  27104. * Gets or sets the unique id of the texture
  27105. */
  27106. uniqueId: number;
  27107. /**
  27108. * Define the name of the texture.
  27109. */
  27110. name: string;
  27111. /**
  27112. * Gets or sets an object used to store user defined information.
  27113. */
  27114. metadata: any;
  27115. /**
  27116. * For internal use only. Please do not use.
  27117. */
  27118. reservedDataStore: any;
  27119. private _hasAlpha;
  27120. /**
  27121. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27122. */
  27123. hasAlpha: boolean;
  27124. /**
  27125. * Defines if the alpha value should be determined via the rgb values.
  27126. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27127. */
  27128. getAlphaFromRGB: boolean;
  27129. /**
  27130. * Intensity or strength of the texture.
  27131. * It is commonly used by materials to fine tune the intensity of the texture
  27132. */
  27133. level: number;
  27134. /**
  27135. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27136. * This is part of the texture as textures usually maps to one uv set.
  27137. */
  27138. coordinatesIndex: number;
  27139. private _coordinatesMode;
  27140. /**
  27141. * How a texture is mapped.
  27142. *
  27143. * | Value | Type | Description |
  27144. * | ----- | ----------------------------------- | ----------- |
  27145. * | 0 | EXPLICIT_MODE | |
  27146. * | 1 | SPHERICAL_MODE | |
  27147. * | 2 | PLANAR_MODE | |
  27148. * | 3 | CUBIC_MODE | |
  27149. * | 4 | PROJECTION_MODE | |
  27150. * | 5 | SKYBOX_MODE | |
  27151. * | 6 | INVCUBIC_MODE | |
  27152. * | 7 | EQUIRECTANGULAR_MODE | |
  27153. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27154. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27155. */
  27156. coordinatesMode: number;
  27157. /**
  27158. * | Value | Type | Description |
  27159. * | ----- | ------------------ | ----------- |
  27160. * | 0 | CLAMP_ADDRESSMODE | |
  27161. * | 1 | WRAP_ADDRESSMODE | |
  27162. * | 2 | MIRROR_ADDRESSMODE | |
  27163. */
  27164. wrapU: number;
  27165. /**
  27166. * | Value | Type | Description |
  27167. * | ----- | ------------------ | ----------- |
  27168. * | 0 | CLAMP_ADDRESSMODE | |
  27169. * | 1 | WRAP_ADDRESSMODE | |
  27170. * | 2 | MIRROR_ADDRESSMODE | |
  27171. */
  27172. wrapV: number;
  27173. /**
  27174. * | Value | Type | Description |
  27175. * | ----- | ------------------ | ----------- |
  27176. * | 0 | CLAMP_ADDRESSMODE | |
  27177. * | 1 | WRAP_ADDRESSMODE | |
  27178. * | 2 | MIRROR_ADDRESSMODE | |
  27179. */
  27180. wrapR: number;
  27181. /**
  27182. * With compliant hardware and browser (supporting anisotropic filtering)
  27183. * this defines the level of anisotropic filtering in the texture.
  27184. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27185. */
  27186. anisotropicFilteringLevel: number;
  27187. /**
  27188. * Define if the texture is a cube texture or if false a 2d texture.
  27189. */
  27190. isCube: boolean;
  27191. /**
  27192. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27193. */
  27194. is3D: boolean;
  27195. /**
  27196. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27197. * HDR texture are usually stored in linear space.
  27198. * This only impacts the PBR and Background materials
  27199. */
  27200. gammaSpace: boolean;
  27201. /**
  27202. * Gets whether or not the texture contains RGBD data.
  27203. */
  27204. readonly isRGBD: boolean;
  27205. /**
  27206. * Is Z inverted in the texture (useful in a cube texture).
  27207. */
  27208. invertZ: boolean;
  27209. /**
  27210. * Are mip maps generated for this texture or not.
  27211. */
  27212. readonly noMipmap: boolean;
  27213. /**
  27214. * @hidden
  27215. */
  27216. lodLevelInAlpha: boolean;
  27217. /**
  27218. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27219. */
  27220. lodGenerationOffset: number;
  27221. /**
  27222. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27223. */
  27224. lodGenerationScale: number;
  27225. /**
  27226. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27227. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27228. * average roughness values.
  27229. */
  27230. linearSpecularLOD: boolean;
  27231. /**
  27232. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27233. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27234. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27235. */
  27236. irradianceTexture: Nullable<BaseTexture>;
  27237. /**
  27238. * Define if the texture is a render target.
  27239. */
  27240. isRenderTarget: boolean;
  27241. /**
  27242. * Define the unique id of the texture in the scene.
  27243. */
  27244. readonly uid: string;
  27245. /**
  27246. * Return a string representation of the texture.
  27247. * @returns the texture as a string
  27248. */
  27249. toString(): string;
  27250. /**
  27251. * Get the class name of the texture.
  27252. * @returns "BaseTexture"
  27253. */
  27254. getClassName(): string;
  27255. /**
  27256. * Define the list of animation attached to the texture.
  27257. */
  27258. animations: Animation[];
  27259. /**
  27260. * An event triggered when the texture is disposed.
  27261. */
  27262. onDisposeObservable: Observable<BaseTexture>;
  27263. private _onDisposeObserver;
  27264. /**
  27265. * Callback triggered when the texture has been disposed.
  27266. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27267. */
  27268. onDispose: () => void;
  27269. /**
  27270. * Define the current state of the loading sequence when in delayed load mode.
  27271. */
  27272. delayLoadState: number;
  27273. private _scene;
  27274. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27275. private _uid;
  27276. /**
  27277. * Define if the texture is preventinga material to render or not.
  27278. * If not and the texture is not ready, the engine will use a default black texture instead.
  27279. */
  27280. readonly isBlocking: boolean;
  27281. /**
  27282. * Instantiates a new BaseTexture.
  27283. * Base class of all the textures in babylon.
  27284. * It groups all the common properties the materials, post process, lights... might need
  27285. * in order to make a correct use of the texture.
  27286. * @param scene Define the scene the texture blongs to
  27287. */
  27288. constructor(scene: Nullable<Scene>);
  27289. /**
  27290. * Get the scene the texture belongs to.
  27291. * @returns the scene or null if undefined
  27292. */
  27293. getScene(): Nullable<Scene>;
  27294. /**
  27295. * Get the texture transform matrix used to offset tile the texture for istance.
  27296. * @returns the transformation matrix
  27297. */
  27298. getTextureMatrix(): Matrix;
  27299. /**
  27300. * Get the texture reflection matrix used to rotate/transform the reflection.
  27301. * @returns the reflection matrix
  27302. */
  27303. getReflectionTextureMatrix(): Matrix;
  27304. /**
  27305. * Get the underlying lower level texture from Babylon.
  27306. * @returns the insternal texture
  27307. */
  27308. getInternalTexture(): Nullable<InternalTexture>;
  27309. /**
  27310. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27311. * @returns true if ready or not blocking
  27312. */
  27313. isReadyOrNotBlocking(): boolean;
  27314. /**
  27315. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27316. * @returns true if fully ready
  27317. */
  27318. isReady(): boolean;
  27319. private _cachedSize;
  27320. /**
  27321. * Get the size of the texture.
  27322. * @returns the texture size.
  27323. */
  27324. getSize(): ISize;
  27325. /**
  27326. * Get the base size of the texture.
  27327. * It can be different from the size if the texture has been resized for POT for instance
  27328. * @returns the base size
  27329. */
  27330. getBaseSize(): ISize;
  27331. /**
  27332. * Update the sampling mode of the texture.
  27333. * Default is Trilinear mode.
  27334. *
  27335. * | Value | Type | Description |
  27336. * | ----- | ------------------ | ----------- |
  27337. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27338. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27339. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27340. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27341. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27342. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27343. * | 7 | NEAREST_LINEAR | |
  27344. * | 8 | NEAREST_NEAREST | |
  27345. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27346. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27347. * | 11 | LINEAR_LINEAR | |
  27348. * | 12 | LINEAR_NEAREST | |
  27349. *
  27350. * > _mag_: magnification filter (close to the viewer)
  27351. * > _min_: minification filter (far from the viewer)
  27352. * > _mip_: filter used between mip map levels
  27353. *@param samplingMode Define the new sampling mode of the texture
  27354. */
  27355. updateSamplingMode(samplingMode: number): void;
  27356. /**
  27357. * Scales the texture if is `canRescale()`
  27358. * @param ratio the resize factor we want to use to rescale
  27359. */
  27360. scale(ratio: number): void;
  27361. /**
  27362. * Get if the texture can rescale.
  27363. */
  27364. readonly canRescale: boolean;
  27365. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27366. /** @hidden */ private _rebuild(): void;
  27367. /**
  27368. * Triggers the load sequence in delayed load mode.
  27369. */
  27370. delayLoad(): void;
  27371. /**
  27372. * Clones the texture.
  27373. * @returns the cloned texture
  27374. */
  27375. clone(): Nullable<BaseTexture>;
  27376. /**
  27377. * Get the texture underlying type (INT, FLOAT...)
  27378. */
  27379. readonly textureType: number;
  27380. /**
  27381. * Get the texture underlying format (RGB, RGBA...)
  27382. */
  27383. readonly textureFormat: number;
  27384. /**
  27385. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27386. * This will returns an RGBA array buffer containing either in values (0-255) or
  27387. * float values (0-1) depending of the underlying buffer type.
  27388. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27389. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27390. * @param buffer defines a user defined buffer to fill with data (can be null)
  27391. * @returns The Array buffer containing the pixels data.
  27392. */
  27393. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27394. /**
  27395. * Release and destroy the underlying lower level texture aka internalTexture.
  27396. */
  27397. releaseInternalTexture(): void;
  27398. /**
  27399. * Get the polynomial representation of the texture data.
  27400. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27401. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27402. */
  27403. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27404. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27405. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27406. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27407. /**
  27408. * Dispose the texture and release its associated resources.
  27409. */
  27410. dispose(): void;
  27411. /**
  27412. * Serialize the texture into a JSON representation that can be parsed later on.
  27413. * @returns the JSON representation of the texture
  27414. */
  27415. serialize(): any;
  27416. /**
  27417. * Helper function to be called back once a list of texture contains only ready textures.
  27418. * @param textures Define the list of textures to wait for
  27419. * @param callback Define the callback triggered once the entire list will be ready
  27420. */
  27421. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27422. }
  27423. }
  27424. declare module BABYLON {
  27425. /**
  27426. * Class used to store data associated with WebGL texture data for the engine
  27427. * This class should not be used directly
  27428. */
  27429. export class InternalTexture {
  27430. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27431. /**
  27432. * The source of the texture data is unknown
  27433. */
  27434. static DATASOURCE_UNKNOWN: number;
  27435. /**
  27436. * Texture data comes from an URL
  27437. */
  27438. static DATASOURCE_URL: number;
  27439. /**
  27440. * Texture data is only used for temporary storage
  27441. */
  27442. static DATASOURCE_TEMP: number;
  27443. /**
  27444. * Texture data comes from raw data (ArrayBuffer)
  27445. */
  27446. static DATASOURCE_RAW: number;
  27447. /**
  27448. * Texture content is dynamic (video or dynamic texture)
  27449. */
  27450. static DATASOURCE_DYNAMIC: number;
  27451. /**
  27452. * Texture content is generated by rendering to it
  27453. */
  27454. static DATASOURCE_RENDERTARGET: number;
  27455. /**
  27456. * Texture content is part of a multi render target process
  27457. */
  27458. static DATASOURCE_MULTIRENDERTARGET: number;
  27459. /**
  27460. * Texture data comes from a cube data file
  27461. */
  27462. static DATASOURCE_CUBE: number;
  27463. /**
  27464. * Texture data comes from a raw cube data
  27465. */
  27466. static DATASOURCE_CUBERAW: number;
  27467. /**
  27468. * Texture data come from a prefiltered cube data file
  27469. */
  27470. static DATASOURCE_CUBEPREFILTERED: number;
  27471. /**
  27472. * Texture content is raw 3D data
  27473. */
  27474. static DATASOURCE_RAW3D: number;
  27475. /**
  27476. * Texture content is a depth texture
  27477. */
  27478. static DATASOURCE_DEPTHTEXTURE: number;
  27479. /**
  27480. * Texture data comes from a raw cube data encoded with RGBD
  27481. */
  27482. static DATASOURCE_CUBERAW_RGBD: number;
  27483. /**
  27484. * Defines if the texture is ready
  27485. */
  27486. isReady: boolean;
  27487. /**
  27488. * Defines if the texture is a cube texture
  27489. */
  27490. isCube: boolean;
  27491. /**
  27492. * Defines if the texture contains 3D data
  27493. */
  27494. is3D: boolean;
  27495. /**
  27496. * Defines if the texture contains multiview data
  27497. */
  27498. isMultiview: boolean;
  27499. /**
  27500. * Gets the URL used to load this texture
  27501. */
  27502. url: string;
  27503. /**
  27504. * Gets the sampling mode of the texture
  27505. */
  27506. samplingMode: number;
  27507. /**
  27508. * Gets a boolean indicating if the texture needs mipmaps generation
  27509. */
  27510. generateMipMaps: boolean;
  27511. /**
  27512. * Gets the number of samples used by the texture (WebGL2+ only)
  27513. */
  27514. samples: number;
  27515. /**
  27516. * Gets the type of the texture (int, float...)
  27517. */
  27518. type: number;
  27519. /**
  27520. * Gets the format of the texture (RGB, RGBA...)
  27521. */
  27522. format: number;
  27523. /**
  27524. * Observable called when the texture is loaded
  27525. */
  27526. onLoadedObservable: Observable<InternalTexture>;
  27527. /**
  27528. * Gets the width of the texture
  27529. */
  27530. width: number;
  27531. /**
  27532. * Gets the height of the texture
  27533. */
  27534. height: number;
  27535. /**
  27536. * Gets the depth of the texture
  27537. */
  27538. depth: number;
  27539. /**
  27540. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27541. */
  27542. baseWidth: number;
  27543. /**
  27544. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27545. */
  27546. baseHeight: number;
  27547. /**
  27548. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27549. */
  27550. baseDepth: number;
  27551. /**
  27552. * Gets a boolean indicating if the texture is inverted on Y axis
  27553. */
  27554. invertY: boolean;
  27555. /** @hidden */ private _invertVScale: boolean;
  27556. /** @hidden */ private _associatedChannel: number;
  27557. /** @hidden */ private _dataSource: number;
  27558. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  27559. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27560. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27561. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27562. /** @hidden */ private _size: number;
  27563. /** @hidden */ private _extension: string;
  27564. /** @hidden */ private _files: Nullable<string[]>;
  27565. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27566. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27567. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27568. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27569. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27570. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27571. /** @hidden */ private _attachments: Nullable<number[]>;
  27572. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27573. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27574. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27575. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27576. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27577. /** @hidden */ private _isDisabled: boolean;
  27578. /** @hidden */ private _compression: Nullable<string>;
  27579. /** @hidden */ private _generateStencilBuffer: boolean;
  27580. /** @hidden */ private _generateDepthBuffer: boolean;
  27581. /** @hidden */ private _comparisonFunction: number;
  27582. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27583. /** @hidden */ private _lodGenerationScale: number;
  27584. /** @hidden */ private _lodGenerationOffset: number;
  27585. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27586. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27587. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27588. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27589. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27590. /** @hidden */ private _isRGBD: boolean;
  27591. /** @hidden */ private _linearSpecularLOD: boolean;
  27592. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27593. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27594. /** @hidden */ private _references: number;
  27595. private _engine;
  27596. /**
  27597. * Gets the Engine the texture belongs to.
  27598. * @returns The babylon engine
  27599. */
  27600. getEngine(): Engine;
  27601. /**
  27602. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27603. */
  27604. readonly dataSource: number;
  27605. /**
  27606. * Creates a new InternalTexture
  27607. * @param engine defines the engine to use
  27608. * @param dataSource defines the type of data that will be used
  27609. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27610. */
  27611. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27612. /**
  27613. * Increments the number of references (ie. the number of Texture that point to it)
  27614. */
  27615. incrementReferences(): void;
  27616. /**
  27617. * Change the size of the texture (not the size of the content)
  27618. * @param width defines the new width
  27619. * @param height defines the new height
  27620. * @param depth defines the new depth (1 by default)
  27621. */
  27622. updateSize(width: int, height: int, depth?: int): void;
  27623. /** @hidden */ private _rebuild(): void;
  27624. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27625. /**
  27626. * Dispose the current allocated resources
  27627. */
  27628. dispose(): void;
  27629. }
  27630. }
  27631. declare module BABYLON {
  27632. /**
  27633. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27634. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27635. */
  27636. export class EffectFallbacks {
  27637. private _defines;
  27638. private _currentRank;
  27639. private _maxRank;
  27640. private _mesh;
  27641. /**
  27642. * Removes the fallback from the bound mesh.
  27643. */
  27644. unBindMesh(): void;
  27645. /**
  27646. * Adds a fallback on the specified property.
  27647. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27648. * @param define The name of the define in the shader
  27649. */
  27650. addFallback(rank: number, define: string): void;
  27651. /**
  27652. * Sets the mesh to use CPU skinning when needing to fallback.
  27653. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27654. * @param mesh The mesh to use the fallbacks.
  27655. */
  27656. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27657. /**
  27658. * Checks to see if more fallbacks are still availible.
  27659. */
  27660. readonly hasMoreFallbacks: boolean;
  27661. /**
  27662. * Removes the defines that should be removed when falling back.
  27663. * @param currentDefines defines the current define statements for the shader.
  27664. * @param effect defines the current effect we try to compile
  27665. * @returns The resulting defines with defines of the current rank removed.
  27666. */
  27667. reduce(currentDefines: string, effect: Effect): string;
  27668. }
  27669. /**
  27670. * Options to be used when creating an effect.
  27671. */
  27672. export class EffectCreationOptions {
  27673. /**
  27674. * Atrributes that will be used in the shader.
  27675. */
  27676. attributes: string[];
  27677. /**
  27678. * Uniform varible names that will be set in the shader.
  27679. */
  27680. uniformsNames: string[];
  27681. /**
  27682. * Uniform buffer varible names that will be set in the shader.
  27683. */
  27684. uniformBuffersNames: string[];
  27685. /**
  27686. * Sampler texture variable names that will be set in the shader.
  27687. */
  27688. samplers: string[];
  27689. /**
  27690. * Define statements that will be set in the shader.
  27691. */
  27692. defines: any;
  27693. /**
  27694. * Possible fallbacks for this effect to improve performance when needed.
  27695. */
  27696. fallbacks: Nullable<EffectFallbacks>;
  27697. /**
  27698. * Callback that will be called when the shader is compiled.
  27699. */
  27700. onCompiled: Nullable<(effect: Effect) => void>;
  27701. /**
  27702. * Callback that will be called if an error occurs during shader compilation.
  27703. */
  27704. onError: Nullable<(effect: Effect, errors: string) => void>;
  27705. /**
  27706. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27707. */
  27708. indexParameters: any;
  27709. /**
  27710. * Max number of lights that can be used in the shader.
  27711. */
  27712. maxSimultaneousLights: number;
  27713. /**
  27714. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27715. */
  27716. transformFeedbackVaryings: Nullable<string[]>;
  27717. }
  27718. /**
  27719. * Effect containing vertex and fragment shader that can be executed on an object.
  27720. */
  27721. export class Effect implements IDisposable {
  27722. /**
  27723. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27724. */
  27725. static ShadersRepository: string;
  27726. /**
  27727. * Name of the effect.
  27728. */
  27729. name: any;
  27730. /**
  27731. * String container all the define statements that should be set on the shader.
  27732. */
  27733. defines: string;
  27734. /**
  27735. * Callback that will be called when the shader is compiled.
  27736. */
  27737. onCompiled: Nullable<(effect: Effect) => void>;
  27738. /**
  27739. * Callback that will be called if an error occurs during shader compilation.
  27740. */
  27741. onError: Nullable<(effect: Effect, errors: string) => void>;
  27742. /**
  27743. * Callback that will be called when effect is bound.
  27744. */
  27745. onBind: Nullable<(effect: Effect) => void>;
  27746. /**
  27747. * Unique ID of the effect.
  27748. */
  27749. uniqueId: number;
  27750. /**
  27751. * Observable that will be called when the shader is compiled.
  27752. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27753. */
  27754. onCompileObservable: Observable<Effect>;
  27755. /**
  27756. * Observable that will be called if an error occurs during shader compilation.
  27757. */
  27758. onErrorObservable: Observable<Effect>;
  27759. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27760. /**
  27761. * Observable that will be called when effect is bound.
  27762. */
  27763. readonly onBindObservable: Observable<Effect>;
  27764. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27765. private static _uniqueIdSeed;
  27766. private _engine;
  27767. private _uniformBuffersNames;
  27768. private _uniformsNames;
  27769. private _samplerList;
  27770. private _samplers;
  27771. private _isReady;
  27772. private _compilationError;
  27773. private _attributesNames;
  27774. private _attributes;
  27775. private _uniforms;
  27776. /**
  27777. * Key for the effect.
  27778. * @hidden
  27779. */ private _key: string;
  27780. private _indexParameters;
  27781. private _fallbacks;
  27782. private _vertexSourceCode;
  27783. private _fragmentSourceCode;
  27784. private _vertexSourceCodeOverride;
  27785. private _fragmentSourceCodeOverride;
  27786. private _transformFeedbackVaryings;
  27787. /**
  27788. * Compiled shader to webGL program.
  27789. * @hidden
  27790. */ private _pipelineContext: Nullable<IPipelineContext>;
  27791. private _valueCache;
  27792. private static _baseCache;
  27793. /**
  27794. * Instantiates an effect.
  27795. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27796. * @param baseName Name of the effect.
  27797. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27798. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27799. * @param samplers List of sampler variables that will be passed to the shader.
  27800. * @param engine Engine to be used to render the effect
  27801. * @param defines Define statements to be added to the shader.
  27802. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27803. * @param onCompiled Callback that will be called when the shader is compiled.
  27804. * @param onError Callback that will be called if an error occurs during shader compilation.
  27805. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27806. */
  27807. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27808. private _useFinalCode;
  27809. /**
  27810. * Unique key for this effect
  27811. */
  27812. readonly key: string;
  27813. /**
  27814. * If the effect has been compiled and prepared.
  27815. * @returns if the effect is compiled and prepared.
  27816. */
  27817. isReady(): boolean;
  27818. private _isReadyInternal;
  27819. /**
  27820. * The engine the effect was initialized with.
  27821. * @returns the engine.
  27822. */
  27823. getEngine(): Engine;
  27824. /**
  27825. * The pipeline context for this effect
  27826. * @returns the associated pipeline context
  27827. */
  27828. getPipelineContext(): Nullable<IPipelineContext>;
  27829. /**
  27830. * The set of names of attribute variables for the shader.
  27831. * @returns An array of attribute names.
  27832. */
  27833. getAttributesNames(): string[];
  27834. /**
  27835. * Returns the attribute at the given index.
  27836. * @param index The index of the attribute.
  27837. * @returns The location of the attribute.
  27838. */
  27839. getAttributeLocation(index: number): number;
  27840. /**
  27841. * Returns the attribute based on the name of the variable.
  27842. * @param name of the attribute to look up.
  27843. * @returns the attribute location.
  27844. */
  27845. getAttributeLocationByName(name: string): number;
  27846. /**
  27847. * The number of attributes.
  27848. * @returns the numnber of attributes.
  27849. */
  27850. getAttributesCount(): number;
  27851. /**
  27852. * Gets the index of a uniform variable.
  27853. * @param uniformName of the uniform to look up.
  27854. * @returns the index.
  27855. */
  27856. getUniformIndex(uniformName: string): number;
  27857. /**
  27858. * Returns the attribute based on the name of the variable.
  27859. * @param uniformName of the uniform to look up.
  27860. * @returns the location of the uniform.
  27861. */
  27862. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27863. /**
  27864. * Returns an array of sampler variable names
  27865. * @returns The array of sampler variable neames.
  27866. */
  27867. getSamplers(): string[];
  27868. /**
  27869. * The error from the last compilation.
  27870. * @returns the error string.
  27871. */
  27872. getCompilationError(): string;
  27873. /**
  27874. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27875. * @param func The callback to be used.
  27876. */
  27877. executeWhenCompiled(func: (effect: Effect) => void): void;
  27878. private _checkIsReady;
  27879. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27880. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27881. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27882. /**
  27883. * Recompiles the webGL program
  27884. * @param vertexSourceCode The source code for the vertex shader.
  27885. * @param fragmentSourceCode The source code for the fragment shader.
  27886. * @param onCompiled Callback called when completed.
  27887. * @param onError Callback called on error.
  27888. * @hidden
  27889. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27890. /**
  27891. * Prepares the effect
  27892. * @hidden
  27893. */ private _prepareEffect(): void;
  27894. private _processCompilationErrors;
  27895. /**
  27896. * Checks if the effect is supported. (Must be called after compilation)
  27897. */
  27898. readonly isSupported: boolean;
  27899. /**
  27900. * Binds a texture to the engine to be used as output of the shader.
  27901. * @param channel Name of the output variable.
  27902. * @param texture Texture to bind.
  27903. * @hidden
  27904. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27905. /**
  27906. * Sets a texture on the engine to be used in the shader.
  27907. * @param channel Name of the sampler variable.
  27908. * @param texture Texture to set.
  27909. */
  27910. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27911. /**
  27912. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27913. * @param channel Name of the sampler variable.
  27914. * @param texture Texture to set.
  27915. */
  27916. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27917. /**
  27918. * Sets an array of textures on the engine to be used in the shader.
  27919. * @param channel Name of the variable.
  27920. * @param textures Textures to set.
  27921. */
  27922. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27923. /**
  27924. * 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)
  27925. * @param channel Name of the sampler variable.
  27926. * @param postProcess Post process to get the input texture from.
  27927. */
  27928. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27929. /**
  27930. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27931. * 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)
  27932. * @param channel Name of the sampler variable.
  27933. * @param postProcess Post process to get the output texture from.
  27934. */
  27935. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27936. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27937. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27938. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27939. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27940. /**
  27941. * Binds a buffer to a uniform.
  27942. * @param buffer Buffer to bind.
  27943. * @param name Name of the uniform variable to bind to.
  27944. */
  27945. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27946. /**
  27947. * Binds block to a uniform.
  27948. * @param blockName Name of the block to bind.
  27949. * @param index Index to bind.
  27950. */
  27951. bindUniformBlock(blockName: string, index: number): void;
  27952. /**
  27953. * Sets an interger value on a uniform variable.
  27954. * @param uniformName Name of the variable.
  27955. * @param value Value to be set.
  27956. * @returns this effect.
  27957. */
  27958. setInt(uniformName: string, value: number): Effect;
  27959. /**
  27960. * Sets an int array on a uniform variable.
  27961. * @param uniformName Name of the variable.
  27962. * @param array array to be set.
  27963. * @returns this effect.
  27964. */
  27965. setIntArray(uniformName: string, array: Int32Array): Effect;
  27966. /**
  27967. * 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)
  27968. * @param uniformName Name of the variable.
  27969. * @param array array to be set.
  27970. * @returns this effect.
  27971. */
  27972. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27973. /**
  27974. * 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)
  27975. * @param uniformName Name of the variable.
  27976. * @param array array to be set.
  27977. * @returns this effect.
  27978. */
  27979. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27980. /**
  27981. * 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)
  27982. * @param uniformName Name of the variable.
  27983. * @param array array to be set.
  27984. * @returns this effect.
  27985. */
  27986. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27987. /**
  27988. * Sets an float array on a uniform variable.
  27989. * @param uniformName Name of the variable.
  27990. * @param array array to be set.
  27991. * @returns this effect.
  27992. */
  27993. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27994. /**
  27995. * 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)
  27996. * @param uniformName Name of the variable.
  27997. * @param array array to be set.
  27998. * @returns this effect.
  27999. */
  28000. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28001. /**
  28002. * 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)
  28003. * @param uniformName Name of the variable.
  28004. * @param array array to be set.
  28005. * @returns this effect.
  28006. */
  28007. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28008. /**
  28009. * 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)
  28010. * @param uniformName Name of the variable.
  28011. * @param array array to be set.
  28012. * @returns this effect.
  28013. */
  28014. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28015. /**
  28016. * Sets an array on a uniform variable.
  28017. * @param uniformName Name of the variable.
  28018. * @param array array to be set.
  28019. * @returns this effect.
  28020. */
  28021. setArray(uniformName: string, array: number[]): Effect;
  28022. /**
  28023. * 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)
  28024. * @param uniformName Name of the variable.
  28025. * @param array array to be set.
  28026. * @returns this effect.
  28027. */
  28028. setArray2(uniformName: string, array: number[]): Effect;
  28029. /**
  28030. * 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)
  28031. * @param uniformName Name of the variable.
  28032. * @param array array to be set.
  28033. * @returns this effect.
  28034. */
  28035. setArray3(uniformName: string, array: number[]): Effect;
  28036. /**
  28037. * 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)
  28038. * @param uniformName Name of the variable.
  28039. * @param array array to be set.
  28040. * @returns this effect.
  28041. */
  28042. setArray4(uniformName: string, array: number[]): Effect;
  28043. /**
  28044. * Sets matrices on a uniform variable.
  28045. * @param uniformName Name of the variable.
  28046. * @param matrices matrices to be set.
  28047. * @returns this effect.
  28048. */
  28049. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28050. /**
  28051. * Sets matrix on a uniform variable.
  28052. * @param uniformName Name of the variable.
  28053. * @param matrix matrix to be set.
  28054. * @returns this effect.
  28055. */
  28056. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28057. /**
  28058. * 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)
  28059. * @param uniformName Name of the variable.
  28060. * @param matrix matrix to be set.
  28061. * @returns this effect.
  28062. */
  28063. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28064. /**
  28065. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28066. * @param uniformName Name of the variable.
  28067. * @param matrix matrix to be set.
  28068. * @returns this effect.
  28069. */
  28070. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28071. /**
  28072. * Sets a float on a uniform variable.
  28073. * @param uniformName Name of the variable.
  28074. * @param value value to be set.
  28075. * @returns this effect.
  28076. */
  28077. setFloat(uniformName: string, value: number): Effect;
  28078. /**
  28079. * Sets a boolean on a uniform variable.
  28080. * @param uniformName Name of the variable.
  28081. * @param bool value to be set.
  28082. * @returns this effect.
  28083. */
  28084. setBool(uniformName: string, bool: boolean): Effect;
  28085. /**
  28086. * Sets a Vector2 on a uniform variable.
  28087. * @param uniformName Name of the variable.
  28088. * @param vector2 vector2 to be set.
  28089. * @returns this effect.
  28090. */
  28091. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28092. /**
  28093. * Sets a float2 on a uniform variable.
  28094. * @param uniformName Name of the variable.
  28095. * @param x First float in float2.
  28096. * @param y Second float in float2.
  28097. * @returns this effect.
  28098. */
  28099. setFloat2(uniformName: string, x: number, y: number): Effect;
  28100. /**
  28101. * Sets a Vector3 on a uniform variable.
  28102. * @param uniformName Name of the variable.
  28103. * @param vector3 Value to be set.
  28104. * @returns this effect.
  28105. */
  28106. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28107. /**
  28108. * Sets a float3 on a uniform variable.
  28109. * @param uniformName Name of the variable.
  28110. * @param x First float in float3.
  28111. * @param y Second float in float3.
  28112. * @param z Third float in float3.
  28113. * @returns this effect.
  28114. */
  28115. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28116. /**
  28117. * Sets a Vector4 on a uniform variable.
  28118. * @param uniformName Name of the variable.
  28119. * @param vector4 Value to be set.
  28120. * @returns this effect.
  28121. */
  28122. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28123. /**
  28124. * Sets a float4 on a uniform variable.
  28125. * @param uniformName Name of the variable.
  28126. * @param x First float in float4.
  28127. * @param y Second float in float4.
  28128. * @param z Third float in float4.
  28129. * @param w Fourth float in float4.
  28130. * @returns this effect.
  28131. */
  28132. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28133. /**
  28134. * Sets a Color3 on a uniform variable.
  28135. * @param uniformName Name of the variable.
  28136. * @param color3 Value to be set.
  28137. * @returns this effect.
  28138. */
  28139. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28140. /**
  28141. * Sets a Color4 on a uniform variable.
  28142. * @param uniformName Name of the variable.
  28143. * @param color3 Value to be set.
  28144. * @param alpha Alpha value to be set.
  28145. * @returns this effect.
  28146. */
  28147. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28148. /**
  28149. * Sets a Color4 on a uniform variable
  28150. * @param uniformName defines the name of the variable
  28151. * @param color4 defines the value to be set
  28152. * @returns this effect.
  28153. */
  28154. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28155. /** Release all associated resources */
  28156. dispose(): void;
  28157. /**
  28158. * This function will add a new shader to the shader store
  28159. * @param name the name of the shader
  28160. * @param pixelShader optional pixel shader content
  28161. * @param vertexShader optional vertex shader content
  28162. */
  28163. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28164. /**
  28165. * Store of each shader (The can be looked up using effect.key)
  28166. */
  28167. static ShadersStore: {
  28168. [key: string]: string;
  28169. };
  28170. /**
  28171. * Store of each included file for a shader (The can be looked up using effect.key)
  28172. */
  28173. static IncludesShadersStore: {
  28174. [key: string]: string;
  28175. };
  28176. /**
  28177. * Resets the cache of effects.
  28178. */
  28179. static ResetCache(): void;
  28180. }
  28181. }
  28182. declare module BABYLON {
  28183. /**
  28184. * Uniform buffer objects.
  28185. *
  28186. * Handles blocks of uniform on the GPU.
  28187. *
  28188. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28189. *
  28190. * For more information, please refer to :
  28191. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28192. */
  28193. export class UniformBuffer {
  28194. private _engine;
  28195. private _buffer;
  28196. private _data;
  28197. private _bufferData;
  28198. private _dynamic?;
  28199. private _uniformLocations;
  28200. private _uniformSizes;
  28201. private _uniformLocationPointer;
  28202. private _needSync;
  28203. private _noUBO;
  28204. private _currentEffect;
  28205. private static _MAX_UNIFORM_SIZE;
  28206. private static _tempBuffer;
  28207. /**
  28208. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28209. * This is dynamic to allow compat with webgl 1 and 2.
  28210. * You will need to pass the name of the uniform as well as the value.
  28211. */
  28212. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28213. /**
  28214. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28215. * This is dynamic to allow compat with webgl 1 and 2.
  28216. * You will need to pass the name of the uniform as well as the value.
  28217. */
  28218. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28219. /**
  28220. * Lambda to Update a single float in a uniform buffer.
  28221. * This is dynamic to allow compat with webgl 1 and 2.
  28222. * You will need to pass the name of the uniform as well as the value.
  28223. */
  28224. updateFloat: (name: string, x: number) => void;
  28225. /**
  28226. * Lambda to Update a vec2 of float in a uniform buffer.
  28227. * This is dynamic to allow compat with webgl 1 and 2.
  28228. * You will need to pass the name of the uniform as well as the value.
  28229. */
  28230. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28231. /**
  28232. * Lambda to Update a vec3 of float in a uniform buffer.
  28233. * This is dynamic to allow compat with webgl 1 and 2.
  28234. * You will need to pass the name of the uniform as well as the value.
  28235. */
  28236. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28237. /**
  28238. * Lambda to Update a vec4 of float in a uniform buffer.
  28239. * This is dynamic to allow compat with webgl 1 and 2.
  28240. * You will need to pass the name of the uniform as well as the value.
  28241. */
  28242. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28243. /**
  28244. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28245. * This is dynamic to allow compat with webgl 1 and 2.
  28246. * You will need to pass the name of the uniform as well as the value.
  28247. */
  28248. updateMatrix: (name: string, mat: Matrix) => void;
  28249. /**
  28250. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28251. * This is dynamic to allow compat with webgl 1 and 2.
  28252. * You will need to pass the name of the uniform as well as the value.
  28253. */
  28254. updateVector3: (name: string, vector: Vector3) => void;
  28255. /**
  28256. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28257. * This is dynamic to allow compat with webgl 1 and 2.
  28258. * You will need to pass the name of the uniform as well as the value.
  28259. */
  28260. updateVector4: (name: string, vector: Vector4) => void;
  28261. /**
  28262. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28263. * This is dynamic to allow compat with webgl 1 and 2.
  28264. * You will need to pass the name of the uniform as well as the value.
  28265. */
  28266. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28267. /**
  28268. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28269. * This is dynamic to allow compat with webgl 1 and 2.
  28270. * You will need to pass the name of the uniform as well as the value.
  28271. */
  28272. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28273. /**
  28274. * Instantiates a new Uniform buffer objects.
  28275. *
  28276. * Handles blocks of uniform on the GPU.
  28277. *
  28278. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28279. *
  28280. * For more information, please refer to :
  28281. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28282. * @param engine Define the engine the buffer is associated with
  28283. * @param data Define the data contained in the buffer
  28284. * @param dynamic Define if the buffer is updatable
  28285. */
  28286. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28287. /**
  28288. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28289. * or just falling back on setUniformXXX calls.
  28290. */
  28291. readonly useUbo: boolean;
  28292. /**
  28293. * Indicates if the WebGL underlying uniform buffer is in sync
  28294. * with the javascript cache data.
  28295. */
  28296. readonly isSync: boolean;
  28297. /**
  28298. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28299. * Also, a dynamic UniformBuffer will disable cache verification and always
  28300. * update the underlying WebGL uniform buffer to the GPU.
  28301. * @returns if Dynamic, otherwise false
  28302. */
  28303. isDynamic(): boolean;
  28304. /**
  28305. * The data cache on JS side.
  28306. * @returns the underlying data as a float array
  28307. */
  28308. getData(): Float32Array;
  28309. /**
  28310. * The underlying WebGL Uniform buffer.
  28311. * @returns the webgl buffer
  28312. */
  28313. getBuffer(): Nullable<DataBuffer>;
  28314. /**
  28315. * std140 layout specifies how to align data within an UBO structure.
  28316. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28317. * for specs.
  28318. */
  28319. private _fillAlignment;
  28320. /**
  28321. * Adds an uniform in the buffer.
  28322. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28323. * for the layout to be correct !
  28324. * @param name Name of the uniform, as used in the uniform block in the shader.
  28325. * @param size Data size, or data directly.
  28326. */
  28327. addUniform(name: string, size: number | number[]): void;
  28328. /**
  28329. * Adds a Matrix 4x4 to the uniform buffer.
  28330. * @param name Name of the uniform, as used in the uniform block in the shader.
  28331. * @param mat A 4x4 matrix.
  28332. */
  28333. addMatrix(name: string, mat: Matrix): void;
  28334. /**
  28335. * Adds a vec2 to the uniform buffer.
  28336. * @param name Name of the uniform, as used in the uniform block in the shader.
  28337. * @param x Define the x component value of the vec2
  28338. * @param y Define the y component value of the vec2
  28339. */
  28340. addFloat2(name: string, x: number, y: number): void;
  28341. /**
  28342. * Adds a vec3 to the uniform buffer.
  28343. * @param name Name of the uniform, as used in the uniform block in the shader.
  28344. * @param x Define the x component value of the vec3
  28345. * @param y Define the y component value of the vec3
  28346. * @param z Define the z component value of the vec3
  28347. */
  28348. addFloat3(name: string, x: number, y: number, z: number): void;
  28349. /**
  28350. * Adds a vec3 to the uniform buffer.
  28351. * @param name Name of the uniform, as used in the uniform block in the shader.
  28352. * @param color Define the vec3 from a Color
  28353. */
  28354. addColor3(name: string, color: Color3): void;
  28355. /**
  28356. * Adds a vec4 to the uniform buffer.
  28357. * @param name Name of the uniform, as used in the uniform block in the shader.
  28358. * @param color Define the rgb components from a Color
  28359. * @param alpha Define the a component of the vec4
  28360. */
  28361. addColor4(name: string, color: Color3, alpha: number): void;
  28362. /**
  28363. * Adds a vec3 to the uniform buffer.
  28364. * @param name Name of the uniform, as used in the uniform block in the shader.
  28365. * @param vector Define the vec3 components from a Vector
  28366. */
  28367. addVector3(name: string, vector: Vector3): void;
  28368. /**
  28369. * Adds a Matrix 3x3 to the uniform buffer.
  28370. * @param name Name of the uniform, as used in the uniform block in the shader.
  28371. */
  28372. addMatrix3x3(name: string): void;
  28373. /**
  28374. * Adds a Matrix 2x2 to the uniform buffer.
  28375. * @param name Name of the uniform, as used in the uniform block in the shader.
  28376. */
  28377. addMatrix2x2(name: string): void;
  28378. /**
  28379. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28380. */
  28381. create(): void;
  28382. /** @hidden */ private _rebuild(): void;
  28383. /**
  28384. * Updates the WebGL Uniform Buffer on the GPU.
  28385. * If the `dynamic` flag is set to true, no cache comparison is done.
  28386. * Otherwise, the buffer will be updated only if the cache differs.
  28387. */
  28388. update(): void;
  28389. /**
  28390. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28391. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28392. * @param data Define the flattened data
  28393. * @param size Define the size of the data.
  28394. */
  28395. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28396. private _valueCache;
  28397. private _cacheMatrix;
  28398. private _updateMatrix3x3ForUniform;
  28399. private _updateMatrix3x3ForEffect;
  28400. private _updateMatrix2x2ForEffect;
  28401. private _updateMatrix2x2ForUniform;
  28402. private _updateFloatForEffect;
  28403. private _updateFloatForUniform;
  28404. private _updateFloat2ForEffect;
  28405. private _updateFloat2ForUniform;
  28406. private _updateFloat3ForEffect;
  28407. private _updateFloat3ForUniform;
  28408. private _updateFloat4ForEffect;
  28409. private _updateFloat4ForUniform;
  28410. private _updateMatrixForEffect;
  28411. private _updateMatrixForUniform;
  28412. private _updateVector3ForEffect;
  28413. private _updateVector3ForUniform;
  28414. private _updateVector4ForEffect;
  28415. private _updateVector4ForUniform;
  28416. private _updateColor3ForEffect;
  28417. private _updateColor3ForUniform;
  28418. private _updateColor4ForEffect;
  28419. private _updateColor4ForUniform;
  28420. /**
  28421. * Sets a sampler uniform on the effect.
  28422. * @param name Define the name of the sampler.
  28423. * @param texture Define the texture to set in the sampler
  28424. */
  28425. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28426. /**
  28427. * Directly updates the value of the uniform in the cache AND on the GPU.
  28428. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28429. * @param data Define the flattened data
  28430. */
  28431. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28432. /**
  28433. * Binds this uniform buffer to an effect.
  28434. * @param effect Define the effect to bind the buffer to
  28435. * @param name Name of the uniform block in the shader.
  28436. */
  28437. bindToEffect(effect: Effect, name: string): void;
  28438. /**
  28439. * Disposes the uniform buffer.
  28440. */
  28441. dispose(): void;
  28442. }
  28443. }
  28444. declare module BABYLON {
  28445. /**
  28446. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28447. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28448. */
  28449. export class Analyser {
  28450. /**
  28451. * Gets or sets the smoothing
  28452. * @ignorenaming
  28453. */
  28454. SMOOTHING: number;
  28455. /**
  28456. * Gets or sets the FFT table size
  28457. * @ignorenaming
  28458. */
  28459. FFT_SIZE: number;
  28460. /**
  28461. * Gets or sets the bar graph amplitude
  28462. * @ignorenaming
  28463. */
  28464. BARGRAPHAMPLITUDE: number;
  28465. /**
  28466. * Gets or sets the position of the debug canvas
  28467. * @ignorenaming
  28468. */
  28469. DEBUGCANVASPOS: {
  28470. x: number;
  28471. y: number;
  28472. };
  28473. /**
  28474. * Gets or sets the debug canvas size
  28475. * @ignorenaming
  28476. */
  28477. DEBUGCANVASSIZE: {
  28478. width: number;
  28479. height: number;
  28480. };
  28481. private _byteFreqs;
  28482. private _byteTime;
  28483. private _floatFreqs;
  28484. private _webAudioAnalyser;
  28485. private _debugCanvas;
  28486. private _debugCanvasContext;
  28487. private _scene;
  28488. private _registerFunc;
  28489. private _audioEngine;
  28490. /**
  28491. * Creates a new analyser
  28492. * @param scene defines hosting scene
  28493. */
  28494. constructor(scene: Scene);
  28495. /**
  28496. * Get the number of data values you will have to play with for the visualization
  28497. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28498. * @returns a number
  28499. */
  28500. getFrequencyBinCount(): number;
  28501. /**
  28502. * Gets the current frequency data as a byte array
  28503. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28504. * @returns a Uint8Array
  28505. */
  28506. getByteFrequencyData(): Uint8Array;
  28507. /**
  28508. * Gets the current waveform as a byte array
  28509. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28510. * @returns a Uint8Array
  28511. */
  28512. getByteTimeDomainData(): Uint8Array;
  28513. /**
  28514. * Gets the current frequency data as a float array
  28515. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28516. * @returns a Float32Array
  28517. */
  28518. getFloatFrequencyData(): Float32Array;
  28519. /**
  28520. * Renders the debug canvas
  28521. */
  28522. drawDebugCanvas(): void;
  28523. /**
  28524. * Stops rendering the debug canvas and removes it
  28525. */
  28526. stopDebugCanvas(): void;
  28527. /**
  28528. * Connects two audio nodes
  28529. * @param inputAudioNode defines first node to connect
  28530. * @param outputAudioNode defines second node to connect
  28531. */
  28532. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28533. /**
  28534. * Releases all associated resources
  28535. */
  28536. dispose(): void;
  28537. }
  28538. }
  28539. declare module BABYLON {
  28540. /**
  28541. * This represents an audio engine and it is responsible
  28542. * to play, synchronize and analyse sounds throughout the application.
  28543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28544. */
  28545. export interface IAudioEngine extends IDisposable {
  28546. /**
  28547. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28548. */
  28549. readonly canUseWebAudio: boolean;
  28550. /**
  28551. * Gets the current AudioContext if available.
  28552. */
  28553. readonly audioContext: Nullable<AudioContext>;
  28554. /**
  28555. * The master gain node defines the global audio volume of your audio engine.
  28556. */
  28557. readonly masterGain: GainNode;
  28558. /**
  28559. * Gets whether or not mp3 are supported by your browser.
  28560. */
  28561. readonly isMP3supported: boolean;
  28562. /**
  28563. * Gets whether or not ogg are supported by your browser.
  28564. */
  28565. readonly isOGGsupported: boolean;
  28566. /**
  28567. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28568. * @ignoreNaming
  28569. */
  28570. WarnedWebAudioUnsupported: boolean;
  28571. /**
  28572. * Defines if the audio engine relies on a custom unlocked button.
  28573. * In this case, the embedded button will not be displayed.
  28574. */
  28575. useCustomUnlockedButton: boolean;
  28576. /**
  28577. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28578. */
  28579. readonly unlocked: boolean;
  28580. /**
  28581. * Event raised when audio has been unlocked on the browser.
  28582. */
  28583. onAudioUnlockedObservable: Observable<AudioEngine>;
  28584. /**
  28585. * Event raised when audio has been locked on the browser.
  28586. */
  28587. onAudioLockedObservable: Observable<AudioEngine>;
  28588. /**
  28589. * Flags the audio engine in Locked state.
  28590. * This happens due to new browser policies preventing audio to autoplay.
  28591. */
  28592. lock(): void;
  28593. /**
  28594. * Unlocks the audio engine once a user action has been done on the dom.
  28595. * This is helpful to resume play once browser policies have been satisfied.
  28596. */
  28597. unlock(): void;
  28598. }
  28599. /**
  28600. * This represents the default audio engine used in babylon.
  28601. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28603. */
  28604. export class AudioEngine implements IAudioEngine {
  28605. private _audioContext;
  28606. private _audioContextInitialized;
  28607. private _muteButton;
  28608. private _hostElement;
  28609. /**
  28610. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28611. */
  28612. canUseWebAudio: boolean;
  28613. /**
  28614. * The master gain node defines the global audio volume of your audio engine.
  28615. */
  28616. masterGain: GainNode;
  28617. /**
  28618. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28619. * @ignoreNaming
  28620. */
  28621. WarnedWebAudioUnsupported: boolean;
  28622. /**
  28623. * Gets whether or not mp3 are supported by your browser.
  28624. */
  28625. isMP3supported: boolean;
  28626. /**
  28627. * Gets whether or not ogg are supported by your browser.
  28628. */
  28629. isOGGsupported: boolean;
  28630. /**
  28631. * Gets whether audio has been unlocked on the device.
  28632. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28633. * a user interaction has happened.
  28634. */
  28635. unlocked: boolean;
  28636. /**
  28637. * Defines if the audio engine relies on a custom unlocked button.
  28638. * In this case, the embedded button will not be displayed.
  28639. */
  28640. useCustomUnlockedButton: boolean;
  28641. /**
  28642. * Event raised when audio has been unlocked on the browser.
  28643. */
  28644. onAudioUnlockedObservable: Observable<AudioEngine>;
  28645. /**
  28646. * Event raised when audio has been locked on the browser.
  28647. */
  28648. onAudioLockedObservable: Observable<AudioEngine>;
  28649. /**
  28650. * Gets the current AudioContext if available.
  28651. */
  28652. readonly audioContext: Nullable<AudioContext>;
  28653. private _connectedAnalyser;
  28654. /**
  28655. * Instantiates a new audio engine.
  28656. *
  28657. * There should be only one per page as some browsers restrict the number
  28658. * of audio contexts you can create.
  28659. * @param hostElement defines the host element where to display the mute icon if necessary
  28660. */
  28661. constructor(hostElement?: Nullable<HTMLElement>);
  28662. /**
  28663. * Flags the audio engine in Locked state.
  28664. * This happens due to new browser policies preventing audio to autoplay.
  28665. */
  28666. lock(): void;
  28667. /**
  28668. * Unlocks the audio engine once a user action has been done on the dom.
  28669. * This is helpful to resume play once browser policies have been satisfied.
  28670. */
  28671. unlock(): void;
  28672. private _resumeAudioContext;
  28673. private _initializeAudioContext;
  28674. private _tryToRun;
  28675. private _triggerRunningState;
  28676. private _triggerSuspendedState;
  28677. private _displayMuteButton;
  28678. private _moveButtonToTopLeft;
  28679. private _onResize;
  28680. private _hideMuteButton;
  28681. /**
  28682. * Destroy and release the resources associated with the audio ccontext.
  28683. */
  28684. dispose(): void;
  28685. /**
  28686. * Gets the global volume sets on the master gain.
  28687. * @returns the global volume if set or -1 otherwise
  28688. */
  28689. getGlobalVolume(): number;
  28690. /**
  28691. * Sets the global volume of your experience (sets on the master gain).
  28692. * @param newVolume Defines the new global volume of the application
  28693. */
  28694. setGlobalVolume(newVolume: number): void;
  28695. /**
  28696. * Connect the audio engine to an audio analyser allowing some amazing
  28697. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28699. * @param analyser The analyser to connect to the engine
  28700. */
  28701. connectToAnalyser(analyser: Analyser): void;
  28702. }
  28703. }
  28704. declare module BABYLON {
  28705. /**
  28706. * Interface used to present a loading screen while loading a scene
  28707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28708. */
  28709. export interface ILoadingScreen {
  28710. /**
  28711. * Function called to display the loading screen
  28712. */
  28713. displayLoadingUI: () => void;
  28714. /**
  28715. * Function called to hide the loading screen
  28716. */
  28717. hideLoadingUI: () => void;
  28718. /**
  28719. * Gets or sets the color to use for the background
  28720. */
  28721. loadingUIBackgroundColor: string;
  28722. /**
  28723. * Gets or sets the text to display while loading
  28724. */
  28725. loadingUIText: string;
  28726. }
  28727. /**
  28728. * Class used for the default loading screen
  28729. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28730. */
  28731. export class DefaultLoadingScreen implements ILoadingScreen {
  28732. private _renderingCanvas;
  28733. private _loadingText;
  28734. private _loadingDivBackgroundColor;
  28735. private _loadingDiv;
  28736. private _loadingTextDiv;
  28737. /** Gets or sets the logo url to use for the default loading screen */
  28738. static DefaultLogoUrl: string;
  28739. /** Gets or sets the spinner url to use for the default loading screen */
  28740. static DefaultSpinnerUrl: string;
  28741. /**
  28742. * Creates a new default loading screen
  28743. * @param _renderingCanvas defines the canvas used to render the scene
  28744. * @param _loadingText defines the default text to display
  28745. * @param _loadingDivBackgroundColor defines the default background color
  28746. */
  28747. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28748. /**
  28749. * Function called to display the loading screen
  28750. */
  28751. displayLoadingUI(): void;
  28752. /**
  28753. * Function called to hide the loading screen
  28754. */
  28755. hideLoadingUI(): void;
  28756. /**
  28757. * Gets or sets the text to display while loading
  28758. */
  28759. loadingUIText: string;
  28760. /**
  28761. * Gets or sets the color to use for the background
  28762. */
  28763. loadingUIBackgroundColor: string;
  28764. private _resizeLoadingUI;
  28765. }
  28766. }
  28767. declare module BABYLON {
  28768. /** @hidden */
  28769. export class WebGLPipelineContext implements IPipelineContext {
  28770. engine: Engine;
  28771. program: Nullable<WebGLProgram>;
  28772. context?: WebGLRenderingContext;
  28773. vertexShader?: WebGLShader;
  28774. fragmentShader?: WebGLShader;
  28775. isParallelCompiled: boolean;
  28776. onCompiled?: () => void;
  28777. transformFeedback?: WebGLTransformFeedback | null;
  28778. readonly isAsync: boolean;
  28779. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28780. }
  28781. }
  28782. declare module BABYLON {
  28783. /** @hidden */
  28784. export class WebGLDataBuffer extends DataBuffer {
  28785. private _buffer;
  28786. constructor(resource: WebGLBuffer);
  28787. readonly underlyingResource: any;
  28788. }
  28789. }
  28790. declare module BABYLON {
  28791. /** @hidden */
  28792. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28793. attributeProcessor(attribute: string): string;
  28794. varyingProcessor(varying: string, isFragment: boolean): string;
  28795. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28796. }
  28797. }
  28798. declare module BABYLON {
  28799. /**
  28800. * This class is used to track a performance counter which is number based.
  28801. * The user has access to many properties which give statistics of different nature.
  28802. *
  28803. * The implementer can track two kinds of Performance Counter: time and count.
  28804. * 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.
  28805. * 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.
  28806. */
  28807. export class PerfCounter {
  28808. /**
  28809. * Gets or sets a global boolean to turn on and off all the counters
  28810. */
  28811. static Enabled: boolean;
  28812. /**
  28813. * Returns the smallest value ever
  28814. */
  28815. readonly min: number;
  28816. /**
  28817. * Returns the biggest value ever
  28818. */
  28819. readonly max: number;
  28820. /**
  28821. * Returns the average value since the performance counter is running
  28822. */
  28823. readonly average: number;
  28824. /**
  28825. * Returns the average value of the last second the counter was monitored
  28826. */
  28827. readonly lastSecAverage: number;
  28828. /**
  28829. * Returns the current value
  28830. */
  28831. readonly current: number;
  28832. /**
  28833. * Gets the accumulated total
  28834. */
  28835. readonly total: number;
  28836. /**
  28837. * Gets the total value count
  28838. */
  28839. readonly count: number;
  28840. /**
  28841. * Creates a new counter
  28842. */
  28843. constructor();
  28844. /**
  28845. * Call this method to start monitoring a new frame.
  28846. * 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.
  28847. */
  28848. fetchNewFrame(): void;
  28849. /**
  28850. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28851. * @param newCount the count value to add to the monitored count
  28852. * @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.
  28853. */
  28854. addCount(newCount: number, fetchResult: boolean): void;
  28855. /**
  28856. * Start monitoring this performance counter
  28857. */
  28858. beginMonitoring(): void;
  28859. /**
  28860. * Compute the time lapsed since the previous beginMonitoring() call.
  28861. * @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
  28862. */
  28863. endMonitoring(newFrame?: boolean): void;
  28864. private _fetchResult;
  28865. private _startMonitoringTime;
  28866. private _min;
  28867. private _max;
  28868. private _average;
  28869. private _current;
  28870. private _totalValueCount;
  28871. private _totalAccumulated;
  28872. private _lastSecAverage;
  28873. private _lastSecAccumulated;
  28874. private _lastSecTime;
  28875. private _lastSecValueCount;
  28876. }
  28877. }
  28878. declare module BABYLON {
  28879. /**
  28880. * Interface for any object that can request an animation frame
  28881. */
  28882. export interface ICustomAnimationFrameRequester {
  28883. /**
  28884. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  28885. */
  28886. renderFunction?: Function;
  28887. /**
  28888. * Called to request the next frame to render to
  28889. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  28890. */
  28891. requestAnimationFrame: Function;
  28892. /**
  28893. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  28894. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  28895. */
  28896. requestID?: number;
  28897. }
  28898. }
  28899. declare module BABYLON {
  28900. /**
  28901. * Settings for finer control over video usage
  28902. */
  28903. export interface VideoTextureSettings {
  28904. /**
  28905. * Applies `autoplay` to video, if specified
  28906. */
  28907. autoPlay?: boolean;
  28908. /**
  28909. * Applies `loop` to video, if specified
  28910. */
  28911. loop?: boolean;
  28912. /**
  28913. * Automatically updates internal texture from video at every frame in the render loop
  28914. */
  28915. autoUpdateTexture: boolean;
  28916. /**
  28917. * Image src displayed during the video loading or until the user interacts with the video.
  28918. */
  28919. poster?: string;
  28920. }
  28921. /**
  28922. * If you want to display a video in your scene, this is the special texture for that.
  28923. * This special texture works similar to other textures, with the exception of a few parameters.
  28924. * @see https://doc.babylonjs.com/how_to/video_texture
  28925. */
  28926. export class VideoTexture extends Texture {
  28927. /**
  28928. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28929. */
  28930. readonly autoUpdateTexture: boolean;
  28931. /**
  28932. * The video instance used by the texture internally
  28933. */
  28934. readonly video: HTMLVideoElement;
  28935. private _onUserActionRequestedObservable;
  28936. /**
  28937. * Event triggerd when a dom action is required by the user to play the video.
  28938. * This happens due to recent changes in browser policies preventing video to auto start.
  28939. */
  28940. readonly onUserActionRequestedObservable: Observable<Texture>;
  28941. private _generateMipMaps;
  28942. private _engine;
  28943. private _stillImageCaptured;
  28944. private _displayingPosterTexture;
  28945. private _settings;
  28946. private _createInternalTextureOnEvent;
  28947. private _frameId;
  28948. /**
  28949. * Creates a video texture.
  28950. * If you want to display a video in your scene, this is the special texture for that.
  28951. * This special texture works similar to other textures, with the exception of a few parameters.
  28952. * @see https://doc.babylonjs.com/how_to/video_texture
  28953. * @param name optional name, will detect from video source, if not defined
  28954. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28955. * @param scene is obviously the current scene.
  28956. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28957. * @param invertY is false by default but can be used to invert video on Y axis
  28958. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28959. * @param settings allows finer control over video usage
  28960. */
  28961. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28962. private _getName;
  28963. private _getVideo;
  28964. private _createInternalTexture;
  28965. private reset;
  28966. /**
  28967. * @hidden Internal method to initiate `update`.
  28968. */ private _rebuild(): void;
  28969. /**
  28970. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28971. */
  28972. update(): void;
  28973. /**
  28974. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28975. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28976. */
  28977. updateTexture(isVisible: boolean): void;
  28978. protected _updateInternalTexture: () => void;
  28979. /**
  28980. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28981. * @param url New url.
  28982. */
  28983. updateURL(url: string): void;
  28984. /**
  28985. * Dispose the texture and release its associated resources.
  28986. */
  28987. dispose(): void;
  28988. /**
  28989. * Creates a video texture straight from a stream.
  28990. * @param scene Define the scene the texture should be created in
  28991. * @param stream Define the stream the texture should be created from
  28992. * @returns The created video texture as a promise
  28993. */
  28994. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28995. /**
  28996. * Creates a video texture straight from your WebCam video feed.
  28997. * @param scene Define the scene the texture should be created in
  28998. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28999. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29000. * @returns The created video texture as a promise
  29001. */
  29002. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29003. minWidth: number;
  29004. maxWidth: number;
  29005. minHeight: number;
  29006. maxHeight: number;
  29007. deviceId: string;
  29008. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29009. /**
  29010. * Creates a video texture straight from your WebCam video feed.
  29011. * @param scene Define the scene the texture should be created in
  29012. * @param onReady Define a callback to triggered once the texture will be ready
  29013. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29014. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29015. */
  29016. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29017. minWidth: number;
  29018. maxWidth: number;
  29019. minHeight: number;
  29020. maxHeight: number;
  29021. deviceId: string;
  29022. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. /**
  29027. * Defines the interface used by objects containing a viewport (like a camera)
  29028. */
  29029. interface IViewportOwnerLike {
  29030. /**
  29031. * Gets or sets the viewport
  29032. */
  29033. viewport: IViewportLike;
  29034. }
  29035. /**
  29036. * Interface for attribute information associated with buffer instanciation
  29037. */
  29038. export class InstancingAttributeInfo {
  29039. /**
  29040. * Index/offset of the attribute in the vertex shader
  29041. */
  29042. index: number;
  29043. /**
  29044. * size of the attribute, 1, 2, 3 or 4
  29045. */
  29046. attributeSize: number;
  29047. /**
  29048. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29049. * default is FLOAT
  29050. */
  29051. attribyteType: number;
  29052. /**
  29053. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29054. */
  29055. normalized: boolean;
  29056. /**
  29057. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29058. */
  29059. offset: number;
  29060. /**
  29061. * Name of the GLSL attribute, for debugging purpose only
  29062. */
  29063. attributeName: string;
  29064. }
  29065. /**
  29066. * Define options used to create a depth texture
  29067. */
  29068. export class DepthTextureCreationOptions {
  29069. /** Specifies whether or not a stencil should be allocated in the texture */
  29070. generateStencil?: boolean;
  29071. /** Specifies whether or not bilinear filtering is enable on the texture */
  29072. bilinearFiltering?: boolean;
  29073. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29074. comparisonFunction?: number;
  29075. /** Specifies if the created texture is a cube texture */
  29076. isCube?: boolean;
  29077. }
  29078. /**
  29079. * Class used to describe the capabilities of the engine relatively to the current browser
  29080. */
  29081. export class EngineCapabilities {
  29082. /** Maximum textures units per fragment shader */
  29083. maxTexturesImageUnits: number;
  29084. /** Maximum texture units per vertex shader */
  29085. maxVertexTextureImageUnits: number;
  29086. /** Maximum textures units in the entire pipeline */
  29087. maxCombinedTexturesImageUnits: number;
  29088. /** Maximum texture size */
  29089. maxTextureSize: number;
  29090. /** Maximum cube texture size */
  29091. maxCubemapTextureSize: number;
  29092. /** Maximum render texture size */
  29093. maxRenderTextureSize: number;
  29094. /** Maximum number of vertex attributes */
  29095. maxVertexAttribs: number;
  29096. /** Maximum number of varyings */
  29097. maxVaryingVectors: number;
  29098. /** Maximum number of uniforms per vertex shader */
  29099. maxVertexUniformVectors: number;
  29100. /** Maximum number of uniforms per fragment shader */
  29101. maxFragmentUniformVectors: number;
  29102. /** Defines if standard derivates (dx/dy) are supported */
  29103. standardDerivatives: boolean;
  29104. /** Defines if s3tc texture compression is supported */
  29105. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29106. /** Defines if pvrtc texture compression is supported */
  29107. pvrtc: any;
  29108. /** Defines if etc1 texture compression is supported */
  29109. etc1: any;
  29110. /** Defines if etc2 texture compression is supported */
  29111. etc2: any;
  29112. /** Defines if astc texture compression is supported */
  29113. astc: any;
  29114. /** Defines if float textures are supported */
  29115. textureFloat: boolean;
  29116. /** Defines if vertex array objects are supported */
  29117. vertexArrayObject: boolean;
  29118. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29119. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29120. /** Gets the maximum level of anisotropy supported */
  29121. maxAnisotropy: number;
  29122. /** Defines if instancing is supported */
  29123. instancedArrays: boolean;
  29124. /** Defines if 32 bits indices are supported */
  29125. uintIndices: boolean;
  29126. /** Defines if high precision shaders are supported */
  29127. highPrecisionShaderSupported: boolean;
  29128. /** Defines if depth reading in the fragment shader is supported */
  29129. fragmentDepthSupported: boolean;
  29130. /** Defines if float texture linear filtering is supported*/
  29131. textureFloatLinearFiltering: boolean;
  29132. /** Defines if rendering to float textures is supported */
  29133. textureFloatRender: boolean;
  29134. /** Defines if half float textures are supported*/
  29135. textureHalfFloat: boolean;
  29136. /** Defines if half float texture linear filtering is supported*/
  29137. textureHalfFloatLinearFiltering: boolean;
  29138. /** Defines if rendering to half float textures is supported */
  29139. textureHalfFloatRender: boolean;
  29140. /** Defines if textureLOD shader command is supported */
  29141. textureLOD: boolean;
  29142. /** Defines if draw buffers extension is supported */
  29143. drawBuffersExtension: boolean;
  29144. /** Defines if depth textures are supported */
  29145. depthTextureExtension: boolean;
  29146. /** Defines if float color buffer are supported */
  29147. colorBufferFloat: boolean;
  29148. /** Gets disjoint timer query extension (null if not supported) */
  29149. timerQuery: EXT_disjoint_timer_query;
  29150. /** Defines if timestamp can be used with timer query */
  29151. canUseTimestampForTimerQuery: boolean;
  29152. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29153. multiview: any;
  29154. /** Function used to let the system compiles shaders in background */
  29155. parallelShaderCompile: {
  29156. COMPLETION_STATUS_KHR: number;
  29157. };
  29158. /** Max number of texture samples for MSAA */
  29159. maxMSAASamples: number;
  29160. }
  29161. /** Interface defining initialization parameters for Engine class */
  29162. export interface EngineOptions extends WebGLContextAttributes {
  29163. /**
  29164. * Defines if the engine should no exceed a specified device ratio
  29165. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29166. */
  29167. limitDeviceRatio?: number;
  29168. /**
  29169. * Defines if webvr should be enabled automatically
  29170. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29171. */
  29172. autoEnableWebVR?: boolean;
  29173. /**
  29174. * Defines if webgl2 should be turned off even if supported
  29175. * @see http://doc.babylonjs.com/features/webgl2
  29176. */
  29177. disableWebGL2Support?: boolean;
  29178. /**
  29179. * Defines if webaudio should be initialized as well
  29180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29181. */
  29182. audioEngine?: boolean;
  29183. /**
  29184. * Defines if animations should run using a deterministic lock step
  29185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29186. */
  29187. deterministicLockstep?: boolean;
  29188. /** Defines the maximum steps to use with deterministic lock step mode */
  29189. lockstepMaxSteps?: number;
  29190. /**
  29191. * Defines that engine should ignore context lost events
  29192. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29193. */
  29194. doNotHandleContextLost?: boolean;
  29195. /**
  29196. * Defines that engine should ignore modifying touch action attribute and style
  29197. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29198. */
  29199. doNotHandleTouchAction?: boolean;
  29200. /**
  29201. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29202. */
  29203. useHighPrecisionFloats?: boolean;
  29204. }
  29205. /**
  29206. * Defines the interface used by display changed events
  29207. */
  29208. export interface IDisplayChangedEventArgs {
  29209. /** Gets the vrDisplay object (if any) */
  29210. vrDisplay: Nullable<any>;
  29211. /** Gets a boolean indicating if webVR is supported */
  29212. vrSupported: boolean;
  29213. }
  29214. /**
  29215. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29216. */
  29217. export class Engine {
  29218. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29219. static ExceptionList: ({
  29220. key: string;
  29221. capture: string;
  29222. captureConstraint: number;
  29223. targets: string[];
  29224. } | {
  29225. key: string;
  29226. capture: null;
  29227. captureConstraint: null;
  29228. targets: string[];
  29229. })[];
  29230. /** Gets the list of created engines */
  29231. static readonly Instances: Engine[];
  29232. /**
  29233. * Gets the latest created engine
  29234. */
  29235. static readonly LastCreatedEngine: Nullable<Engine>;
  29236. /**
  29237. * Gets the latest created scene
  29238. */
  29239. static readonly LastCreatedScene: Nullable<Scene>;
  29240. /**
  29241. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29242. * @param flag defines which part of the materials must be marked as dirty
  29243. * @param predicate defines a predicate used to filter which materials should be affected
  29244. */
  29245. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29246. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29247. /** Defines that alpha blending is disabled */
  29248. static readonly ALPHA_DISABLE: number;
  29249. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29250. static readonly ALPHA_ADD: number;
  29251. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29252. static readonly ALPHA_COMBINE: number;
  29253. /** Defines that alpha blending to DEST - SRC * DEST */
  29254. static readonly ALPHA_SUBTRACT: number;
  29255. /** Defines that alpha blending to SRC * DEST */
  29256. static readonly ALPHA_MULTIPLY: number;
  29257. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29258. static readonly ALPHA_MAXIMIZED: number;
  29259. /** Defines that alpha blending to SRC + DEST */
  29260. static readonly ALPHA_ONEONE: number;
  29261. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29262. static readonly ALPHA_PREMULTIPLIED: number;
  29263. /**
  29264. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29265. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29266. */
  29267. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29268. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29269. static readonly ALPHA_INTERPOLATE: number;
  29270. /**
  29271. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29272. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29273. */
  29274. static readonly ALPHA_SCREENMODE: number;
  29275. /** Defines that the ressource is not delayed*/
  29276. static readonly DELAYLOADSTATE_NONE: number;
  29277. /** Defines that the ressource was successfully delay loaded */
  29278. static readonly DELAYLOADSTATE_LOADED: number;
  29279. /** Defines that the ressource is currently delay loading */
  29280. static readonly DELAYLOADSTATE_LOADING: number;
  29281. /** Defines that the ressource is delayed and has not started loading */
  29282. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29283. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29284. static readonly NEVER: number;
  29285. /** 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 */
  29286. static readonly ALWAYS: number;
  29287. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29288. static readonly LESS: number;
  29289. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29290. static readonly EQUAL: number;
  29291. /** 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 */
  29292. static readonly LEQUAL: number;
  29293. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29294. static readonly GREATER: number;
  29295. /** 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 */
  29296. static readonly GEQUAL: number;
  29297. /** 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 */
  29298. static readonly NOTEQUAL: number;
  29299. /** Passed to stencilOperation to specify that stencil value must be kept */
  29300. static readonly KEEP: number;
  29301. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29302. static readonly REPLACE: number;
  29303. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29304. static readonly INCR: number;
  29305. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29306. static readonly DECR: number;
  29307. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29308. static readonly INVERT: number;
  29309. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29310. static readonly INCR_WRAP: number;
  29311. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29312. static readonly DECR_WRAP: number;
  29313. /** Texture is not repeating outside of 0..1 UVs */
  29314. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29315. /** Texture is repeating outside of 0..1 UVs */
  29316. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29317. /** Texture is repeating and mirrored */
  29318. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29319. /** ALPHA */
  29320. static readonly TEXTUREFORMAT_ALPHA: number;
  29321. /** LUMINANCE */
  29322. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29323. /** LUMINANCE_ALPHA */
  29324. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29325. /** RGB */
  29326. static readonly TEXTUREFORMAT_RGB: number;
  29327. /** RGBA */
  29328. static readonly TEXTUREFORMAT_RGBA: number;
  29329. /** RED */
  29330. static readonly TEXTUREFORMAT_RED: number;
  29331. /** RED (2nd reference) */
  29332. static readonly TEXTUREFORMAT_R: number;
  29333. /** RG */
  29334. static readonly TEXTUREFORMAT_RG: number;
  29335. /** RED_INTEGER */
  29336. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29337. /** RED_INTEGER (2nd reference) */
  29338. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29339. /** RG_INTEGER */
  29340. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29341. /** RGB_INTEGER */
  29342. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29343. /** RGBA_INTEGER */
  29344. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29345. /** UNSIGNED_BYTE */
  29346. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29347. /** UNSIGNED_BYTE (2nd reference) */
  29348. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29349. /** FLOAT */
  29350. static readonly TEXTURETYPE_FLOAT: number;
  29351. /** HALF_FLOAT */
  29352. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29353. /** BYTE */
  29354. static readonly TEXTURETYPE_BYTE: number;
  29355. /** SHORT */
  29356. static readonly TEXTURETYPE_SHORT: number;
  29357. /** UNSIGNED_SHORT */
  29358. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29359. /** INT */
  29360. static readonly TEXTURETYPE_INT: number;
  29361. /** UNSIGNED_INT */
  29362. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29363. /** UNSIGNED_SHORT_4_4_4_4 */
  29364. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29365. /** UNSIGNED_SHORT_5_5_5_1 */
  29366. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29367. /** UNSIGNED_SHORT_5_6_5 */
  29368. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29369. /** UNSIGNED_INT_2_10_10_10_REV */
  29370. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29371. /** UNSIGNED_INT_24_8 */
  29372. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29373. /** UNSIGNED_INT_10F_11F_11F_REV */
  29374. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29375. /** UNSIGNED_INT_5_9_9_9_REV */
  29376. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29377. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29378. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29379. /** nearest is mag = nearest and min = nearest and mip = linear */
  29380. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29381. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29382. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29383. /** Trilinear is mag = linear and min = linear and mip = linear */
  29384. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29385. /** nearest is mag = nearest and min = nearest and mip = linear */
  29386. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29387. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29388. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29389. /** Trilinear is mag = linear and min = linear and mip = linear */
  29390. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29391. /** mag = nearest and min = nearest and mip = nearest */
  29392. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29393. /** mag = nearest and min = linear and mip = nearest */
  29394. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29395. /** mag = nearest and min = linear and mip = linear */
  29396. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29397. /** mag = nearest and min = linear and mip = none */
  29398. static readonly TEXTURE_NEAREST_LINEAR: number;
  29399. /** mag = nearest and min = nearest and mip = none */
  29400. static readonly TEXTURE_NEAREST_NEAREST: number;
  29401. /** mag = linear and min = nearest and mip = nearest */
  29402. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29403. /** mag = linear and min = nearest and mip = linear */
  29404. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29405. /** mag = linear and min = linear and mip = none */
  29406. static readonly TEXTURE_LINEAR_LINEAR: number;
  29407. /** mag = linear and min = nearest and mip = none */
  29408. static readonly TEXTURE_LINEAR_NEAREST: number;
  29409. /** Explicit coordinates mode */
  29410. static readonly TEXTURE_EXPLICIT_MODE: number;
  29411. /** Spherical coordinates mode */
  29412. static readonly TEXTURE_SPHERICAL_MODE: number;
  29413. /** Planar coordinates mode */
  29414. static readonly TEXTURE_PLANAR_MODE: number;
  29415. /** Cubic coordinates mode */
  29416. static readonly TEXTURE_CUBIC_MODE: number;
  29417. /** Projection coordinates mode */
  29418. static readonly TEXTURE_PROJECTION_MODE: number;
  29419. /** Skybox coordinates mode */
  29420. static readonly TEXTURE_SKYBOX_MODE: number;
  29421. /** Inverse Cubic coordinates mode */
  29422. static readonly TEXTURE_INVCUBIC_MODE: number;
  29423. /** Equirectangular coordinates mode */
  29424. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29425. /** Equirectangular Fixed coordinates mode */
  29426. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29427. /** Equirectangular Fixed Mirrored coordinates mode */
  29428. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29429. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29430. static readonly SCALEMODE_FLOOR: number;
  29431. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29432. static readonly SCALEMODE_NEAREST: number;
  29433. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29434. static readonly SCALEMODE_CEILING: number;
  29435. /**
  29436. * Returns the current npm package of the sdk
  29437. */
  29438. static readonly NpmPackage: string;
  29439. /**
  29440. * Returns the current version of the framework
  29441. */
  29442. static readonly Version: string;
  29443. /**
  29444. * Returns a string describing the current engine
  29445. */
  29446. readonly description: string;
  29447. /**
  29448. * Gets or sets the epsilon value used by collision engine
  29449. */
  29450. static CollisionsEpsilon: number;
  29451. /**
  29452. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29453. */
  29454. static ShadersRepository: string;
  29455. /**
  29456. * Method called to create the default loading screen.
  29457. * This can be overriden in your own app.
  29458. * @param canvas The rendering canvas element
  29459. * @returns The loading screen
  29460. */
  29461. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29462. /**
  29463. * Method called to create the default rescale post process on each engine.
  29464. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29465. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  29466. /**
  29467. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29468. */
  29469. forcePOTTextures: boolean;
  29470. /**
  29471. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29472. */
  29473. isFullscreen: boolean;
  29474. /**
  29475. * Gets a boolean indicating if the pointer is currently locked
  29476. */
  29477. isPointerLock: boolean;
  29478. /**
  29479. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29480. */
  29481. cullBackFaces: boolean;
  29482. /**
  29483. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29484. */
  29485. renderEvenInBackground: boolean;
  29486. /**
  29487. * Gets or sets a boolean indicating that cache can be kept between frames
  29488. */
  29489. preventCacheWipeBetweenFrames: boolean;
  29490. /**
  29491. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29492. **/
  29493. enableOfflineSupport: boolean;
  29494. /**
  29495. * 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)
  29496. **/
  29497. disableManifestCheck: boolean;
  29498. /**
  29499. * Gets the list of created scenes
  29500. */
  29501. scenes: Scene[];
  29502. /**
  29503. * Event raised when a new scene is created
  29504. */
  29505. onNewSceneAddedObservable: Observable<Scene>;
  29506. /**
  29507. * Gets the list of created postprocesses
  29508. */
  29509. postProcesses: PostProcess[];
  29510. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29511. validateShaderPrograms: boolean;
  29512. /**
  29513. * Observable event triggered each time the rendering canvas is resized
  29514. */
  29515. onResizeObservable: Observable<Engine>;
  29516. /**
  29517. * Observable event triggered each time the canvas loses focus
  29518. */
  29519. onCanvasBlurObservable: Observable<Engine>;
  29520. /**
  29521. * Observable event triggered each time the canvas gains focus
  29522. */
  29523. onCanvasFocusObservable: Observable<Engine>;
  29524. /**
  29525. * Observable event triggered each time the canvas receives pointerout event
  29526. */
  29527. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29528. /**
  29529. * Observable event triggered before each texture is initialized
  29530. */
  29531. onBeforeTextureInitObservable: Observable<Texture>;
  29532. /**
  29533. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29534. */
  29535. disableUniformBuffers: boolean;
  29536. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29537. /**
  29538. * Gets a boolean indicating that the engine supports uniform buffers
  29539. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29540. */
  29541. readonly supportsUniformBuffers: boolean;
  29542. /**
  29543. * Observable raised when the engine begins a new frame
  29544. */
  29545. onBeginFrameObservable: Observable<Engine>;
  29546. /**
  29547. * If set, will be used to request the next animation frame for the render loop
  29548. */
  29549. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29550. /**
  29551. * Observable raised when the engine ends the current frame
  29552. */
  29553. onEndFrameObservable: Observable<Engine>;
  29554. /**
  29555. * Observable raised when the engine is about to compile a shader
  29556. */
  29557. onBeforeShaderCompilationObservable: Observable<Engine>;
  29558. /**
  29559. * Observable raised when the engine has jsut compiled a shader
  29560. */
  29561. onAfterShaderCompilationObservable: Observable<Engine>;
  29562. /** @hidden */ private _gl: WebGLRenderingContext;
  29563. private _renderingCanvas;
  29564. private _windowIsBackground;
  29565. protected _webGLVersion: number;
  29566. protected _highPrecisionShadersAllowed: boolean;
  29567. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  29568. /**
  29569. * Gets a boolean indicating that only power of 2 textures are supported
  29570. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29571. */
  29572. readonly needPOTTextures: boolean;
  29573. /** @hidden */ private _badOS: boolean;
  29574. /** @hidden */ private _badDesktopOS: boolean;
  29575. /**
  29576. * Gets the audio engine
  29577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29578. * @ignorenaming
  29579. */
  29580. static audioEngine: IAudioEngine;
  29581. /**
  29582. * Default AudioEngine factory responsible of creating the Audio Engine.
  29583. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29584. */
  29585. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29586. /**
  29587. * Default offline support factory responsible of creating a tool used to store data locally.
  29588. * By default, this will create a Database object if the workload has been embedded.
  29589. */
  29590. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29591. private _onFocus;
  29592. private _onBlur;
  29593. private _onCanvasPointerOut;
  29594. private _onCanvasBlur;
  29595. private _onCanvasFocus;
  29596. private _onFullscreenChange;
  29597. private _onPointerLockChange;
  29598. private _hardwareScalingLevel;
  29599. /** @hidden */ private _caps: EngineCapabilities;
  29600. private _pointerLockRequested;
  29601. private _isStencilEnable;
  29602. protected _colorWrite: boolean;
  29603. private _loadingScreen;
  29604. /** @hidden */ private _drawCalls: PerfCounter;
  29605. private _glVersion;
  29606. private _glRenderer;
  29607. private _glVendor;
  29608. private _videoTextureSupported;
  29609. private _renderingQueueLaunched;
  29610. private _activeRenderLoops;
  29611. private _deterministicLockstep;
  29612. private _lockstepMaxSteps;
  29613. /**
  29614. * Observable signaled when a context lost event is raised
  29615. */
  29616. onContextLostObservable: Observable<Engine>;
  29617. /**
  29618. * Observable signaled when a context restored event is raised
  29619. */
  29620. onContextRestoredObservable: Observable<Engine>;
  29621. private _onContextLost;
  29622. private _onContextRestored;
  29623. private _contextWasLost;
  29624. /** @hidden */ private _doNotHandleContextLost: boolean;
  29625. /**
  29626. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29628. */
  29629. doNotHandleContextLost: boolean;
  29630. private _performanceMonitor;
  29631. private _fps;
  29632. private _deltaTime;
  29633. /**
  29634. * Turn this value on if you want to pause FPS computation when in background
  29635. */
  29636. disablePerformanceMonitorInBackground: boolean;
  29637. /**
  29638. * Gets the performance monitor attached to this engine
  29639. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29640. */
  29641. readonly performanceMonitor: PerformanceMonitor;
  29642. /**
  29643. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29644. */
  29645. disableVertexArrayObjects: boolean;
  29646. /** @hidden */
  29647. protected _depthCullingState: _DepthCullingState;
  29648. /** @hidden */
  29649. protected _stencilState: _StencilState;
  29650. /** @hidden */
  29651. protected _alphaState: _AlphaState;
  29652. /** @hidden */
  29653. protected _alphaMode: number;
  29654. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  29655. /** @hidden */
  29656. protected _activeChannel: number;
  29657. private _currentTextureChannel;
  29658. /** @hidden */
  29659. protected _boundTexturesCache: {
  29660. [key: string]: Nullable<InternalTexture>;
  29661. };
  29662. /** @hidden */
  29663. protected _currentEffect: Nullable<Effect>;
  29664. /** @hidden */
  29665. protected _currentProgram: Nullable<WebGLProgram>;
  29666. private _compiledEffects;
  29667. private _vertexAttribArraysEnabled;
  29668. /** @hidden */
  29669. protected _cachedViewport: Nullable<IViewportLike>;
  29670. private _cachedVertexArrayObject;
  29671. /** @hidden */
  29672. protected _cachedVertexBuffers: any;
  29673. /** @hidden */
  29674. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29675. /** @hidden */
  29676. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29677. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  29678. private _uintIndicesCurrentlySet;
  29679. private _currentBoundBuffer;
  29680. /** @hidden */
  29681. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29682. private _currentBufferPointers;
  29683. private _currentInstanceLocations;
  29684. private _currentInstanceBuffers;
  29685. private _textureUnits;
  29686. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29687. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29688. private _rescalePostProcess;
  29689. private _dummyFramebuffer;
  29690. private _externalData;
  29691. /** @hidden */ private _bindedRenderFunction: any;
  29692. private _vaoRecordInProgress;
  29693. private _mustWipeVertexAttributes;
  29694. private _emptyTexture;
  29695. private _emptyCubeTexture;
  29696. private _emptyTexture3D;
  29697. /** @hidden */ private _frameHandler: number;
  29698. private _nextFreeTextureSlots;
  29699. private _maxSimultaneousTextures;
  29700. private _activeRequests;
  29701. private _texturesSupported;
  29702. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  29703. /**
  29704. * Gets the list of texture formats supported
  29705. */
  29706. readonly texturesSupported: Array<string>;
  29707. /**
  29708. * Gets the list of texture formats in use
  29709. */
  29710. readonly textureFormatInUse: Nullable<string>;
  29711. /**
  29712. * Gets the current viewport
  29713. */
  29714. readonly currentViewport: Nullable<IViewportLike>;
  29715. /**
  29716. * Gets the default empty texture
  29717. */
  29718. readonly emptyTexture: InternalTexture;
  29719. /**
  29720. * Gets the default empty 3D texture
  29721. */
  29722. readonly emptyTexture3D: InternalTexture;
  29723. /**
  29724. * Gets the default empty cube texture
  29725. */
  29726. readonly emptyCubeTexture: InternalTexture;
  29727. /**
  29728. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29729. */
  29730. readonly premultipliedAlpha: boolean;
  29731. /**
  29732. * Creates a new engine
  29733. * @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
  29734. * @param antialias defines enable antialiasing (default: false)
  29735. * @param options defines further options to be sent to the getContext() function
  29736. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29737. */
  29738. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29739. /**
  29740. * Initializes a webVR display and starts listening to display change events
  29741. * The onVRDisplayChangedObservable will be notified upon these changes
  29742. * @returns The onVRDisplayChangedObservable
  29743. */
  29744. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29745. /** @hidden */ private _prepareVRComponent(): void;
  29746. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  29747. /** @hidden */ private _submitVRFrame(): void;
  29748. /**
  29749. * Call this function to leave webVR mode
  29750. * Will do nothing if webVR is not supported or if there is no webVR device
  29751. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29752. */
  29753. disableVR(): void;
  29754. /**
  29755. * Gets a boolean indicating that the system is in VR mode and is presenting
  29756. * @returns true if VR mode is engaged
  29757. */
  29758. isVRPresenting(): boolean;
  29759. /** @hidden */ private _requestVRFrame(): void;
  29760. private _disableTouchAction;
  29761. private _rebuildInternalTextures;
  29762. private _rebuildEffects;
  29763. /**
  29764. * Gets a boolean indicating if all created effects are ready
  29765. * @returns true if all effects are ready
  29766. */
  29767. areAllEffectsReady(): boolean;
  29768. private _rebuildBuffers;
  29769. private _initGLContext;
  29770. /**
  29771. * Gets version of the current webGL context
  29772. */
  29773. readonly webGLVersion: number;
  29774. /**
  29775. * Gets a string idenfifying the name of the class
  29776. * @returns "Engine" string
  29777. */
  29778. getClassName(): string;
  29779. /**
  29780. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29781. */
  29782. readonly isStencilEnable: boolean;
  29783. /** @hidden */ private _prepareWorkingCanvas(): void;
  29784. /**
  29785. * Reset the texture cache to empty state
  29786. */
  29787. resetTextureCache(): void;
  29788. /**
  29789. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29790. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29791. * @returns true if engine is in deterministic lock step mode
  29792. */
  29793. isDeterministicLockStep(): boolean;
  29794. /**
  29795. * Gets the max steps when engine is running in deterministic lock step
  29796. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29797. * @returns the max steps
  29798. */
  29799. getLockstepMaxSteps(): number;
  29800. /**
  29801. * Gets an object containing information about the current webGL context
  29802. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29803. */
  29804. getGlInfo(): {
  29805. vendor: string;
  29806. renderer: string;
  29807. version: string;
  29808. };
  29809. /**
  29810. * Gets current aspect ratio
  29811. * @param viewportOwner defines the camera to use to get the aspect ratio
  29812. * @param useScreen defines if screen size must be used (or the current render target if any)
  29813. * @returns a number defining the aspect ratio
  29814. */
  29815. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29816. /**
  29817. * Gets current screen aspect ratio
  29818. * @returns a number defining the aspect ratio
  29819. */
  29820. getScreenAspectRatio(): number;
  29821. /**
  29822. * Gets the current render width
  29823. * @param useScreen defines if screen size must be used (or the current render target if any)
  29824. * @returns a number defining the current render width
  29825. */
  29826. getRenderWidth(useScreen?: boolean): number;
  29827. /**
  29828. * Gets the current render height
  29829. * @param useScreen defines if screen size must be used (or the current render target if any)
  29830. * @returns a number defining the current render height
  29831. */
  29832. getRenderHeight(useScreen?: boolean): number;
  29833. /**
  29834. * Gets the HTML canvas attached with the current webGL context
  29835. * @returns a HTML canvas
  29836. */
  29837. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29838. /**
  29839. * Gets host window
  29840. * @returns the host window object
  29841. */
  29842. getHostWindow(): Window;
  29843. /**
  29844. * Gets host document
  29845. * @returns the host document object
  29846. */
  29847. getHostDocument(): Document;
  29848. /**
  29849. * Gets the client rect of the HTML canvas attached with the current webGL context
  29850. * @returns a client rectanglee
  29851. */
  29852. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29853. /**
  29854. * Defines the hardware scaling level.
  29855. * By default the hardware scaling level is computed from the window device ratio.
  29856. * 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.
  29857. * @param level defines the level to use
  29858. */
  29859. setHardwareScalingLevel(level: number): void;
  29860. /**
  29861. * Gets the current hardware scaling level.
  29862. * By default the hardware scaling level is computed from the window device ratio.
  29863. * 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.
  29864. * @returns a number indicating the current hardware scaling level
  29865. */
  29866. getHardwareScalingLevel(): number;
  29867. /**
  29868. * Gets the list of loaded textures
  29869. * @returns an array containing all loaded textures
  29870. */
  29871. getLoadedTexturesCache(): InternalTexture[];
  29872. /**
  29873. * Gets the object containing all engine capabilities
  29874. * @returns the EngineCapabilities object
  29875. */
  29876. getCaps(): EngineCapabilities;
  29877. /**
  29878. * Gets the current depth function
  29879. * @returns a number defining the depth function
  29880. */
  29881. getDepthFunction(): Nullable<number>;
  29882. /**
  29883. * Sets the current depth function
  29884. * @param depthFunc defines the function to use
  29885. */
  29886. setDepthFunction(depthFunc: number): void;
  29887. /**
  29888. * Sets the current depth function to GREATER
  29889. */
  29890. setDepthFunctionToGreater(): void;
  29891. /**
  29892. * Sets the current depth function to GEQUAL
  29893. */
  29894. setDepthFunctionToGreaterOrEqual(): void;
  29895. /**
  29896. * Sets the current depth function to LESS
  29897. */
  29898. setDepthFunctionToLess(): void;
  29899. private _cachedStencilBuffer;
  29900. private _cachedStencilFunction;
  29901. private _cachedStencilMask;
  29902. private _cachedStencilOperationPass;
  29903. private _cachedStencilOperationFail;
  29904. private _cachedStencilOperationDepthFail;
  29905. private _cachedStencilReference;
  29906. /**
  29907. * Caches the the state of the stencil buffer
  29908. */
  29909. cacheStencilState(): void;
  29910. /**
  29911. * Restores the state of the stencil buffer
  29912. */
  29913. restoreStencilState(): void;
  29914. /**
  29915. * Sets the current depth function to LEQUAL
  29916. */
  29917. setDepthFunctionToLessOrEqual(): void;
  29918. /**
  29919. * Gets a boolean indicating if stencil buffer is enabled
  29920. * @returns the current stencil buffer state
  29921. */
  29922. getStencilBuffer(): boolean;
  29923. /**
  29924. * Enable or disable the stencil buffer
  29925. * @param enable defines if the stencil buffer must be enabled or disabled
  29926. */
  29927. setStencilBuffer(enable: boolean): void;
  29928. /**
  29929. * Gets the current stencil mask
  29930. * @returns a number defining the new stencil mask to use
  29931. */
  29932. getStencilMask(): number;
  29933. /**
  29934. * Sets the current stencil mask
  29935. * @param mask defines the new stencil mask to use
  29936. */
  29937. setStencilMask(mask: number): void;
  29938. /**
  29939. * Gets the current stencil function
  29940. * @returns a number defining the stencil function to use
  29941. */
  29942. getStencilFunction(): number;
  29943. /**
  29944. * Gets the current stencil reference value
  29945. * @returns a number defining the stencil reference value to use
  29946. */
  29947. getStencilFunctionReference(): number;
  29948. /**
  29949. * Gets the current stencil mask
  29950. * @returns a number defining the stencil mask to use
  29951. */
  29952. getStencilFunctionMask(): number;
  29953. /**
  29954. * Sets the current stencil function
  29955. * @param stencilFunc defines the new stencil function to use
  29956. */
  29957. setStencilFunction(stencilFunc: number): void;
  29958. /**
  29959. * Sets the current stencil reference
  29960. * @param reference defines the new stencil reference to use
  29961. */
  29962. setStencilFunctionReference(reference: number): void;
  29963. /**
  29964. * Sets the current stencil mask
  29965. * @param mask defines the new stencil mask to use
  29966. */
  29967. setStencilFunctionMask(mask: number): void;
  29968. /**
  29969. * Gets the current stencil operation when stencil fails
  29970. * @returns a number defining stencil operation to use when stencil fails
  29971. */
  29972. getStencilOperationFail(): number;
  29973. /**
  29974. * Gets the current stencil operation when depth fails
  29975. * @returns a number defining stencil operation to use when depth fails
  29976. */
  29977. getStencilOperationDepthFail(): number;
  29978. /**
  29979. * Gets the current stencil operation when stencil passes
  29980. * @returns a number defining stencil operation to use when stencil passes
  29981. */
  29982. getStencilOperationPass(): number;
  29983. /**
  29984. * Sets the stencil operation to use when stencil fails
  29985. * @param operation defines the stencil operation to use when stencil fails
  29986. */
  29987. setStencilOperationFail(operation: number): void;
  29988. /**
  29989. * Sets the stencil operation to use when depth fails
  29990. * @param operation defines the stencil operation to use when depth fails
  29991. */
  29992. setStencilOperationDepthFail(operation: number): void;
  29993. /**
  29994. * Sets the stencil operation to use when stencil passes
  29995. * @param operation defines the stencil operation to use when stencil passes
  29996. */
  29997. setStencilOperationPass(operation: number): void;
  29998. /**
  29999. * Sets a boolean indicating if the dithering state is enabled or disabled
  30000. * @param value defines the dithering state
  30001. */
  30002. setDitheringState(value: boolean): void;
  30003. /**
  30004. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30005. * @param value defines the rasterizer state
  30006. */
  30007. setRasterizerState(value: boolean): void;
  30008. /**
  30009. * stop executing a render loop function and remove it from the execution array
  30010. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30011. */
  30012. stopRenderLoop(renderFunction?: () => void): void;
  30013. /** @hidden */ private _renderLoop(): void;
  30014. /**
  30015. * Can be used to override the current requestAnimationFrame requester.
  30016. * @hidden
  30017. */
  30018. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30019. /**
  30020. * Register and execute a render loop. The engine can have more than one render function
  30021. * @param renderFunction defines the function to continuously execute
  30022. */
  30023. runRenderLoop(renderFunction: () => void): void;
  30024. /**
  30025. * Toggle full screen mode
  30026. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30027. */
  30028. switchFullscreen(requestPointerLock: boolean): void;
  30029. /**
  30030. * Enters full screen mode
  30031. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30032. */
  30033. enterFullscreen(requestPointerLock: boolean): void;
  30034. /**
  30035. * Exits full screen mode
  30036. */
  30037. exitFullscreen(): void;
  30038. /**
  30039. * Enters Pointerlock mode
  30040. */
  30041. enterPointerlock(): void;
  30042. /**
  30043. * Exits Pointerlock mode
  30044. */
  30045. exitPointerlock(): void;
  30046. /**
  30047. * Clear the current render buffer or the current render target (if any is set up)
  30048. * @param color defines the color to use
  30049. * @param backBuffer defines if the back buffer must be cleared
  30050. * @param depth defines if the depth buffer must be cleared
  30051. * @param stencil defines if the stencil buffer must be cleared
  30052. */
  30053. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30054. /**
  30055. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30056. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30057. * @param y defines the y-coordinate of the corner of the clear rectangle
  30058. * @param width defines the width of the clear rectangle
  30059. * @param height defines the height of the clear rectangle
  30060. * @param clearColor defines the clear color
  30061. */
  30062. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30063. /**
  30064. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30065. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30066. * @param y defines the y-coordinate of the corner of the clear rectangle
  30067. * @param width defines the width of the clear rectangle
  30068. * @param height defines the height of the clear rectangle
  30069. */
  30070. enableScissor(x: number, y: number, width: number, height: number): void;
  30071. /**
  30072. * Disable previously set scissor test rectangle
  30073. */
  30074. disableScissor(): void;
  30075. private _viewportCached;
  30076. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  30077. /**
  30078. * Set the WebGL's viewport
  30079. * @param viewport defines the viewport element to be used
  30080. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30081. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30082. */
  30083. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30084. /**
  30085. * Directly set the WebGL Viewport
  30086. * @param x defines the x coordinate of the viewport (in screen space)
  30087. * @param y defines the y coordinate of the viewport (in screen space)
  30088. * @param width defines the width of the viewport (in screen space)
  30089. * @param height defines the height of the viewport (in screen space)
  30090. * @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
  30091. */
  30092. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30093. /**
  30094. * Begin a new frame
  30095. */
  30096. beginFrame(): void;
  30097. /**
  30098. * Enf the current frame
  30099. */
  30100. endFrame(): void;
  30101. /**
  30102. * Resize the view according to the canvas' size
  30103. */
  30104. resize(): void;
  30105. /**
  30106. * Force a specific size of the canvas
  30107. * @param width defines the new canvas' width
  30108. * @param height defines the new canvas' height
  30109. */
  30110. setSize(width: number, height: number): void;
  30111. /**
  30112. * Binds the frame buffer to the specified texture.
  30113. * @param texture The texture to render to or null for the default canvas
  30114. * @param faceIndex The face of the texture to render to in case of cube texture
  30115. * @param requiredWidth The width of the target to render to
  30116. * @param requiredHeight The height of the target to render to
  30117. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30118. * @param depthStencilTexture The depth stencil texture to use to render
  30119. * @param lodLevel defines le lod level to bind to the frame buffer
  30120. */
  30121. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30122. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30123. /**
  30124. * Unbind the current render target texture from the webGL context
  30125. * @param texture defines the render target texture to unbind
  30126. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30127. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30128. */
  30129. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30130. /**
  30131. * Force the mipmap generation for the given render target texture
  30132. * @param texture defines the render target texture to use
  30133. */
  30134. generateMipMapsForCubemap(texture: InternalTexture): void;
  30135. /**
  30136. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30137. */
  30138. flushFramebuffer(): void;
  30139. /**
  30140. * Unbind the current render target and bind the default framebuffer
  30141. */
  30142. restoreDefaultFramebuffer(): void;
  30143. /**
  30144. * Create an uniform buffer
  30145. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30146. * @param elements defines the content of the uniform buffer
  30147. * @returns the webGL uniform buffer
  30148. */
  30149. createUniformBuffer(elements: FloatArray): DataBuffer;
  30150. /**
  30151. * Create a dynamic uniform buffer
  30152. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30153. * @param elements defines the content of the uniform buffer
  30154. * @returns the webGL uniform buffer
  30155. */
  30156. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30157. /**
  30158. * Update an existing uniform buffer
  30159. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30160. * @param uniformBuffer defines the target uniform buffer
  30161. * @param elements defines the content to update
  30162. * @param offset defines the offset in the uniform buffer where update should start
  30163. * @param count defines the size of the data to update
  30164. */
  30165. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30166. private _resetVertexBufferBinding;
  30167. /**
  30168. * Creates a vertex buffer
  30169. * @param data the data for the vertex buffer
  30170. * @returns the new WebGL static buffer
  30171. */
  30172. createVertexBuffer(data: DataArray): DataBuffer;
  30173. /**
  30174. * Creates a dynamic vertex buffer
  30175. * @param data the data for the dynamic vertex buffer
  30176. * @returns the new WebGL dynamic buffer
  30177. */
  30178. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30179. /**
  30180. * Update a dynamic index buffer
  30181. * @param indexBuffer defines the target index buffer
  30182. * @param indices defines the data to update
  30183. * @param offset defines the offset in the target index buffer where update should start
  30184. */
  30185. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30186. /**
  30187. * Updates a dynamic vertex buffer.
  30188. * @param vertexBuffer the vertex buffer to update
  30189. * @param data the data used to update the vertex buffer
  30190. * @param byteOffset the byte offset of the data
  30191. * @param byteLength the byte length of the data
  30192. */
  30193. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30194. private _resetIndexBufferBinding;
  30195. /**
  30196. * Creates a new index buffer
  30197. * @param indices defines the content of the index buffer
  30198. * @param updatable defines if the index buffer must be updatable
  30199. * @returns a new webGL buffer
  30200. */
  30201. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30202. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30203. /**
  30204. * Bind a webGL buffer to the webGL context
  30205. * @param buffer defines the buffer to bind
  30206. */
  30207. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30208. /**
  30209. * Bind an uniform buffer to the current webGL context
  30210. * @param buffer defines the buffer to bind
  30211. */
  30212. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30213. /**
  30214. * Bind a buffer to the current webGL context at a given location
  30215. * @param buffer defines the buffer to bind
  30216. * @param location defines the index where to bind the buffer
  30217. */
  30218. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30219. /**
  30220. * Bind a specific block at a given index in a specific shader program
  30221. * @param pipelineContext defines the pipeline context to use
  30222. * @param blockName defines the block name
  30223. * @param index defines the index where to bind the block
  30224. */
  30225. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30226. private bindIndexBuffer;
  30227. private bindBuffer;
  30228. /**
  30229. * update the bound buffer with the given data
  30230. * @param data defines the data to update
  30231. */
  30232. updateArrayBuffer(data: Float32Array): void;
  30233. private _vertexAttribPointer;
  30234. private _bindIndexBufferWithCache;
  30235. private _bindVertexBuffersAttributes;
  30236. /**
  30237. * Records a vertex array object
  30238. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30239. * @param vertexBuffers defines the list of vertex buffers to store
  30240. * @param indexBuffer defines the index buffer to store
  30241. * @param effect defines the effect to store
  30242. * @returns the new vertex array object
  30243. */
  30244. recordVertexArrayObject(vertexBuffers: {
  30245. [key: string]: VertexBuffer;
  30246. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30247. /**
  30248. * Bind a specific vertex array object
  30249. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30250. * @param vertexArrayObject defines the vertex array object to bind
  30251. * @param indexBuffer defines the index buffer to bind
  30252. */
  30253. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30254. /**
  30255. * Bind webGl buffers directly to the webGL context
  30256. * @param vertexBuffer defines the vertex buffer to bind
  30257. * @param indexBuffer defines the index buffer to bind
  30258. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30259. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30260. * @param effect defines the effect associated with the vertex buffer
  30261. */
  30262. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30263. private _unbindVertexArrayObject;
  30264. /**
  30265. * Bind a list of vertex buffers to the webGL context
  30266. * @param vertexBuffers defines the list of vertex buffers to bind
  30267. * @param indexBuffer defines the index buffer to bind
  30268. * @param effect defines the effect associated with the vertex buffers
  30269. */
  30270. bindBuffers(vertexBuffers: {
  30271. [key: string]: Nullable<VertexBuffer>;
  30272. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30273. /**
  30274. * Unbind all instance attributes
  30275. */
  30276. unbindInstanceAttributes(): void;
  30277. /**
  30278. * Release and free the memory of a vertex array object
  30279. * @param vao defines the vertex array object to delete
  30280. */
  30281. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30282. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30283. protected _deleteBuffer(buffer: DataBuffer): void;
  30284. /**
  30285. * Creates a webGL buffer to use with instanciation
  30286. * @param capacity defines the size of the buffer
  30287. * @returns the webGL buffer
  30288. */
  30289. createInstancesBuffer(capacity: number): DataBuffer;
  30290. /**
  30291. * Delete a webGL buffer used with instanciation
  30292. * @param buffer defines the webGL buffer to delete
  30293. */
  30294. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30295. /**
  30296. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30297. * @param instancesBuffer defines the webGL buffer to update and bind
  30298. * @param data defines the data to store in the buffer
  30299. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30300. */
  30301. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30302. /**
  30303. * Apply all cached states (depth, culling, stencil and alpha)
  30304. */
  30305. applyStates(): void;
  30306. /**
  30307. * Send a draw order
  30308. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30309. * @param indexStart defines the starting index
  30310. * @param indexCount defines the number of index to draw
  30311. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30312. */
  30313. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30314. /**
  30315. * Draw a list of points
  30316. * @param verticesStart defines the index of first vertex to draw
  30317. * @param verticesCount defines the count of vertices to draw
  30318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30319. */
  30320. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30321. /**
  30322. * Draw a list of unindexed primitives
  30323. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30324. * @param verticesStart defines the index of first vertex to draw
  30325. * @param verticesCount defines the count of vertices to draw
  30326. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30327. */
  30328. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30329. /**
  30330. * Draw a list of indexed primitives
  30331. * @param fillMode defines the primitive to use
  30332. * @param indexStart defines the starting index
  30333. * @param indexCount defines the number of index to draw
  30334. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30335. */
  30336. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30337. /**
  30338. * Draw a list of unindexed primitives
  30339. * @param fillMode defines the primitive to use
  30340. * @param verticesStart defines the index of first vertex to draw
  30341. * @param verticesCount defines the count of vertices to draw
  30342. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30343. */
  30344. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30345. private _drawMode;
  30346. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30347. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30348. /**
  30349. * Create a new effect (used to store vertex/fragment shaders)
  30350. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30351. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30352. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30353. * @param samplers defines an array of string used to represent textures
  30354. * @param defines defines the string containing the defines to use to compile the shaders
  30355. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30356. * @param onCompiled defines a function to call when the effect creation is successful
  30357. * @param onError defines a function to call when the effect creation has failed
  30358. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30359. * @returns the new Effect
  30360. */
  30361. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30362. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30363. private _compileShader;
  30364. private _compileRawShader;
  30365. /**
  30366. * Directly creates a webGL program
  30367. * @param pipelineContext defines the pipeline context to attach to
  30368. * @param vertexCode defines the vertex shader code to use
  30369. * @param fragmentCode defines the fragment shader code to use
  30370. * @param context defines the webGL context to use (if not set, the current one will be used)
  30371. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30372. * @returns the new webGL program
  30373. */
  30374. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30375. /**
  30376. * Creates a webGL program
  30377. * @param pipelineContext defines the pipeline context to attach to
  30378. * @param vertexCode defines the vertex shader code to use
  30379. * @param fragmentCode defines the fragment shader code to use
  30380. * @param defines defines the string containing the defines to use to compile the shaders
  30381. * @param context defines the webGL context to use (if not set, the current one will be used)
  30382. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30383. * @returns the new webGL program
  30384. */
  30385. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30386. /**
  30387. * Creates a new pipeline context
  30388. * @returns the new pipeline
  30389. */
  30390. createPipelineContext(): IPipelineContext;
  30391. private _createShaderProgram;
  30392. private _finalizePipelineContext;
  30393. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30394. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30395. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30396. /**
  30397. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30398. * @param pipelineContext defines the pipeline context to use
  30399. * @param uniformsNames defines the list of uniform names
  30400. * @returns an array of webGL uniform locations
  30401. */
  30402. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30403. /**
  30404. * Gets the lsit of active attributes for a given webGL program
  30405. * @param pipelineContext defines the pipeline context to use
  30406. * @param attributesNames defines the list of attribute names to get
  30407. * @returns an array of indices indicating the offset of each attribute
  30408. */
  30409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30410. /**
  30411. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30412. * @param effect defines the effect to activate
  30413. */
  30414. enableEffect(effect: Nullable<Effect>): void;
  30415. /**
  30416. * Set the value of an uniform to an array of int32
  30417. * @param uniform defines the webGL uniform location where to store the value
  30418. * @param array defines the array of int32 to store
  30419. */
  30420. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30421. /**
  30422. * Set the value of an uniform to an array of int32 (stored as vec2)
  30423. * @param uniform defines the webGL uniform location where to store the value
  30424. * @param array defines the array of int32 to store
  30425. */
  30426. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30427. /**
  30428. * Set the value of an uniform to an array of int32 (stored as vec3)
  30429. * @param uniform defines the webGL uniform location where to store the value
  30430. * @param array defines the array of int32 to store
  30431. */
  30432. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30433. /**
  30434. * Set the value of an uniform to an array of int32 (stored as vec4)
  30435. * @param uniform defines the webGL uniform location where to store the value
  30436. * @param array defines the array of int32 to store
  30437. */
  30438. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30439. /**
  30440. * Set the value of an uniform to an array of float32
  30441. * @param uniform defines the webGL uniform location where to store the value
  30442. * @param array defines the array of float32 to store
  30443. */
  30444. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30445. /**
  30446. * Set the value of an uniform to an array of float32 (stored as vec2)
  30447. * @param uniform defines the webGL uniform location where to store the value
  30448. * @param array defines the array of float32 to store
  30449. */
  30450. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30451. /**
  30452. * Set the value of an uniform to an array of float32 (stored as vec3)
  30453. * @param uniform defines the webGL uniform location where to store the value
  30454. * @param array defines the array of float32 to store
  30455. */
  30456. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30457. /**
  30458. * Set the value of an uniform to an array of float32 (stored as vec4)
  30459. * @param uniform defines the webGL uniform location where to store the value
  30460. * @param array defines the array of float32 to store
  30461. */
  30462. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30463. /**
  30464. * Set the value of an uniform to an array of number
  30465. * @param uniform defines the webGL uniform location where to store the value
  30466. * @param array defines the array of number to store
  30467. */
  30468. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30469. /**
  30470. * Set the value of an uniform to an array of number (stored as vec2)
  30471. * @param uniform defines the webGL uniform location where to store the value
  30472. * @param array defines the array of number to store
  30473. */
  30474. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30475. /**
  30476. * Set the value of an uniform to an array of number (stored as vec3)
  30477. * @param uniform defines the webGL uniform location where to store the value
  30478. * @param array defines the array of number to store
  30479. */
  30480. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30481. /**
  30482. * Set the value of an uniform to an array of number (stored as vec4)
  30483. * @param uniform defines the webGL uniform location where to store the value
  30484. * @param array defines the array of number to store
  30485. */
  30486. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30487. /**
  30488. * Set the value of an uniform to an array of float32 (stored as matrices)
  30489. * @param uniform defines the webGL uniform location where to store the value
  30490. * @param matrices defines the array of float32 to store
  30491. */
  30492. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30493. /**
  30494. * Set the value of an uniform to a matrix (3x3)
  30495. * @param uniform defines the webGL uniform location where to store the value
  30496. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30497. */
  30498. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30499. /**
  30500. * Set the value of an uniform to a matrix (2x2)
  30501. * @param uniform defines the webGL uniform location where to store the value
  30502. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30503. */
  30504. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30505. /**
  30506. * Set the value of an uniform to a number (int)
  30507. * @param uniform defines the webGL uniform location where to store the value
  30508. * @param value defines the int number to store
  30509. */
  30510. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30511. /**
  30512. * Set the value of an uniform to a number (float)
  30513. * @param uniform defines the webGL uniform location where to store the value
  30514. * @param value defines the float number to store
  30515. */
  30516. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30517. /**
  30518. * Set the value of an uniform to a vec2
  30519. * @param uniform defines the webGL uniform location where to store the value
  30520. * @param x defines the 1st component of the value
  30521. * @param y defines the 2nd component of the value
  30522. */
  30523. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30524. /**
  30525. * Set the value of an uniform to a vec3
  30526. * @param uniform defines the webGL uniform location where to store the value
  30527. * @param x defines the 1st component of the value
  30528. * @param y defines the 2nd component of the value
  30529. * @param z defines the 3rd component of the value
  30530. */
  30531. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30532. /**
  30533. * Set the value of an uniform to a boolean
  30534. * @param uniform defines the webGL uniform location where to store the value
  30535. * @param bool defines the boolean to store
  30536. */
  30537. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30538. /**
  30539. * Set the value of an uniform to a vec4
  30540. * @param uniform defines the webGL uniform location where to store the value
  30541. * @param x defines the 1st component of the value
  30542. * @param y defines the 2nd component of the value
  30543. * @param z defines the 3rd component of the value
  30544. * @param w defines the 4th component of the value
  30545. */
  30546. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30547. /**
  30548. * Sets a Color4 on a uniform variable
  30549. * @param uniform defines the uniform location
  30550. * @param color4 defines the value to be set
  30551. */
  30552. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30553. /**
  30554. * Set various states to the webGL context
  30555. * @param culling defines backface culling state
  30556. * @param zOffset defines the value to apply to zOffset (0 by default)
  30557. * @param force defines if states must be applied even if cache is up to date
  30558. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30559. */
  30560. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30561. /**
  30562. * Set the z offset to apply to current rendering
  30563. * @param value defines the offset to apply
  30564. */
  30565. setZOffset(value: number): void;
  30566. /**
  30567. * Gets the current value of the zOffset
  30568. * @returns the current zOffset state
  30569. */
  30570. getZOffset(): number;
  30571. /**
  30572. * Enable or disable depth buffering
  30573. * @param enable defines the state to set
  30574. */
  30575. setDepthBuffer(enable: boolean): void;
  30576. /**
  30577. * Gets a boolean indicating if depth writing is enabled
  30578. * @returns the current depth writing state
  30579. */
  30580. getDepthWrite(): boolean;
  30581. /**
  30582. * Enable or disable depth writing
  30583. * @param enable defines the state to set
  30584. */
  30585. setDepthWrite(enable: boolean): void;
  30586. /**
  30587. * Enable or disable color writing
  30588. * @param enable defines the state to set
  30589. */
  30590. setColorWrite(enable: boolean): void;
  30591. /**
  30592. * Gets a boolean indicating if color writing is enabled
  30593. * @returns the current color writing state
  30594. */
  30595. getColorWrite(): boolean;
  30596. /**
  30597. * Sets alpha constants used by some alpha blending modes
  30598. * @param r defines the red component
  30599. * @param g defines the green component
  30600. * @param b defines the blue component
  30601. * @param a defines the alpha component
  30602. */
  30603. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30604. /**
  30605. * Sets the current alpha mode
  30606. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30607. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30608. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30609. */
  30610. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30611. /**
  30612. * Gets the current alpha mode
  30613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30614. * @returns the current alpha mode
  30615. */
  30616. getAlphaMode(): number;
  30617. /**
  30618. * Clears the list of texture accessible through engine.
  30619. * This can help preventing texture load conflict due to name collision.
  30620. */
  30621. clearInternalTexturesCache(): void;
  30622. /**
  30623. * Force the entire cache to be cleared
  30624. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30625. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30626. */
  30627. wipeCaches(bruteForce?: boolean): void;
  30628. /**
  30629. * Set the compressed texture format to use, based on the formats you have, and the formats
  30630. * supported by the hardware / browser.
  30631. *
  30632. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30633. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30634. * to API arguments needed to compressed textures. This puts the burden on the container
  30635. * generator to house the arcane code for determining these for current & future formats.
  30636. *
  30637. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30638. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30639. *
  30640. * Note: The result of this call is not taken into account when a texture is base64.
  30641. *
  30642. * @param formatsAvailable defines the list of those format families you have created
  30643. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30644. *
  30645. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30646. * @returns The extension selected.
  30647. */
  30648. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30649. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30650. min: number;
  30651. mag: number;
  30652. };
  30653. /** @hidden */ private _createTexture(): WebGLTexture;
  30654. /**
  30655. * Usually called from Texture.ts.
  30656. * Passed information to create a WebGLTexture
  30657. * @param urlArg defines a value which contains one of the following:
  30658. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30659. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30660. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30661. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30662. * @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)
  30663. * @param scene needed for loading to the correct scene
  30664. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30665. * @param onLoad optional callback to be called upon successful completion
  30666. * @param onError optional callback to be called upon failure
  30667. * @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
  30668. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30669. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30670. * @param forcedExtension defines the extension to use to pick the right loader
  30671. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30672. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30673. */
  30674. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30675. /**
  30676. * @hidden
  30677. * Rescales a texture
  30678. * @param source input texutre
  30679. * @param destination destination texture
  30680. * @param scene scene to use to render the resize
  30681. * @param internalFormat format to use when resizing
  30682. * @param onComplete callback to be called when resize has completed
  30683. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  30684. private _unpackFlipYCached;
  30685. /**
  30686. * In case you are sharing the context with other applications, it might
  30687. * be interested to not cache the unpack flip y state to ensure a consistent
  30688. * value would be set.
  30689. */
  30690. enableUnpackFlipYCached: boolean;
  30691. /** @hidden */ private _unpackFlipY(value: boolean): void;
  30692. /** @hidden */ private _getUnpackAlignement(): number;
  30693. /**
  30694. * Creates a dynamic texture
  30695. * @param width defines the width of the texture
  30696. * @param height defines the height of the texture
  30697. * @param generateMipMaps defines if the engine should generate the mip levels
  30698. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30699. * @returns the dynamic texture inside an InternalTexture
  30700. */
  30701. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30702. /**
  30703. * Update the sampling mode of a given texture
  30704. * @param samplingMode defines the required sampling mode
  30705. * @param texture defines the texture to update
  30706. */
  30707. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30708. /**
  30709. * Update the content of a dynamic texture
  30710. * @param texture defines the texture to update
  30711. * @param canvas defines the canvas containing the source
  30712. * @param invertY defines if data must be stored with Y axis inverted
  30713. * @param premulAlpha defines if alpha is stored as premultiplied
  30714. * @param format defines the format of the data
  30715. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30716. */
  30717. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30718. /**
  30719. * Update a video texture
  30720. * @param texture defines the texture to update
  30721. * @param video defines the video element to use
  30722. * @param invertY defines if data must be stored with Y axis inverted
  30723. */
  30724. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30725. /**
  30726. * Updates a depth texture Comparison Mode and Function.
  30727. * If the comparison Function is equal to 0, the mode will be set to none.
  30728. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30729. * @param texture The texture to set the comparison function for
  30730. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30731. */
  30732. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30733. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30734. width: number;
  30735. height: number;
  30736. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30737. /**
  30738. * Creates a depth stencil texture.
  30739. * This is only available in WebGL 2 or with the depth texture extension available.
  30740. * @param size The size of face edge in the texture.
  30741. * @param options The options defining the texture.
  30742. * @returns The texture
  30743. */
  30744. createDepthStencilTexture(size: number | {
  30745. width: number;
  30746. height: number;
  30747. }, options: DepthTextureCreationOptions): InternalTexture;
  30748. /**
  30749. * Creates a depth stencil texture.
  30750. * This is only available in WebGL 2 or with the depth texture extension available.
  30751. * @param size The size of face edge in the texture.
  30752. * @param options The options defining the texture.
  30753. * @returns The texture
  30754. */
  30755. private _createDepthStencilTexture;
  30756. /**
  30757. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30758. * @param renderTarget The render target to set the frame buffer for
  30759. */
  30760. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30761. /**
  30762. * Creates a new render target texture
  30763. * @param size defines the size of the texture
  30764. * @param options defines the options used to create the texture
  30765. * @returns a new render target texture stored in an InternalTexture
  30766. */
  30767. createRenderTargetTexture(size: number | {
  30768. width: number;
  30769. height: number;
  30770. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30771. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30772. /**
  30773. * Updates the sample count of a render target texture
  30774. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30775. * @param texture defines the texture to update
  30776. * @param samples defines the sample count to set
  30777. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30778. */
  30779. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30780. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30781. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30782. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30783. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30784. /**
  30785. * @hidden
  30786. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  30787. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30788. private _prepareWebGLTexture;
  30789. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30790. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  30791. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  30792. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30793. protected _setProgram(program: WebGLProgram): void;
  30794. protected _boundUniforms: {
  30795. [key: number]: WebGLUniformLocation;
  30796. };
  30797. /**
  30798. * Binds an effect to the webGL context
  30799. * @param effect defines the effect to bind
  30800. */
  30801. bindSamplers(effect: Effect): void;
  30802. private _activateCurrentTexture;
  30803. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30804. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30805. /**
  30806. * Sets a texture to the webGL context from a postprocess
  30807. * @param channel defines the channel to use
  30808. * @param postProcess defines the source postprocess
  30809. */
  30810. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30811. /**
  30812. * Binds the output of the passed in post process to the texture channel specified
  30813. * @param channel The channel the texture should be bound to
  30814. * @param postProcess The post process which's output should be bound
  30815. */
  30816. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30817. /**
  30818. * Unbind all textures from the webGL context
  30819. */
  30820. unbindAllTextures(): void;
  30821. /**
  30822. * Sets a texture to the according uniform.
  30823. * @param channel The texture channel
  30824. * @param uniform The uniform to set
  30825. * @param texture The texture to apply
  30826. */
  30827. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30828. /**
  30829. * Sets a depth stencil texture from a render target to the according uniform.
  30830. * @param channel The texture channel
  30831. * @param uniform The uniform to set
  30832. * @param texture The render target texture containing the depth stencil texture to apply
  30833. */
  30834. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30835. private _bindSamplerUniformToChannel;
  30836. private _getTextureWrapMode;
  30837. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30838. /**
  30839. * Sets an array of texture to the webGL context
  30840. * @param channel defines the channel where the texture array must be set
  30841. * @param uniform defines the associated uniform location
  30842. * @param textures defines the array of textures to bind
  30843. */
  30844. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30845. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30846. private _setTextureParameterFloat;
  30847. private _setTextureParameterInteger;
  30848. /**
  30849. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30850. * @param x defines the x coordinate of the rectangle where pixels must be read
  30851. * @param y defines the y coordinate of the rectangle where pixels must be read
  30852. * @param width defines the width of the rectangle where pixels must be read
  30853. * @param height defines the height of the rectangle where pixels must be read
  30854. * @returns a Uint8Array containing RGBA colors
  30855. */
  30856. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30857. /**
  30858. * Add an externaly attached data from its key.
  30859. * This method call will fail and return false, if such key already exists.
  30860. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  30861. * @param key the unique key that identifies the data
  30862. * @param data the data object to associate to the key for this Engine instance
  30863. * @return true if no such key were already present and the data was added successfully, false otherwise
  30864. */
  30865. addExternalData<T>(key: string, data: T): boolean;
  30866. /**
  30867. * Get an externaly attached data from its key
  30868. * @param key the unique key that identifies the data
  30869. * @return the associated data, if present (can be null), or undefined if not present
  30870. */
  30871. getExternalData<T>(key: string): T;
  30872. /**
  30873. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30874. * @param key the unique key that identifies the data
  30875. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30876. * @return the associated data, can be null if the factory returned null.
  30877. */
  30878. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30879. /**
  30880. * Remove an externaly attached data from the Engine instance
  30881. * @param key the unique key that identifies the data
  30882. * @return true if the data was successfully removed, false if it doesn't exist
  30883. */
  30884. removeExternalData(key: string): boolean;
  30885. /**
  30886. * Unbind all vertex attributes from the webGL context
  30887. */
  30888. unbindAllAttributes(): void;
  30889. /**
  30890. * 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
  30891. */
  30892. releaseEffects(): void;
  30893. /**
  30894. * Dispose and release all associated resources
  30895. */
  30896. dispose(): void;
  30897. /**
  30898. * Display the loading screen
  30899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30900. */
  30901. displayLoadingUI(): void;
  30902. /**
  30903. * Hide the loading screen
  30904. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30905. */
  30906. hideLoadingUI(): void;
  30907. /**
  30908. * Gets the current loading screen object
  30909. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30910. */
  30911. /**
  30912. * Sets the current loading screen object
  30913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30914. */
  30915. loadingScreen: ILoadingScreen;
  30916. /**
  30917. * Sets the current loading screen text
  30918. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30919. */
  30920. loadingUIText: string;
  30921. /**
  30922. * Sets the current loading screen background color
  30923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30924. */
  30925. loadingUIBackgroundColor: string;
  30926. /**
  30927. * Attach a new callback raised when context lost event is fired
  30928. * @param callback defines the callback to call
  30929. */
  30930. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30931. /**
  30932. * Attach a new callback raised when context restored event is fired
  30933. * @param callback defines the callback to call
  30934. */
  30935. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30936. /**
  30937. * Gets the source code of the vertex shader associated with a specific webGL program
  30938. * @param program defines the program to use
  30939. * @returns a string containing the source code of the vertex shader associated with the program
  30940. */
  30941. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30942. /**
  30943. * Gets the source code of the fragment shader associated with a specific webGL program
  30944. * @param program defines the program to use
  30945. * @returns a string containing the source code of the fragment shader associated with the program
  30946. */
  30947. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30948. /**
  30949. * Get the current error code of the webGL context
  30950. * @returns the error code
  30951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30952. */
  30953. getError(): number;
  30954. /**
  30955. * Gets the current framerate
  30956. * @returns a number representing the framerate
  30957. */
  30958. getFps(): number;
  30959. /**
  30960. * Gets the time spent between current and previous frame
  30961. * @returns a number representing the delta time in ms
  30962. */
  30963. getDeltaTime(): number;
  30964. private _measureFps;
  30965. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30966. private _canRenderToFloatFramebuffer;
  30967. private _canRenderToHalfFloatFramebuffer;
  30968. private _canRenderToFramebuffer;
  30969. /** @hidden */ private _getWebGLTextureType(type: number): number;
  30970. /** @hidden */ private _getInternalFormat(format: number): number;
  30971. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30972. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  30973. /** @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;
  30974. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30975. /**
  30976. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30977. * @returns true if the engine can be created
  30978. * @ignorenaming
  30979. */
  30980. static isSupported(): boolean;
  30981. /**
  30982. * Find the next highest power of two.
  30983. * @param x Number to start search from.
  30984. * @return Next highest power of two.
  30985. */
  30986. static CeilingPOT(x: number): number;
  30987. /**
  30988. * Find the next lowest power of two.
  30989. * @param x Number to start search from.
  30990. * @return Next lowest power of two.
  30991. */
  30992. static FloorPOT(x: number): number;
  30993. /**
  30994. * Find the nearest power of two.
  30995. * @param x Number to start search from.
  30996. * @return Next nearest power of two.
  30997. */
  30998. static NearestPOT(x: number): number;
  30999. /**
  31000. * Get the closest exponent of two
  31001. * @param value defines the value to approximate
  31002. * @param max defines the maximum value to return
  31003. * @param mode defines how to define the closest value
  31004. * @returns closest exponent of two of the given value
  31005. */
  31006. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31007. /**
  31008. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31009. * @param func - the function to be called
  31010. * @param requester - the object that will request the next frame. Falls back to window.
  31011. * @returns frame number
  31012. */
  31013. static QueueNewFrame(func: () => void, requester?: any): number;
  31014. /**
  31015. * Ask the browser to promote the current element to pointerlock mode
  31016. * @param element defines the DOM element to promote
  31017. */ private static _RequestPointerlock(element: HTMLElement): void;
  31018. /**
  31019. * Asks the browser to exit pointerlock mode
  31020. */ private static _ExitPointerlock(): void;
  31021. /**
  31022. * Ask the browser to promote the current element to fullscreen rendering mode
  31023. * @param element defines the DOM element to promote
  31024. */ private static _RequestFullscreen(element: HTMLElement): void;
  31025. /**
  31026. * Asks the browser to exit fullscreen mode
  31027. */ private static _ExitFullscreen(): void;
  31028. }
  31029. }
  31030. declare module BABYLON {
  31031. /**
  31032. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31033. * during the life time of the application.
  31034. */
  31035. export class EngineStore {
  31036. /** Gets the list of created engines */
  31037. static Instances: Engine[];
  31038. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31039. /**
  31040. * Gets the latest created engine
  31041. */
  31042. static readonly LastCreatedEngine: Nullable<Engine>;
  31043. /**
  31044. * Gets the latest created scene
  31045. */
  31046. static readonly LastCreatedScene: Nullable<Scene>;
  31047. /**
  31048. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31049. * @ignorenaming
  31050. */
  31051. static UseFallbackTexture: boolean;
  31052. /**
  31053. * Texture content used if a texture cannot loaded
  31054. * @ignorenaming
  31055. */
  31056. static FallbackTexture: string;
  31057. }
  31058. }
  31059. declare module BABYLON {
  31060. /**
  31061. * Helper class that provides a small promise polyfill
  31062. */
  31063. export class PromisePolyfill {
  31064. /**
  31065. * Static function used to check if the polyfill is required
  31066. * If this is the case then the function will inject the polyfill to window.Promise
  31067. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31068. */
  31069. static Apply(force?: boolean): void;
  31070. }
  31071. }
  31072. declare module BABYLON {
  31073. /**
  31074. * Interface for screenshot methods with describe argument called `size` as object with options
  31075. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31076. */
  31077. export interface IScreenshotSize {
  31078. /**
  31079. * number in pixels for canvas height
  31080. */
  31081. height?: number;
  31082. /**
  31083. * multiplier allowing render at a higher or lower resolution
  31084. * If value is defined then height and width will be ignored and taken from camera
  31085. */
  31086. precision?: number;
  31087. /**
  31088. * number in pixels for canvas width
  31089. */
  31090. width?: number;
  31091. }
  31092. }
  31093. declare module BABYLON {
  31094. interface IColor4Like {
  31095. r: float;
  31096. g: float;
  31097. b: float;
  31098. a: float;
  31099. }
  31100. /**
  31101. * Class containing a set of static utilities functions
  31102. */
  31103. export class Tools {
  31104. /**
  31105. * Gets or sets the base URL to use to load assets
  31106. */
  31107. static BaseUrl: string;
  31108. /**
  31109. * Enable/Disable Custom HTTP Request Headers globally.
  31110. * default = false
  31111. * @see CustomRequestHeaders
  31112. */
  31113. static UseCustomRequestHeaders: boolean;
  31114. /**
  31115. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31116. * i.e. when loading files, where the server/service expects an Authorization header
  31117. */
  31118. static CustomRequestHeaders: {
  31119. [key: string]: string;
  31120. };
  31121. /**
  31122. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31123. */
  31124. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31125. /**
  31126. * Default behaviour for cors in the application.
  31127. * It can be a string if the expected behavior is identical in the entire app.
  31128. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31129. */
  31130. static CorsBehavior: string | ((url: string | string[]) => string);
  31131. /**
  31132. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31133. * @ignorenaming
  31134. */
  31135. static UseFallbackTexture: boolean;
  31136. /**
  31137. * Use this object to register external classes like custom textures or material
  31138. * to allow the laoders to instantiate them
  31139. */
  31140. static RegisteredExternalClasses: {
  31141. [key: string]: Object;
  31142. };
  31143. /**
  31144. * Texture content used if a texture cannot loaded
  31145. * @ignorenaming
  31146. */
  31147. static fallbackTexture: string;
  31148. /**
  31149. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31150. * @param u defines the coordinate on X axis
  31151. * @param v defines the coordinate on Y axis
  31152. * @param width defines the width of the source data
  31153. * @param height defines the height of the source data
  31154. * @param pixels defines the source byte array
  31155. * @param color defines the output color
  31156. */
  31157. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31158. /**
  31159. * Interpolates between a and b via alpha
  31160. * @param a The lower value (returned when alpha = 0)
  31161. * @param b The upper value (returned when alpha = 1)
  31162. * @param alpha The interpolation-factor
  31163. * @return The mixed value
  31164. */
  31165. static Mix(a: number, b: number, alpha: number): number;
  31166. /**
  31167. * Tries to instantiate a new object from a given class name
  31168. * @param className defines the class name to instantiate
  31169. * @returns the new object or null if the system was not able to do the instantiation
  31170. */
  31171. static Instantiate(className: string): any;
  31172. /**
  31173. * Provides a slice function that will work even on IE
  31174. * @param data defines the array to slice
  31175. * @param start defines the start of the data (optional)
  31176. * @param end defines the end of the data (optional)
  31177. * @returns the new sliced array
  31178. */
  31179. static Slice<T>(data: T, start?: number, end?: number): T;
  31180. /**
  31181. * Polyfill for setImmediate
  31182. * @param action defines the action to execute after the current execution block
  31183. */
  31184. static SetImmediate(action: () => void): void;
  31185. /**
  31186. * Function indicating if a number is an exponent of 2
  31187. * @param value defines the value to test
  31188. * @returns true if the value is an exponent of 2
  31189. */
  31190. static IsExponentOfTwo(value: number): boolean;
  31191. private static _tmpFloatArray;
  31192. /**
  31193. * Returns the nearest 32-bit single precision float representation of a Number
  31194. * @param value A Number. If the parameter is of a different type, it will get converted
  31195. * to a number or to NaN if it cannot be converted
  31196. * @returns number
  31197. */
  31198. static FloatRound(value: number): number;
  31199. /**
  31200. * Extracts the filename from a path
  31201. * @param path defines the path to use
  31202. * @returns the filename
  31203. */
  31204. static GetFilename(path: string): string;
  31205. /**
  31206. * Extracts the "folder" part of a path (everything before the filename).
  31207. * @param uri The URI to extract the info from
  31208. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31209. * @returns The "folder" part of the path
  31210. */
  31211. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31212. /**
  31213. * Extracts text content from a DOM element hierarchy
  31214. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31215. */
  31216. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31217. /**
  31218. * Convert an angle in radians to degrees
  31219. * @param angle defines the angle to convert
  31220. * @returns the angle in degrees
  31221. */
  31222. static ToDegrees(angle: number): number;
  31223. /**
  31224. * Convert an angle in degrees to radians
  31225. * @param angle defines the angle to convert
  31226. * @returns the angle in radians
  31227. */
  31228. static ToRadians(angle: number): number;
  31229. /**
  31230. * Encode a buffer to a base64 string
  31231. * @param buffer defines the buffer to encode
  31232. * @returns the encoded string
  31233. */
  31234. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31235. /**
  31236. * Returns an array if obj is not an array
  31237. * @param obj defines the object to evaluate as an array
  31238. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31239. * @returns either obj directly if obj is an array or a new array containing obj
  31240. */
  31241. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31242. /**
  31243. * Gets the pointer prefix to use
  31244. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31245. */
  31246. static GetPointerPrefix(): string;
  31247. /**
  31248. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31249. * @param url define the url we are trying
  31250. * @param element define the dom element where to configure the cors policy
  31251. */
  31252. static SetCorsBehavior(url: string | string[], element: {
  31253. crossOrigin: string | null;
  31254. }): void;
  31255. /**
  31256. * Removes unwanted characters from an url
  31257. * @param url defines the url to clean
  31258. * @returns the cleaned url
  31259. */
  31260. static CleanUrl(url: string): string;
  31261. /**
  31262. * Gets or sets a function used to pre-process url before using them to load assets
  31263. */
  31264. static PreprocessUrl: (url: string) => string;
  31265. /**
  31266. * Loads an image as an HTMLImageElement.
  31267. * @param input url string, ArrayBuffer, or Blob to load
  31268. * @param onLoad callback called when the image successfully loads
  31269. * @param onError callback called when the image fails to load
  31270. * @param offlineProvider offline provider for caching
  31271. * @returns the HTMLImageElement of the loaded image
  31272. */
  31273. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31274. /**
  31275. * Loads a file
  31276. * @param url url string, ArrayBuffer, or Blob to load
  31277. * @param onSuccess callback called when the file successfully loads
  31278. * @param onProgress callback called while file is loading (if the server supports this mode)
  31279. * @param offlineProvider defines the offline provider for caching
  31280. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31281. * @param onError callback called when the file fails to load
  31282. * @returns a file request object
  31283. */
  31284. 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;
  31285. /**
  31286. * Loads a file from a url
  31287. * @param url the file url to load
  31288. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31289. */
  31290. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31291. /**
  31292. * Load a script (identified by an url). When the url returns, the
  31293. * content of this file is added into a new script element, attached to the DOM (body element)
  31294. * @param scriptUrl defines the url of the script to laod
  31295. * @param onSuccess defines the callback called when the script is loaded
  31296. * @param onError defines the callback to call if an error occurs
  31297. * @param scriptId defines the id of the script element
  31298. */
  31299. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31300. /**
  31301. * Load an asynchronous script (identified by an url). When the url returns, the
  31302. * content of this file is added into a new script element, attached to the DOM (body element)
  31303. * @param scriptUrl defines the url of the script to laod
  31304. * @param scriptId defines the id of the script element
  31305. * @returns a promise request object
  31306. */
  31307. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31308. /**
  31309. * Loads a file from a blob
  31310. * @param fileToLoad defines the blob to use
  31311. * @param callback defines the callback to call when data is loaded
  31312. * @param progressCallback defines the callback to call during loading process
  31313. * @returns a file request object
  31314. */
  31315. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31316. /**
  31317. * Loads a file
  31318. * @param fileToLoad defines the file to load
  31319. * @param callback defines the callback to call when data is loaded
  31320. * @param progressCallBack defines the callback to call during loading process
  31321. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31322. * @returns a file request object
  31323. */
  31324. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31325. /**
  31326. * Creates a data url from a given string content
  31327. * @param content defines the content to convert
  31328. * @returns the new data url link
  31329. */
  31330. static FileAsURL(content: string): string;
  31331. /**
  31332. * Format the given number to a specific decimal format
  31333. * @param value defines the number to format
  31334. * @param decimals defines the number of decimals to use
  31335. * @returns the formatted string
  31336. */
  31337. static Format(value: number, decimals?: number): string;
  31338. /**
  31339. * Tries to copy an object by duplicating every property
  31340. * @param source defines the source object
  31341. * @param destination defines the target object
  31342. * @param doNotCopyList defines a list of properties to avoid
  31343. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31344. */
  31345. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31346. /**
  31347. * Gets a boolean indicating if the given object has no own property
  31348. * @param obj defines the object to test
  31349. * @returns true if object has no own property
  31350. */
  31351. static IsEmpty(obj: any): boolean;
  31352. /**
  31353. * Function used to register events at window level
  31354. * @param windowElement defines the Window object to use
  31355. * @param events defines the events to register
  31356. */
  31357. static RegisterTopRootEvents(windowElement: Window, events: {
  31358. name: string;
  31359. handler: Nullable<(e: FocusEvent) => any>;
  31360. }[]): void;
  31361. /**
  31362. * Function used to unregister events from window level
  31363. * @param windowElement defines the Window object to use
  31364. * @param events defines the events to unregister
  31365. */
  31366. static UnregisterTopRootEvents(windowElement: Window, events: {
  31367. name: string;
  31368. handler: Nullable<(e: FocusEvent) => any>;
  31369. }[]): void;
  31370. /**
  31371. * @ignore
  31372. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31373. /**
  31374. * Dumps the current bound framebuffer
  31375. * @param width defines the rendering width
  31376. * @param height defines the rendering height
  31377. * @param engine defines the hosting engine
  31378. * @param successCallback defines the callback triggered once the data are available
  31379. * @param mimeType defines the mime type of the result
  31380. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31381. */
  31382. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31383. /**
  31384. * Converts the canvas data to blob.
  31385. * This acts as a polyfill for browsers not supporting the to blob function.
  31386. * @param canvas Defines the canvas to extract the data from
  31387. * @param successCallback Defines the callback triggered once the data are available
  31388. * @param mimeType Defines the mime type of the result
  31389. */
  31390. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31391. /**
  31392. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31393. * @param successCallback defines the callback triggered once the data are available
  31394. * @param mimeType defines the mime type of the result
  31395. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31396. */
  31397. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31398. /**
  31399. * Downloads a blob in the browser
  31400. * @param blob defines the blob to download
  31401. * @param fileName defines the name of the downloaded file
  31402. */
  31403. static Download(blob: Blob, fileName: string): void;
  31404. /**
  31405. * Captures a screenshot of the current rendering
  31406. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31407. * @param engine defines the rendering engine
  31408. * @param camera defines the source camera
  31409. * @param size This parameter can be set to a single number or to an object with the
  31410. * following (optional) properties: precision, width, height. If a single number is passed,
  31411. * it will be used for both width and height. If an object is passed, the screenshot size
  31412. * will be derived from the parameters. The precision property is a multiplier allowing
  31413. * rendering at a higher or lower resolution
  31414. * @param successCallback defines the callback receives a single parameter which contains the
  31415. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31416. * src parameter of an <img> to display it
  31417. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31418. * Check your browser for supported MIME types
  31419. */
  31420. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31421. /**
  31422. * Captures a screenshot of the current rendering
  31423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31424. * @param engine defines the rendering engine
  31425. * @param camera defines the source camera
  31426. * @param size This parameter can be set to a single number or to an object with the
  31427. * following (optional) properties: precision, width, height. If a single number is passed,
  31428. * it will be used for both width and height. If an object is passed, the screenshot size
  31429. * will be derived from the parameters. The precision property is a multiplier allowing
  31430. * rendering at a higher or lower resolution
  31431. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31432. * Check your browser for supported MIME types
  31433. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31434. * to the src parameter of an <img> to display it
  31435. */
  31436. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31437. /**
  31438. * Generates an image screenshot from the specified camera.
  31439. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31440. * @param engine The engine to use for rendering
  31441. * @param camera The camera to use for rendering
  31442. * @param size This parameter can be set to a single number or to an object with the
  31443. * following (optional) properties: precision, width, height. If a single number is passed,
  31444. * it will be used for both width and height. If an object is passed, the screenshot size
  31445. * will be derived from the parameters. The precision property is a multiplier allowing
  31446. * rendering at a higher or lower resolution
  31447. * @param successCallback The callback receives a single parameter which contains the
  31448. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31449. * src parameter of an <img> to display it
  31450. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31451. * Check your browser for supported MIME types
  31452. * @param samples Texture samples (default: 1)
  31453. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31454. * @param fileName A name for for the downloaded file.
  31455. */
  31456. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31457. /**
  31458. * Generates an image screenshot from the specified camera.
  31459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31460. * @param engine The engine to use for rendering
  31461. * @param camera The camera to use for rendering
  31462. * @param size This parameter can be set to a single number or to an object with the
  31463. * following (optional) properties: precision, width, height. If a single number is passed,
  31464. * it will be used for both width and height. If an object is passed, the screenshot size
  31465. * will be derived from the parameters. The precision property is a multiplier allowing
  31466. * rendering at a higher or lower resolution
  31467. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31468. * Check your browser for supported MIME types
  31469. * @param samples Texture samples (default: 1)
  31470. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31471. * @param fileName A name for for the downloaded file.
  31472. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31473. * to the src parameter of an <img> to display it
  31474. */
  31475. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31476. /**
  31477. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31478. * Be aware Math.random() could cause collisions, but:
  31479. * "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"
  31480. * @returns a pseudo random id
  31481. */
  31482. static RandomId(): string;
  31483. /**
  31484. * Test if the given uri is a base64 string
  31485. * @param uri The uri to test
  31486. * @return True if the uri is a base64 string or false otherwise
  31487. */
  31488. static IsBase64(uri: string): boolean;
  31489. /**
  31490. * Decode the given base64 uri.
  31491. * @param uri The uri to decode
  31492. * @return The decoded base64 data.
  31493. */
  31494. static DecodeBase64(uri: string): ArrayBuffer;
  31495. /**
  31496. * Gets the absolute url.
  31497. * @param url the input url
  31498. * @return the absolute url
  31499. */
  31500. static GetAbsoluteUrl(url: string): string;
  31501. /**
  31502. * No log
  31503. */
  31504. static readonly NoneLogLevel: number;
  31505. /**
  31506. * Only message logs
  31507. */
  31508. static readonly MessageLogLevel: number;
  31509. /**
  31510. * Only warning logs
  31511. */
  31512. static readonly WarningLogLevel: number;
  31513. /**
  31514. * Only error logs
  31515. */
  31516. static readonly ErrorLogLevel: number;
  31517. /**
  31518. * All logs
  31519. */
  31520. static readonly AllLogLevel: number;
  31521. /**
  31522. * Gets a value indicating the number of loading errors
  31523. * @ignorenaming
  31524. */
  31525. static readonly errorsCount: number;
  31526. /**
  31527. * Callback called when a new log is added
  31528. */
  31529. static OnNewCacheEntry: (entry: string) => void;
  31530. /**
  31531. * Log a message to the console
  31532. * @param message defines the message to log
  31533. */
  31534. static Log(message: string): void;
  31535. /**
  31536. * Write a warning message to the console
  31537. * @param message defines the message to log
  31538. */
  31539. static Warn(message: string): void;
  31540. /**
  31541. * Write an error message to the console
  31542. * @param message defines the message to log
  31543. */
  31544. static Error(message: string): void;
  31545. /**
  31546. * Gets current log cache (list of logs)
  31547. */
  31548. static readonly LogCache: string;
  31549. /**
  31550. * Clears the log cache
  31551. */
  31552. static ClearLogCache(): void;
  31553. /**
  31554. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31555. */
  31556. static LogLevels: number;
  31557. /**
  31558. * Checks if the window object exists
  31559. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31560. */
  31561. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31562. /**
  31563. * No performance log
  31564. */
  31565. static readonly PerformanceNoneLogLevel: number;
  31566. /**
  31567. * Use user marks to log performance
  31568. */
  31569. static readonly PerformanceUserMarkLogLevel: number;
  31570. /**
  31571. * Log performance to the console
  31572. */
  31573. static readonly PerformanceConsoleLogLevel: number;
  31574. private static _performance;
  31575. /**
  31576. * Sets the current performance log level
  31577. */
  31578. static PerformanceLogLevel: number;
  31579. private static _StartPerformanceCounterDisabled;
  31580. private static _EndPerformanceCounterDisabled;
  31581. private static _StartUserMark;
  31582. private static _EndUserMark;
  31583. private static _StartPerformanceConsole;
  31584. private static _EndPerformanceConsole;
  31585. /**
  31586. * Starts a performance counter
  31587. */
  31588. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31589. /**
  31590. * Ends a specific performance coutner
  31591. */
  31592. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31593. /**
  31594. * Gets either window.performance.now() if supported or Date.now() else
  31595. */
  31596. static readonly Now: number;
  31597. /**
  31598. * This method will return the name of the class used to create the instance of the given object.
  31599. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31600. * @param object the object to get the class name from
  31601. * @param isType defines if the object is actually a type
  31602. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31603. */
  31604. static GetClassName(object: any, isType?: boolean): string;
  31605. /**
  31606. * Gets the first element of an array satisfying a given predicate
  31607. * @param array defines the array to browse
  31608. * @param predicate defines the predicate to use
  31609. * @returns null if not found or the element
  31610. */
  31611. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31612. /**
  31613. * This method will return the name of the full name of the class, including its owning module (if any).
  31614. * 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).
  31615. * @param object the object to get the class name from
  31616. * @param isType defines if the object is actually a type
  31617. * @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.
  31618. * @ignorenaming
  31619. */
  31620. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31621. /**
  31622. * Returns a promise that resolves after the given amount of time.
  31623. * @param delay Number of milliseconds to delay
  31624. * @returns Promise that resolves after the given amount of time
  31625. */
  31626. static DelayAsync(delay: number): Promise<void>;
  31627. }
  31628. /**
  31629. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31630. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31631. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31632. * @param name The name of the class, case should be preserved
  31633. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31634. */
  31635. export function className(name: string, module?: string): (target: Object) => void;
  31636. /**
  31637. * An implementation of a loop for asynchronous functions.
  31638. */
  31639. export class AsyncLoop {
  31640. /**
  31641. * Defines the number of iterations for the loop
  31642. */
  31643. iterations: number;
  31644. /**
  31645. * Defines the current index of the loop.
  31646. */
  31647. index: number;
  31648. private _done;
  31649. private _fn;
  31650. private _successCallback;
  31651. /**
  31652. * Constructor.
  31653. * @param iterations the number of iterations.
  31654. * @param func the function to run each iteration
  31655. * @param successCallback the callback that will be called upon succesful execution
  31656. * @param offset starting offset.
  31657. */
  31658. constructor(
  31659. /**
  31660. * Defines the number of iterations for the loop
  31661. */
  31662. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31663. /**
  31664. * Execute the next iteration. Must be called after the last iteration was finished.
  31665. */
  31666. executeNext(): void;
  31667. /**
  31668. * Break the loop and run the success callback.
  31669. */
  31670. breakLoop(): void;
  31671. /**
  31672. * Create and run an async loop.
  31673. * @param iterations the number of iterations.
  31674. * @param fn the function to run each iteration
  31675. * @param successCallback the callback that will be called upon succesful execution
  31676. * @param offset starting offset.
  31677. * @returns the created async loop object
  31678. */
  31679. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31680. /**
  31681. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31682. * @param iterations total number of iterations
  31683. * @param syncedIterations number of synchronous iterations in each async iteration.
  31684. * @param fn the function to call each iteration.
  31685. * @param callback a success call back that will be called when iterating stops.
  31686. * @param breakFunction a break condition (optional)
  31687. * @param timeout timeout settings for the setTimeout function. default - 0.
  31688. * @returns the created async loop object
  31689. */
  31690. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31691. }
  31692. }
  31693. declare module BABYLON {
  31694. /** @hidden */
  31695. export interface ICollisionCoordinator {
  31696. createCollider(): Collider;
  31697. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31698. init(scene: Scene): void;
  31699. }
  31700. /** @hidden */
  31701. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31702. private _scene;
  31703. private _scaledPosition;
  31704. private _scaledVelocity;
  31705. private _finalPosition;
  31706. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31707. createCollider(): Collider;
  31708. init(scene: Scene): void;
  31709. private _collideWithWorld;
  31710. }
  31711. }
  31712. declare module BABYLON {
  31713. /**
  31714. * Class used to manage all inputs for the scene.
  31715. */
  31716. export class InputManager {
  31717. /** The distance in pixel that you have to move to prevent some events */
  31718. static DragMovementThreshold: number;
  31719. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31720. static LongPressDelay: number;
  31721. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31722. static DoubleClickDelay: number;
  31723. /** If you need to check double click without raising a single click at first click, enable this flag */
  31724. static ExclusiveDoubleClickMode: boolean;
  31725. private _wheelEventName;
  31726. private _onPointerMove;
  31727. private _onPointerDown;
  31728. private _onPointerUp;
  31729. private _initClickEvent;
  31730. private _initActionManager;
  31731. private _delayedSimpleClick;
  31732. private _delayedSimpleClickTimeout;
  31733. private _previousDelayedSimpleClickTimeout;
  31734. private _meshPickProceed;
  31735. private _previousButtonPressed;
  31736. private _currentPickResult;
  31737. private _previousPickResult;
  31738. private _totalPointersPressed;
  31739. private _doubleClickOccured;
  31740. private _pointerOverMesh;
  31741. private _pickedDownMesh;
  31742. private _pickedUpMesh;
  31743. private _pointerX;
  31744. private _pointerY;
  31745. private _unTranslatedPointerX;
  31746. private _unTranslatedPointerY;
  31747. private _startingPointerPosition;
  31748. private _previousStartingPointerPosition;
  31749. private _startingPointerTime;
  31750. private _previousStartingPointerTime;
  31751. private _pointerCaptures;
  31752. private _onKeyDown;
  31753. private _onKeyUp;
  31754. private _onCanvasFocusObserver;
  31755. private _onCanvasBlurObserver;
  31756. private _scene;
  31757. /**
  31758. * Creates a new InputManager
  31759. * @param scene defines the hosting scene
  31760. */
  31761. constructor(scene: Scene);
  31762. /**
  31763. * Gets the mesh that is currently under the pointer
  31764. */
  31765. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31766. /**
  31767. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31768. */
  31769. readonly unTranslatedPointer: Vector2;
  31770. /**
  31771. * Gets or sets the current on-screen X position of the pointer
  31772. */
  31773. pointerX: number;
  31774. /**
  31775. * Gets or sets the current on-screen Y position of the pointer
  31776. */
  31777. pointerY: number;
  31778. private _updatePointerPosition;
  31779. private _processPointerMove;
  31780. private _setRayOnPointerInfo;
  31781. private _checkPrePointerObservable;
  31782. /**
  31783. * Use this method to simulate a pointer move on a mesh
  31784. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31785. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31786. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31787. */
  31788. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31789. /**
  31790. * Use this method to simulate a pointer down on a mesh
  31791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31794. */
  31795. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31796. private _processPointerDown;
  31797. /** @hidden */ private _isPointerSwiping(): boolean;
  31798. /**
  31799. * Use this method to simulate a pointer up on a mesh
  31800. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31801. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31802. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31803. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31804. */
  31805. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31806. private _processPointerUp;
  31807. /**
  31808. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31809. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31810. * @returns true if the pointer was captured
  31811. */
  31812. isPointerCaptured(pointerId?: number): boolean;
  31813. /**
  31814. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31815. * @param attachUp defines if you want to attach events to pointerup
  31816. * @param attachDown defines if you want to attach events to pointerdown
  31817. * @param attachMove defines if you want to attach events to pointermove
  31818. */
  31819. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31820. /**
  31821. * Detaches all event handlers
  31822. */
  31823. detachControl(): void;
  31824. /**
  31825. * Force the value of meshUnderPointer
  31826. * @param mesh defines the mesh to use
  31827. */
  31828. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31829. /**
  31830. * Gets the mesh under the pointer
  31831. * @returns a Mesh or null if no mesh is under the pointer
  31832. */
  31833. getPointerOverMesh(): Nullable<AbstractMesh>;
  31834. }
  31835. }
  31836. declare module BABYLON {
  31837. /**
  31838. * Helper class used to generate session unique ID
  31839. */
  31840. export class UniqueIdGenerator {
  31841. private static _UniqueIdCounter;
  31842. /**
  31843. * Gets an unique (relatively to the current scene) Id
  31844. */
  31845. static readonly UniqueId: number;
  31846. }
  31847. }
  31848. declare module BABYLON {
  31849. /**
  31850. * This class defines the direct association between an animation and a target
  31851. */
  31852. export class TargetedAnimation {
  31853. /**
  31854. * Animation to perform
  31855. */
  31856. animation: Animation;
  31857. /**
  31858. * Target to animate
  31859. */
  31860. target: any;
  31861. /**
  31862. * Serialize the object
  31863. * @returns the JSON object representing the current entity
  31864. */
  31865. serialize(): any;
  31866. }
  31867. /**
  31868. * Use this class to create coordinated animations on multiple targets
  31869. */
  31870. export class AnimationGroup implements IDisposable {
  31871. /** The name of the animation group */
  31872. name: string;
  31873. private _scene;
  31874. private _targetedAnimations;
  31875. private _animatables;
  31876. private _from;
  31877. private _to;
  31878. private _isStarted;
  31879. private _isPaused;
  31880. private _speedRatio;
  31881. private _loopAnimation;
  31882. /**
  31883. * Gets or sets the unique id of the node
  31884. */
  31885. uniqueId: number;
  31886. /**
  31887. * This observable will notify when one animation have ended
  31888. */
  31889. onAnimationEndObservable: Observable<TargetedAnimation>;
  31890. /**
  31891. * Observer raised when one animation loops
  31892. */
  31893. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31894. /**
  31895. * This observable will notify when all animations have ended.
  31896. */
  31897. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31898. /**
  31899. * This observable will notify when all animations have paused.
  31900. */
  31901. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31902. /**
  31903. * This observable will notify when all animations are playing.
  31904. */
  31905. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31906. /**
  31907. * Gets the first frame
  31908. */
  31909. readonly from: number;
  31910. /**
  31911. * Gets the last frame
  31912. */
  31913. readonly to: number;
  31914. /**
  31915. * Define if the animations are started
  31916. */
  31917. readonly isStarted: boolean;
  31918. /**
  31919. * Gets a value indicating that the current group is playing
  31920. */
  31921. readonly isPlaying: boolean;
  31922. /**
  31923. * Gets or sets the speed ratio to use for all animations
  31924. */
  31925. /**
  31926. * Gets or sets the speed ratio to use for all animations
  31927. */
  31928. speedRatio: number;
  31929. /**
  31930. * Gets or sets if all animations should loop or not
  31931. */
  31932. loopAnimation: boolean;
  31933. /**
  31934. * Gets the targeted animations for this animation group
  31935. */
  31936. readonly targetedAnimations: Array<TargetedAnimation>;
  31937. /**
  31938. * returning the list of animatables controlled by this animation group.
  31939. */
  31940. readonly animatables: Array<Animatable>;
  31941. /**
  31942. * Instantiates a new Animation Group.
  31943. * This helps managing several animations at once.
  31944. * @see http://doc.babylonjs.com/how_to/group
  31945. * @param name Defines the name of the group
  31946. * @param scene Defines the scene the group belongs to
  31947. */
  31948. constructor(
  31949. /** The name of the animation group */
  31950. name: string, scene?: Nullable<Scene>);
  31951. /**
  31952. * Add an animation (with its target) in the group
  31953. * @param animation defines the animation we want to add
  31954. * @param target defines the target of the animation
  31955. * @returns the TargetedAnimation object
  31956. */
  31957. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31958. /**
  31959. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31960. * It can add constant keys at begin or end
  31961. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31962. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31963. * @returns the animation group
  31964. */
  31965. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31966. /**
  31967. * Start all animations on given targets
  31968. * @param loop defines if animations must loop
  31969. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31970. * @param from defines the from key (optional)
  31971. * @param to defines the to key (optional)
  31972. * @returns the current animation group
  31973. */
  31974. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31975. /**
  31976. * Pause all animations
  31977. * @returns the animation group
  31978. */
  31979. pause(): AnimationGroup;
  31980. /**
  31981. * Play all animations to initial state
  31982. * This function will start() the animations if they were not started or will restart() them if they were paused
  31983. * @param loop defines if animations must loop
  31984. * @returns the animation group
  31985. */
  31986. play(loop?: boolean): AnimationGroup;
  31987. /**
  31988. * Reset all animations to initial state
  31989. * @returns the animation group
  31990. */
  31991. reset(): AnimationGroup;
  31992. /**
  31993. * Restart animations from key 0
  31994. * @returns the animation group
  31995. */
  31996. restart(): AnimationGroup;
  31997. /**
  31998. * Stop all animations
  31999. * @returns the animation group
  32000. */
  32001. stop(): AnimationGroup;
  32002. /**
  32003. * Set animation weight for all animatables
  32004. * @param weight defines the weight to use
  32005. * @return the animationGroup
  32006. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32007. */
  32008. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32009. /**
  32010. * Synchronize and normalize all animatables with a source animatable
  32011. * @param root defines the root animatable to synchronize with
  32012. * @return the animationGroup
  32013. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32014. */
  32015. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32016. /**
  32017. * Goes to a specific frame in this animation group
  32018. * @param frame the frame number to go to
  32019. * @return the animationGroup
  32020. */
  32021. goToFrame(frame: number): AnimationGroup;
  32022. /**
  32023. * Dispose all associated resources
  32024. */
  32025. dispose(): void;
  32026. private _checkAnimationGroupEnded;
  32027. /**
  32028. * Clone the current animation group and returns a copy
  32029. * @param newName defines the name of the new group
  32030. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32031. * @returns the new aniamtion group
  32032. */
  32033. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32034. /**
  32035. * Serializes the animationGroup to an object
  32036. * @returns Serialized object
  32037. */
  32038. serialize(): any;
  32039. /**
  32040. * Returns a new AnimationGroup object parsed from the source provided.
  32041. * @param parsedAnimationGroup defines the source
  32042. * @param scene defines the scene that will receive the animationGroup
  32043. * @returns a new AnimationGroup
  32044. */
  32045. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32046. /**
  32047. * Returns the string "AnimationGroup"
  32048. * @returns "AnimationGroup"
  32049. */
  32050. getClassName(): string;
  32051. /**
  32052. * Creates a detailled string about the object
  32053. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32054. * @returns a string representing the object
  32055. */
  32056. toString(fullDetails?: boolean): string;
  32057. }
  32058. }
  32059. declare module BABYLON {
  32060. /**
  32061. * Define an interface for all classes that will hold resources
  32062. */
  32063. export interface IDisposable {
  32064. /**
  32065. * Releases all held resources
  32066. */
  32067. dispose(): void;
  32068. }
  32069. /** Interface defining initialization parameters for Scene class */
  32070. export interface SceneOptions {
  32071. /**
  32072. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32073. * It will improve performance when the number of geometries becomes important.
  32074. */
  32075. useGeometryUniqueIdsMap?: boolean;
  32076. /**
  32077. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32078. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32079. */
  32080. useMaterialMeshMap?: boolean;
  32081. /**
  32082. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32083. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32084. */
  32085. useClonedMeshhMap?: boolean;
  32086. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32087. virtual?: boolean;
  32088. }
  32089. /**
  32090. * Represents a scene to be rendered by the engine.
  32091. * @see http://doc.babylonjs.com/features/scene
  32092. */
  32093. export class Scene extends AbstractScene implements IAnimatable {
  32094. /** The fog is deactivated */
  32095. static readonly FOGMODE_NONE: number;
  32096. /** The fog density is following an exponential function */
  32097. static readonly FOGMODE_EXP: number;
  32098. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32099. static readonly FOGMODE_EXP2: number;
  32100. /** The fog density is following a linear function. */
  32101. static readonly FOGMODE_LINEAR: number;
  32102. /**
  32103. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32104. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32105. */
  32106. static MinDeltaTime: number;
  32107. /**
  32108. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32109. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32110. */
  32111. static MaxDeltaTime: number;
  32112. /**
  32113. * Factory used to create the default material.
  32114. * @param name The name of the material to create
  32115. * @param scene The scene to create the material for
  32116. * @returns The default material
  32117. */
  32118. static DefaultMaterialFactory(scene: Scene): Material;
  32119. /**
  32120. * Factory used to create the a collision coordinator.
  32121. * @returns The collision coordinator
  32122. */
  32123. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32124. /** @hidden */ private _inputManager: InputManager;
  32125. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32126. cameraToUseForPointers: Nullable<Camera>;
  32127. /** @hidden */ protected readonly _isScene: boolean;
  32128. /**
  32129. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32130. */
  32131. autoClear: boolean;
  32132. /**
  32133. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32134. */
  32135. autoClearDepthAndStencil: boolean;
  32136. /**
  32137. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32138. */
  32139. clearColor: Color4;
  32140. /**
  32141. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32142. */
  32143. ambientColor: Color3;
  32144. /**
  32145. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32146. * It should only be one of the following (if not the default embedded one):
  32147. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32148. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32149. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32150. * The material properties need to be setup according to the type of texture in use.
  32151. */
  32152. environmentBRDFTexture: BaseTexture;
  32153. /** @hidden */
  32154. protected _environmentTexture: Nullable<BaseTexture>;
  32155. /**
  32156. * Texture used in all pbr material as the reflection texture.
  32157. * As in the majority of the scene they are the same (exception for multi room and so on),
  32158. * this is easier to reference from here than from all the materials.
  32159. */
  32160. /**
  32161. * Texture used in all pbr material as the reflection texture.
  32162. * As in the majority of the scene they are the same (exception for multi room and so on),
  32163. * this is easier to set here than in all the materials.
  32164. */
  32165. environmentTexture: Nullable<BaseTexture>;
  32166. /** @hidden */
  32167. protected _environmentIntensity: number;
  32168. /**
  32169. * Intensity of the environment in all pbr material.
  32170. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32171. * As in the majority of the scene they are the same (exception for multi room and so on),
  32172. * this is easier to reference from here than from all the materials.
  32173. */
  32174. /**
  32175. * Intensity of the environment in all pbr material.
  32176. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32177. * As in the majority of the scene they are the same (exception for multi room and so on),
  32178. * this is easier to set here than in all the materials.
  32179. */
  32180. environmentIntensity: number;
  32181. /** @hidden */
  32182. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32183. /**
  32184. * Default image processing configuration used either in the rendering
  32185. * Forward main pass or through the imageProcessingPostProcess if present.
  32186. * As in the majority of the scene they are the same (exception for multi camera),
  32187. * this is easier to reference from here than from all the materials and post process.
  32188. *
  32189. * No setter as we it is a shared configuration, you can set the values instead.
  32190. */
  32191. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32192. private _forceWireframe;
  32193. /**
  32194. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32195. */
  32196. forceWireframe: boolean;
  32197. private _forcePointsCloud;
  32198. /**
  32199. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32200. */
  32201. forcePointsCloud: boolean;
  32202. /**
  32203. * Gets or sets the active clipplane 1
  32204. */
  32205. clipPlane: Nullable<Plane>;
  32206. /**
  32207. * Gets or sets the active clipplane 2
  32208. */
  32209. clipPlane2: Nullable<Plane>;
  32210. /**
  32211. * Gets or sets the active clipplane 3
  32212. */
  32213. clipPlane3: Nullable<Plane>;
  32214. /**
  32215. * Gets or sets the active clipplane 4
  32216. */
  32217. clipPlane4: Nullable<Plane>;
  32218. /**
  32219. * Gets or sets a boolean indicating if animations are enabled
  32220. */
  32221. animationsEnabled: boolean;
  32222. private _animationPropertiesOverride;
  32223. /**
  32224. * Gets or sets the animation properties override
  32225. */
  32226. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32227. /**
  32228. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32229. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32230. */
  32231. useConstantAnimationDeltaTime: boolean;
  32232. /**
  32233. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32234. * Please note that it requires to run a ray cast through the scene on every frame
  32235. */
  32236. constantlyUpdateMeshUnderPointer: boolean;
  32237. /**
  32238. * Defines the HTML cursor to use when hovering over interactive elements
  32239. */
  32240. hoverCursor: string;
  32241. /**
  32242. * Defines the HTML default cursor to use (empty by default)
  32243. */
  32244. defaultCursor: string;
  32245. /**
  32246. * This is used to call preventDefault() on pointer down
  32247. * in order to block unwanted artifacts like system double clicks
  32248. */
  32249. preventDefaultOnPointerDown: boolean;
  32250. /**
  32251. * This is used to call preventDefault() on pointer up
  32252. * in order to block unwanted artifacts like system double clicks
  32253. */
  32254. preventDefaultOnPointerUp: boolean;
  32255. /**
  32256. * Gets or sets user defined metadata
  32257. */
  32258. metadata: any;
  32259. /**
  32260. * For internal use only. Please do not use.
  32261. */
  32262. reservedDataStore: any;
  32263. /**
  32264. * Gets the name of the plugin used to load this scene (null by default)
  32265. */
  32266. loadingPluginName: string;
  32267. /**
  32268. * Use this array to add regular expressions used to disable offline support for specific urls
  32269. */
  32270. disableOfflineSupportExceptionRules: RegExp[];
  32271. /**
  32272. * An event triggered when the scene is disposed.
  32273. */
  32274. onDisposeObservable: Observable<Scene>;
  32275. private _onDisposeObserver;
  32276. /** Sets a function to be executed when this scene is disposed. */
  32277. onDispose: () => void;
  32278. /**
  32279. * An event triggered before rendering the scene (right after animations and physics)
  32280. */
  32281. onBeforeRenderObservable: Observable<Scene>;
  32282. private _onBeforeRenderObserver;
  32283. /** Sets a function to be executed before rendering this scene */
  32284. beforeRender: Nullable<() => void>;
  32285. /**
  32286. * An event triggered after rendering the scene
  32287. */
  32288. onAfterRenderObservable: Observable<Scene>;
  32289. /**
  32290. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32291. */
  32292. onAfterRenderCameraObservable: Observable<Camera>;
  32293. private _onAfterRenderObserver;
  32294. /** Sets a function to be executed after rendering this scene */
  32295. afterRender: Nullable<() => void>;
  32296. /**
  32297. * An event triggered before animating the scene
  32298. */
  32299. onBeforeAnimationsObservable: Observable<Scene>;
  32300. /**
  32301. * An event triggered after animations processing
  32302. */
  32303. onAfterAnimationsObservable: Observable<Scene>;
  32304. /**
  32305. * An event triggered before draw calls are ready to be sent
  32306. */
  32307. onBeforeDrawPhaseObservable: Observable<Scene>;
  32308. /**
  32309. * An event triggered after draw calls have been sent
  32310. */
  32311. onAfterDrawPhaseObservable: Observable<Scene>;
  32312. /**
  32313. * An event triggered when the scene is ready
  32314. */
  32315. onReadyObservable: Observable<Scene>;
  32316. /**
  32317. * An event triggered before rendering a camera
  32318. */
  32319. onBeforeCameraRenderObservable: Observable<Camera>;
  32320. private _onBeforeCameraRenderObserver;
  32321. /** Sets a function to be executed before rendering a camera*/
  32322. beforeCameraRender: () => void;
  32323. /**
  32324. * An event triggered after rendering a camera
  32325. */
  32326. onAfterCameraRenderObservable: Observable<Camera>;
  32327. private _onAfterCameraRenderObserver;
  32328. /** Sets a function to be executed after rendering a camera*/
  32329. afterCameraRender: () => void;
  32330. /**
  32331. * An event triggered when active meshes evaluation is about to start
  32332. */
  32333. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32334. /**
  32335. * An event triggered when active meshes evaluation is done
  32336. */
  32337. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32338. /**
  32339. * An event triggered when particles rendering is about to start
  32340. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32341. */
  32342. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32343. /**
  32344. * An event triggered when particles rendering is done
  32345. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32346. */
  32347. onAfterParticlesRenderingObservable: Observable<Scene>;
  32348. /**
  32349. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32350. */
  32351. onDataLoadedObservable: Observable<Scene>;
  32352. /**
  32353. * An event triggered when a camera is created
  32354. */
  32355. onNewCameraAddedObservable: Observable<Camera>;
  32356. /**
  32357. * An event triggered when a camera is removed
  32358. */
  32359. onCameraRemovedObservable: Observable<Camera>;
  32360. /**
  32361. * An event triggered when a light is created
  32362. */
  32363. onNewLightAddedObservable: Observable<Light>;
  32364. /**
  32365. * An event triggered when a light is removed
  32366. */
  32367. onLightRemovedObservable: Observable<Light>;
  32368. /**
  32369. * An event triggered when a geometry is created
  32370. */
  32371. onNewGeometryAddedObservable: Observable<Geometry>;
  32372. /**
  32373. * An event triggered when a geometry is removed
  32374. */
  32375. onGeometryRemovedObservable: Observable<Geometry>;
  32376. /**
  32377. * An event triggered when a transform node is created
  32378. */
  32379. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32380. /**
  32381. * An event triggered when a transform node is removed
  32382. */
  32383. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32384. /**
  32385. * An event triggered when a mesh is created
  32386. */
  32387. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32388. /**
  32389. * An event triggered when a mesh is removed
  32390. */
  32391. onMeshRemovedObservable: Observable<AbstractMesh>;
  32392. /**
  32393. * An event triggered when a skeleton is created
  32394. */
  32395. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32396. /**
  32397. * An event triggered when a skeleton is removed
  32398. */
  32399. onSkeletonRemovedObservable: Observable<Skeleton>;
  32400. /**
  32401. * An event triggered when a material is created
  32402. */
  32403. onNewMaterialAddedObservable: Observable<Material>;
  32404. /**
  32405. * An event triggered when a material is removed
  32406. */
  32407. onMaterialRemovedObservable: Observable<Material>;
  32408. /**
  32409. * An event triggered when a texture is created
  32410. */
  32411. onNewTextureAddedObservable: Observable<BaseTexture>;
  32412. /**
  32413. * An event triggered when a texture is removed
  32414. */
  32415. onTextureRemovedObservable: Observable<BaseTexture>;
  32416. /**
  32417. * An event triggered when render targets are about to be rendered
  32418. * Can happen multiple times per frame.
  32419. */
  32420. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32421. /**
  32422. * An event triggered when render targets were rendered.
  32423. * Can happen multiple times per frame.
  32424. */
  32425. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32426. /**
  32427. * An event triggered before calculating deterministic simulation step
  32428. */
  32429. onBeforeStepObservable: Observable<Scene>;
  32430. /**
  32431. * An event triggered after calculating deterministic simulation step
  32432. */
  32433. onAfterStepObservable: Observable<Scene>;
  32434. /**
  32435. * An event triggered when the activeCamera property is updated
  32436. */
  32437. onActiveCameraChanged: Observable<Scene>;
  32438. /**
  32439. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32440. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32441. * 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)
  32442. */
  32443. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32444. /**
  32445. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32446. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32447. * 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)
  32448. */
  32449. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32450. /**
  32451. * This Observable will when a mesh has been imported into the scene.
  32452. */
  32453. onMeshImportedObservable: Observable<AbstractMesh>;
  32454. /**
  32455. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32456. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32457. */
  32458. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32459. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32460. /**
  32461. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32462. */
  32463. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32464. /**
  32465. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32466. */
  32467. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32468. /**
  32469. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32470. */
  32471. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32472. /** Callback called when a pointer move is detected */
  32473. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32474. /** Callback called when a pointer down is detected */
  32475. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32476. /** Callback called when a pointer up is detected */
  32477. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32478. /** Callback called when a pointer pick is detected */
  32479. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32480. /**
  32481. * 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).
  32482. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32483. */
  32484. onPrePointerObservable: Observable<PointerInfoPre>;
  32485. /**
  32486. * Observable event triggered each time an input event is received from the rendering canvas
  32487. */
  32488. onPointerObservable: Observable<PointerInfo>;
  32489. /**
  32490. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32491. */
  32492. readonly unTranslatedPointer: Vector2;
  32493. /**
  32494. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32495. */
  32496. static DragMovementThreshold: number;
  32497. /**
  32498. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32499. */
  32500. static LongPressDelay: number;
  32501. /**
  32502. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32503. */
  32504. static DoubleClickDelay: number;
  32505. /** If you need to check double click without raising a single click at first click, enable this flag */
  32506. static ExclusiveDoubleClickMode: boolean;
  32507. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32508. /**
  32509. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32510. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32511. */
  32512. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32513. /**
  32514. * Observable event triggered each time an keyboard event is received from the hosting window
  32515. */
  32516. onKeyboardObservable: Observable<KeyboardInfo>;
  32517. private _useRightHandedSystem;
  32518. /**
  32519. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32520. */
  32521. useRightHandedSystem: boolean;
  32522. private _timeAccumulator;
  32523. private _currentStepId;
  32524. private _currentInternalStep;
  32525. /**
  32526. * Sets the step Id used by deterministic lock step
  32527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32528. * @param newStepId defines the step Id
  32529. */
  32530. setStepId(newStepId: number): void;
  32531. /**
  32532. * Gets the step Id used by deterministic lock step
  32533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32534. * @returns the step Id
  32535. */
  32536. getStepId(): number;
  32537. /**
  32538. * Gets the internal step used by deterministic lock step
  32539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32540. * @returns the internal step
  32541. */
  32542. getInternalStep(): number;
  32543. private _fogEnabled;
  32544. /**
  32545. * Gets or sets a boolean indicating if fog is enabled on this scene
  32546. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32547. * (Default is true)
  32548. */
  32549. fogEnabled: boolean;
  32550. private _fogMode;
  32551. /**
  32552. * Gets or sets the fog mode to use
  32553. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32554. * | mode | value |
  32555. * | --- | --- |
  32556. * | FOGMODE_NONE | 0 |
  32557. * | FOGMODE_EXP | 1 |
  32558. * | FOGMODE_EXP2 | 2 |
  32559. * | FOGMODE_LINEAR | 3 |
  32560. */
  32561. fogMode: number;
  32562. /**
  32563. * Gets or sets the fog color to use
  32564. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32565. * (Default is Color3(0.2, 0.2, 0.3))
  32566. */
  32567. fogColor: Color3;
  32568. /**
  32569. * Gets or sets the fog density to use
  32570. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32571. * (Default is 0.1)
  32572. */
  32573. fogDensity: number;
  32574. /**
  32575. * Gets or sets the fog start distance to use
  32576. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32577. * (Default is 0)
  32578. */
  32579. fogStart: number;
  32580. /**
  32581. * Gets or sets the fog end distance to use
  32582. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32583. * (Default is 1000)
  32584. */
  32585. fogEnd: number;
  32586. private _shadowsEnabled;
  32587. /**
  32588. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32589. */
  32590. shadowsEnabled: boolean;
  32591. private _lightsEnabled;
  32592. /**
  32593. * Gets or sets a boolean indicating if lights are enabled on this scene
  32594. */
  32595. lightsEnabled: boolean;
  32596. /** All of the active cameras added to this scene. */
  32597. activeCameras: Camera[];
  32598. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32599. /** Gets or sets the current active camera */
  32600. activeCamera: Nullable<Camera>;
  32601. private _defaultMaterial;
  32602. /** The default material used on meshes when no material is affected */
  32603. /** The default material used on meshes when no material is affected */
  32604. defaultMaterial: Material;
  32605. private _texturesEnabled;
  32606. /**
  32607. * Gets or sets a boolean indicating if textures are enabled on this scene
  32608. */
  32609. texturesEnabled: boolean;
  32610. /**
  32611. * Gets or sets a boolean indicating if particles are enabled on this scene
  32612. */
  32613. particlesEnabled: boolean;
  32614. /**
  32615. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32616. */
  32617. spritesEnabled: boolean;
  32618. private _skeletonsEnabled;
  32619. /**
  32620. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32621. */
  32622. skeletonsEnabled: boolean;
  32623. /**
  32624. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32625. */
  32626. lensFlaresEnabled: boolean;
  32627. /**
  32628. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32630. */
  32631. collisionsEnabled: boolean;
  32632. private _collisionCoordinator;
  32633. /** @hidden */
  32634. readonly collisionCoordinator: ICollisionCoordinator;
  32635. /**
  32636. * Defines the gravity applied to this scene (used only for collisions)
  32637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32638. */
  32639. gravity: Vector3;
  32640. /**
  32641. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32642. */
  32643. postProcessesEnabled: boolean;
  32644. /**
  32645. * The list of postprocesses added to the scene
  32646. */
  32647. postProcesses: PostProcess[];
  32648. /**
  32649. * Gets the current postprocess manager
  32650. */
  32651. postProcessManager: PostProcessManager;
  32652. /**
  32653. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32654. */
  32655. renderTargetsEnabled: boolean;
  32656. /**
  32657. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32658. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32659. */
  32660. dumpNextRenderTargets: boolean;
  32661. /**
  32662. * The list of user defined render targets added to the scene
  32663. */
  32664. customRenderTargets: RenderTargetTexture[];
  32665. /**
  32666. * Defines if texture loading must be delayed
  32667. * If true, textures will only be loaded when they need to be rendered
  32668. */
  32669. useDelayedTextureLoading: boolean;
  32670. /**
  32671. * Gets the list of meshes imported to the scene through SceneLoader
  32672. */
  32673. importedMeshesFiles: String[];
  32674. /**
  32675. * Gets or sets a boolean indicating if probes are enabled on this scene
  32676. */
  32677. probesEnabled: boolean;
  32678. /**
  32679. * Gets or sets the current offline provider to use to store scene data
  32680. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32681. */
  32682. offlineProvider: IOfflineProvider;
  32683. /**
  32684. * Gets or sets the action manager associated with the scene
  32685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32686. */
  32687. actionManager: AbstractActionManager;
  32688. private _meshesForIntersections;
  32689. /**
  32690. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32691. */
  32692. proceduralTexturesEnabled: boolean;
  32693. private _engine;
  32694. private _totalVertices;
  32695. /** @hidden */ private _activeIndices: PerfCounter;
  32696. /** @hidden */ private _activeParticles: PerfCounter;
  32697. /** @hidden */ private _activeBones: PerfCounter;
  32698. private _animationRatio;
  32699. /** @hidden */ private _animationTimeLast: number;
  32700. /** @hidden */ private _animationTime: number;
  32701. /**
  32702. * Gets or sets a general scale for animation speed
  32703. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32704. */
  32705. animationTimeScale: number;
  32706. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32707. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32708. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32709. private _renderId;
  32710. private _frameId;
  32711. private _executeWhenReadyTimeoutId;
  32712. private _intermediateRendering;
  32713. private _viewUpdateFlag;
  32714. private _projectionUpdateFlag;
  32715. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32716. private _activeRequests;
  32717. /** @hidden */ private _pendingData: any[];
  32718. private _isDisposed;
  32719. /**
  32720. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32721. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32722. */
  32723. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32724. private _activeMeshes;
  32725. private _processedMaterials;
  32726. private _renderTargets;
  32727. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32728. private _activeSkeletons;
  32729. private _softwareSkinnedMeshes;
  32730. private _renderingManager;
  32731. /** @hidden */ private _activeAnimatables: Animatable[];
  32732. private _transformMatrix;
  32733. private _sceneUbo;
  32734. /** @hidden */ private _viewMatrix: Matrix;
  32735. private _projectionMatrix;
  32736. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32737. /** @hidden */ private _frustumPlanes: Plane[];
  32738. /**
  32739. * Gets the list of frustum planes (built from the active camera)
  32740. */
  32741. readonly frustumPlanes: Plane[];
  32742. /**
  32743. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32744. * This is useful if there are more lights that the maximum simulteanous authorized
  32745. */
  32746. requireLightSorting: boolean;
  32747. /** @hidden */
  32748. readonly useMaterialMeshMap: boolean;
  32749. /** @hidden */
  32750. readonly useClonedMeshhMap: boolean;
  32751. private _externalData;
  32752. private _uid;
  32753. /**
  32754. * @hidden
  32755. * Backing store of defined scene components.
  32756. */ private _components: ISceneComponent[];
  32757. /**
  32758. * @hidden
  32759. * Backing store of defined scene components.
  32760. */ private _serializableComponents: ISceneSerializableComponent[];
  32761. /**
  32762. * List of components to register on the next registration step.
  32763. */
  32764. private _transientComponents;
  32765. /**
  32766. * Registers the transient components if needed.
  32767. */
  32768. private _registerTransientComponents;
  32769. /**
  32770. * @hidden
  32771. * Add a component to the scene.
  32772. * Note that the ccomponent could be registered on th next frame if this is called after
  32773. * the register component stage.
  32774. * @param component Defines the component to add to the scene
  32775. */ private _addComponent(component: ISceneComponent): void;
  32776. /**
  32777. * @hidden
  32778. * Gets a component from the scene.
  32779. * @param name defines the name of the component to retrieve
  32780. * @returns the component or null if not present
  32781. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32782. /**
  32783. * @hidden
  32784. * Defines the actions happening before camera updates.
  32785. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32786. /**
  32787. * @hidden
  32788. * Defines the actions happening before clear the canvas.
  32789. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32790. /**
  32791. * @hidden
  32792. * Defines the actions when collecting render targets for the frame.
  32793. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32794. /**
  32795. * @hidden
  32796. * Defines the actions happening for one camera in the frame.
  32797. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32798. /**
  32799. * @hidden
  32800. * Defines the actions happening during the per mesh ready checks.
  32801. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32802. /**
  32803. * @hidden
  32804. * Defines the actions happening before evaluate active mesh checks.
  32805. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32806. /**
  32807. * @hidden
  32808. * Defines the actions happening during the evaluate sub mesh checks.
  32809. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32810. /**
  32811. * @hidden
  32812. * Defines the actions happening during the active mesh stage.
  32813. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32814. /**
  32815. * @hidden
  32816. * Defines the actions happening during the per camera render target step.
  32817. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32818. /**
  32819. * @hidden
  32820. * Defines the actions happening just before the active camera is drawing.
  32821. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32822. /**
  32823. * @hidden
  32824. * Defines the actions happening just before a render target is drawing.
  32825. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32826. /**
  32827. * @hidden
  32828. * Defines the actions happening just before a rendering group is drawing.
  32829. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32830. /**
  32831. * @hidden
  32832. * Defines the actions happening just before a mesh is drawing.
  32833. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32834. /**
  32835. * @hidden
  32836. * Defines the actions happening just after a mesh has been drawn.
  32837. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32838. /**
  32839. * @hidden
  32840. * Defines the actions happening just after a rendering group has been drawn.
  32841. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32842. /**
  32843. * @hidden
  32844. * Defines the actions happening just after the active camera has been drawn.
  32845. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32846. /**
  32847. * @hidden
  32848. * Defines the actions happening just after a render target has been drawn.
  32849. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32850. /**
  32851. * @hidden
  32852. * Defines the actions happening just after rendering all cameras and computing intersections.
  32853. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32854. /**
  32855. * @hidden
  32856. * Defines the actions happening when a pointer move event happens.
  32857. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32858. /**
  32859. * @hidden
  32860. * Defines the actions happening when a pointer down event happens.
  32861. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32862. /**
  32863. * @hidden
  32864. * Defines the actions happening when a pointer up event happens.
  32865. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32866. /**
  32867. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32868. */
  32869. private geometriesByUniqueId;
  32870. /**
  32871. * Creates a new Scene
  32872. * @param engine defines the engine to use to render this scene
  32873. * @param options defines the scene options
  32874. */
  32875. constructor(engine: Engine, options?: SceneOptions);
  32876. /**
  32877. * Gets a string idenfifying the name of the class
  32878. * @returns "Scene" string
  32879. */
  32880. getClassName(): string;
  32881. private _defaultMeshCandidates;
  32882. /**
  32883. * @hidden
  32884. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32885. private _defaultSubMeshCandidates;
  32886. /**
  32887. * @hidden
  32888. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32889. /**
  32890. * Sets the default candidate providers for the scene.
  32891. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32892. * and getCollidingSubMeshCandidates to their default function
  32893. */
  32894. setDefaultCandidateProviders(): void;
  32895. /**
  32896. * Gets the mesh that is currently under the pointer
  32897. */
  32898. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32899. /**
  32900. * Gets or sets the current on-screen X position of the pointer
  32901. */
  32902. pointerX: number;
  32903. /**
  32904. * Gets or sets the current on-screen Y position of the pointer
  32905. */
  32906. pointerY: number;
  32907. /**
  32908. * Gets the cached material (ie. the latest rendered one)
  32909. * @returns the cached material
  32910. */
  32911. getCachedMaterial(): Nullable<Material>;
  32912. /**
  32913. * Gets the cached effect (ie. the latest rendered one)
  32914. * @returns the cached effect
  32915. */
  32916. getCachedEffect(): Nullable<Effect>;
  32917. /**
  32918. * Gets the cached visibility state (ie. the latest rendered one)
  32919. * @returns the cached visibility state
  32920. */
  32921. getCachedVisibility(): Nullable<number>;
  32922. /**
  32923. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32924. * @param material defines the current material
  32925. * @param effect defines the current effect
  32926. * @param visibility defines the current visibility state
  32927. * @returns true if one parameter is not cached
  32928. */
  32929. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32930. /**
  32931. * Gets the engine associated with the scene
  32932. * @returns an Engine
  32933. */
  32934. getEngine(): Engine;
  32935. /**
  32936. * Gets the total number of vertices rendered per frame
  32937. * @returns the total number of vertices rendered per frame
  32938. */
  32939. getTotalVertices(): number;
  32940. /**
  32941. * Gets the performance counter for total vertices
  32942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32943. */
  32944. readonly totalVerticesPerfCounter: PerfCounter;
  32945. /**
  32946. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32947. * @returns the total number of active indices rendered per frame
  32948. */
  32949. getActiveIndices(): number;
  32950. /**
  32951. * Gets the performance counter for active indices
  32952. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32953. */
  32954. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32955. /**
  32956. * Gets the total number of active particles rendered per frame
  32957. * @returns the total number of active particles rendered per frame
  32958. */
  32959. getActiveParticles(): number;
  32960. /**
  32961. * Gets the performance counter for active particles
  32962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32963. */
  32964. readonly activeParticlesPerfCounter: PerfCounter;
  32965. /**
  32966. * Gets the total number of active bones rendered per frame
  32967. * @returns the total number of active bones rendered per frame
  32968. */
  32969. getActiveBones(): number;
  32970. /**
  32971. * Gets the performance counter for active bones
  32972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32973. */
  32974. readonly activeBonesPerfCounter: PerfCounter;
  32975. /**
  32976. * Gets the array of active meshes
  32977. * @returns an array of AbstractMesh
  32978. */
  32979. getActiveMeshes(): SmartArray<AbstractMesh>;
  32980. /**
  32981. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32982. * @returns a number
  32983. */
  32984. getAnimationRatio(): number;
  32985. /**
  32986. * Gets an unique Id for the current render phase
  32987. * @returns a number
  32988. */
  32989. getRenderId(): number;
  32990. /**
  32991. * Gets an unique Id for the current frame
  32992. * @returns a number
  32993. */
  32994. getFrameId(): number;
  32995. /** Call this function if you want to manually increment the render Id*/
  32996. incrementRenderId(): void;
  32997. private _createUbo;
  32998. /**
  32999. * Use this method to simulate a pointer move on a mesh
  33000. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33001. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33002. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33003. * @returns the current scene
  33004. */
  33005. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33006. /**
  33007. * Use this method to simulate a pointer down on a mesh
  33008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33011. * @returns the current scene
  33012. */
  33013. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33014. /**
  33015. * Use this method to simulate a pointer up on a mesh
  33016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33019. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33020. * @returns the current scene
  33021. */
  33022. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33023. /**
  33024. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33025. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33026. * @returns true if the pointer was captured
  33027. */
  33028. isPointerCaptured(pointerId?: number): boolean;
  33029. /**
  33030. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33031. * @param attachUp defines if you want to attach events to pointerup
  33032. * @param attachDown defines if you want to attach events to pointerdown
  33033. * @param attachMove defines if you want to attach events to pointermove
  33034. */
  33035. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33036. /** Detaches all event handlers*/
  33037. detachControl(): void;
  33038. /**
  33039. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33040. * Delay loaded resources are not taking in account
  33041. * @return true if all required resources are ready
  33042. */
  33043. isReady(): boolean;
  33044. /** Resets all cached information relative to material (including effect and visibility) */
  33045. resetCachedMaterial(): void;
  33046. /**
  33047. * Registers a function to be called before every frame render
  33048. * @param func defines the function to register
  33049. */
  33050. registerBeforeRender(func: () => void): void;
  33051. /**
  33052. * Unregisters a function called before every frame render
  33053. * @param func defines the function to unregister
  33054. */
  33055. unregisterBeforeRender(func: () => void): void;
  33056. /**
  33057. * Registers a function to be called after every frame render
  33058. * @param func defines the function to register
  33059. */
  33060. registerAfterRender(func: () => void): void;
  33061. /**
  33062. * Unregisters a function called after every frame render
  33063. * @param func defines the function to unregister
  33064. */
  33065. unregisterAfterRender(func: () => void): void;
  33066. private _executeOnceBeforeRender;
  33067. /**
  33068. * The provided function will run before render once and will be disposed afterwards.
  33069. * A timeout delay can be provided so that the function will be executed in N ms.
  33070. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33071. * @param func The function to be executed.
  33072. * @param timeout optional delay in ms
  33073. */
  33074. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33075. /** @hidden */ private _addPendingData(data: any): void;
  33076. /** @hidden */ private _removePendingData(data: any): void;
  33077. /**
  33078. * Returns the number of items waiting to be loaded
  33079. * @returns the number of items waiting to be loaded
  33080. */
  33081. getWaitingItemsCount(): number;
  33082. /**
  33083. * Returns a boolean indicating if the scene is still loading data
  33084. */
  33085. readonly isLoading: boolean;
  33086. /**
  33087. * Registers a function to be executed when the scene is ready
  33088. * @param {Function} func - the function to be executed
  33089. */
  33090. executeWhenReady(func: () => void): void;
  33091. /**
  33092. * Returns a promise that resolves when the scene is ready
  33093. * @returns A promise that resolves when the scene is ready
  33094. */
  33095. whenReadyAsync(): Promise<void>;
  33096. /** @hidden */ private _checkIsReady(): void;
  33097. /**
  33098. * Gets all animatable attached to the scene
  33099. */
  33100. readonly animatables: Animatable[];
  33101. /**
  33102. * Resets the last animation time frame.
  33103. * Useful to override when animations start running when loading a scene for the first time.
  33104. */
  33105. resetLastAnimationTimeFrame(): void;
  33106. /**
  33107. * Gets the current view matrix
  33108. * @returns a Matrix
  33109. */
  33110. getViewMatrix(): Matrix;
  33111. /**
  33112. * Gets the current projection matrix
  33113. * @returns a Matrix
  33114. */
  33115. getProjectionMatrix(): Matrix;
  33116. /**
  33117. * Gets the current transform matrix
  33118. * @returns a Matrix made of View * Projection
  33119. */
  33120. getTransformMatrix(): Matrix;
  33121. /**
  33122. * Sets the current transform matrix
  33123. * @param viewL defines the View matrix to use
  33124. * @param projectionL defines the Projection matrix to use
  33125. * @param viewR defines the right View matrix to use (if provided)
  33126. * @param projectionR defines the right Projection matrix to use (if provided)
  33127. */
  33128. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33129. /**
  33130. * Gets the uniform buffer used to store scene data
  33131. * @returns a UniformBuffer
  33132. */
  33133. getSceneUniformBuffer(): UniformBuffer;
  33134. /**
  33135. * Gets an unique (relatively to the current scene) Id
  33136. * @returns an unique number for the scene
  33137. */
  33138. getUniqueId(): number;
  33139. /**
  33140. * Add a mesh to the list of scene's meshes
  33141. * @param newMesh defines the mesh to add
  33142. * @param recursive if all child meshes should also be added to the scene
  33143. */
  33144. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33145. /**
  33146. * Remove a mesh for the list of scene's meshes
  33147. * @param toRemove defines the mesh to remove
  33148. * @param recursive if all child meshes should also be removed from the scene
  33149. * @returns the index where the mesh was in the mesh list
  33150. */
  33151. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33152. /**
  33153. * Add a transform node to the list of scene's transform nodes
  33154. * @param newTransformNode defines the transform node to add
  33155. */
  33156. addTransformNode(newTransformNode: TransformNode): void;
  33157. /**
  33158. * Remove a transform node for the list of scene's transform nodes
  33159. * @param toRemove defines the transform node to remove
  33160. * @returns the index where the transform node was in the transform node list
  33161. */
  33162. removeTransformNode(toRemove: TransformNode): number;
  33163. /**
  33164. * Remove a skeleton for the list of scene's skeletons
  33165. * @param toRemove defines the skeleton to remove
  33166. * @returns the index where the skeleton was in the skeleton list
  33167. */
  33168. removeSkeleton(toRemove: Skeleton): number;
  33169. /**
  33170. * Remove a morph target for the list of scene's morph targets
  33171. * @param toRemove defines the morph target to remove
  33172. * @returns the index where the morph target was in the morph target list
  33173. */
  33174. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33175. /**
  33176. * Remove a light for the list of scene's lights
  33177. * @param toRemove defines the light to remove
  33178. * @returns the index where the light was in the light list
  33179. */
  33180. removeLight(toRemove: Light): number;
  33181. /**
  33182. * Remove a camera for the list of scene's cameras
  33183. * @param toRemove defines the camera to remove
  33184. * @returns the index where the camera was in the camera list
  33185. */
  33186. removeCamera(toRemove: Camera): number;
  33187. /**
  33188. * Remove a particle system for the list of scene's particle systems
  33189. * @param toRemove defines the particle system to remove
  33190. * @returns the index where the particle system was in the particle system list
  33191. */
  33192. removeParticleSystem(toRemove: IParticleSystem): number;
  33193. /**
  33194. * Remove a animation for the list of scene's animations
  33195. * @param toRemove defines the animation to remove
  33196. * @returns the index where the animation was in the animation list
  33197. */
  33198. removeAnimation(toRemove: Animation): number;
  33199. /**
  33200. * Will stop the animation of the given target
  33201. * @param target - the target
  33202. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33203. * @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)
  33204. */
  33205. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33206. /**
  33207. * Removes the given animation group from this scene.
  33208. * @param toRemove The animation group to remove
  33209. * @returns The index of the removed animation group
  33210. */
  33211. removeAnimationGroup(toRemove: AnimationGroup): number;
  33212. /**
  33213. * Removes the given multi-material from this scene.
  33214. * @param toRemove The multi-material to remove
  33215. * @returns The index of the removed multi-material
  33216. */
  33217. removeMultiMaterial(toRemove: MultiMaterial): number;
  33218. /**
  33219. * Removes the given material from this scene.
  33220. * @param toRemove The material to remove
  33221. * @returns The index of the removed material
  33222. */
  33223. removeMaterial(toRemove: Material): number;
  33224. /**
  33225. * Removes the given action manager from this scene.
  33226. * @param toRemove The action manager to remove
  33227. * @returns The index of the removed action manager
  33228. */
  33229. removeActionManager(toRemove: AbstractActionManager): number;
  33230. /**
  33231. * Removes the given texture from this scene.
  33232. * @param toRemove The texture to remove
  33233. * @returns The index of the removed texture
  33234. */
  33235. removeTexture(toRemove: BaseTexture): number;
  33236. /**
  33237. * Adds the given light to this scene
  33238. * @param newLight The light to add
  33239. */
  33240. addLight(newLight: Light): void;
  33241. /**
  33242. * Sorts the list list based on light priorities
  33243. */
  33244. sortLightsByPriority(): void;
  33245. /**
  33246. * Adds the given camera to this scene
  33247. * @param newCamera The camera to add
  33248. */
  33249. addCamera(newCamera: Camera): void;
  33250. /**
  33251. * Adds the given skeleton to this scene
  33252. * @param newSkeleton The skeleton to add
  33253. */
  33254. addSkeleton(newSkeleton: Skeleton): void;
  33255. /**
  33256. * Adds the given particle system to this scene
  33257. * @param newParticleSystem The particle system to add
  33258. */
  33259. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33260. /**
  33261. * Adds the given animation to this scene
  33262. * @param newAnimation The animation to add
  33263. */
  33264. addAnimation(newAnimation: Animation): void;
  33265. /**
  33266. * Adds the given animation group to this scene.
  33267. * @param newAnimationGroup The animation group to add
  33268. */
  33269. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33270. /**
  33271. * Adds the given multi-material to this scene
  33272. * @param newMultiMaterial The multi-material to add
  33273. */
  33274. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33275. /**
  33276. * Adds the given material to this scene
  33277. * @param newMaterial The material to add
  33278. */
  33279. addMaterial(newMaterial: Material): void;
  33280. /**
  33281. * Adds the given morph target to this scene
  33282. * @param newMorphTargetManager The morph target to add
  33283. */
  33284. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33285. /**
  33286. * Adds the given geometry to this scene
  33287. * @param newGeometry The geometry to add
  33288. */
  33289. addGeometry(newGeometry: Geometry): void;
  33290. /**
  33291. * Adds the given action manager to this scene
  33292. * @param newActionManager The action manager to add
  33293. */
  33294. addActionManager(newActionManager: AbstractActionManager): void;
  33295. /**
  33296. * Adds the given texture to this scene.
  33297. * @param newTexture The texture to add
  33298. */
  33299. addTexture(newTexture: BaseTexture): void;
  33300. /**
  33301. * Switch active camera
  33302. * @param newCamera defines the new active camera
  33303. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33304. */
  33305. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33306. /**
  33307. * sets the active camera of the scene using its ID
  33308. * @param id defines the camera's ID
  33309. * @return the new active camera or null if none found.
  33310. */
  33311. setActiveCameraByID(id: string): Nullable<Camera>;
  33312. /**
  33313. * sets the active camera of the scene using its name
  33314. * @param name defines the camera's name
  33315. * @returns the new active camera or null if none found.
  33316. */
  33317. setActiveCameraByName(name: string): Nullable<Camera>;
  33318. /**
  33319. * get an animation group using its name
  33320. * @param name defines the material's name
  33321. * @return the animation group or null if none found.
  33322. */
  33323. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33324. /**
  33325. * Get a material using its unique id
  33326. * @param uniqueId defines the material's unique id
  33327. * @return the material or null if none found.
  33328. */
  33329. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33330. /**
  33331. * get a material using its id
  33332. * @param id defines the material's ID
  33333. * @return the material or null if none found.
  33334. */
  33335. getMaterialByID(id: string): Nullable<Material>;
  33336. /**
  33337. * Gets a the last added material using a given id
  33338. * @param id defines the material's ID
  33339. * @return the last material with the given id or null if none found.
  33340. */
  33341. getLastMaterialByID(id: string): Nullable<Material>;
  33342. /**
  33343. * Gets a material using its name
  33344. * @param name defines the material's name
  33345. * @return the material or null if none found.
  33346. */
  33347. getMaterialByName(name: string): Nullable<Material>;
  33348. /**
  33349. * Get a texture using its unique id
  33350. * @param uniqueId defines the texture's unique id
  33351. * @return the texture or null if none found.
  33352. */
  33353. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33354. /**
  33355. * Gets a camera using its id
  33356. * @param id defines the id to look for
  33357. * @returns the camera or null if not found
  33358. */
  33359. getCameraByID(id: string): Nullable<Camera>;
  33360. /**
  33361. * Gets a camera using its unique id
  33362. * @param uniqueId defines the unique id to look for
  33363. * @returns the camera or null if not found
  33364. */
  33365. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33366. /**
  33367. * Gets a camera using its name
  33368. * @param name defines the camera's name
  33369. * @return the camera or null if none found.
  33370. */
  33371. getCameraByName(name: string): Nullable<Camera>;
  33372. /**
  33373. * Gets a bone using its id
  33374. * @param id defines the bone's id
  33375. * @return the bone or null if not found
  33376. */
  33377. getBoneByID(id: string): Nullable<Bone>;
  33378. /**
  33379. * Gets a bone using its id
  33380. * @param name defines the bone's name
  33381. * @return the bone or null if not found
  33382. */
  33383. getBoneByName(name: string): Nullable<Bone>;
  33384. /**
  33385. * Gets a light node using its name
  33386. * @param name defines the the light's name
  33387. * @return the light or null if none found.
  33388. */
  33389. getLightByName(name: string): Nullable<Light>;
  33390. /**
  33391. * Gets a light node using its id
  33392. * @param id defines the light's id
  33393. * @return the light or null if none found.
  33394. */
  33395. getLightByID(id: string): Nullable<Light>;
  33396. /**
  33397. * Gets a light node using its scene-generated unique ID
  33398. * @param uniqueId defines the light's unique id
  33399. * @return the light or null if none found.
  33400. */
  33401. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33402. /**
  33403. * Gets a particle system by id
  33404. * @param id defines the particle system id
  33405. * @return the corresponding system or null if none found
  33406. */
  33407. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33408. /**
  33409. * Gets a geometry using its ID
  33410. * @param id defines the geometry's id
  33411. * @return the geometry or null if none found.
  33412. */
  33413. getGeometryByID(id: string): Nullable<Geometry>;
  33414. private _getGeometryByUniqueID;
  33415. /**
  33416. * Add a new geometry to this scene
  33417. * @param geometry defines the geometry to be added to the scene.
  33418. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33419. * @return a boolean defining if the geometry was added or not
  33420. */
  33421. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33422. /**
  33423. * Removes an existing geometry
  33424. * @param geometry defines the geometry to be removed from the scene
  33425. * @return a boolean defining if the geometry was removed or not
  33426. */
  33427. removeGeometry(geometry: Geometry): boolean;
  33428. /**
  33429. * Gets the list of geometries attached to the scene
  33430. * @returns an array of Geometry
  33431. */
  33432. getGeometries(): Geometry[];
  33433. /**
  33434. * Gets the first added mesh found of a given ID
  33435. * @param id defines the id to search for
  33436. * @return the mesh found or null if not found at all
  33437. */
  33438. getMeshByID(id: string): Nullable<AbstractMesh>;
  33439. /**
  33440. * Gets a list of meshes using their id
  33441. * @param id defines the id to search for
  33442. * @returns a list of meshes
  33443. */
  33444. getMeshesByID(id: string): Array<AbstractMesh>;
  33445. /**
  33446. * Gets the first added transform node found of a given ID
  33447. * @param id defines the id to search for
  33448. * @return the found transform node or null if not found at all.
  33449. */
  33450. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33451. /**
  33452. * Gets a transform node with its auto-generated unique id
  33453. * @param uniqueId efines the unique id to search for
  33454. * @return the found transform node or null if not found at all.
  33455. */
  33456. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33457. /**
  33458. * Gets a list of transform nodes using their id
  33459. * @param id defines the id to search for
  33460. * @returns a list of transform nodes
  33461. */
  33462. getTransformNodesByID(id: string): Array<TransformNode>;
  33463. /**
  33464. * Gets a mesh with its auto-generated unique id
  33465. * @param uniqueId defines the unique id to search for
  33466. * @return the found mesh or null if not found at all.
  33467. */
  33468. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33469. /**
  33470. * Gets a the last added mesh using a given id
  33471. * @param id defines the id to search for
  33472. * @return the found mesh or null if not found at all.
  33473. */
  33474. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33475. /**
  33476. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33477. * @param id defines the id to search for
  33478. * @return the found node or null if not found at all
  33479. */
  33480. getLastEntryByID(id: string): Nullable<Node>;
  33481. /**
  33482. * Gets a node (Mesh, Camera, Light) using a given id
  33483. * @param id defines the id to search for
  33484. * @return the found node or null if not found at all
  33485. */
  33486. getNodeByID(id: string): Nullable<Node>;
  33487. /**
  33488. * Gets a node (Mesh, Camera, Light) using a given name
  33489. * @param name defines the name to search for
  33490. * @return the found node or null if not found at all.
  33491. */
  33492. getNodeByName(name: string): Nullable<Node>;
  33493. /**
  33494. * Gets a mesh using a given name
  33495. * @param name defines the name to search for
  33496. * @return the found mesh or null if not found at all.
  33497. */
  33498. getMeshByName(name: string): Nullable<AbstractMesh>;
  33499. /**
  33500. * Gets a transform node using a given name
  33501. * @param name defines the name to search for
  33502. * @return the found transform node or null if not found at all.
  33503. */
  33504. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33505. /**
  33506. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33507. * @param id defines the id to search for
  33508. * @return the found skeleton or null if not found at all.
  33509. */
  33510. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33511. /**
  33512. * Gets a skeleton using a given auto generated unique id
  33513. * @param uniqueId defines the unique id to search for
  33514. * @return the found skeleton or null if not found at all.
  33515. */
  33516. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33517. /**
  33518. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33519. * @param id defines the id to search for
  33520. * @return the found skeleton or null if not found at all.
  33521. */
  33522. getSkeletonById(id: string): Nullable<Skeleton>;
  33523. /**
  33524. * Gets a skeleton using a given name
  33525. * @param name defines the name to search for
  33526. * @return the found skeleton or null if not found at all.
  33527. */
  33528. getSkeletonByName(name: string): Nullable<Skeleton>;
  33529. /**
  33530. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33531. * @param id defines the id to search for
  33532. * @return the found morph target manager or null if not found at all.
  33533. */
  33534. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33535. /**
  33536. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33537. * @param id defines the id to search for
  33538. * @return the found morph target or null if not found at all.
  33539. */
  33540. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33541. /**
  33542. * Gets a boolean indicating if the given mesh is active
  33543. * @param mesh defines the mesh to look for
  33544. * @returns true if the mesh is in the active list
  33545. */
  33546. isActiveMesh(mesh: AbstractMesh): boolean;
  33547. /**
  33548. * Return a unique id as a string which can serve as an identifier for the scene
  33549. */
  33550. readonly uid: string;
  33551. /**
  33552. * Add an externaly attached data from its key.
  33553. * This method call will fail and return false, if such key already exists.
  33554. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33555. * @param key the unique key that identifies the data
  33556. * @param data the data object to associate to the key for this Engine instance
  33557. * @return true if no such key were already present and the data was added successfully, false otherwise
  33558. */
  33559. addExternalData<T>(key: string, data: T): boolean;
  33560. /**
  33561. * Get an externaly attached data from its key
  33562. * @param key the unique key that identifies the data
  33563. * @return the associated data, if present (can be null), or undefined if not present
  33564. */
  33565. getExternalData<T>(key: string): Nullable<T>;
  33566. /**
  33567. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33568. * @param key the unique key that identifies the data
  33569. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33570. * @return the associated data, can be null if the factory returned null.
  33571. */
  33572. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33573. /**
  33574. * Remove an externaly attached data from the Engine instance
  33575. * @param key the unique key that identifies the data
  33576. * @return true if the data was successfully removed, false if it doesn't exist
  33577. */
  33578. removeExternalData(key: string): boolean;
  33579. private _evaluateSubMesh;
  33580. /**
  33581. * Clear the processed materials smart array preventing retention point in material dispose.
  33582. */
  33583. freeProcessedMaterials(): void;
  33584. private _preventFreeActiveMeshesAndRenderingGroups;
  33585. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33586. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33587. * when disposing several meshes in a row or a hierarchy of meshes.
  33588. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33589. */
  33590. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33591. /**
  33592. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33593. */
  33594. freeActiveMeshes(): void;
  33595. /**
  33596. * Clear the info related to rendering groups preventing retention points during dispose.
  33597. */
  33598. freeRenderingGroups(): void;
  33599. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33600. /**
  33601. * Lambda returning the list of potentially active meshes.
  33602. */
  33603. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33604. /**
  33605. * Lambda returning the list of potentially active sub meshes.
  33606. */
  33607. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33608. /**
  33609. * Lambda returning the list of potentially intersecting sub meshes.
  33610. */
  33611. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33612. /**
  33613. * Lambda returning the list of potentially colliding sub meshes.
  33614. */
  33615. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33616. private _activeMeshesFrozen;
  33617. /**
  33618. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33619. * @returns the current scene
  33620. */
  33621. freezeActiveMeshes(): Scene;
  33622. /**
  33623. * Use this function to restart evaluating active meshes on every frame
  33624. * @returns the current scene
  33625. */
  33626. unfreezeActiveMeshes(): Scene;
  33627. private _evaluateActiveMeshes;
  33628. private _activeMesh;
  33629. /**
  33630. * Update the transform matrix to update from the current active camera
  33631. * @param force defines a boolean used to force the update even if cache is up to date
  33632. */
  33633. updateTransformMatrix(force?: boolean): void;
  33634. private _bindFrameBuffer;
  33635. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33636. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33637. private _processSubCameras;
  33638. private _checkIntersections;
  33639. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33640. /**
  33641. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33642. */
  33643. getDeterministicFrameTime: () => number;
  33644. /** @hidden */ private _animate(): void;
  33645. /** Execute all animations (for a frame) */
  33646. animate(): void;
  33647. /**
  33648. * Render the scene
  33649. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33650. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33651. */
  33652. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33653. /**
  33654. * Freeze all materials
  33655. * A frozen material will not be updatable but should be faster to render
  33656. */
  33657. freezeMaterials(): void;
  33658. /**
  33659. * Unfreeze all materials
  33660. * A frozen material will not be updatable but should be faster to render
  33661. */
  33662. unfreezeMaterials(): void;
  33663. /**
  33664. * Releases all held ressources
  33665. */
  33666. dispose(): void;
  33667. /**
  33668. * Gets if the scene is already disposed
  33669. */
  33670. readonly isDisposed: boolean;
  33671. /**
  33672. * Call this function to reduce memory footprint of the scene.
  33673. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33674. */
  33675. clearCachedVertexData(): void;
  33676. /**
  33677. * This function will remove the local cached buffer data from texture.
  33678. * It will save memory but will prevent the texture from being rebuilt
  33679. */
  33680. cleanCachedTextureBuffer(): void;
  33681. /**
  33682. * Get the world extend vectors with an optional filter
  33683. *
  33684. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33685. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33686. */
  33687. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33688. min: Vector3;
  33689. max: Vector3;
  33690. };
  33691. /**
  33692. * Creates a ray that can be used to pick in the scene
  33693. * @param x defines the x coordinate of the origin (on-screen)
  33694. * @param y defines the y coordinate of the origin (on-screen)
  33695. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33696. * @param camera defines the camera to use for the picking
  33697. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33698. * @returns a Ray
  33699. */
  33700. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33701. /**
  33702. * Creates a ray that can be used to pick in the scene
  33703. * @param x defines the x coordinate of the origin (on-screen)
  33704. * @param y defines the y coordinate of the origin (on-screen)
  33705. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33706. * @param result defines the ray where to store the picking ray
  33707. * @param camera defines the camera to use for the picking
  33708. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33709. * @returns the current scene
  33710. */
  33711. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33712. /**
  33713. * Creates a ray that can be used to pick in the scene
  33714. * @param x defines the x coordinate of the origin (on-screen)
  33715. * @param y defines the y coordinate of the origin (on-screen)
  33716. * @param camera defines the camera to use for the picking
  33717. * @returns a Ray
  33718. */
  33719. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33720. /**
  33721. * Creates a ray that can be used to pick in the scene
  33722. * @param x defines the x coordinate of the origin (on-screen)
  33723. * @param y defines the y coordinate of the origin (on-screen)
  33724. * @param result defines the ray where to store the picking ray
  33725. * @param camera defines the camera to use for the picking
  33726. * @returns the current scene
  33727. */
  33728. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33729. /** Launch a ray to try to pick a mesh in the scene
  33730. * @param x position on screen
  33731. * @param y position on screen
  33732. * @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
  33733. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33734. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33735. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33736. * @returns a PickingInfo
  33737. */
  33738. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33739. /** Use the given ray to pick a mesh in the scene
  33740. * @param ray The ray to use to pick meshes
  33741. * @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
  33742. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33743. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33744. * @returns a PickingInfo
  33745. */
  33746. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33747. /**
  33748. * Launch a ray to try to pick a mesh in the scene
  33749. * @param x X position on screen
  33750. * @param y Y position on screen
  33751. * @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
  33752. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33753. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33754. * @returns an array of PickingInfo
  33755. */
  33756. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33757. /**
  33758. * Launch a ray to try to pick a mesh in the scene
  33759. * @param ray Ray to use
  33760. * @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
  33761. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33762. * @returns an array of PickingInfo
  33763. */
  33764. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33765. /**
  33766. * Force the value of meshUnderPointer
  33767. * @param mesh defines the mesh to use
  33768. */
  33769. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33770. /**
  33771. * Gets the mesh under the pointer
  33772. * @returns a Mesh or null if no mesh is under the pointer
  33773. */
  33774. getPointerOverMesh(): Nullable<AbstractMesh>;
  33775. /** @hidden */ private _rebuildGeometries(): void;
  33776. /** @hidden */ private _rebuildTextures(): void;
  33777. private _getByTags;
  33778. /**
  33779. * Get a list of meshes by tags
  33780. * @param tagsQuery defines the tags query to use
  33781. * @param forEach defines a predicate used to filter results
  33782. * @returns an array of Mesh
  33783. */
  33784. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33785. /**
  33786. * Get a list of cameras by tags
  33787. * @param tagsQuery defines the tags query to use
  33788. * @param forEach defines a predicate used to filter results
  33789. * @returns an array of Camera
  33790. */
  33791. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33792. /**
  33793. * Get a list of lights by tags
  33794. * @param tagsQuery defines the tags query to use
  33795. * @param forEach defines a predicate used to filter results
  33796. * @returns an array of Light
  33797. */
  33798. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33799. /**
  33800. * Get a list of materials by tags
  33801. * @param tagsQuery defines the tags query to use
  33802. * @param forEach defines a predicate used to filter results
  33803. * @returns an array of Material
  33804. */
  33805. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33806. /**
  33807. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33808. * This allowed control for front to back rendering or reversly depending of the special needs.
  33809. *
  33810. * @param renderingGroupId The rendering group id corresponding to its index
  33811. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33812. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33813. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33814. */
  33815. 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;
  33816. /**
  33817. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33818. *
  33819. * @param renderingGroupId The rendering group id corresponding to its index
  33820. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33821. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33822. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33823. */
  33824. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33825. /**
  33826. * Gets the current auto clear configuration for one rendering group of the rendering
  33827. * manager.
  33828. * @param index the rendering group index to get the information for
  33829. * @returns The auto clear setup for the requested rendering group
  33830. */
  33831. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33832. private _blockMaterialDirtyMechanism;
  33833. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33834. blockMaterialDirtyMechanism: boolean;
  33835. /**
  33836. * Will flag all materials as dirty to trigger new shader compilation
  33837. * @param flag defines the flag used to specify which material part must be marked as dirty
  33838. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33839. */
  33840. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33841. /** @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;
  33842. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33843. }
  33844. }
  33845. declare module BABYLON {
  33846. /**
  33847. * Set of assets to keep when moving a scene into an asset container.
  33848. */
  33849. export class KeepAssets extends AbstractScene {
  33850. }
  33851. /**
  33852. * Container with a set of assets that can be added or removed from a scene.
  33853. */
  33854. export class AssetContainer extends AbstractScene {
  33855. /**
  33856. * The scene the AssetContainer belongs to.
  33857. */
  33858. scene: Scene;
  33859. /**
  33860. * Instantiates an AssetContainer.
  33861. * @param scene The scene the AssetContainer belongs to.
  33862. */
  33863. constructor(scene: Scene);
  33864. /**
  33865. * Adds all the assets from the container to the scene.
  33866. */
  33867. addAllToScene(): void;
  33868. /**
  33869. * Removes all the assets in the container from the scene
  33870. */
  33871. removeAllFromScene(): void;
  33872. /**
  33873. * Disposes all the assets in the container
  33874. */
  33875. dispose(): void;
  33876. private _moveAssets;
  33877. /**
  33878. * Removes all the assets contained in the scene and adds them to the container.
  33879. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33880. */
  33881. moveAllFromScene(keepAssets?: KeepAssets): void;
  33882. /**
  33883. * 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.
  33884. * @returns the root mesh
  33885. */
  33886. createRootMesh(): Mesh;
  33887. }
  33888. }
  33889. declare module BABYLON {
  33890. /**
  33891. * Defines how the parser contract is defined.
  33892. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33893. */
  33894. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33895. /**
  33896. * Defines how the individual parser contract is defined.
  33897. * These parser can parse an individual asset
  33898. */
  33899. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33900. /**
  33901. * Base class of the scene acting as a container for the different elements composing a scene.
  33902. * This class is dynamically extended by the different components of the scene increasing
  33903. * flexibility and reducing coupling
  33904. */
  33905. export abstract class AbstractScene {
  33906. /**
  33907. * Stores the list of available parsers in the application.
  33908. */
  33909. private static _BabylonFileParsers;
  33910. /**
  33911. * Stores the list of available individual parsers in the application.
  33912. */
  33913. private static _IndividualBabylonFileParsers;
  33914. /**
  33915. * Adds a parser in the list of available ones
  33916. * @param name Defines the name of the parser
  33917. * @param parser Defines the parser to add
  33918. */
  33919. static AddParser(name: string, parser: BabylonFileParser): void;
  33920. /**
  33921. * Gets a general parser from the list of avaialble ones
  33922. * @param name Defines the name of the parser
  33923. * @returns the requested parser or null
  33924. */
  33925. static GetParser(name: string): Nullable<BabylonFileParser>;
  33926. /**
  33927. * Adds n individual parser in the list of available ones
  33928. * @param name Defines the name of the parser
  33929. * @param parser Defines the parser to add
  33930. */
  33931. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33932. /**
  33933. * Gets an individual parser from the list of avaialble ones
  33934. * @param name Defines the name of the parser
  33935. * @returns the requested parser or null
  33936. */
  33937. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33938. /**
  33939. * Parser json data and populate both a scene and its associated container object
  33940. * @param jsonData Defines the data to parse
  33941. * @param scene Defines the scene to parse the data for
  33942. * @param container Defines the container attached to the parsing sequence
  33943. * @param rootUrl Defines the root url of the data
  33944. */
  33945. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33946. /**
  33947. * Gets the list of root nodes (ie. nodes with no parent)
  33948. */
  33949. rootNodes: Node[];
  33950. /** All of the cameras added to this scene
  33951. * @see http://doc.babylonjs.com/babylon101/cameras
  33952. */
  33953. cameras: Camera[];
  33954. /**
  33955. * All of the lights added to this scene
  33956. * @see http://doc.babylonjs.com/babylon101/lights
  33957. */
  33958. lights: Light[];
  33959. /**
  33960. * All of the (abstract) meshes added to this scene
  33961. */
  33962. meshes: AbstractMesh[];
  33963. /**
  33964. * The list of skeletons added to the scene
  33965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33966. */
  33967. skeletons: Skeleton[];
  33968. /**
  33969. * All of the particle systems added to this scene
  33970. * @see http://doc.babylonjs.com/babylon101/particles
  33971. */
  33972. particleSystems: IParticleSystem[];
  33973. /**
  33974. * Gets a list of Animations associated with the scene
  33975. */
  33976. animations: Animation[];
  33977. /**
  33978. * All of the animation groups added to this scene
  33979. * @see http://doc.babylonjs.com/how_to/group
  33980. */
  33981. animationGroups: AnimationGroup[];
  33982. /**
  33983. * All of the multi-materials added to this scene
  33984. * @see http://doc.babylonjs.com/how_to/multi_materials
  33985. */
  33986. multiMaterials: MultiMaterial[];
  33987. /**
  33988. * All of the materials added to this scene
  33989. * In the context of a Scene, it is not supposed to be modified manually.
  33990. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33991. * Note also that the order of the Material wihin the array is not significant and might change.
  33992. * @see http://doc.babylonjs.com/babylon101/materials
  33993. */
  33994. materials: Material[];
  33995. /**
  33996. * The list of morph target managers added to the scene
  33997. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33998. */
  33999. morphTargetManagers: MorphTargetManager[];
  34000. /**
  34001. * The list of geometries used in the scene.
  34002. */
  34003. geometries: Geometry[];
  34004. /**
  34005. * All of the tranform nodes added to this scene
  34006. * In the context of a Scene, it is not supposed to be modified manually.
  34007. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34008. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34009. * @see http://doc.babylonjs.com/how_to/transformnode
  34010. */
  34011. transformNodes: TransformNode[];
  34012. /**
  34013. * ActionManagers available on the scene.
  34014. */
  34015. actionManagers: AbstractActionManager[];
  34016. /**
  34017. * Textures to keep.
  34018. */
  34019. textures: BaseTexture[];
  34020. /**
  34021. * Environment texture for the scene
  34022. */
  34023. environmentTexture: Nullable<BaseTexture>;
  34024. }
  34025. }
  34026. declare module BABYLON {
  34027. /**
  34028. * Interface used to define options for Sound class
  34029. */
  34030. export interface ISoundOptions {
  34031. /**
  34032. * Does the sound autoplay once loaded.
  34033. */
  34034. autoplay?: boolean;
  34035. /**
  34036. * Does the sound loop after it finishes playing once.
  34037. */
  34038. loop?: boolean;
  34039. /**
  34040. * Sound's volume
  34041. */
  34042. volume?: number;
  34043. /**
  34044. * Is it a spatial sound?
  34045. */
  34046. spatialSound?: boolean;
  34047. /**
  34048. * Maximum distance to hear that sound
  34049. */
  34050. maxDistance?: number;
  34051. /**
  34052. * Uses user defined attenuation function
  34053. */
  34054. useCustomAttenuation?: boolean;
  34055. /**
  34056. * Define the roll off factor of spatial sounds.
  34057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34058. */
  34059. rolloffFactor?: number;
  34060. /**
  34061. * Define the reference distance the sound should be heard perfectly.
  34062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34063. */
  34064. refDistance?: number;
  34065. /**
  34066. * Define the distance attenuation model the sound will follow.
  34067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34068. */
  34069. distanceModel?: string;
  34070. /**
  34071. * Defines the playback speed (1 by default)
  34072. */
  34073. playbackRate?: number;
  34074. /**
  34075. * Defines if the sound is from a streaming source
  34076. */
  34077. streaming?: boolean;
  34078. /**
  34079. * Defines an optional length (in seconds) inside the sound file
  34080. */
  34081. length?: number;
  34082. /**
  34083. * Defines an optional offset (in seconds) inside the sound file
  34084. */
  34085. offset?: number;
  34086. /**
  34087. * If true, URLs will not be required to state the audio file codec to use.
  34088. */
  34089. skipCodecCheck?: boolean;
  34090. }
  34091. /**
  34092. * Defines a sound that can be played in the application.
  34093. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34095. */
  34096. export class Sound {
  34097. /**
  34098. * The name of the sound in the scene.
  34099. */
  34100. name: string;
  34101. /**
  34102. * Does the sound autoplay once loaded.
  34103. */
  34104. autoplay: boolean;
  34105. /**
  34106. * Does the sound loop after it finishes playing once.
  34107. */
  34108. loop: boolean;
  34109. /**
  34110. * Does the sound use a custom attenuation curve to simulate the falloff
  34111. * happening when the source gets further away from the camera.
  34112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34113. */
  34114. useCustomAttenuation: boolean;
  34115. /**
  34116. * The sound track id this sound belongs to.
  34117. */
  34118. soundTrackId: number;
  34119. /**
  34120. * Is this sound currently played.
  34121. */
  34122. isPlaying: boolean;
  34123. /**
  34124. * Is this sound currently paused.
  34125. */
  34126. isPaused: boolean;
  34127. /**
  34128. * Does this sound enables spatial sound.
  34129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34130. */
  34131. spatialSound: boolean;
  34132. /**
  34133. * Define the reference distance the sound should be heard perfectly.
  34134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34135. */
  34136. refDistance: number;
  34137. /**
  34138. * Define the roll off factor of spatial sounds.
  34139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34140. */
  34141. rolloffFactor: number;
  34142. /**
  34143. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34145. */
  34146. maxDistance: number;
  34147. /**
  34148. * Define the distance attenuation model the sound will follow.
  34149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34150. */
  34151. distanceModel: string;
  34152. /**
  34153. * @hidden
  34154. * Back Compat
  34155. **/
  34156. onended: () => any;
  34157. /**
  34158. * Observable event when the current playing sound finishes.
  34159. */
  34160. onEndedObservable: Observable<Sound>;
  34161. private _panningModel;
  34162. private _playbackRate;
  34163. private _streaming;
  34164. private _startTime;
  34165. private _startOffset;
  34166. private _position;
  34167. /** @hidden */ private _positionInEmitterSpace: boolean;
  34168. private _localDirection;
  34169. private _volume;
  34170. private _isReadyToPlay;
  34171. private _isDirectional;
  34172. private _readyToPlayCallback;
  34173. private _audioBuffer;
  34174. private _soundSource;
  34175. private _streamingSource;
  34176. private _soundPanner;
  34177. private _soundGain;
  34178. private _inputAudioNode;
  34179. private _outputAudioNode;
  34180. private _coneInnerAngle;
  34181. private _coneOuterAngle;
  34182. private _coneOuterGain;
  34183. private _scene;
  34184. private _connectedTransformNode;
  34185. private _customAttenuationFunction;
  34186. private _registerFunc;
  34187. private _isOutputConnected;
  34188. private _htmlAudioElement;
  34189. private _urlType;
  34190. private _length?;
  34191. private _offset?;
  34192. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34193. /**
  34194. * Create a sound and attach it to a scene
  34195. * @param name Name of your sound
  34196. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34197. * @param scene defines the scene the sound belongs to
  34198. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34199. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34200. */
  34201. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34202. /**
  34203. * Release the sound and its associated resources
  34204. */
  34205. dispose(): void;
  34206. /**
  34207. * Gets if the sounds is ready to be played or not.
  34208. * @returns true if ready, otherwise false
  34209. */
  34210. isReady(): boolean;
  34211. private _soundLoaded;
  34212. /**
  34213. * Sets the data of the sound from an audiobuffer
  34214. * @param audioBuffer The audioBuffer containing the data
  34215. */
  34216. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34217. /**
  34218. * Updates the current sounds options such as maxdistance, loop...
  34219. * @param options A JSON object containing values named as the object properties
  34220. */
  34221. updateOptions(options: ISoundOptions): void;
  34222. private _createSpatialParameters;
  34223. private _updateSpatialParameters;
  34224. /**
  34225. * Switch the panning model to HRTF:
  34226. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34228. */
  34229. switchPanningModelToHRTF(): void;
  34230. /**
  34231. * Switch the panning model to Equal Power:
  34232. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34234. */
  34235. switchPanningModelToEqualPower(): void;
  34236. private _switchPanningModel;
  34237. /**
  34238. * Connect this sound to a sound track audio node like gain...
  34239. * @param soundTrackAudioNode the sound track audio node to connect to
  34240. */
  34241. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34242. /**
  34243. * Transform this sound into a directional source
  34244. * @param coneInnerAngle Size of the inner cone in degree
  34245. * @param coneOuterAngle Size of the outer cone in degree
  34246. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34247. */
  34248. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34249. /**
  34250. * Gets or sets the inner angle for the directional cone.
  34251. */
  34252. /**
  34253. * Gets or sets the inner angle for the directional cone.
  34254. */
  34255. directionalConeInnerAngle: number;
  34256. /**
  34257. * Gets or sets the outer angle for the directional cone.
  34258. */
  34259. /**
  34260. * Gets or sets the outer angle for the directional cone.
  34261. */
  34262. directionalConeOuterAngle: number;
  34263. /**
  34264. * Sets the position of the emitter if spatial sound is enabled
  34265. * @param newPosition Defines the new posisiton
  34266. */
  34267. setPosition(newPosition: Vector3): void;
  34268. /**
  34269. * Sets the local direction of the emitter if spatial sound is enabled
  34270. * @param newLocalDirection Defines the new local direction
  34271. */
  34272. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34273. private _updateDirection;
  34274. /** @hidden */
  34275. updateDistanceFromListener(): void;
  34276. /**
  34277. * Sets a new custom attenuation function for the sound.
  34278. * @param callback Defines the function used for the attenuation
  34279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34280. */
  34281. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34282. /**
  34283. * Play the sound
  34284. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34285. * @param offset (optional) Start the sound at a specific time in seconds
  34286. * @param length (optional) Sound duration (in seconds)
  34287. */
  34288. play(time?: number, offset?: number, length?: number): void;
  34289. private _onended;
  34290. /**
  34291. * Stop the sound
  34292. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34293. */
  34294. stop(time?: number): void;
  34295. /**
  34296. * Put the sound in pause
  34297. */
  34298. pause(): void;
  34299. /**
  34300. * Sets a dedicated volume for this sounds
  34301. * @param newVolume Define the new volume of the sound
  34302. * @param time Define time for gradual change to new volume
  34303. */
  34304. setVolume(newVolume: number, time?: number): void;
  34305. /**
  34306. * Set the sound play back rate
  34307. * @param newPlaybackRate Define the playback rate the sound should be played at
  34308. */
  34309. setPlaybackRate(newPlaybackRate: number): void;
  34310. /**
  34311. * Gets the volume of the sound.
  34312. * @returns the volume of the sound
  34313. */
  34314. getVolume(): number;
  34315. /**
  34316. * Attach the sound to a dedicated mesh
  34317. * @param transformNode The transform node to connect the sound with
  34318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34319. */
  34320. attachToMesh(transformNode: TransformNode): void;
  34321. /**
  34322. * Detach the sound from the previously attached mesh
  34323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34324. */
  34325. detachFromMesh(): void;
  34326. private _onRegisterAfterWorldMatrixUpdate;
  34327. /**
  34328. * Clone the current sound in the scene.
  34329. * @returns the new sound clone
  34330. */
  34331. clone(): Nullable<Sound>;
  34332. /**
  34333. * Gets the current underlying audio buffer containing the data
  34334. * @returns the audio buffer
  34335. */
  34336. getAudioBuffer(): Nullable<AudioBuffer>;
  34337. /**
  34338. * Serializes the Sound in a JSON representation
  34339. * @returns the JSON representation of the sound
  34340. */
  34341. serialize(): any;
  34342. /**
  34343. * Parse a JSON representation of a sound to innstantiate in a given scene
  34344. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34345. * @param scene Define the scene the new parsed sound should be created in
  34346. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34347. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34348. * @returns the newly parsed sound
  34349. */
  34350. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34351. }
  34352. }
  34353. declare module BABYLON {
  34354. /**
  34355. * This defines an action helpful to play a defined sound on a triggered action.
  34356. */
  34357. export class PlaySoundAction extends Action {
  34358. private _sound;
  34359. /**
  34360. * Instantiate the action
  34361. * @param triggerOptions defines the trigger options
  34362. * @param sound defines the sound to play
  34363. * @param condition defines the trigger related conditions
  34364. */
  34365. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34366. /** @hidden */ private _prepare(): void;
  34367. /**
  34368. * Execute the action and play the sound.
  34369. */
  34370. execute(): void;
  34371. /**
  34372. * Serializes the actions and its related information.
  34373. * @param parent defines the object to serialize in
  34374. * @returns the serialized object
  34375. */
  34376. serialize(parent: any): any;
  34377. }
  34378. /**
  34379. * This defines an action helpful to stop a defined sound on a triggered action.
  34380. */
  34381. export class StopSoundAction extends Action {
  34382. private _sound;
  34383. /**
  34384. * Instantiate the action
  34385. * @param triggerOptions defines the trigger options
  34386. * @param sound defines the sound to stop
  34387. * @param condition defines the trigger related conditions
  34388. */
  34389. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34390. /** @hidden */ private _prepare(): void;
  34391. /**
  34392. * Execute the action and stop the sound.
  34393. */
  34394. execute(): void;
  34395. /**
  34396. * Serializes the actions and its related information.
  34397. * @param parent defines the object to serialize in
  34398. * @returns the serialized object
  34399. */
  34400. serialize(parent: any): any;
  34401. }
  34402. }
  34403. declare module BABYLON {
  34404. /**
  34405. * This defines an action responsible to change the value of a property
  34406. * by interpolating between its current value and the newly set one once triggered.
  34407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34408. */
  34409. export class InterpolateValueAction extends Action {
  34410. /**
  34411. * Defines the path of the property where the value should be interpolated
  34412. */
  34413. propertyPath: string;
  34414. /**
  34415. * Defines the target value at the end of the interpolation.
  34416. */
  34417. value: any;
  34418. /**
  34419. * Defines the time it will take for the property to interpolate to the value.
  34420. */
  34421. duration: number;
  34422. /**
  34423. * Defines if the other scene animations should be stopped when the action has been triggered
  34424. */
  34425. stopOtherAnimations?: boolean;
  34426. /**
  34427. * Defines a callback raised once the interpolation animation has been done.
  34428. */
  34429. onInterpolationDone?: () => void;
  34430. /**
  34431. * Observable triggered once the interpolation animation has been done.
  34432. */
  34433. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34434. private _target;
  34435. private _effectiveTarget;
  34436. private _property;
  34437. /**
  34438. * Instantiate the action
  34439. * @param triggerOptions defines the trigger options
  34440. * @param target defines the object containing the value to interpolate
  34441. * @param propertyPath defines the path to the property in the target object
  34442. * @param value defines the target value at the end of the interpolation
  34443. * @param duration deines the time it will take for the property to interpolate to the value.
  34444. * @param condition defines the trigger related conditions
  34445. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34446. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34447. */
  34448. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34449. /** @hidden */ private _prepare(): void;
  34450. /**
  34451. * Execute the action starts the value interpolation.
  34452. */
  34453. execute(): void;
  34454. /**
  34455. * Serializes the actions and its related information.
  34456. * @param parent defines the object to serialize in
  34457. * @returns the serialized object
  34458. */
  34459. serialize(parent: any): any;
  34460. }
  34461. }
  34462. declare module BABYLON {
  34463. /**
  34464. * Options allowed during the creation of a sound track.
  34465. */
  34466. export interface ISoundTrackOptions {
  34467. /**
  34468. * The volume the sound track should take during creation
  34469. */
  34470. volume?: number;
  34471. /**
  34472. * Define if the sound track is the main sound track of the scene
  34473. */
  34474. mainTrack?: boolean;
  34475. }
  34476. /**
  34477. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34478. * It will be also used in a future release to apply effects on a specific track.
  34479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34480. */
  34481. export class SoundTrack {
  34482. /**
  34483. * The unique identifier of the sound track in the scene.
  34484. */
  34485. id: number;
  34486. /**
  34487. * The list of sounds included in the sound track.
  34488. */
  34489. soundCollection: Array<Sound>;
  34490. private _outputAudioNode;
  34491. private _scene;
  34492. private _isMainTrack;
  34493. private _connectedAnalyser;
  34494. private _options;
  34495. private _isInitialized;
  34496. /**
  34497. * Creates a new sound track.
  34498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34499. * @param scene Define the scene the sound track belongs to
  34500. * @param options
  34501. */
  34502. constructor(scene: Scene, options?: ISoundTrackOptions);
  34503. private _initializeSoundTrackAudioGraph;
  34504. /**
  34505. * Release the sound track and its associated resources
  34506. */
  34507. dispose(): void;
  34508. /**
  34509. * Adds a sound to this sound track
  34510. * @param sound define the cound to add
  34511. * @ignoreNaming
  34512. */
  34513. AddSound(sound: Sound): void;
  34514. /**
  34515. * Removes a sound to this sound track
  34516. * @param sound define the cound to remove
  34517. * @ignoreNaming
  34518. */
  34519. RemoveSound(sound: Sound): void;
  34520. /**
  34521. * Set a global volume for the full sound track.
  34522. * @param newVolume Define the new volume of the sound track
  34523. */
  34524. setVolume(newVolume: number): void;
  34525. /**
  34526. * Switch the panning model to HRTF:
  34527. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34529. */
  34530. switchPanningModelToHRTF(): void;
  34531. /**
  34532. * Switch the panning model to Equal Power:
  34533. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34535. */
  34536. switchPanningModelToEqualPower(): void;
  34537. /**
  34538. * Connect the sound track to an audio analyser allowing some amazing
  34539. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34541. * @param analyser The analyser to connect to the engine
  34542. */
  34543. connectToAnalyser(analyser: Analyser): void;
  34544. }
  34545. }
  34546. declare module BABYLON {
  34547. interface AbstractScene {
  34548. /**
  34549. * The list of sounds used in the scene.
  34550. */
  34551. sounds: Nullable<Array<Sound>>;
  34552. }
  34553. interface Scene {
  34554. /**
  34555. * @hidden
  34556. * Backing field
  34557. */ private _mainSoundTrack: SoundTrack;
  34558. /**
  34559. * The main sound track played by the scene.
  34560. * It cotains your primary collection of sounds.
  34561. */
  34562. mainSoundTrack: SoundTrack;
  34563. /**
  34564. * The list of sound tracks added to the scene
  34565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34566. */
  34567. soundTracks: Nullable<Array<SoundTrack>>;
  34568. /**
  34569. * Gets a sound using a given name
  34570. * @param name defines the name to search for
  34571. * @return the found sound or null if not found at all.
  34572. */
  34573. getSoundByName(name: string): Nullable<Sound>;
  34574. /**
  34575. * Gets or sets if audio support is enabled
  34576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34577. */
  34578. audioEnabled: boolean;
  34579. /**
  34580. * Gets or sets if audio will be output to headphones
  34581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34582. */
  34583. headphone: boolean;
  34584. /**
  34585. * Gets or sets custom audio listener position provider
  34586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34587. */
  34588. audioListenerPositionProvider: Nullable<() => Vector3>;
  34589. }
  34590. /**
  34591. * Defines the sound scene component responsible to manage any sounds
  34592. * in a given scene.
  34593. */
  34594. export class AudioSceneComponent implements ISceneSerializableComponent {
  34595. /**
  34596. * The component name helpfull to identify the component in the list of scene components.
  34597. */
  34598. readonly name: string;
  34599. /**
  34600. * The scene the component belongs to.
  34601. */
  34602. scene: Scene;
  34603. private _audioEnabled;
  34604. /**
  34605. * Gets whether audio is enabled or not.
  34606. * Please use related enable/disable method to switch state.
  34607. */
  34608. readonly audioEnabled: boolean;
  34609. private _headphone;
  34610. /**
  34611. * Gets whether audio is outputing to headphone or not.
  34612. * Please use the according Switch methods to change output.
  34613. */
  34614. readonly headphone: boolean;
  34615. private _audioListenerPositionProvider;
  34616. /**
  34617. * Gets the current audio listener position provider
  34618. */
  34619. /**
  34620. * Sets a custom listener position for all sounds in the scene
  34621. * By default, this is the position of the first active camera
  34622. */
  34623. audioListenerPositionProvider: Nullable<() => Vector3>;
  34624. /**
  34625. * Creates a new instance of the component for the given scene
  34626. * @param scene Defines the scene to register the component in
  34627. */
  34628. constructor(scene: Scene);
  34629. /**
  34630. * Registers the component in a given scene
  34631. */
  34632. register(): void;
  34633. /**
  34634. * Rebuilds the elements related to this component in case of
  34635. * context lost for instance.
  34636. */
  34637. rebuild(): void;
  34638. /**
  34639. * Serializes the component data to the specified json object
  34640. * @param serializationObject The object to serialize to
  34641. */
  34642. serialize(serializationObject: any): void;
  34643. /**
  34644. * Adds all the elements from the container to the scene
  34645. * @param container the container holding the elements
  34646. */
  34647. addFromContainer(container: AbstractScene): void;
  34648. /**
  34649. * Removes all the elements in the container from the scene
  34650. * @param container contains the elements to remove
  34651. * @param dispose if the removed element should be disposed (default: false)
  34652. */
  34653. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34654. /**
  34655. * Disposes the component and the associated ressources.
  34656. */
  34657. dispose(): void;
  34658. /**
  34659. * Disables audio in the associated scene.
  34660. */
  34661. disableAudio(): void;
  34662. /**
  34663. * Enables audio in the associated scene.
  34664. */
  34665. enableAudio(): void;
  34666. /**
  34667. * Switch audio to headphone output.
  34668. */
  34669. switchAudioModeForHeadphones(): void;
  34670. /**
  34671. * Switch audio to normal speakers.
  34672. */
  34673. switchAudioModeForNormalSpeakers(): void;
  34674. private _afterRender;
  34675. }
  34676. }
  34677. declare module BABYLON {
  34678. /**
  34679. * Wraps one or more Sound objects and selects one with random weight for playback.
  34680. */
  34681. export class WeightedSound {
  34682. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34683. loop: boolean;
  34684. private _coneInnerAngle;
  34685. private _coneOuterAngle;
  34686. private _volume;
  34687. /** A Sound is currently playing. */
  34688. isPlaying: boolean;
  34689. /** A Sound is currently paused. */
  34690. isPaused: boolean;
  34691. private _sounds;
  34692. private _weights;
  34693. private _currentIndex?;
  34694. /**
  34695. * Creates a new WeightedSound from the list of sounds given.
  34696. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34697. * @param sounds Array of Sounds that will be selected from.
  34698. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34699. */
  34700. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34701. /**
  34702. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34703. */
  34704. /**
  34705. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34706. */
  34707. directionalConeInnerAngle: number;
  34708. /**
  34709. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34710. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34711. */
  34712. /**
  34713. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34714. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34715. */
  34716. directionalConeOuterAngle: number;
  34717. /**
  34718. * Playback volume.
  34719. */
  34720. /**
  34721. * Playback volume.
  34722. */
  34723. volume: number;
  34724. private _onended;
  34725. /**
  34726. * Suspend playback
  34727. */
  34728. pause(): void;
  34729. /**
  34730. * Stop playback
  34731. */
  34732. stop(): void;
  34733. /**
  34734. * Start playback.
  34735. * @param startOffset Position the clip head at a specific time in seconds.
  34736. */
  34737. play(startOffset?: number): void;
  34738. }
  34739. }
  34740. declare module BABYLON {
  34741. /**
  34742. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34744. */
  34745. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34746. /**
  34747. * Gets the name of the behavior.
  34748. */
  34749. readonly name: string;
  34750. /**
  34751. * The easing function used by animations
  34752. */
  34753. static EasingFunction: BackEase;
  34754. /**
  34755. * The easing mode used by animations
  34756. */
  34757. static EasingMode: number;
  34758. /**
  34759. * The duration of the animation, in milliseconds
  34760. */
  34761. transitionDuration: number;
  34762. /**
  34763. * Length of the distance animated by the transition when lower radius is reached
  34764. */
  34765. lowerRadiusTransitionRange: number;
  34766. /**
  34767. * Length of the distance animated by the transition when upper radius is reached
  34768. */
  34769. upperRadiusTransitionRange: number;
  34770. private _autoTransitionRange;
  34771. /**
  34772. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34773. */
  34774. /**
  34775. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34776. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34777. */
  34778. autoTransitionRange: boolean;
  34779. private _attachedCamera;
  34780. private _onAfterCheckInputsObserver;
  34781. private _onMeshTargetChangedObserver;
  34782. /**
  34783. * Initializes the behavior.
  34784. */
  34785. init(): void;
  34786. /**
  34787. * Attaches the behavior to its arc rotate camera.
  34788. * @param camera Defines the camera to attach the behavior to
  34789. */
  34790. attach(camera: ArcRotateCamera): void;
  34791. /**
  34792. * Detaches the behavior from its current arc rotate camera.
  34793. */
  34794. detach(): void;
  34795. private _radiusIsAnimating;
  34796. private _radiusBounceTransition;
  34797. private _animatables;
  34798. private _cachedWheelPrecision;
  34799. /**
  34800. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34801. * @param radiusLimit The limit to check against.
  34802. * @return Bool to indicate if at limit.
  34803. */
  34804. private _isRadiusAtLimit;
  34805. /**
  34806. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34807. * @param radiusDelta The delta by which to animate to. Can be negative.
  34808. */
  34809. private _applyBoundRadiusAnimation;
  34810. /**
  34811. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34812. */
  34813. protected _clearAnimationLocks(): void;
  34814. /**
  34815. * Stops and removes all animations that have been applied to the camera
  34816. */
  34817. stopAllAnimations(): void;
  34818. }
  34819. }
  34820. declare module BABYLON {
  34821. /**
  34822. * 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.
  34823. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34824. */
  34825. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34826. /**
  34827. * Gets the name of the behavior.
  34828. */
  34829. readonly name: string;
  34830. private _mode;
  34831. private _radiusScale;
  34832. private _positionScale;
  34833. private _defaultElevation;
  34834. private _elevationReturnTime;
  34835. private _elevationReturnWaitTime;
  34836. private _zoomStopsAnimation;
  34837. private _framingTime;
  34838. /**
  34839. * The easing function used by animations
  34840. */
  34841. static EasingFunction: ExponentialEase;
  34842. /**
  34843. * The easing mode used by animations
  34844. */
  34845. static EasingMode: number;
  34846. /**
  34847. * Sets the current mode used by the behavior
  34848. */
  34849. /**
  34850. * Gets current mode used by the behavior.
  34851. */
  34852. mode: number;
  34853. /**
  34854. * Sets the scale applied to the radius (1 by default)
  34855. */
  34856. /**
  34857. * Gets the scale applied to the radius
  34858. */
  34859. radiusScale: number;
  34860. /**
  34861. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34862. */
  34863. /**
  34864. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34865. */
  34866. positionScale: number;
  34867. /**
  34868. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34869. * behaviour is triggered, in radians.
  34870. */
  34871. /**
  34872. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34873. * behaviour is triggered, in radians.
  34874. */
  34875. defaultElevation: number;
  34876. /**
  34877. * Sets the time (in milliseconds) taken to return to the default beta position.
  34878. * Negative value indicates camera should not return to default.
  34879. */
  34880. /**
  34881. * Gets the time (in milliseconds) taken to return to the default beta position.
  34882. * Negative value indicates camera should not return to default.
  34883. */
  34884. elevationReturnTime: number;
  34885. /**
  34886. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34887. */
  34888. /**
  34889. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34890. */
  34891. elevationReturnWaitTime: number;
  34892. /**
  34893. * Sets the flag that indicates if user zooming should stop animation.
  34894. */
  34895. /**
  34896. * Gets the flag that indicates if user zooming should stop animation.
  34897. */
  34898. zoomStopsAnimation: boolean;
  34899. /**
  34900. * Sets the transition time when framing the mesh, in milliseconds
  34901. */
  34902. /**
  34903. * Gets the transition time when framing the mesh, in milliseconds
  34904. */
  34905. framingTime: number;
  34906. /**
  34907. * Define if the behavior should automatically change the configured
  34908. * camera limits and sensibilities.
  34909. */
  34910. autoCorrectCameraLimitsAndSensibility: boolean;
  34911. private _onPrePointerObservableObserver;
  34912. private _onAfterCheckInputsObserver;
  34913. private _onMeshTargetChangedObserver;
  34914. private _attachedCamera;
  34915. private _isPointerDown;
  34916. private _lastInteractionTime;
  34917. /**
  34918. * Initializes the behavior.
  34919. */
  34920. init(): void;
  34921. /**
  34922. * Attaches the behavior to its arc rotate camera.
  34923. * @param camera Defines the camera to attach the behavior to
  34924. */
  34925. attach(camera: ArcRotateCamera): void;
  34926. /**
  34927. * Detaches the behavior from its current arc rotate camera.
  34928. */
  34929. detach(): void;
  34930. private _animatables;
  34931. private _betaIsAnimating;
  34932. private _betaTransition;
  34933. private _radiusTransition;
  34934. private _vectorTransition;
  34935. /**
  34936. * Targets the given mesh and updates zoom level accordingly.
  34937. * @param mesh The mesh to target.
  34938. * @param radius Optional. If a cached radius position already exists, overrides default.
  34939. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34940. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34941. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34942. */
  34943. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34944. /**
  34945. * Targets the given mesh with its children and updates zoom level accordingly.
  34946. * @param mesh The mesh to target.
  34947. * @param radius Optional. If a cached radius position already exists, overrides default.
  34948. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34949. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34950. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34951. */
  34952. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34953. /**
  34954. * Targets the given meshes with their children and updates zoom level accordingly.
  34955. * @param meshes The mesh to target.
  34956. * @param radius Optional. If a cached radius position already exists, overrides default.
  34957. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34958. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34959. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34960. */
  34961. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34962. /**
  34963. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34964. * @param minimumWorld Determines the smaller position of the bounding box extend
  34965. * @param maximumWorld Determines the bigger position of the bounding box extend
  34966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34968. */
  34969. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34970. /**
  34971. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34972. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34973. * frustum width.
  34974. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34975. * to fully enclose the mesh in the viewing frustum.
  34976. */
  34977. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34978. /**
  34979. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34980. * is automatically returned to its default position (expected to be above ground plane).
  34981. */
  34982. private _maintainCameraAboveGround;
  34983. /**
  34984. * Returns the frustum slope based on the canvas ratio and camera FOV
  34985. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34986. */
  34987. private _getFrustumSlope;
  34988. /**
  34989. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34990. */
  34991. private _clearAnimationLocks;
  34992. /**
  34993. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34994. */
  34995. private _applyUserInteraction;
  34996. /**
  34997. * Stops and removes all animations that have been applied to the camera
  34998. */
  34999. stopAllAnimations(): void;
  35000. /**
  35001. * Gets a value indicating if the user is moving the camera
  35002. */
  35003. readonly isUserIsMoving: boolean;
  35004. /**
  35005. * The camera can move all the way towards the mesh.
  35006. */
  35007. static IgnoreBoundsSizeMode: number;
  35008. /**
  35009. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35010. */
  35011. static FitFrustumSidesMode: number;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. /**
  35016. * Base class for Camera Pointer Inputs.
  35017. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35018. * for example usage.
  35019. */
  35020. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35021. /**
  35022. * Defines the camera the input is attached to.
  35023. */
  35024. abstract camera: Camera;
  35025. /**
  35026. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35027. */
  35028. protected _altKey: boolean;
  35029. protected _ctrlKey: boolean;
  35030. protected _metaKey: boolean;
  35031. protected _shiftKey: boolean;
  35032. /**
  35033. * Which mouse buttons were pressed at time of last mouse event.
  35034. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35035. */
  35036. protected _buttonsPressed: number;
  35037. /**
  35038. * Defines the buttons associated with the input to handle camera move.
  35039. */
  35040. buttons: number[];
  35041. /**
  35042. * Attach the input controls to a specific dom element to get the input from.
  35043. * @param element Defines the element the controls should be listened from
  35044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35045. */
  35046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35047. /**
  35048. * Detach the current controls from the specified dom element.
  35049. * @param element Defines the element to stop listening the inputs from
  35050. */
  35051. detachControl(element: Nullable<HTMLElement>): void;
  35052. /**
  35053. * Gets the class name of the current input.
  35054. * @returns the class name
  35055. */
  35056. getClassName(): string;
  35057. /**
  35058. * Get the friendly name associated with the input class.
  35059. * @returns the input friendly name
  35060. */
  35061. getSimpleName(): string;
  35062. /**
  35063. * Called on pointer POINTERDOUBLETAP event.
  35064. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35065. */
  35066. protected onDoubleTap(type: string): void;
  35067. /**
  35068. * Called on pointer POINTERMOVE event if only a single touch is active.
  35069. * Override this method to provide functionality.
  35070. */
  35071. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35072. /**
  35073. * Called on pointer POINTERMOVE event if multiple touches are active.
  35074. * Override this method to provide functionality.
  35075. */
  35076. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35077. /**
  35078. * Called on JS contextmenu event.
  35079. * Override this method to provide functionality.
  35080. */
  35081. protected onContextMenu(evt: PointerEvent): void;
  35082. /**
  35083. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35084. * press.
  35085. * Override this method to provide functionality.
  35086. */
  35087. protected onButtonDown(evt: PointerEvent): void;
  35088. /**
  35089. * Called each time a new POINTERUP event occurs. Ie, for each button
  35090. * release.
  35091. * Override this method to provide functionality.
  35092. */
  35093. protected onButtonUp(evt: PointerEvent): void;
  35094. /**
  35095. * Called when window becomes inactive.
  35096. * Override this method to provide functionality.
  35097. */
  35098. protected onLostFocus(): void;
  35099. private _pointerInput;
  35100. private _observer;
  35101. private _onLostFocus;
  35102. private pointA;
  35103. private pointB;
  35104. }
  35105. }
  35106. declare module BABYLON {
  35107. /**
  35108. * Manage the pointers inputs to control an arc rotate camera.
  35109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35110. */
  35111. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35112. /**
  35113. * Defines the camera the input is attached to.
  35114. */
  35115. camera: ArcRotateCamera;
  35116. /**
  35117. * Gets the class name of the current input.
  35118. * @returns the class name
  35119. */
  35120. getClassName(): string;
  35121. /**
  35122. * Defines the buttons associated with the input to handle camera move.
  35123. */
  35124. buttons: number[];
  35125. /**
  35126. * Defines the pointer angular sensibility along the X axis or how fast is
  35127. * the camera rotating.
  35128. */
  35129. angularSensibilityX: number;
  35130. /**
  35131. * Defines the pointer angular sensibility along the Y axis or how fast is
  35132. * the camera rotating.
  35133. */
  35134. angularSensibilityY: number;
  35135. /**
  35136. * Defines the pointer pinch precision or how fast is the camera zooming.
  35137. */
  35138. pinchPrecision: number;
  35139. /**
  35140. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35141. * from 0.
  35142. * It defines the percentage of current camera.radius to use as delta when
  35143. * pinch zoom is used.
  35144. */
  35145. pinchDeltaPercentage: number;
  35146. /**
  35147. * Defines the pointer panning sensibility or how fast is the camera moving.
  35148. */
  35149. panningSensibility: number;
  35150. /**
  35151. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35152. */
  35153. multiTouchPanning: boolean;
  35154. /**
  35155. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35156. * zoom (pinch) through multitouch.
  35157. */
  35158. multiTouchPanAndZoom: boolean;
  35159. /**
  35160. * Revers pinch action direction.
  35161. */
  35162. pinchInwards: boolean;
  35163. private _isPanClick;
  35164. private _twoFingerActivityCount;
  35165. private _isPinching;
  35166. /**
  35167. * Called on pointer POINTERMOVE event if only a single touch is active.
  35168. */
  35169. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35170. /**
  35171. * Called on pointer POINTERDOUBLETAP event.
  35172. */
  35173. protected onDoubleTap(type: string): void;
  35174. /**
  35175. * Called on pointer POINTERMOVE event if multiple touches are active.
  35176. */
  35177. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35178. /**
  35179. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35180. * press.
  35181. */
  35182. protected onButtonDown(evt: PointerEvent): void;
  35183. /**
  35184. * Called each time a new POINTERUP event occurs. Ie, for each button
  35185. * release.
  35186. */
  35187. protected onButtonUp(evt: PointerEvent): void;
  35188. /**
  35189. * Called when window becomes inactive.
  35190. */
  35191. protected onLostFocus(): void;
  35192. }
  35193. }
  35194. declare module BABYLON {
  35195. /**
  35196. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35198. */
  35199. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35200. /**
  35201. * Defines the camera the input is attached to.
  35202. */
  35203. camera: ArcRotateCamera;
  35204. /**
  35205. * Defines the list of key codes associated with the up action (increase alpha)
  35206. */
  35207. keysUp: number[];
  35208. /**
  35209. * Defines the list of key codes associated with the down action (decrease alpha)
  35210. */
  35211. keysDown: number[];
  35212. /**
  35213. * Defines the list of key codes associated with the left action (increase beta)
  35214. */
  35215. keysLeft: number[];
  35216. /**
  35217. * Defines the list of key codes associated with the right action (decrease beta)
  35218. */
  35219. keysRight: number[];
  35220. /**
  35221. * Defines the list of key codes associated with the reset action.
  35222. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35223. */
  35224. keysReset: number[];
  35225. /**
  35226. * Defines the panning sensibility of the inputs.
  35227. * (How fast is the camera paning)
  35228. */
  35229. panningSensibility: number;
  35230. /**
  35231. * Defines the zooming sensibility of the inputs.
  35232. * (How fast is the camera zooming)
  35233. */
  35234. zoomingSensibility: number;
  35235. /**
  35236. * Defines wether maintaining the alt key down switch the movement mode from
  35237. * orientation to zoom.
  35238. */
  35239. useAltToZoom: boolean;
  35240. /**
  35241. * Rotation speed of the camera
  35242. */
  35243. angularSpeed: number;
  35244. private _keys;
  35245. private _ctrlPressed;
  35246. private _altPressed;
  35247. private _onCanvasBlurObserver;
  35248. private _onKeyboardObserver;
  35249. private _engine;
  35250. private _scene;
  35251. /**
  35252. * Attach the input controls to a specific dom element to get the input from.
  35253. * @param element Defines the element the controls should be listened from
  35254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35255. */
  35256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35257. /**
  35258. * Detach the current controls from the specified dom element.
  35259. * @param element Defines the element to stop listening the inputs from
  35260. */
  35261. detachControl(element: Nullable<HTMLElement>): void;
  35262. /**
  35263. * Update the current camera state depending on the inputs that have been used this frame.
  35264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35265. */
  35266. checkInputs(): void;
  35267. /**
  35268. * Gets the class name of the current intput.
  35269. * @returns the class name
  35270. */
  35271. getClassName(): string;
  35272. /**
  35273. * Get the friendly name associated with the input class.
  35274. * @returns the input friendly name
  35275. */
  35276. getSimpleName(): string;
  35277. }
  35278. }
  35279. declare module BABYLON {
  35280. /**
  35281. * Manage the mouse wheel inputs to control an arc rotate camera.
  35282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35283. */
  35284. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35285. /**
  35286. * Defines the camera the input is attached to.
  35287. */
  35288. camera: ArcRotateCamera;
  35289. /**
  35290. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35291. */
  35292. wheelPrecision: number;
  35293. /**
  35294. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35295. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35296. */
  35297. wheelDeltaPercentage: number;
  35298. private _wheel;
  35299. private _observer;
  35300. private computeDeltaFromMouseWheelLegacyEvent;
  35301. /**
  35302. * Attach the input controls to a specific dom element to get the input from.
  35303. * @param element Defines the element the controls should be listened from
  35304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35305. */
  35306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35307. /**
  35308. * Detach the current controls from the specified dom element.
  35309. * @param element Defines the element to stop listening the inputs from
  35310. */
  35311. detachControl(element: Nullable<HTMLElement>): void;
  35312. /**
  35313. * Gets the class name of the current intput.
  35314. * @returns the class name
  35315. */
  35316. getClassName(): string;
  35317. /**
  35318. * Get the friendly name associated with the input class.
  35319. * @returns the input friendly name
  35320. */
  35321. getSimpleName(): string;
  35322. }
  35323. }
  35324. declare module BABYLON {
  35325. /**
  35326. * Default Inputs manager for the ArcRotateCamera.
  35327. * It groups all the default supported inputs for ease of use.
  35328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35329. */
  35330. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35331. /**
  35332. * Instantiates a new ArcRotateCameraInputsManager.
  35333. * @param camera Defines the camera the inputs belong to
  35334. */
  35335. constructor(camera: ArcRotateCamera);
  35336. /**
  35337. * Add mouse wheel input support to the input manager.
  35338. * @returns the current input manager
  35339. */
  35340. addMouseWheel(): ArcRotateCameraInputsManager;
  35341. /**
  35342. * Add pointers input support to the input manager.
  35343. * @returns the current input manager
  35344. */
  35345. addPointers(): ArcRotateCameraInputsManager;
  35346. /**
  35347. * Add keyboard input support to the input manager.
  35348. * @returns the current input manager
  35349. */
  35350. addKeyboard(): ArcRotateCameraInputsManager;
  35351. }
  35352. }
  35353. declare module BABYLON {
  35354. /**
  35355. * This represents an orbital type of camera.
  35356. *
  35357. * 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.
  35358. * 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.
  35359. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35360. */
  35361. export class ArcRotateCamera extends TargetCamera {
  35362. /**
  35363. * Defines the rotation angle of the camera along the longitudinal axis.
  35364. */
  35365. alpha: number;
  35366. /**
  35367. * Defines the rotation angle of the camera along the latitudinal axis.
  35368. */
  35369. beta: number;
  35370. /**
  35371. * Defines the radius of the camera from it s target point.
  35372. */
  35373. radius: number;
  35374. protected _target: Vector3;
  35375. protected _targetHost: Nullable<AbstractMesh>;
  35376. /**
  35377. * Defines the target point of the camera.
  35378. * The camera looks towards it form the radius distance.
  35379. */
  35380. target: Vector3;
  35381. /**
  35382. * Define the current local position of the camera in the scene
  35383. */
  35384. position: Vector3;
  35385. protected _upVector: Vector3;
  35386. protected _upToYMatrix: Matrix;
  35387. protected _YToUpMatrix: Matrix;
  35388. /**
  35389. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35390. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35391. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35392. */
  35393. upVector: Vector3;
  35394. /**
  35395. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35396. */
  35397. setMatUp(): void;
  35398. /**
  35399. * Current inertia value on the longitudinal axis.
  35400. * The bigger this number the longer it will take for the camera to stop.
  35401. */
  35402. inertialAlphaOffset: number;
  35403. /**
  35404. * Current inertia value on the latitudinal axis.
  35405. * The bigger this number the longer it will take for the camera to stop.
  35406. */
  35407. inertialBetaOffset: number;
  35408. /**
  35409. * Current inertia value on the radius axis.
  35410. * The bigger this number the longer it will take for the camera to stop.
  35411. */
  35412. inertialRadiusOffset: number;
  35413. /**
  35414. * Minimum allowed angle on the longitudinal axis.
  35415. * This can help limiting how the Camera is able to move in the scene.
  35416. */
  35417. lowerAlphaLimit: Nullable<number>;
  35418. /**
  35419. * Maximum allowed angle on the longitudinal axis.
  35420. * This can help limiting how the Camera is able to move in the scene.
  35421. */
  35422. upperAlphaLimit: Nullable<number>;
  35423. /**
  35424. * Minimum allowed angle on the latitudinal axis.
  35425. * This can help limiting how the Camera is able to move in the scene.
  35426. */
  35427. lowerBetaLimit: number;
  35428. /**
  35429. * Maximum allowed angle on the latitudinal axis.
  35430. * This can help limiting how the Camera is able to move in the scene.
  35431. */
  35432. upperBetaLimit: number;
  35433. /**
  35434. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35435. * This can help limiting how the Camera is able to move in the scene.
  35436. */
  35437. lowerRadiusLimit: Nullable<number>;
  35438. /**
  35439. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35440. * This can help limiting how the Camera is able to move in the scene.
  35441. */
  35442. upperRadiusLimit: Nullable<number>;
  35443. /**
  35444. * Defines the current inertia value used during panning of the camera along the X axis.
  35445. */
  35446. inertialPanningX: number;
  35447. /**
  35448. * Defines the current inertia value used during panning of the camera along the Y axis.
  35449. */
  35450. inertialPanningY: number;
  35451. /**
  35452. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35453. * Basically if your fingers moves away from more than this distance you will be considered
  35454. * in pinch mode.
  35455. */
  35456. pinchToPanMaxDistance: number;
  35457. /**
  35458. * Defines the maximum distance the camera can pan.
  35459. * This could help keeping the cammera always in your scene.
  35460. */
  35461. panningDistanceLimit: Nullable<number>;
  35462. /**
  35463. * Defines the target of the camera before paning.
  35464. */
  35465. panningOriginTarget: Vector3;
  35466. /**
  35467. * Defines the value of the inertia used during panning.
  35468. * 0 would mean stop inertia and one would mean no decelleration at all.
  35469. */
  35470. panningInertia: number;
  35471. /**
  35472. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35473. */
  35474. angularSensibilityX: number;
  35475. /**
  35476. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35477. */
  35478. angularSensibilityY: number;
  35479. /**
  35480. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35481. */
  35482. pinchPrecision: number;
  35483. /**
  35484. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35485. * It will be used instead of pinchDeltaPrecision if different from 0.
  35486. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35487. */
  35488. pinchDeltaPercentage: number;
  35489. /**
  35490. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35491. */
  35492. panningSensibility: number;
  35493. /**
  35494. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35495. */
  35496. keysUp: number[];
  35497. /**
  35498. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35499. */
  35500. keysDown: number[];
  35501. /**
  35502. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35503. */
  35504. keysLeft: number[];
  35505. /**
  35506. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35507. */
  35508. keysRight: number[];
  35509. /**
  35510. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35511. */
  35512. wheelPrecision: number;
  35513. /**
  35514. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35515. * It will be used instead of pinchDeltaPrecision if different from 0.
  35516. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35517. */
  35518. wheelDeltaPercentage: number;
  35519. /**
  35520. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35521. */
  35522. zoomOnFactor: number;
  35523. /**
  35524. * Defines a screen offset for the camera position.
  35525. */
  35526. targetScreenOffset: Vector2;
  35527. /**
  35528. * Allows the camera to be completely reversed.
  35529. * If false the camera can not arrive upside down.
  35530. */
  35531. allowUpsideDown: boolean;
  35532. /**
  35533. * Define if double tap/click is used to restore the previously saved state of the camera.
  35534. */
  35535. useInputToRestoreState: boolean;
  35536. /** @hidden */ private _viewMatrix: Matrix;
  35537. /** @hidden */ private _useCtrlForPanning: boolean;
  35538. /** @hidden */ private _panningMouseButton: number;
  35539. /**
  35540. * Defines the input associated to the camera.
  35541. */
  35542. inputs: ArcRotateCameraInputsManager;
  35543. /** @hidden */ private _reset: () => void;
  35544. /**
  35545. * Defines the allowed panning axis.
  35546. */
  35547. panningAxis: Vector3;
  35548. protected _localDirection: Vector3;
  35549. protected _transformedDirection: Vector3;
  35550. private _bouncingBehavior;
  35551. /**
  35552. * Gets the bouncing behavior of the camera if it has been enabled.
  35553. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35554. */
  35555. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35556. /**
  35557. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35559. */
  35560. useBouncingBehavior: boolean;
  35561. private _framingBehavior;
  35562. /**
  35563. * Gets the framing behavior of the camera if it has been enabled.
  35564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35565. */
  35566. readonly framingBehavior: Nullable<FramingBehavior>;
  35567. /**
  35568. * Defines if the framing behavior of the camera is enabled on the camera.
  35569. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35570. */
  35571. useFramingBehavior: boolean;
  35572. private _autoRotationBehavior;
  35573. /**
  35574. * Gets the auto rotation behavior of the camera if it has been enabled.
  35575. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35576. */
  35577. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35578. /**
  35579. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35580. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35581. */
  35582. useAutoRotationBehavior: boolean;
  35583. /**
  35584. * Observable triggered when the mesh target has been changed on the camera.
  35585. */
  35586. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35587. /**
  35588. * Event raised when the camera is colliding with a mesh.
  35589. */
  35590. onCollide: (collidedMesh: AbstractMesh) => void;
  35591. /**
  35592. * Defines whether the camera should check collision with the objects oh the scene.
  35593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35594. */
  35595. checkCollisions: boolean;
  35596. /**
  35597. * Defines the collision radius of the camera.
  35598. * This simulates a sphere around the camera.
  35599. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35600. */
  35601. collisionRadius: Vector3;
  35602. protected _collider: Collider;
  35603. protected _previousPosition: Vector3;
  35604. protected _collisionVelocity: Vector3;
  35605. protected _newPosition: Vector3;
  35606. protected _previousAlpha: number;
  35607. protected _previousBeta: number;
  35608. protected _previousRadius: number;
  35609. protected _collisionTriggered: boolean;
  35610. protected _targetBoundingCenter: Nullable<Vector3>;
  35611. private _computationVector;
  35612. /**
  35613. * Instantiates a new ArcRotateCamera in a given scene
  35614. * @param name Defines the name of the camera
  35615. * @param alpha Defines the camera rotation along the logitudinal axis
  35616. * @param beta Defines the camera rotation along the latitudinal axis
  35617. * @param radius Defines the camera distance from its target
  35618. * @param target Defines the camera target
  35619. * @param scene Defines the scene the camera belongs to
  35620. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35621. */
  35622. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35623. /** @hidden */ private _initCache(): void;
  35624. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35625. protected _getTargetPosition(): Vector3;
  35626. private _storedAlpha;
  35627. private _storedBeta;
  35628. private _storedRadius;
  35629. private _storedTarget;
  35630. private _storedTargetScreenOffset;
  35631. /**
  35632. * Stores the current state of the camera (alpha, beta, radius and target)
  35633. * @returns the camera itself
  35634. */
  35635. storeState(): Camera;
  35636. /**
  35637. * @hidden
  35638. * Restored camera state. You must call storeState() first
  35639. */ private _restoreStateValues(): boolean;
  35640. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35641. /**
  35642. * Attached controls to the current camera.
  35643. * @param element Defines the element the controls should be listened from
  35644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35645. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35646. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35647. */
  35648. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35649. /**
  35650. * Detach the current controls from the camera.
  35651. * The camera will stop reacting to inputs.
  35652. * @param element Defines the element to stop listening the inputs from
  35653. */
  35654. detachControl(element: HTMLElement): void;
  35655. /** @hidden */ private _checkInputs(): void;
  35656. protected _checkLimits(): void;
  35657. /**
  35658. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35659. */
  35660. rebuildAnglesAndRadius(): void;
  35661. /**
  35662. * Use a position to define the current camera related information like aplha, beta and radius
  35663. * @param position Defines the position to set the camera at
  35664. */
  35665. setPosition(position: Vector3): void;
  35666. /**
  35667. * Defines the target the camera should look at.
  35668. * This will automatically adapt alpha beta and radius to fit within the new target.
  35669. * @param target Defines the new target as a Vector or a mesh
  35670. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35671. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35672. */
  35673. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35674. /** @hidden */ private _getViewMatrix(): Matrix;
  35675. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35676. /**
  35677. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35678. * @param meshes Defines the mesh to zoom on
  35679. * @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)
  35680. */
  35681. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35682. /**
  35683. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35684. * The target will be changed but the radius
  35685. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35686. * @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)
  35687. */
  35688. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35689. min: Vector3;
  35690. max: Vector3;
  35691. distance: number;
  35692. }, doNotUpdateMaxZ?: boolean): void;
  35693. /**
  35694. * @override
  35695. * Override Camera.createRigCamera
  35696. */
  35697. createRigCamera(name: string, cameraIndex: number): Camera;
  35698. /**
  35699. * @hidden
  35700. * @override
  35701. * Override Camera._updateRigCameras
  35702. */ private _updateRigCameras(): void;
  35703. /**
  35704. * Destroy the camera and release the current resources hold by it.
  35705. */
  35706. dispose(): void;
  35707. /**
  35708. * Gets the current object class name.
  35709. * @return the class name
  35710. */
  35711. getClassName(): string;
  35712. }
  35713. }
  35714. declare module BABYLON {
  35715. /**
  35716. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35717. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35718. */
  35719. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35720. /**
  35721. * Gets the name of the behavior.
  35722. */
  35723. readonly name: string;
  35724. private _zoomStopsAnimation;
  35725. private _idleRotationSpeed;
  35726. private _idleRotationWaitTime;
  35727. private _idleRotationSpinupTime;
  35728. /**
  35729. * Sets the flag that indicates if user zooming should stop animation.
  35730. */
  35731. /**
  35732. * Gets the flag that indicates if user zooming should stop animation.
  35733. */
  35734. zoomStopsAnimation: boolean;
  35735. /**
  35736. * Sets the default speed at which the camera rotates around the model.
  35737. */
  35738. /**
  35739. * Gets the default speed at which the camera rotates around the model.
  35740. */
  35741. idleRotationSpeed: number;
  35742. /**
  35743. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35744. */
  35745. /**
  35746. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35747. */
  35748. idleRotationWaitTime: number;
  35749. /**
  35750. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35751. */
  35752. /**
  35753. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35754. */
  35755. idleRotationSpinupTime: number;
  35756. /**
  35757. * Gets a value indicating if the camera is currently rotating because of this behavior
  35758. */
  35759. readonly rotationInProgress: boolean;
  35760. private _onPrePointerObservableObserver;
  35761. private _onAfterCheckInputsObserver;
  35762. private _attachedCamera;
  35763. private _isPointerDown;
  35764. private _lastFrameTime;
  35765. private _lastInteractionTime;
  35766. private _cameraRotationSpeed;
  35767. /**
  35768. * Initializes the behavior.
  35769. */
  35770. init(): void;
  35771. /**
  35772. * Attaches the behavior to its arc rotate camera.
  35773. * @param camera Defines the camera to attach the behavior to
  35774. */
  35775. attach(camera: ArcRotateCamera): void;
  35776. /**
  35777. * Detaches the behavior from its current arc rotate camera.
  35778. */
  35779. detach(): void;
  35780. /**
  35781. * Returns true if user is scrolling.
  35782. * @return true if user is scrolling.
  35783. */
  35784. private _userIsZooming;
  35785. private _lastFrameRadius;
  35786. private _shouldAnimationStopForInteraction;
  35787. /**
  35788. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35789. */
  35790. private _applyUserInteraction;
  35791. private _userIsMoving;
  35792. }
  35793. }
  35794. declare module BABYLON {
  35795. /**
  35796. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35797. */
  35798. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35799. private ui;
  35800. /**
  35801. * The name of the behavior
  35802. */
  35803. name: string;
  35804. /**
  35805. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35806. */
  35807. distanceAwayFromFace: number;
  35808. /**
  35809. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35810. */
  35811. distanceAwayFromBottomOfFace: number;
  35812. private _faceVectors;
  35813. private _target;
  35814. private _scene;
  35815. private _onRenderObserver;
  35816. private _tmpMatrix;
  35817. private _tmpVector;
  35818. /**
  35819. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35820. * @param ui The transform node that should be attched to the mesh
  35821. */
  35822. constructor(ui: TransformNode);
  35823. /**
  35824. * Initializes the behavior
  35825. */
  35826. init(): void;
  35827. private _closestFace;
  35828. private _zeroVector;
  35829. private _lookAtTmpMatrix;
  35830. private _lookAtToRef;
  35831. /**
  35832. * Attaches the AttachToBoxBehavior to the passed in mesh
  35833. * @param target The mesh that the specified node will be attached to
  35834. */
  35835. attach(target: Mesh): void;
  35836. /**
  35837. * Detaches the behavior from the mesh
  35838. */
  35839. detach(): void;
  35840. }
  35841. }
  35842. declare module BABYLON {
  35843. /**
  35844. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35845. */
  35846. export class FadeInOutBehavior implements Behavior<Mesh> {
  35847. /**
  35848. * Time in milliseconds to delay before fading in (Default: 0)
  35849. */
  35850. delay: number;
  35851. /**
  35852. * Time in milliseconds for the mesh to fade in (Default: 300)
  35853. */
  35854. fadeInTime: number;
  35855. private _millisecondsPerFrame;
  35856. private _hovered;
  35857. private _hoverValue;
  35858. private _ownerNode;
  35859. /**
  35860. * Instatiates the FadeInOutBehavior
  35861. */
  35862. constructor();
  35863. /**
  35864. * The name of the behavior
  35865. */
  35866. readonly name: string;
  35867. /**
  35868. * Initializes the behavior
  35869. */
  35870. init(): void;
  35871. /**
  35872. * Attaches the fade behavior on the passed in mesh
  35873. * @param ownerNode The mesh that will be faded in/out once attached
  35874. */
  35875. attach(ownerNode: Mesh): void;
  35876. /**
  35877. * Detaches the behavior from the mesh
  35878. */
  35879. detach(): void;
  35880. /**
  35881. * Triggers the mesh to begin fading in or out
  35882. * @param value if the object should fade in or out (true to fade in)
  35883. */
  35884. fadeIn(value: boolean): void;
  35885. private _update;
  35886. private _setAllVisibility;
  35887. }
  35888. }
  35889. declare module BABYLON {
  35890. /**
  35891. * Class containing a set of static utilities functions for managing Pivots
  35892. * @hidden
  35893. */
  35894. export class PivotTools {
  35895. private static _PivotCached;
  35896. private static _OldPivotPoint;
  35897. private static _PivotTranslation;
  35898. private static _PivotTmpVector;
  35899. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35900. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35901. }
  35902. }
  35903. declare module BABYLON {
  35904. /**
  35905. * Class containing static functions to help procedurally build meshes
  35906. */
  35907. export class PlaneBuilder {
  35908. /**
  35909. * Creates a plane mesh
  35910. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35911. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35912. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35914. * * 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
  35915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35916. * @param name defines the name of the mesh
  35917. * @param options defines the options used to create the mesh
  35918. * @param scene defines the hosting scene
  35919. * @returns the plane mesh
  35920. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35921. */
  35922. static CreatePlane(name: string, options: {
  35923. size?: number;
  35924. width?: number;
  35925. height?: number;
  35926. sideOrientation?: number;
  35927. frontUVs?: Vector4;
  35928. backUVs?: Vector4;
  35929. updatable?: boolean;
  35930. sourcePlane?: Plane;
  35931. }, scene?: Nullable<Scene>): Mesh;
  35932. }
  35933. }
  35934. declare module BABYLON {
  35935. /**
  35936. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35937. */
  35938. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35939. private static _AnyMouseID;
  35940. /**
  35941. * Abstract mesh the behavior is set on
  35942. */
  35943. attachedNode: AbstractMesh;
  35944. private _dragPlane;
  35945. private _scene;
  35946. private _pointerObserver;
  35947. private _beforeRenderObserver;
  35948. private static _planeScene;
  35949. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35950. /**
  35951. * 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)
  35952. */
  35953. maxDragAngle: number;
  35954. /**
  35955. * @hidden
  35956. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35957. /**
  35958. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35959. */
  35960. currentDraggingPointerID: number;
  35961. /**
  35962. * The last position where the pointer hit the drag plane in world space
  35963. */
  35964. lastDragPosition: Vector3;
  35965. /**
  35966. * If the behavior is currently in a dragging state
  35967. */
  35968. dragging: boolean;
  35969. /**
  35970. * 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)
  35971. */
  35972. dragDeltaRatio: number;
  35973. /**
  35974. * If the drag plane orientation should be updated during the dragging (Default: true)
  35975. */
  35976. updateDragPlane: boolean;
  35977. private _debugMode;
  35978. private _moving;
  35979. /**
  35980. * Fires each time the attached mesh is dragged with the pointer
  35981. * * delta between last drag position and current drag position in world space
  35982. * * dragDistance along the drag axis
  35983. * * dragPlaneNormal normal of the current drag plane used during the drag
  35984. * * dragPlanePoint in world space where the drag intersects the drag plane
  35985. */
  35986. onDragObservable: Observable<{
  35987. delta: Vector3;
  35988. dragPlanePoint: Vector3;
  35989. dragPlaneNormal: Vector3;
  35990. dragDistance: number;
  35991. pointerId: number;
  35992. }>;
  35993. /**
  35994. * Fires each time a drag begins (eg. mouse down on mesh)
  35995. */
  35996. onDragStartObservable: Observable<{
  35997. dragPlanePoint: Vector3;
  35998. pointerId: number;
  35999. }>;
  36000. /**
  36001. * Fires each time a drag ends (eg. mouse release after drag)
  36002. */
  36003. onDragEndObservable: Observable<{
  36004. dragPlanePoint: Vector3;
  36005. pointerId: number;
  36006. }>;
  36007. /**
  36008. * If the attached mesh should be moved when dragged
  36009. */
  36010. moveAttached: boolean;
  36011. /**
  36012. * If the drag behavior will react to drag events (Default: true)
  36013. */
  36014. enabled: boolean;
  36015. /**
  36016. * If pointer events should start and release the drag (Default: true)
  36017. */
  36018. startAndReleaseDragOnPointerEvents: boolean;
  36019. /**
  36020. * If camera controls should be detached during the drag
  36021. */
  36022. detachCameraControls: boolean;
  36023. /**
  36024. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36025. */
  36026. useObjectOrienationForDragging: boolean;
  36027. private _options;
  36028. /**
  36029. * Creates a pointer drag behavior that can be attached to a mesh
  36030. * @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)
  36031. */
  36032. constructor(options?: {
  36033. dragAxis?: Vector3;
  36034. dragPlaneNormal?: Vector3;
  36035. });
  36036. /**
  36037. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36038. */
  36039. validateDrag: (targetPosition: Vector3) => boolean;
  36040. /**
  36041. * The name of the behavior
  36042. */
  36043. readonly name: string;
  36044. /**
  36045. * Initializes the behavior
  36046. */
  36047. init(): void;
  36048. private _tmpVector;
  36049. private _alternatePickedPoint;
  36050. private _worldDragAxis;
  36051. private _targetPosition;
  36052. private _attachedElement;
  36053. /**
  36054. * Attaches the drag behavior the passed in mesh
  36055. * @param ownerNode The mesh that will be dragged around once attached
  36056. */
  36057. attach(ownerNode: AbstractMesh): void;
  36058. /**
  36059. * Force relase the drag action by code.
  36060. */
  36061. releaseDrag(): void;
  36062. private _startDragRay;
  36063. private _lastPointerRay;
  36064. /**
  36065. * Simulates the start of a pointer drag event on the behavior
  36066. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36067. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36068. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36069. */
  36070. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36071. private _startDrag;
  36072. private _dragDelta;
  36073. private _moveDrag;
  36074. private _pickWithRayOnDragPlane;
  36075. private _pointA;
  36076. private _pointB;
  36077. private _pointC;
  36078. private _lineA;
  36079. private _lineB;
  36080. private _localAxis;
  36081. private _lookAt;
  36082. private _updateDragPlanePosition;
  36083. /**
  36084. * Detaches the behavior from the mesh
  36085. */
  36086. detach(): void;
  36087. }
  36088. }
  36089. declare module BABYLON {
  36090. /**
  36091. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36092. */
  36093. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36094. private _dragBehaviorA;
  36095. private _dragBehaviorB;
  36096. private _startDistance;
  36097. private _initialScale;
  36098. private _targetScale;
  36099. private _ownerNode;
  36100. private _sceneRenderObserver;
  36101. /**
  36102. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36103. */
  36104. constructor();
  36105. /**
  36106. * The name of the behavior
  36107. */
  36108. readonly name: string;
  36109. /**
  36110. * Initializes the behavior
  36111. */
  36112. init(): void;
  36113. private _getCurrentDistance;
  36114. /**
  36115. * Attaches the scale behavior the passed in mesh
  36116. * @param ownerNode The mesh that will be scaled around once attached
  36117. */
  36118. attach(ownerNode: Mesh): void;
  36119. /**
  36120. * Detaches the behavior from the mesh
  36121. */
  36122. detach(): void;
  36123. }
  36124. }
  36125. declare module BABYLON {
  36126. /**
  36127. * 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
  36128. */
  36129. export class SixDofDragBehavior implements Behavior<Mesh> {
  36130. private static _virtualScene;
  36131. private _ownerNode;
  36132. private _sceneRenderObserver;
  36133. private _scene;
  36134. private _targetPosition;
  36135. private _virtualOriginMesh;
  36136. private _virtualDragMesh;
  36137. private _pointerObserver;
  36138. private _moving;
  36139. private _startingOrientation;
  36140. /**
  36141. * 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)
  36142. */
  36143. private zDragFactor;
  36144. /**
  36145. * If the object should rotate to face the drag origin
  36146. */
  36147. rotateDraggedObject: boolean;
  36148. /**
  36149. * If the behavior is currently in a dragging state
  36150. */
  36151. dragging: boolean;
  36152. /**
  36153. * 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)
  36154. */
  36155. dragDeltaRatio: number;
  36156. /**
  36157. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36158. */
  36159. currentDraggingPointerID: number;
  36160. /**
  36161. * If camera controls should be detached during the drag
  36162. */
  36163. detachCameraControls: boolean;
  36164. /**
  36165. * Fires each time a drag starts
  36166. */
  36167. onDragStartObservable: Observable<{}>;
  36168. /**
  36169. * Fires each time a drag ends (eg. mouse release after drag)
  36170. */
  36171. onDragEndObservable: Observable<{}>;
  36172. /**
  36173. * 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
  36174. */
  36175. constructor();
  36176. /**
  36177. * The name of the behavior
  36178. */
  36179. readonly name: string;
  36180. /**
  36181. * Initializes the behavior
  36182. */
  36183. init(): void;
  36184. /**
  36185. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36186. */
  36187. private readonly _pointerCamera;
  36188. /**
  36189. * Attaches the scale behavior the passed in mesh
  36190. * @param ownerNode The mesh that will be scaled around once attached
  36191. */
  36192. attach(ownerNode: Mesh): void;
  36193. /**
  36194. * Detaches the behavior from the mesh
  36195. */
  36196. detach(): void;
  36197. }
  36198. }
  36199. declare module BABYLON {
  36200. /**
  36201. * Class used to apply inverse kinematics to bones
  36202. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36203. */
  36204. export class BoneIKController {
  36205. private static _tmpVecs;
  36206. private static _tmpQuat;
  36207. private static _tmpMats;
  36208. /**
  36209. * Gets or sets the target mesh
  36210. */
  36211. targetMesh: AbstractMesh;
  36212. /** Gets or sets the mesh used as pole */
  36213. poleTargetMesh: AbstractMesh;
  36214. /**
  36215. * Gets or sets the bone used as pole
  36216. */
  36217. poleTargetBone: Nullable<Bone>;
  36218. /**
  36219. * Gets or sets the target position
  36220. */
  36221. targetPosition: Vector3;
  36222. /**
  36223. * Gets or sets the pole target position
  36224. */
  36225. poleTargetPosition: Vector3;
  36226. /**
  36227. * Gets or sets the pole target local offset
  36228. */
  36229. poleTargetLocalOffset: Vector3;
  36230. /**
  36231. * Gets or sets the pole angle
  36232. */
  36233. poleAngle: number;
  36234. /**
  36235. * Gets or sets the mesh associated with the controller
  36236. */
  36237. mesh: AbstractMesh;
  36238. /**
  36239. * 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)
  36240. */
  36241. slerpAmount: number;
  36242. private _bone1Quat;
  36243. private _bone1Mat;
  36244. private _bone2Ang;
  36245. private _bone1;
  36246. private _bone2;
  36247. private _bone1Length;
  36248. private _bone2Length;
  36249. private _maxAngle;
  36250. private _maxReach;
  36251. private _rightHandedSystem;
  36252. private _bendAxis;
  36253. private _slerping;
  36254. private _adjustRoll;
  36255. /**
  36256. * Gets or sets maximum allowed angle
  36257. */
  36258. maxAngle: number;
  36259. /**
  36260. * Creates a new BoneIKController
  36261. * @param mesh defines the mesh to control
  36262. * @param bone defines the bone to control
  36263. * @param options defines options to set up the controller
  36264. */
  36265. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36266. targetMesh?: AbstractMesh;
  36267. poleTargetMesh?: AbstractMesh;
  36268. poleTargetBone?: Bone;
  36269. poleTargetLocalOffset?: Vector3;
  36270. poleAngle?: number;
  36271. bendAxis?: Vector3;
  36272. maxAngle?: number;
  36273. slerpAmount?: number;
  36274. });
  36275. private _setMaxAngle;
  36276. /**
  36277. * Force the controller to update the bones
  36278. */
  36279. update(): void;
  36280. }
  36281. }
  36282. declare module BABYLON {
  36283. /**
  36284. * Class used to make a bone look toward a point in space
  36285. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36286. */
  36287. export class BoneLookController {
  36288. private static _tmpVecs;
  36289. private static _tmpQuat;
  36290. private static _tmpMats;
  36291. /**
  36292. * The target Vector3 that the bone will look at
  36293. */
  36294. target: Vector3;
  36295. /**
  36296. * The mesh that the bone is attached to
  36297. */
  36298. mesh: AbstractMesh;
  36299. /**
  36300. * The bone that will be looking to the target
  36301. */
  36302. bone: Bone;
  36303. /**
  36304. * The up axis of the coordinate system that is used when the bone is rotated
  36305. */
  36306. upAxis: Vector3;
  36307. /**
  36308. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36309. */
  36310. upAxisSpace: Space;
  36311. /**
  36312. * Used to make an adjustment to the yaw of the bone
  36313. */
  36314. adjustYaw: number;
  36315. /**
  36316. * Used to make an adjustment to the pitch of the bone
  36317. */
  36318. adjustPitch: number;
  36319. /**
  36320. * Used to make an adjustment to the roll of the bone
  36321. */
  36322. adjustRoll: number;
  36323. /**
  36324. * 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)
  36325. */
  36326. slerpAmount: number;
  36327. private _minYaw;
  36328. private _maxYaw;
  36329. private _minPitch;
  36330. private _maxPitch;
  36331. private _minYawSin;
  36332. private _minYawCos;
  36333. private _maxYawSin;
  36334. private _maxYawCos;
  36335. private _midYawConstraint;
  36336. private _minPitchTan;
  36337. private _maxPitchTan;
  36338. private _boneQuat;
  36339. private _slerping;
  36340. private _transformYawPitch;
  36341. private _transformYawPitchInv;
  36342. private _firstFrameSkipped;
  36343. private _yawRange;
  36344. private _fowardAxis;
  36345. /**
  36346. * Gets or sets the minimum yaw angle that the bone can look to
  36347. */
  36348. minYaw: number;
  36349. /**
  36350. * Gets or sets the maximum yaw angle that the bone can look to
  36351. */
  36352. maxYaw: number;
  36353. /**
  36354. * Gets or sets the minimum pitch angle that the bone can look to
  36355. */
  36356. minPitch: number;
  36357. /**
  36358. * Gets or sets the maximum pitch angle that the bone can look to
  36359. */
  36360. maxPitch: number;
  36361. /**
  36362. * Create a BoneLookController
  36363. * @param mesh the mesh that the bone belongs to
  36364. * @param bone the bone that will be looking to the target
  36365. * @param target the target Vector3 to look at
  36366. * @param options optional settings:
  36367. * * maxYaw: the maximum angle the bone will yaw to
  36368. * * minYaw: the minimum angle the bone will yaw to
  36369. * * maxPitch: the maximum angle the bone will pitch to
  36370. * * minPitch: the minimum angle the bone will yaw to
  36371. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36372. * * upAxis: the up axis of the coordinate system
  36373. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36374. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36375. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36376. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36377. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36378. * * adjustRoll: used to make an adjustment to the roll of the bone
  36379. **/
  36380. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36381. maxYaw?: number;
  36382. minYaw?: number;
  36383. maxPitch?: number;
  36384. minPitch?: number;
  36385. slerpAmount?: number;
  36386. upAxis?: Vector3;
  36387. upAxisSpace?: Space;
  36388. yawAxis?: Vector3;
  36389. pitchAxis?: Vector3;
  36390. adjustYaw?: number;
  36391. adjustPitch?: number;
  36392. adjustRoll?: number;
  36393. });
  36394. /**
  36395. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36396. */
  36397. update(): void;
  36398. private _getAngleDiff;
  36399. private _getAngleBetween;
  36400. private _isAngleBetween;
  36401. }
  36402. }
  36403. declare module BABYLON {
  36404. /**
  36405. * Manage the gamepad inputs to control an arc rotate camera.
  36406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36407. */
  36408. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36409. /**
  36410. * Defines the camera the input is attached to.
  36411. */
  36412. camera: ArcRotateCamera;
  36413. /**
  36414. * Defines the gamepad the input is gathering event from.
  36415. */
  36416. gamepad: Nullable<Gamepad>;
  36417. /**
  36418. * Defines the gamepad rotation sensiblity.
  36419. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36420. */
  36421. gamepadRotationSensibility: number;
  36422. /**
  36423. * Defines the gamepad move sensiblity.
  36424. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36425. */
  36426. gamepadMoveSensibility: number;
  36427. private _onGamepadConnectedObserver;
  36428. private _onGamepadDisconnectedObserver;
  36429. /**
  36430. * Attach the input controls to a specific dom element to get the input from.
  36431. * @param element Defines the element the controls should be listened from
  36432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36433. */
  36434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36435. /**
  36436. * Detach the current controls from the specified dom element.
  36437. * @param element Defines the element to stop listening the inputs from
  36438. */
  36439. detachControl(element: Nullable<HTMLElement>): void;
  36440. /**
  36441. * Update the current camera state depending on the inputs that have been used this frame.
  36442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36443. */
  36444. checkInputs(): void;
  36445. /**
  36446. * Gets the class name of the current intput.
  36447. * @returns the class name
  36448. */
  36449. getClassName(): string;
  36450. /**
  36451. * Get the friendly name associated with the input class.
  36452. * @returns the input friendly name
  36453. */
  36454. getSimpleName(): string;
  36455. }
  36456. }
  36457. declare module BABYLON {
  36458. interface ArcRotateCameraInputsManager {
  36459. /**
  36460. * Add orientation input support to the input manager.
  36461. * @returns the current input manager
  36462. */
  36463. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36464. }
  36465. /**
  36466. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36468. */
  36469. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36470. /**
  36471. * Defines the camera the input is attached to.
  36472. */
  36473. camera: ArcRotateCamera;
  36474. /**
  36475. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36476. */
  36477. alphaCorrection: number;
  36478. /**
  36479. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36480. */
  36481. gammaCorrection: number;
  36482. private _alpha;
  36483. private _gamma;
  36484. private _dirty;
  36485. private _deviceOrientationHandler;
  36486. /**
  36487. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36488. */
  36489. constructor();
  36490. /**
  36491. * Attach the input controls to a specific dom element to get the input from.
  36492. * @param element Defines the element the controls should be listened from
  36493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36494. */
  36495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36496. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36497. /**
  36498. * Update the current camera state depending on the inputs that have been used this frame.
  36499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36500. */
  36501. checkInputs(): void;
  36502. /**
  36503. * Detach the current controls from the specified dom element.
  36504. * @param element Defines the element to stop listening the inputs from
  36505. */
  36506. detachControl(element: Nullable<HTMLElement>): void;
  36507. /**
  36508. * Gets the class name of the current intput.
  36509. * @returns the class name
  36510. */
  36511. getClassName(): string;
  36512. /**
  36513. * Get the friendly name associated with the input class.
  36514. * @returns the input friendly name
  36515. */
  36516. getSimpleName(): string;
  36517. }
  36518. }
  36519. declare module BABYLON {
  36520. /**
  36521. * Listen to mouse events to control the camera.
  36522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36523. */
  36524. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36525. /**
  36526. * Defines the camera the input is attached to.
  36527. */
  36528. camera: FlyCamera;
  36529. /**
  36530. * Defines if touch is enabled. (Default is true.)
  36531. */
  36532. touchEnabled: boolean;
  36533. /**
  36534. * Defines the buttons associated with the input to handle camera rotation.
  36535. */
  36536. buttons: number[];
  36537. /**
  36538. * Assign buttons for Yaw control.
  36539. */
  36540. buttonsYaw: number[];
  36541. /**
  36542. * Assign buttons for Pitch control.
  36543. */
  36544. buttonsPitch: number[];
  36545. /**
  36546. * Assign buttons for Roll control.
  36547. */
  36548. buttonsRoll: number[];
  36549. /**
  36550. * Detect if any button is being pressed while mouse is moved.
  36551. * -1 = Mouse locked.
  36552. * 0 = Left button.
  36553. * 1 = Middle Button.
  36554. * 2 = Right Button.
  36555. */
  36556. activeButton: number;
  36557. /**
  36558. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36559. * Higher values reduce its sensitivity.
  36560. */
  36561. angularSensibility: number;
  36562. private _mousemoveCallback;
  36563. private _observer;
  36564. private _rollObserver;
  36565. private previousPosition;
  36566. private noPreventDefault;
  36567. private element;
  36568. /**
  36569. * Listen to mouse events to control the camera.
  36570. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36572. */
  36573. constructor(touchEnabled?: boolean);
  36574. /**
  36575. * Attach the mouse control to the HTML DOM element.
  36576. * @param element Defines the element that listens to the input events.
  36577. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36578. */
  36579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36580. /**
  36581. * Detach the current controls from the specified dom element.
  36582. * @param element Defines the element to stop listening the inputs from
  36583. */
  36584. detachControl(element: Nullable<HTMLElement>): void;
  36585. /**
  36586. * Gets the class name of the current input.
  36587. * @returns the class name.
  36588. */
  36589. getClassName(): string;
  36590. /**
  36591. * Get the friendly name associated with the input class.
  36592. * @returns the input's friendly name.
  36593. */
  36594. getSimpleName(): string;
  36595. private _pointerInput;
  36596. private _onMouseMove;
  36597. /**
  36598. * Rotate camera by mouse offset.
  36599. */
  36600. private rotateCamera;
  36601. }
  36602. }
  36603. declare module BABYLON {
  36604. /**
  36605. * Default Inputs manager for the FlyCamera.
  36606. * It groups all the default supported inputs for ease of use.
  36607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36608. */
  36609. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36610. /**
  36611. * Instantiates a new FlyCameraInputsManager.
  36612. * @param camera Defines the camera the inputs belong to.
  36613. */
  36614. constructor(camera: FlyCamera);
  36615. /**
  36616. * Add keyboard input support to the input manager.
  36617. * @returns the new FlyCameraKeyboardMoveInput().
  36618. */
  36619. addKeyboard(): FlyCameraInputsManager;
  36620. /**
  36621. * Add mouse input support to the input manager.
  36622. * @param touchEnabled Enable touch screen support.
  36623. * @returns the new FlyCameraMouseInput().
  36624. */
  36625. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36626. }
  36627. }
  36628. declare module BABYLON {
  36629. /**
  36630. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36631. * such as in a 3D Space Shooter or a Flight Simulator.
  36632. */
  36633. export class FlyCamera extends TargetCamera {
  36634. /**
  36635. * Define the collision ellipsoid of the camera.
  36636. * This is helpful for simulating a camera body, like a player's body.
  36637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36638. */
  36639. ellipsoid: Vector3;
  36640. /**
  36641. * Define an offset for the position of the ellipsoid around the camera.
  36642. * This can be helpful if the camera is attached away from the player's body center,
  36643. * such as at its head.
  36644. */
  36645. ellipsoidOffset: Vector3;
  36646. /**
  36647. * Enable or disable collisions of the camera with the rest of the scene objects.
  36648. */
  36649. checkCollisions: boolean;
  36650. /**
  36651. * Enable or disable gravity on the camera.
  36652. */
  36653. applyGravity: boolean;
  36654. /**
  36655. * Define the current direction the camera is moving to.
  36656. */
  36657. cameraDirection: Vector3;
  36658. /**
  36659. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36660. * This overrides and empties cameraRotation.
  36661. */
  36662. rotationQuaternion: Quaternion;
  36663. /**
  36664. * Track Roll to maintain the wanted Rolling when looking around.
  36665. */ private _trackRoll: number;
  36666. /**
  36667. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36668. */
  36669. rollCorrect: number;
  36670. /**
  36671. * Mimic a banked turn, Rolling the camera when Yawing.
  36672. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36673. */
  36674. bankedTurn: boolean;
  36675. /**
  36676. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36677. */
  36678. bankedTurnLimit: number;
  36679. /**
  36680. * Value of 0 disables the banked Roll.
  36681. * Value of 1 is equal to the Yaw angle in radians.
  36682. */
  36683. bankedTurnMultiplier: number;
  36684. /**
  36685. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36686. */
  36687. inputs: FlyCameraInputsManager;
  36688. /**
  36689. * Gets the input sensibility for mouse input.
  36690. * Higher values reduce sensitivity.
  36691. */
  36692. /**
  36693. * Sets the input sensibility for a mouse input.
  36694. * Higher values reduce sensitivity.
  36695. */
  36696. angularSensibility: number;
  36697. /**
  36698. * Get the keys for camera movement forward.
  36699. */
  36700. /**
  36701. * Set the keys for camera movement forward.
  36702. */
  36703. keysForward: number[];
  36704. /**
  36705. * Get the keys for camera movement backward.
  36706. */
  36707. keysBackward: number[];
  36708. /**
  36709. * Get the keys for camera movement up.
  36710. */
  36711. /**
  36712. * Set the keys for camera movement up.
  36713. */
  36714. keysUp: number[];
  36715. /**
  36716. * Get the keys for camera movement down.
  36717. */
  36718. /**
  36719. * Set the keys for camera movement down.
  36720. */
  36721. keysDown: number[];
  36722. /**
  36723. * Get the keys for camera movement left.
  36724. */
  36725. /**
  36726. * Set the keys for camera movement left.
  36727. */
  36728. keysLeft: number[];
  36729. /**
  36730. * Set the keys for camera movement right.
  36731. */
  36732. /**
  36733. * Set the keys for camera movement right.
  36734. */
  36735. keysRight: number[];
  36736. /**
  36737. * Event raised when the camera collides with a mesh in the scene.
  36738. */
  36739. onCollide: (collidedMesh: AbstractMesh) => void;
  36740. private _collider;
  36741. private _needMoveForGravity;
  36742. private _oldPosition;
  36743. private _diffPosition;
  36744. private _newPosition;
  36745. /** @hidden */ private _localDirection: Vector3;
  36746. /** @hidden */ private _transformedDirection: Vector3;
  36747. /**
  36748. * Instantiates a FlyCamera.
  36749. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36750. * such as in a 3D Space Shooter or a Flight Simulator.
  36751. * @param name Define the name of the camera in the scene.
  36752. * @param position Define the starting position of the camera in the scene.
  36753. * @param scene Define the scene the camera belongs to.
  36754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36755. */
  36756. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36757. /**
  36758. * Attach a control to the HTML DOM element.
  36759. * @param element Defines the element that listens to the input events.
  36760. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36761. */
  36762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36763. /**
  36764. * Detach a control from the HTML DOM element.
  36765. * The camera will stop reacting to that input.
  36766. * @param element Defines the element that listens to the input events.
  36767. */
  36768. detachControl(element: HTMLElement): void;
  36769. private _collisionMask;
  36770. /**
  36771. * Get the mask that the camera ignores in collision events.
  36772. */
  36773. /**
  36774. * Set the mask that the camera ignores in collision events.
  36775. */
  36776. collisionMask: number;
  36777. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36778. /** @hidden */
  36779. private _onCollisionPositionChange;
  36780. /** @hidden */ private _checkInputs(): void;
  36781. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36782. /** @hidden */ private _updatePosition(): void;
  36783. /**
  36784. * Restore the Roll to its target value at the rate specified.
  36785. * @param rate - Higher means slower restoring.
  36786. * @hidden
  36787. */
  36788. restoreRoll(rate: number): void;
  36789. /**
  36790. * Destroy the camera and release the current resources held by it.
  36791. */
  36792. dispose(): void;
  36793. /**
  36794. * Get the current object class name.
  36795. * @returns the class name.
  36796. */
  36797. getClassName(): string;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * Listen to keyboard events to control the camera.
  36803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36804. */
  36805. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36806. /**
  36807. * Defines the camera the input is attached to.
  36808. */
  36809. camera: FlyCamera;
  36810. /**
  36811. * The list of keyboard keys used to control the forward move of the camera.
  36812. */
  36813. keysForward: number[];
  36814. /**
  36815. * The list of keyboard keys used to control the backward move of the camera.
  36816. */
  36817. keysBackward: number[];
  36818. /**
  36819. * The list of keyboard keys used to control the forward move of the camera.
  36820. */
  36821. keysUp: number[];
  36822. /**
  36823. * The list of keyboard keys used to control the backward move of the camera.
  36824. */
  36825. keysDown: number[];
  36826. /**
  36827. * The list of keyboard keys used to control the right strafe move of the camera.
  36828. */
  36829. keysRight: number[];
  36830. /**
  36831. * The list of keyboard keys used to control the left strafe move of the camera.
  36832. */
  36833. keysLeft: number[];
  36834. private _keys;
  36835. private _onCanvasBlurObserver;
  36836. private _onKeyboardObserver;
  36837. private _engine;
  36838. private _scene;
  36839. /**
  36840. * Attach the input controls to a specific dom element to get the input from.
  36841. * @param element Defines the element the controls should be listened from
  36842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36843. */
  36844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36845. /**
  36846. * Detach the current controls from the specified dom element.
  36847. * @param element Defines the element to stop listening the inputs from
  36848. */
  36849. detachControl(element: Nullable<HTMLElement>): void;
  36850. /**
  36851. * Gets the class name of the current intput.
  36852. * @returns the class name
  36853. */
  36854. getClassName(): string;
  36855. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36856. /**
  36857. * Get the friendly name associated with the input class.
  36858. * @returns the input friendly name
  36859. */
  36860. getSimpleName(): string;
  36861. /**
  36862. * Update the current camera state depending on the inputs that have been used this frame.
  36863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36864. */
  36865. checkInputs(): void;
  36866. }
  36867. }
  36868. declare module BABYLON {
  36869. /**
  36870. * Manage the mouse wheel inputs to control a follow camera.
  36871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36872. */
  36873. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36874. /**
  36875. * Defines the camera the input is attached to.
  36876. */
  36877. camera: FollowCamera;
  36878. /**
  36879. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36880. */
  36881. axisControlRadius: boolean;
  36882. /**
  36883. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36884. */
  36885. axisControlHeight: boolean;
  36886. /**
  36887. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36888. */
  36889. axisControlRotation: boolean;
  36890. /**
  36891. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36892. * relation to mouseWheel events.
  36893. */
  36894. wheelPrecision: number;
  36895. /**
  36896. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36897. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36898. */
  36899. wheelDeltaPercentage: number;
  36900. private _wheel;
  36901. private _observer;
  36902. /**
  36903. * Attach the input controls to a specific dom element to get the input from.
  36904. * @param element Defines the element the controls should be listened from
  36905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36906. */
  36907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36908. /**
  36909. * Detach the current controls from the specified dom element.
  36910. * @param element Defines the element to stop listening the inputs from
  36911. */
  36912. detachControl(element: Nullable<HTMLElement>): void;
  36913. /**
  36914. * Gets the class name of the current intput.
  36915. * @returns the class name
  36916. */
  36917. getClassName(): string;
  36918. /**
  36919. * Get the friendly name associated with the input class.
  36920. * @returns the input friendly name
  36921. */
  36922. getSimpleName(): string;
  36923. }
  36924. }
  36925. declare module BABYLON {
  36926. /**
  36927. * Manage the pointers inputs to control an follow camera.
  36928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36929. */
  36930. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36931. /**
  36932. * Defines the camera the input is attached to.
  36933. */
  36934. camera: FollowCamera;
  36935. /**
  36936. * Gets the class name of the current input.
  36937. * @returns the class name
  36938. */
  36939. getClassName(): string;
  36940. /**
  36941. * Defines the pointer angular sensibility along the X axis or how fast is
  36942. * the camera rotating.
  36943. * A negative number will reverse the axis direction.
  36944. */
  36945. angularSensibilityX: number;
  36946. /**
  36947. * Defines the pointer angular sensibility along the Y axis or how fast is
  36948. * the camera rotating.
  36949. * A negative number will reverse the axis direction.
  36950. */
  36951. angularSensibilityY: number;
  36952. /**
  36953. * Defines the pointer pinch precision or how fast is the camera zooming.
  36954. * A negative number will reverse the axis direction.
  36955. */
  36956. pinchPrecision: number;
  36957. /**
  36958. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36959. * from 0.
  36960. * It defines the percentage of current camera.radius to use as delta when
  36961. * pinch zoom is used.
  36962. */
  36963. pinchDeltaPercentage: number;
  36964. /**
  36965. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36966. */
  36967. axisXControlRadius: boolean;
  36968. /**
  36969. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36970. */
  36971. axisXControlHeight: boolean;
  36972. /**
  36973. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36974. */
  36975. axisXControlRotation: boolean;
  36976. /**
  36977. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36978. */
  36979. axisYControlRadius: boolean;
  36980. /**
  36981. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36982. */
  36983. axisYControlHeight: boolean;
  36984. /**
  36985. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36986. */
  36987. axisYControlRotation: boolean;
  36988. /**
  36989. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36990. */
  36991. axisPinchControlRadius: boolean;
  36992. /**
  36993. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36994. */
  36995. axisPinchControlHeight: boolean;
  36996. /**
  36997. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36998. */
  36999. axisPinchControlRotation: boolean;
  37000. /**
  37001. * Log error messages if basic misconfiguration has occurred.
  37002. */
  37003. warningEnable: boolean;
  37004. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37005. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37006. private _warningCounter;
  37007. private _warning;
  37008. }
  37009. }
  37010. declare module BABYLON {
  37011. /**
  37012. * Default Inputs manager for the FollowCamera.
  37013. * It groups all the default supported inputs for ease of use.
  37014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37015. */
  37016. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37017. /**
  37018. * Instantiates a new FollowCameraInputsManager.
  37019. * @param camera Defines the camera the inputs belong to
  37020. */
  37021. constructor(camera: FollowCamera);
  37022. /**
  37023. * Add keyboard input support to the input manager.
  37024. * @returns the current input manager
  37025. */
  37026. addKeyboard(): FollowCameraInputsManager;
  37027. /**
  37028. * Add mouse wheel input support to the input manager.
  37029. * @returns the current input manager
  37030. */
  37031. addMouseWheel(): FollowCameraInputsManager;
  37032. /**
  37033. * Add pointers input support to the input manager.
  37034. * @returns the current input manager
  37035. */
  37036. addPointers(): FollowCameraInputsManager;
  37037. /**
  37038. * Add orientation input support to the input manager.
  37039. * @returns the current input manager
  37040. */
  37041. addVRDeviceOrientation(): FollowCameraInputsManager;
  37042. }
  37043. }
  37044. declare module BABYLON {
  37045. /**
  37046. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37047. * an arc rotate version arcFollowCamera are available.
  37048. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37049. */
  37050. export class FollowCamera extends TargetCamera {
  37051. /**
  37052. * Distance the follow camera should follow an object at
  37053. */
  37054. radius: number;
  37055. /**
  37056. * Minimum allowed distance of the camera to the axis of rotation
  37057. * (The camera can not get closer).
  37058. * This can help limiting how the Camera is able to move in the scene.
  37059. */
  37060. lowerRadiusLimit: Nullable<number>;
  37061. /**
  37062. * Maximum allowed distance of the camera to the axis of rotation
  37063. * (The camera can not get further).
  37064. * This can help limiting how the Camera is able to move in the scene.
  37065. */
  37066. upperRadiusLimit: Nullable<number>;
  37067. /**
  37068. * Define a rotation offset between the camera and the object it follows
  37069. */
  37070. rotationOffset: number;
  37071. /**
  37072. * Minimum allowed angle to camera position relative to target object.
  37073. * This can help limiting how the Camera is able to move in the scene.
  37074. */
  37075. lowerRotationOffsetLimit: Nullable<number>;
  37076. /**
  37077. * Maximum allowed angle to camera position relative to target object.
  37078. * This can help limiting how the Camera is able to move in the scene.
  37079. */
  37080. upperRotationOffsetLimit: Nullable<number>;
  37081. /**
  37082. * Define a height offset between the camera and the object it follows.
  37083. * It can help following an object from the top (like a car chaing a plane)
  37084. */
  37085. heightOffset: number;
  37086. /**
  37087. * Minimum allowed height of camera position relative to target object.
  37088. * This can help limiting how the Camera is able to move in the scene.
  37089. */
  37090. lowerHeightOffsetLimit: Nullable<number>;
  37091. /**
  37092. * Maximum allowed height of camera position relative to target object.
  37093. * This can help limiting how the Camera is able to move in the scene.
  37094. */
  37095. upperHeightOffsetLimit: Nullable<number>;
  37096. /**
  37097. * Define how fast the camera can accelerate to follow it s target.
  37098. */
  37099. cameraAcceleration: number;
  37100. /**
  37101. * Define the speed limit of the camera following an object.
  37102. */
  37103. maxCameraSpeed: number;
  37104. /**
  37105. * Define the target of the camera.
  37106. */
  37107. lockedTarget: Nullable<AbstractMesh>;
  37108. /**
  37109. * Defines the input associated with the camera.
  37110. */
  37111. inputs: FollowCameraInputsManager;
  37112. /**
  37113. * Instantiates the follow camera.
  37114. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37115. * @param name Define the name of the camera in the scene
  37116. * @param position Define the position of the camera
  37117. * @param scene Define the scene the camera belong to
  37118. * @param lockedTarget Define the target of the camera
  37119. */
  37120. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37121. private _follow;
  37122. /**
  37123. * Attached controls to the current camera.
  37124. * @param element Defines the element the controls should be listened from
  37125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37126. */
  37127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37128. /**
  37129. * Detach the current controls from the camera.
  37130. * The camera will stop reacting to inputs.
  37131. * @param element Defines the element to stop listening the inputs from
  37132. */
  37133. detachControl(element: HTMLElement): void;
  37134. /** @hidden */ private _checkInputs(): void;
  37135. private _checkLimits;
  37136. /**
  37137. * Gets the camera class name.
  37138. * @returns the class name
  37139. */
  37140. getClassName(): string;
  37141. }
  37142. /**
  37143. * Arc Rotate version of the follow camera.
  37144. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37145. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37146. */
  37147. export class ArcFollowCamera extends TargetCamera {
  37148. /** The longitudinal angle of the camera */
  37149. alpha: number;
  37150. /** The latitudinal angle of the camera */
  37151. beta: number;
  37152. /** The radius of the camera from its target */
  37153. radius: number;
  37154. /** Define the camera target (the messh it should follow) */
  37155. target: Nullable<AbstractMesh>;
  37156. private _cartesianCoordinates;
  37157. /**
  37158. * Instantiates a new ArcFollowCamera
  37159. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37160. * @param name Define the name of the camera
  37161. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37162. * @param beta Define the rotation angle of the camera around the elevation axis
  37163. * @param radius Define the radius of the camera from its target point
  37164. * @param target Define the target of the camera
  37165. * @param scene Define the scene the camera belongs to
  37166. */
  37167. constructor(name: string,
  37168. /** The longitudinal angle of the camera */
  37169. alpha: number,
  37170. /** The latitudinal angle of the camera */
  37171. beta: number,
  37172. /** The radius of the camera from its target */
  37173. radius: number,
  37174. /** Define the camera target (the messh it should follow) */
  37175. target: Nullable<AbstractMesh>, scene: Scene);
  37176. private _follow;
  37177. /** @hidden */ private _checkInputs(): void;
  37178. /**
  37179. * Returns the class name of the object.
  37180. * It is mostly used internally for serialization purposes.
  37181. */
  37182. getClassName(): string;
  37183. }
  37184. }
  37185. declare module BABYLON {
  37186. /**
  37187. * Manage the keyboard inputs to control the movement of a follow camera.
  37188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37189. */
  37190. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37191. /**
  37192. * Defines the camera the input is attached to.
  37193. */
  37194. camera: FollowCamera;
  37195. /**
  37196. * Defines the list of key codes associated with the up action (increase heightOffset)
  37197. */
  37198. keysHeightOffsetIncr: number[];
  37199. /**
  37200. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37201. */
  37202. keysHeightOffsetDecr: number[];
  37203. /**
  37204. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37205. */
  37206. keysHeightOffsetModifierAlt: boolean;
  37207. /**
  37208. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37209. */
  37210. keysHeightOffsetModifierCtrl: boolean;
  37211. /**
  37212. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37213. */
  37214. keysHeightOffsetModifierShift: boolean;
  37215. /**
  37216. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37217. */
  37218. keysRotationOffsetIncr: number[];
  37219. /**
  37220. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37221. */
  37222. keysRotationOffsetDecr: number[];
  37223. /**
  37224. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37225. */
  37226. keysRotationOffsetModifierAlt: boolean;
  37227. /**
  37228. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37229. */
  37230. keysRotationOffsetModifierCtrl: boolean;
  37231. /**
  37232. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37233. */
  37234. keysRotationOffsetModifierShift: boolean;
  37235. /**
  37236. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37237. */
  37238. keysRadiusIncr: number[];
  37239. /**
  37240. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37241. */
  37242. keysRadiusDecr: number[];
  37243. /**
  37244. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37245. */
  37246. keysRadiusModifierAlt: boolean;
  37247. /**
  37248. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37249. */
  37250. keysRadiusModifierCtrl: boolean;
  37251. /**
  37252. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37253. */
  37254. keysRadiusModifierShift: boolean;
  37255. /**
  37256. * Defines the rate of change of heightOffset.
  37257. */
  37258. heightSensibility: number;
  37259. /**
  37260. * Defines the rate of change of rotationOffset.
  37261. */
  37262. rotationSensibility: number;
  37263. /**
  37264. * Defines the rate of change of radius.
  37265. */
  37266. radiusSensibility: number;
  37267. private _keys;
  37268. private _ctrlPressed;
  37269. private _altPressed;
  37270. private _shiftPressed;
  37271. private _onCanvasBlurObserver;
  37272. private _onKeyboardObserver;
  37273. private _engine;
  37274. private _scene;
  37275. /**
  37276. * Attach the input controls to a specific dom element to get the input from.
  37277. * @param element Defines the element the controls should be listened from
  37278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37279. */
  37280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37281. /**
  37282. * Detach the current controls from the specified dom element.
  37283. * @param element Defines the element to stop listening the inputs from
  37284. */
  37285. detachControl(element: Nullable<HTMLElement>): void;
  37286. /**
  37287. * Update the current camera state depending on the inputs that have been used this frame.
  37288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37289. */
  37290. checkInputs(): void;
  37291. /**
  37292. * Gets the class name of the current input.
  37293. * @returns the class name
  37294. */
  37295. getClassName(): string;
  37296. /**
  37297. * Get the friendly name associated with the input class.
  37298. * @returns the input friendly name
  37299. */
  37300. getSimpleName(): string;
  37301. /**
  37302. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37303. * allow modification of the heightOffset value.
  37304. */
  37305. private _modifierHeightOffset;
  37306. /**
  37307. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37308. * allow modification of the rotationOffset value.
  37309. */
  37310. private _modifierRotationOffset;
  37311. /**
  37312. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37313. * allow modification of the radius value.
  37314. */
  37315. private _modifierRadius;
  37316. }
  37317. }
  37318. declare module BABYLON {
  37319. interface FreeCameraInputsManager {
  37320. /**
  37321. * @hidden
  37322. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37323. /**
  37324. * Add orientation input support to the input manager.
  37325. * @returns the current input manager
  37326. */
  37327. addDeviceOrientation(): FreeCameraInputsManager;
  37328. }
  37329. /**
  37330. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37331. * Screen rotation is taken into account.
  37332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37333. */
  37334. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37335. private _camera;
  37336. private _screenOrientationAngle;
  37337. private _constantTranform;
  37338. private _screenQuaternion;
  37339. private _alpha;
  37340. private _beta;
  37341. private _gamma;
  37342. /**
  37343. * Can be used to detect if a device orientation sensor is availible on a device
  37344. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37345. * @returns a promise that will resolve on orientation change
  37346. */
  37347. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37348. /**
  37349. * @hidden
  37350. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37351. /**
  37352. * Instantiates a new input
  37353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37354. */
  37355. constructor();
  37356. /**
  37357. * Define the camera controlled by the input.
  37358. */
  37359. camera: FreeCamera;
  37360. /**
  37361. * Attach the input controls to a specific dom element to get the input from.
  37362. * @param element Defines the element the controls should be listened from
  37363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37364. */
  37365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37366. private _orientationChanged;
  37367. private _deviceOrientation;
  37368. /**
  37369. * Detach the current controls from the specified dom element.
  37370. * @param element Defines the element to stop listening the inputs from
  37371. */
  37372. detachControl(element: Nullable<HTMLElement>): void;
  37373. /**
  37374. * Update the current camera state depending on the inputs that have been used this frame.
  37375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37376. */
  37377. checkInputs(): void;
  37378. /**
  37379. * Gets the class name of the current intput.
  37380. * @returns the class name
  37381. */
  37382. getClassName(): string;
  37383. /**
  37384. * Get the friendly name associated with the input class.
  37385. * @returns the input friendly name
  37386. */
  37387. getSimpleName(): string;
  37388. }
  37389. }
  37390. declare module BABYLON {
  37391. /**
  37392. * Manage the gamepad inputs to control a free camera.
  37393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37394. */
  37395. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37396. /**
  37397. * Define the camera the input is attached to.
  37398. */
  37399. camera: FreeCamera;
  37400. /**
  37401. * Define the Gamepad controlling the input
  37402. */
  37403. gamepad: Nullable<Gamepad>;
  37404. /**
  37405. * Defines the gamepad rotation sensiblity.
  37406. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37407. */
  37408. gamepadAngularSensibility: number;
  37409. /**
  37410. * Defines the gamepad move sensiblity.
  37411. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37412. */
  37413. gamepadMoveSensibility: number;
  37414. private _onGamepadConnectedObserver;
  37415. private _onGamepadDisconnectedObserver;
  37416. private _cameraTransform;
  37417. private _deltaTransform;
  37418. private _vector3;
  37419. private _vector2;
  37420. /**
  37421. * Attach the input controls to a specific dom element to get the input from.
  37422. * @param element Defines the element the controls should be listened from
  37423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37424. */
  37425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37426. /**
  37427. * Detach the current controls from the specified dom element.
  37428. * @param element Defines the element to stop listening the inputs from
  37429. */
  37430. detachControl(element: Nullable<HTMLElement>): void;
  37431. /**
  37432. * Update the current camera state depending on the inputs that have been used this frame.
  37433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37434. */
  37435. checkInputs(): void;
  37436. /**
  37437. * Gets the class name of the current intput.
  37438. * @returns the class name
  37439. */
  37440. getClassName(): string;
  37441. /**
  37442. * Get the friendly name associated with the input class.
  37443. * @returns the input friendly name
  37444. */
  37445. getSimpleName(): string;
  37446. }
  37447. }
  37448. declare module BABYLON {
  37449. /**
  37450. * Defines the potential axis of a Joystick
  37451. */
  37452. export enum JoystickAxis {
  37453. /** X axis */
  37454. X = 0,
  37455. /** Y axis */
  37456. Y = 1,
  37457. /** Z axis */
  37458. Z = 2
  37459. }
  37460. /**
  37461. * Class used to define virtual joystick (used in touch mode)
  37462. */
  37463. export class VirtualJoystick {
  37464. /**
  37465. * Gets or sets a boolean indicating that left and right values must be inverted
  37466. */
  37467. reverseLeftRight: boolean;
  37468. /**
  37469. * Gets or sets a boolean indicating that up and down values must be inverted
  37470. */
  37471. reverseUpDown: boolean;
  37472. /**
  37473. * Gets the offset value for the position (ie. the change of the position value)
  37474. */
  37475. deltaPosition: Vector3;
  37476. /**
  37477. * Gets a boolean indicating if the virtual joystick was pressed
  37478. */
  37479. pressed: boolean;
  37480. /**
  37481. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37482. */
  37483. static Canvas: Nullable<HTMLCanvasElement>;
  37484. private static _globalJoystickIndex;
  37485. private static vjCanvasContext;
  37486. private static vjCanvasWidth;
  37487. private static vjCanvasHeight;
  37488. private static halfWidth;
  37489. private _action;
  37490. private _axisTargetedByLeftAndRight;
  37491. private _axisTargetedByUpAndDown;
  37492. private _joystickSensibility;
  37493. private _inversedSensibility;
  37494. private _joystickPointerID;
  37495. private _joystickColor;
  37496. private _joystickPointerPos;
  37497. private _joystickPreviousPointerPos;
  37498. private _joystickPointerStartPos;
  37499. private _deltaJoystickVector;
  37500. private _leftJoystick;
  37501. private _touches;
  37502. private _onPointerDownHandlerRef;
  37503. private _onPointerMoveHandlerRef;
  37504. private _onPointerUpHandlerRef;
  37505. private _onResize;
  37506. /**
  37507. * Creates a new virtual joystick
  37508. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37509. */
  37510. constructor(leftJoystick?: boolean);
  37511. /**
  37512. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37513. * @param newJoystickSensibility defines the new sensibility
  37514. */
  37515. setJoystickSensibility(newJoystickSensibility: number): void;
  37516. private _onPointerDown;
  37517. private _onPointerMove;
  37518. private _onPointerUp;
  37519. /**
  37520. * Change the color of the virtual joystick
  37521. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37522. */
  37523. setJoystickColor(newColor: string): void;
  37524. /**
  37525. * Defines a callback to call when the joystick is touched
  37526. * @param action defines the callback
  37527. */
  37528. setActionOnTouch(action: () => any): void;
  37529. /**
  37530. * Defines which axis you'd like to control for left & right
  37531. * @param axis defines the axis to use
  37532. */
  37533. setAxisForLeftRight(axis: JoystickAxis): void;
  37534. /**
  37535. * Defines which axis you'd like to control for up & down
  37536. * @param axis defines the axis to use
  37537. */
  37538. setAxisForUpDown(axis: JoystickAxis): void;
  37539. private _drawVirtualJoystick;
  37540. /**
  37541. * Release internal HTML canvas
  37542. */
  37543. releaseCanvas(): void;
  37544. }
  37545. }
  37546. declare module BABYLON {
  37547. interface FreeCameraInputsManager {
  37548. /**
  37549. * Add virtual joystick input support to the input manager.
  37550. * @returns the current input manager
  37551. */
  37552. addVirtualJoystick(): FreeCameraInputsManager;
  37553. }
  37554. /**
  37555. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37557. */
  37558. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37559. /**
  37560. * Defines the camera the input is attached to.
  37561. */
  37562. camera: FreeCamera;
  37563. private _leftjoystick;
  37564. private _rightjoystick;
  37565. /**
  37566. * Gets the left stick of the virtual joystick.
  37567. * @returns The virtual Joystick
  37568. */
  37569. getLeftJoystick(): VirtualJoystick;
  37570. /**
  37571. * Gets the right stick of the virtual joystick.
  37572. * @returns The virtual Joystick
  37573. */
  37574. getRightJoystick(): VirtualJoystick;
  37575. /**
  37576. * Update the current camera state depending on the inputs that have been used this frame.
  37577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37578. */
  37579. checkInputs(): void;
  37580. /**
  37581. * Attach the input controls to a specific dom element to get the input from.
  37582. * @param element Defines the element the controls should be listened from
  37583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37584. */
  37585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37586. /**
  37587. * Detach the current controls from the specified dom element.
  37588. * @param element Defines the element to stop listening the inputs from
  37589. */
  37590. detachControl(element: Nullable<HTMLElement>): void;
  37591. /**
  37592. * Gets the class name of the current intput.
  37593. * @returns the class name
  37594. */
  37595. getClassName(): string;
  37596. /**
  37597. * Get the friendly name associated with the input class.
  37598. * @returns the input friendly name
  37599. */
  37600. getSimpleName(): string;
  37601. }
  37602. }
  37603. declare module BABYLON {
  37604. /**
  37605. * This represents a FPS type of camera controlled by touch.
  37606. * This is like a universal camera minus the Gamepad controls.
  37607. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37608. */
  37609. export class TouchCamera extends FreeCamera {
  37610. /**
  37611. * Defines the touch sensibility for rotation.
  37612. * The higher the faster.
  37613. */
  37614. touchAngularSensibility: number;
  37615. /**
  37616. * Defines the touch sensibility for move.
  37617. * The higher the faster.
  37618. */
  37619. touchMoveSensibility: number;
  37620. /**
  37621. * Instantiates a new touch camera.
  37622. * This represents a FPS type of camera controlled by touch.
  37623. * This is like a universal camera minus the Gamepad controls.
  37624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37625. * @param name Define the name of the camera in the scene
  37626. * @param position Define the start position of the camera in the scene
  37627. * @param scene Define the scene the camera belongs to
  37628. */
  37629. constructor(name: string, position: Vector3, scene: Scene);
  37630. /**
  37631. * Gets the current object class name.
  37632. * @return the class name
  37633. */
  37634. getClassName(): string;
  37635. /** @hidden */ private _setupInputs(): void;
  37636. }
  37637. }
  37638. declare module BABYLON {
  37639. /**
  37640. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37641. * being tilted forward or back and left or right.
  37642. */
  37643. export class DeviceOrientationCamera extends FreeCamera {
  37644. private _initialQuaternion;
  37645. private _quaternionCache;
  37646. private _tmpDragQuaternion;
  37647. private _disablePointerInputWhenUsingDeviceOrientation;
  37648. /**
  37649. * Creates a new device orientation camera
  37650. * @param name The name of the camera
  37651. * @param position The start position camera
  37652. * @param scene The scene the camera belongs to
  37653. */
  37654. constructor(name: string, position: Vector3, scene: Scene);
  37655. /**
  37656. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37657. */
  37658. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37659. private _dragFactor;
  37660. /**
  37661. * Enabled turning on the y axis when the orientation sensor is active
  37662. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37663. */
  37664. enableHorizontalDragging(dragFactor?: number): void;
  37665. /**
  37666. * Gets the current instance class name ("DeviceOrientationCamera").
  37667. * This helps avoiding instanceof at run time.
  37668. * @returns the class name
  37669. */
  37670. getClassName(): string;
  37671. /**
  37672. * @hidden
  37673. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37674. */ private _checkInputs(): void;
  37675. /**
  37676. * Reset the camera to its default orientation on the specified axis only.
  37677. * @param axis The axis to reset
  37678. */
  37679. resetToCurrentRotation(axis?: Axis): void;
  37680. }
  37681. }
  37682. declare module BABYLON {
  37683. /**
  37684. * Defines supported buttons for XBox360 compatible gamepads
  37685. */
  37686. export enum Xbox360Button {
  37687. /** A */
  37688. A = 0,
  37689. /** B */
  37690. B = 1,
  37691. /** X */
  37692. X = 2,
  37693. /** Y */
  37694. Y = 3,
  37695. /** Start */
  37696. Start = 4,
  37697. /** Back */
  37698. Back = 5,
  37699. /** Left button */
  37700. LB = 6,
  37701. /** Right button */
  37702. RB = 7,
  37703. /** Left stick */
  37704. LeftStick = 8,
  37705. /** Right stick */
  37706. RightStick = 9
  37707. }
  37708. /** Defines values for XBox360 DPad */
  37709. export enum Xbox360Dpad {
  37710. /** Up */
  37711. Up = 0,
  37712. /** Down */
  37713. Down = 1,
  37714. /** Left */
  37715. Left = 2,
  37716. /** Right */
  37717. Right = 3
  37718. }
  37719. /**
  37720. * Defines a XBox360 gamepad
  37721. */
  37722. export class Xbox360Pad extends Gamepad {
  37723. private _leftTrigger;
  37724. private _rightTrigger;
  37725. private _onlefttriggerchanged;
  37726. private _onrighttriggerchanged;
  37727. private _onbuttondown;
  37728. private _onbuttonup;
  37729. private _ondpaddown;
  37730. private _ondpadup;
  37731. /** Observable raised when a button is pressed */
  37732. onButtonDownObservable: Observable<Xbox360Button>;
  37733. /** Observable raised when a button is released */
  37734. onButtonUpObservable: Observable<Xbox360Button>;
  37735. /** Observable raised when a pad is pressed */
  37736. onPadDownObservable: Observable<Xbox360Dpad>;
  37737. /** Observable raised when a pad is released */
  37738. onPadUpObservable: Observable<Xbox360Dpad>;
  37739. private _buttonA;
  37740. private _buttonB;
  37741. private _buttonX;
  37742. private _buttonY;
  37743. private _buttonBack;
  37744. private _buttonStart;
  37745. private _buttonLB;
  37746. private _buttonRB;
  37747. private _buttonLeftStick;
  37748. private _buttonRightStick;
  37749. private _dPadUp;
  37750. private _dPadDown;
  37751. private _dPadLeft;
  37752. private _dPadRight;
  37753. private _isXboxOnePad;
  37754. /**
  37755. * Creates a new XBox360 gamepad object
  37756. * @param id defines the id of this gamepad
  37757. * @param index defines its index
  37758. * @param gamepad defines the internal HTML gamepad object
  37759. * @param xboxOne defines if it is a XBox One gamepad
  37760. */
  37761. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37762. /**
  37763. * Defines the callback to call when left trigger is pressed
  37764. * @param callback defines the callback to use
  37765. */
  37766. onlefttriggerchanged(callback: (value: number) => void): void;
  37767. /**
  37768. * Defines the callback to call when right trigger is pressed
  37769. * @param callback defines the callback to use
  37770. */
  37771. onrighttriggerchanged(callback: (value: number) => void): void;
  37772. /**
  37773. * Gets the left trigger value
  37774. */
  37775. /**
  37776. * Sets the left trigger value
  37777. */
  37778. leftTrigger: number;
  37779. /**
  37780. * Gets the right trigger value
  37781. */
  37782. /**
  37783. * Sets the right trigger value
  37784. */
  37785. rightTrigger: number;
  37786. /**
  37787. * Defines the callback to call when a button is pressed
  37788. * @param callback defines the callback to use
  37789. */
  37790. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37791. /**
  37792. * Defines the callback to call when a button is released
  37793. * @param callback defines the callback to use
  37794. */
  37795. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37796. /**
  37797. * Defines the callback to call when a pad is pressed
  37798. * @param callback defines the callback to use
  37799. */
  37800. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37801. /**
  37802. * Defines the callback to call when a pad is released
  37803. * @param callback defines the callback to use
  37804. */
  37805. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37806. private _setButtonValue;
  37807. private _setDPadValue;
  37808. /**
  37809. * Gets the value of the `A` button
  37810. */
  37811. /**
  37812. * Sets the value of the `A` button
  37813. */
  37814. buttonA: number;
  37815. /**
  37816. * Gets the value of the `B` button
  37817. */
  37818. /**
  37819. * Sets the value of the `B` button
  37820. */
  37821. buttonB: number;
  37822. /**
  37823. * Gets the value of the `X` button
  37824. */
  37825. /**
  37826. * Sets the value of the `X` button
  37827. */
  37828. buttonX: number;
  37829. /**
  37830. * Gets the value of the `Y` button
  37831. */
  37832. /**
  37833. * Sets the value of the `Y` button
  37834. */
  37835. buttonY: number;
  37836. /**
  37837. * Gets the value of the `Start` button
  37838. */
  37839. /**
  37840. * Sets the value of the `Start` button
  37841. */
  37842. buttonStart: number;
  37843. /**
  37844. * Gets the value of the `Back` button
  37845. */
  37846. /**
  37847. * Sets the value of the `Back` button
  37848. */
  37849. buttonBack: number;
  37850. /**
  37851. * Gets the value of the `Left` button
  37852. */
  37853. /**
  37854. * Sets the value of the `Left` button
  37855. */
  37856. buttonLB: number;
  37857. /**
  37858. * Gets the value of the `Right` button
  37859. */
  37860. /**
  37861. * Sets the value of the `Right` button
  37862. */
  37863. buttonRB: number;
  37864. /**
  37865. * Gets the value of the Left joystick
  37866. */
  37867. /**
  37868. * Sets the value of the Left joystick
  37869. */
  37870. buttonLeftStick: number;
  37871. /**
  37872. * Gets the value of the Right joystick
  37873. */
  37874. /**
  37875. * Sets the value of the Right joystick
  37876. */
  37877. buttonRightStick: number;
  37878. /**
  37879. * Gets the value of D-pad up
  37880. */
  37881. /**
  37882. * Sets the value of D-pad up
  37883. */
  37884. dPadUp: number;
  37885. /**
  37886. * Gets the value of D-pad down
  37887. */
  37888. /**
  37889. * Sets the value of D-pad down
  37890. */
  37891. dPadDown: number;
  37892. /**
  37893. * Gets the value of D-pad left
  37894. */
  37895. /**
  37896. * Sets the value of D-pad left
  37897. */
  37898. dPadLeft: number;
  37899. /**
  37900. * Gets the value of D-pad right
  37901. */
  37902. /**
  37903. * Sets the value of D-pad right
  37904. */
  37905. dPadRight: number;
  37906. /**
  37907. * Force the gamepad to synchronize with device values
  37908. */
  37909. update(): void;
  37910. /**
  37911. * Disposes the gamepad
  37912. */
  37913. dispose(): void;
  37914. }
  37915. }
  37916. declare module BABYLON {
  37917. /**
  37918. * Defines supported buttons for DualShock compatible gamepads
  37919. */
  37920. export enum DualShockButton {
  37921. /** Cross */
  37922. Cross = 0,
  37923. /** Circle */
  37924. Circle = 1,
  37925. /** Square */
  37926. Square = 2,
  37927. /** Triangle */
  37928. Triangle = 3,
  37929. /** Options */
  37930. Options = 4,
  37931. /** Share */
  37932. Share = 5,
  37933. /** L1 */
  37934. L1 = 6,
  37935. /** R1 */
  37936. R1 = 7,
  37937. /** Left stick */
  37938. LeftStick = 8,
  37939. /** Right stick */
  37940. RightStick = 9
  37941. }
  37942. /** Defines values for DualShock DPad */
  37943. export enum DualShockDpad {
  37944. /** Up */
  37945. Up = 0,
  37946. /** Down */
  37947. Down = 1,
  37948. /** Left */
  37949. Left = 2,
  37950. /** Right */
  37951. Right = 3
  37952. }
  37953. /**
  37954. * Defines a DualShock gamepad
  37955. */
  37956. export class DualShockPad extends Gamepad {
  37957. private _leftTrigger;
  37958. private _rightTrigger;
  37959. private _onlefttriggerchanged;
  37960. private _onrighttriggerchanged;
  37961. private _onbuttondown;
  37962. private _onbuttonup;
  37963. private _ondpaddown;
  37964. private _ondpadup;
  37965. /** Observable raised when a button is pressed */
  37966. onButtonDownObservable: Observable<DualShockButton>;
  37967. /** Observable raised when a button is released */
  37968. onButtonUpObservable: Observable<DualShockButton>;
  37969. /** Observable raised when a pad is pressed */
  37970. onPadDownObservable: Observable<DualShockDpad>;
  37971. /** Observable raised when a pad is released */
  37972. onPadUpObservable: Observable<DualShockDpad>;
  37973. private _buttonCross;
  37974. private _buttonCircle;
  37975. private _buttonSquare;
  37976. private _buttonTriangle;
  37977. private _buttonShare;
  37978. private _buttonOptions;
  37979. private _buttonL1;
  37980. private _buttonR1;
  37981. private _buttonLeftStick;
  37982. private _buttonRightStick;
  37983. private _dPadUp;
  37984. private _dPadDown;
  37985. private _dPadLeft;
  37986. private _dPadRight;
  37987. /**
  37988. * Creates a new DualShock gamepad object
  37989. * @param id defines the id of this gamepad
  37990. * @param index defines its index
  37991. * @param gamepad defines the internal HTML gamepad object
  37992. */
  37993. constructor(id: string, index: number, gamepad: any);
  37994. /**
  37995. * Defines the callback to call when left trigger is pressed
  37996. * @param callback defines the callback to use
  37997. */
  37998. onlefttriggerchanged(callback: (value: number) => void): void;
  37999. /**
  38000. * Defines the callback to call when right trigger is pressed
  38001. * @param callback defines the callback to use
  38002. */
  38003. onrighttriggerchanged(callback: (value: number) => void): void;
  38004. /**
  38005. * Gets the left trigger value
  38006. */
  38007. /**
  38008. * Sets the left trigger value
  38009. */
  38010. leftTrigger: number;
  38011. /**
  38012. * Gets the right trigger value
  38013. */
  38014. /**
  38015. * Sets the right trigger value
  38016. */
  38017. rightTrigger: number;
  38018. /**
  38019. * Defines the callback to call when a button is pressed
  38020. * @param callback defines the callback to use
  38021. */
  38022. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38023. /**
  38024. * Defines the callback to call when a button is released
  38025. * @param callback defines the callback to use
  38026. */
  38027. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38028. /**
  38029. * Defines the callback to call when a pad is pressed
  38030. * @param callback defines the callback to use
  38031. */
  38032. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38033. /**
  38034. * Defines the callback to call when a pad is released
  38035. * @param callback defines the callback to use
  38036. */
  38037. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38038. private _setButtonValue;
  38039. private _setDPadValue;
  38040. /**
  38041. * Gets the value of the `Cross` button
  38042. */
  38043. /**
  38044. * Sets the value of the `Cross` button
  38045. */
  38046. buttonCross: number;
  38047. /**
  38048. * Gets the value of the `Circle` button
  38049. */
  38050. /**
  38051. * Sets the value of the `Circle` button
  38052. */
  38053. buttonCircle: number;
  38054. /**
  38055. * Gets the value of the `Square` button
  38056. */
  38057. /**
  38058. * Sets the value of the `Square` button
  38059. */
  38060. buttonSquare: number;
  38061. /**
  38062. * Gets the value of the `Triangle` button
  38063. */
  38064. /**
  38065. * Sets the value of the `Triangle` button
  38066. */
  38067. buttonTriangle: number;
  38068. /**
  38069. * Gets the value of the `Options` button
  38070. */
  38071. /**
  38072. * Sets the value of the `Options` button
  38073. */
  38074. buttonOptions: number;
  38075. /**
  38076. * Gets the value of the `Share` button
  38077. */
  38078. /**
  38079. * Sets the value of the `Share` button
  38080. */
  38081. buttonShare: number;
  38082. /**
  38083. * Gets the value of the `L1` button
  38084. */
  38085. /**
  38086. * Sets the value of the `L1` button
  38087. */
  38088. buttonL1: number;
  38089. /**
  38090. * Gets the value of the `R1` button
  38091. */
  38092. /**
  38093. * Sets the value of the `R1` button
  38094. */
  38095. buttonR1: number;
  38096. /**
  38097. * Gets the value of the Left joystick
  38098. */
  38099. /**
  38100. * Sets the value of the Left joystick
  38101. */
  38102. buttonLeftStick: number;
  38103. /**
  38104. * Gets the value of the Right joystick
  38105. */
  38106. /**
  38107. * Sets the value of the Right joystick
  38108. */
  38109. buttonRightStick: number;
  38110. /**
  38111. * Gets the value of D-pad up
  38112. */
  38113. /**
  38114. * Sets the value of D-pad up
  38115. */
  38116. dPadUp: number;
  38117. /**
  38118. * Gets the value of D-pad down
  38119. */
  38120. /**
  38121. * Sets the value of D-pad down
  38122. */
  38123. dPadDown: number;
  38124. /**
  38125. * Gets the value of D-pad left
  38126. */
  38127. /**
  38128. * Sets the value of D-pad left
  38129. */
  38130. dPadLeft: number;
  38131. /**
  38132. * Gets the value of D-pad right
  38133. */
  38134. /**
  38135. * Sets the value of D-pad right
  38136. */
  38137. dPadRight: number;
  38138. /**
  38139. * Force the gamepad to synchronize with device values
  38140. */
  38141. update(): void;
  38142. /**
  38143. * Disposes the gamepad
  38144. */
  38145. dispose(): void;
  38146. }
  38147. }
  38148. declare module BABYLON {
  38149. /**
  38150. * Manager for handling gamepads
  38151. */
  38152. export class GamepadManager {
  38153. private _scene?;
  38154. private _babylonGamepads;
  38155. private _oneGamepadConnected;
  38156. /** @hidden */ private _isMonitoring: boolean;
  38157. private _gamepadEventSupported;
  38158. private _gamepadSupport;
  38159. /**
  38160. * observable to be triggered when the gamepad controller has been connected
  38161. */
  38162. onGamepadConnectedObservable: Observable<Gamepad>;
  38163. /**
  38164. * observable to be triggered when the gamepad controller has been disconnected
  38165. */
  38166. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38167. private _onGamepadConnectedEvent;
  38168. private _onGamepadDisconnectedEvent;
  38169. /**
  38170. * Initializes the gamepad manager
  38171. * @param _scene BabylonJS scene
  38172. */
  38173. constructor(_scene?: Scene | undefined);
  38174. /**
  38175. * The gamepads in the game pad manager
  38176. */
  38177. readonly gamepads: Gamepad[];
  38178. /**
  38179. * Get the gamepad controllers based on type
  38180. * @param type The type of gamepad controller
  38181. * @returns Nullable gamepad
  38182. */
  38183. getGamepadByType(type?: number): Nullable<Gamepad>;
  38184. /**
  38185. * Disposes the gamepad manager
  38186. */
  38187. dispose(): void;
  38188. private _addNewGamepad;
  38189. private _startMonitoringGamepads;
  38190. private _stopMonitoringGamepads;
  38191. /** @hidden */ private _checkGamepadsStatus(): void;
  38192. private _updateGamepadObjects;
  38193. }
  38194. }
  38195. declare module BABYLON {
  38196. interface Scene {
  38197. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38198. /**
  38199. * Gets the gamepad manager associated with the scene
  38200. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38201. */
  38202. gamepadManager: GamepadManager;
  38203. }
  38204. /**
  38205. * Interface representing a free camera inputs manager
  38206. */
  38207. interface FreeCameraInputsManager {
  38208. /**
  38209. * Adds gamepad input support to the FreeCameraInputsManager.
  38210. * @returns the FreeCameraInputsManager
  38211. */
  38212. addGamepad(): FreeCameraInputsManager;
  38213. }
  38214. /**
  38215. * Interface representing an arc rotate camera inputs manager
  38216. */
  38217. interface ArcRotateCameraInputsManager {
  38218. /**
  38219. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38220. * @returns the camera inputs manager
  38221. */
  38222. addGamepad(): ArcRotateCameraInputsManager;
  38223. }
  38224. /**
  38225. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38226. */
  38227. export class GamepadSystemSceneComponent implements ISceneComponent {
  38228. /**
  38229. * The component name helpfull to identify the component in the list of scene components.
  38230. */
  38231. readonly name: string;
  38232. /**
  38233. * The scene the component belongs to.
  38234. */
  38235. scene: Scene;
  38236. /**
  38237. * Creates a new instance of the component for the given scene
  38238. * @param scene Defines the scene to register the component in
  38239. */
  38240. constructor(scene: Scene);
  38241. /**
  38242. * Registers the component in a given scene
  38243. */
  38244. register(): void;
  38245. /**
  38246. * Rebuilds the elements related to this component in case of
  38247. * context lost for instance.
  38248. */
  38249. rebuild(): void;
  38250. /**
  38251. * Disposes the component and the associated ressources
  38252. */
  38253. dispose(): void;
  38254. private _beforeCameraUpdate;
  38255. }
  38256. }
  38257. declare module BABYLON {
  38258. /**
  38259. * 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,
  38260. * which still works and will still be found in many Playgrounds.
  38261. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38262. */
  38263. export class UniversalCamera extends TouchCamera {
  38264. /**
  38265. * Defines the gamepad rotation sensiblity.
  38266. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38267. */
  38268. gamepadAngularSensibility: number;
  38269. /**
  38270. * Defines the gamepad move sensiblity.
  38271. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38272. */
  38273. gamepadMoveSensibility: number;
  38274. /**
  38275. * 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,
  38276. * which still works and will still be found in many Playgrounds.
  38277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38278. * @param name Define the name of the camera in the scene
  38279. * @param position Define the start position of the camera in the scene
  38280. * @param scene Define the scene the camera belongs to
  38281. */
  38282. constructor(name: string, position: Vector3, scene: Scene);
  38283. /**
  38284. * Gets the current object class name.
  38285. * @return the class name
  38286. */
  38287. getClassName(): string;
  38288. }
  38289. }
  38290. declare module BABYLON {
  38291. /**
  38292. * This represents a FPS type of camera. This is only here for back compat purpose.
  38293. * Please use the UniversalCamera instead as both are identical.
  38294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38295. */
  38296. export class GamepadCamera extends UniversalCamera {
  38297. /**
  38298. * Instantiates a new Gamepad Camera
  38299. * This represents a FPS type of camera. This is only here for back compat purpose.
  38300. * Please use the UniversalCamera instead as both are identical.
  38301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38302. * @param name Define the name of the camera in the scene
  38303. * @param position Define the start position of the camera in the scene
  38304. * @param scene Define the scene the camera belongs to
  38305. */
  38306. constructor(name: string, position: Vector3, scene: Scene);
  38307. /**
  38308. * Gets the current object class name.
  38309. * @return the class name
  38310. */
  38311. getClassName(): string;
  38312. }
  38313. }
  38314. declare module BABYLON {
  38315. /** @hidden */
  38316. export var passPixelShader: {
  38317. name: string;
  38318. shader: string;
  38319. };
  38320. }
  38321. declare module BABYLON {
  38322. /** @hidden */
  38323. export var passCubePixelShader: {
  38324. name: string;
  38325. shader: string;
  38326. };
  38327. }
  38328. declare module BABYLON {
  38329. /**
  38330. * PassPostProcess which produces an output the same as it's input
  38331. */
  38332. export class PassPostProcess extends PostProcess {
  38333. /**
  38334. * Creates the PassPostProcess
  38335. * @param name The name of the effect.
  38336. * @param options The required width/height ratio to downsize to before computing the render pass.
  38337. * @param camera The camera to apply the render pass to.
  38338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38339. * @param engine The engine which the post process will be applied. (default: current engine)
  38340. * @param reusable If the post process can be reused on the same frame. (default: false)
  38341. * @param textureType The type of texture to be used when performing the post processing.
  38342. * @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)
  38343. */
  38344. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38345. }
  38346. /**
  38347. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38348. */
  38349. export class PassCubePostProcess extends PostProcess {
  38350. private _face;
  38351. /**
  38352. * Gets or sets the cube face to display.
  38353. * * 0 is +X
  38354. * * 1 is -X
  38355. * * 2 is +Y
  38356. * * 3 is -Y
  38357. * * 4 is +Z
  38358. * * 5 is -Z
  38359. */
  38360. face: number;
  38361. /**
  38362. * Creates the PassCubePostProcess
  38363. * @param name The name of the effect.
  38364. * @param options The required width/height ratio to downsize to before computing the render pass.
  38365. * @param camera The camera to apply the render pass to.
  38366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38367. * @param engine The engine which the post process will be applied. (default: current engine)
  38368. * @param reusable If the post process can be reused on the same frame. (default: false)
  38369. * @param textureType The type of texture to be used when performing the post processing.
  38370. * @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)
  38371. */
  38372. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38373. }
  38374. }
  38375. declare module BABYLON {
  38376. /** @hidden */
  38377. export var anaglyphPixelShader: {
  38378. name: string;
  38379. shader: string;
  38380. };
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * Postprocess used to generate anaglyphic rendering
  38385. */
  38386. export class AnaglyphPostProcess extends PostProcess {
  38387. private _passedProcess;
  38388. /**
  38389. * Creates a new AnaglyphPostProcess
  38390. * @param name defines postprocess name
  38391. * @param options defines creation options or target ratio scale
  38392. * @param rigCameras defines cameras using this postprocess
  38393. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38394. * @param engine defines hosting engine
  38395. * @param reusable defines if the postprocess will be reused multiple times per frame
  38396. */
  38397. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38398. }
  38399. }
  38400. declare module BABYLON {
  38401. /**
  38402. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38403. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38404. */
  38405. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38406. /**
  38407. * Creates a new AnaglyphArcRotateCamera
  38408. * @param name defines camera name
  38409. * @param alpha defines alpha angle (in radians)
  38410. * @param beta defines beta angle (in radians)
  38411. * @param radius defines radius
  38412. * @param target defines camera target
  38413. * @param interaxialDistance defines distance between each color axis
  38414. * @param scene defines the hosting scene
  38415. */
  38416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38417. /**
  38418. * Gets camera class name
  38419. * @returns AnaglyphArcRotateCamera
  38420. */
  38421. getClassName(): string;
  38422. }
  38423. }
  38424. declare module BABYLON {
  38425. /**
  38426. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38427. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38428. */
  38429. export class AnaglyphFreeCamera extends FreeCamera {
  38430. /**
  38431. * Creates a new AnaglyphFreeCamera
  38432. * @param name defines camera name
  38433. * @param position defines initial position
  38434. * @param interaxialDistance defines distance between each color axis
  38435. * @param scene defines the hosting scene
  38436. */
  38437. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38438. /**
  38439. * Gets camera class name
  38440. * @returns AnaglyphFreeCamera
  38441. */
  38442. getClassName(): string;
  38443. }
  38444. }
  38445. declare module BABYLON {
  38446. /**
  38447. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38449. */
  38450. export class AnaglyphGamepadCamera extends GamepadCamera {
  38451. /**
  38452. * Creates a new AnaglyphGamepadCamera
  38453. * @param name defines camera name
  38454. * @param position defines initial position
  38455. * @param interaxialDistance defines distance between each color axis
  38456. * @param scene defines the hosting scene
  38457. */
  38458. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38459. /**
  38460. * Gets camera class name
  38461. * @returns AnaglyphGamepadCamera
  38462. */
  38463. getClassName(): string;
  38464. }
  38465. }
  38466. declare module BABYLON {
  38467. /**
  38468. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38469. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38470. */
  38471. export class AnaglyphUniversalCamera extends UniversalCamera {
  38472. /**
  38473. * Creates a new AnaglyphUniversalCamera
  38474. * @param name defines camera name
  38475. * @param position defines initial position
  38476. * @param interaxialDistance defines distance between each color axis
  38477. * @param scene defines the hosting scene
  38478. */
  38479. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38480. /**
  38481. * Gets camera class name
  38482. * @returns AnaglyphUniversalCamera
  38483. */
  38484. getClassName(): string;
  38485. }
  38486. }
  38487. declare module BABYLON {
  38488. /** @hidden */
  38489. export var stereoscopicInterlacePixelShader: {
  38490. name: string;
  38491. shader: string;
  38492. };
  38493. }
  38494. declare module BABYLON {
  38495. /**
  38496. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38497. */
  38498. export class StereoscopicInterlacePostProcess extends PostProcess {
  38499. private _stepSize;
  38500. private _passedProcess;
  38501. /**
  38502. * Initializes a StereoscopicInterlacePostProcess
  38503. * @param name The name of the effect.
  38504. * @param rigCameras The rig cameras to be appled to the post process
  38505. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38507. * @param engine The engine which the post process will be applied. (default: current engine)
  38508. * @param reusable If the post process can be reused on the same frame. (default: false)
  38509. */
  38510. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38511. }
  38512. }
  38513. declare module BABYLON {
  38514. /**
  38515. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38516. * @see http://doc.babylonjs.com/features/cameras
  38517. */
  38518. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38519. /**
  38520. * Creates a new StereoscopicArcRotateCamera
  38521. * @param name defines camera name
  38522. * @param alpha defines alpha angle (in radians)
  38523. * @param beta defines beta angle (in radians)
  38524. * @param radius defines radius
  38525. * @param target defines camera target
  38526. * @param interaxialDistance defines distance between each color axis
  38527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38528. * @param scene defines the hosting scene
  38529. */
  38530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38531. /**
  38532. * Gets camera class name
  38533. * @returns StereoscopicArcRotateCamera
  38534. */
  38535. getClassName(): string;
  38536. }
  38537. }
  38538. declare module BABYLON {
  38539. /**
  38540. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38541. * @see http://doc.babylonjs.com/features/cameras
  38542. */
  38543. export class StereoscopicFreeCamera extends FreeCamera {
  38544. /**
  38545. * Creates a new StereoscopicFreeCamera
  38546. * @param name defines camera name
  38547. * @param position defines initial position
  38548. * @param interaxialDistance defines distance between each color axis
  38549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38550. * @param scene defines the hosting scene
  38551. */
  38552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38553. /**
  38554. * Gets camera class name
  38555. * @returns StereoscopicFreeCamera
  38556. */
  38557. getClassName(): string;
  38558. }
  38559. }
  38560. declare module BABYLON {
  38561. /**
  38562. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38563. * @see http://doc.babylonjs.com/features/cameras
  38564. */
  38565. export class StereoscopicGamepadCamera extends GamepadCamera {
  38566. /**
  38567. * Creates a new StereoscopicGamepadCamera
  38568. * @param name defines camera name
  38569. * @param position defines initial position
  38570. * @param interaxialDistance defines distance between each color axis
  38571. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38572. * @param scene defines the hosting scene
  38573. */
  38574. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38575. /**
  38576. * Gets camera class name
  38577. * @returns StereoscopicGamepadCamera
  38578. */
  38579. getClassName(): string;
  38580. }
  38581. }
  38582. declare module BABYLON {
  38583. /**
  38584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38585. * @see http://doc.babylonjs.com/features/cameras
  38586. */
  38587. export class StereoscopicUniversalCamera extends UniversalCamera {
  38588. /**
  38589. * Creates a new StereoscopicUniversalCamera
  38590. * @param name defines camera name
  38591. * @param position defines initial position
  38592. * @param interaxialDistance defines distance between each color axis
  38593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38594. * @param scene defines the hosting scene
  38595. */
  38596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38597. /**
  38598. * Gets camera class name
  38599. * @returns StereoscopicUniversalCamera
  38600. */
  38601. getClassName(): string;
  38602. }
  38603. }
  38604. declare module BABYLON {
  38605. /**
  38606. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38607. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38608. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38609. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38610. */
  38611. export class VirtualJoysticksCamera extends FreeCamera {
  38612. /**
  38613. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38614. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38615. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38616. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38617. * @param name Define the name of the camera in the scene
  38618. * @param position Define the start position of the camera in the scene
  38619. * @param scene Define the scene the camera belongs to
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene);
  38622. /**
  38623. * Gets the current object class name.
  38624. * @return the class name
  38625. */
  38626. getClassName(): string;
  38627. }
  38628. }
  38629. declare module BABYLON {
  38630. /**
  38631. * This represents all the required metrics to create a VR camera.
  38632. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38633. */
  38634. export class VRCameraMetrics {
  38635. /**
  38636. * Define the horizontal resolution off the screen.
  38637. */
  38638. hResolution: number;
  38639. /**
  38640. * Define the vertical resolution off the screen.
  38641. */
  38642. vResolution: number;
  38643. /**
  38644. * Define the horizontal screen size.
  38645. */
  38646. hScreenSize: number;
  38647. /**
  38648. * Define the vertical screen size.
  38649. */
  38650. vScreenSize: number;
  38651. /**
  38652. * Define the vertical screen center position.
  38653. */
  38654. vScreenCenter: number;
  38655. /**
  38656. * Define the distance of the eyes to the screen.
  38657. */
  38658. eyeToScreenDistance: number;
  38659. /**
  38660. * Define the distance between both lenses
  38661. */
  38662. lensSeparationDistance: number;
  38663. /**
  38664. * Define the distance between both viewer's eyes.
  38665. */
  38666. interpupillaryDistance: number;
  38667. /**
  38668. * Define the distortion factor of the VR postprocess.
  38669. * Please, touch with care.
  38670. */
  38671. distortionK: number[];
  38672. /**
  38673. * Define the chromatic aberration correction factors for the VR post process.
  38674. */
  38675. chromaAbCorrection: number[];
  38676. /**
  38677. * Define the scale factor of the post process.
  38678. * The smaller the better but the slower.
  38679. */
  38680. postProcessScaleFactor: number;
  38681. /**
  38682. * Define an offset for the lens center.
  38683. */
  38684. lensCenterOffset: number;
  38685. /**
  38686. * Define if the current vr camera should compensate the distortion of the lense or not.
  38687. */
  38688. compensateDistortion: boolean;
  38689. /**
  38690. * Defines if multiview should be enabled when rendering (Default: false)
  38691. */
  38692. multiviewEnabled: boolean;
  38693. /**
  38694. * Gets the rendering aspect ratio based on the provided resolutions.
  38695. */
  38696. readonly aspectRatio: number;
  38697. /**
  38698. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38699. */
  38700. readonly aspectRatioFov: number;
  38701. /**
  38702. * @hidden
  38703. */
  38704. readonly leftHMatrix: Matrix;
  38705. /**
  38706. * @hidden
  38707. */
  38708. readonly rightHMatrix: Matrix;
  38709. /**
  38710. * @hidden
  38711. */
  38712. readonly leftPreViewMatrix: Matrix;
  38713. /**
  38714. * @hidden
  38715. */
  38716. readonly rightPreViewMatrix: Matrix;
  38717. /**
  38718. * Get the default VRMetrics based on the most generic setup.
  38719. * @returns the default vr metrics
  38720. */
  38721. static GetDefault(): VRCameraMetrics;
  38722. }
  38723. }
  38724. declare module BABYLON {
  38725. /** @hidden */
  38726. export var vrDistortionCorrectionPixelShader: {
  38727. name: string;
  38728. shader: string;
  38729. };
  38730. }
  38731. declare module BABYLON {
  38732. /**
  38733. * VRDistortionCorrectionPostProcess used for mobile VR
  38734. */
  38735. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38736. private _isRightEye;
  38737. private _distortionFactors;
  38738. private _postProcessScaleFactor;
  38739. private _lensCenterOffset;
  38740. private _scaleIn;
  38741. private _scaleFactor;
  38742. private _lensCenter;
  38743. /**
  38744. * Initializes the VRDistortionCorrectionPostProcess
  38745. * @param name The name of the effect.
  38746. * @param camera The camera to apply the render pass to.
  38747. * @param isRightEye If this is for the right eye distortion
  38748. * @param vrMetrics All the required metrics for the VR camera
  38749. */
  38750. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38751. }
  38752. }
  38753. declare module BABYLON {
  38754. /**
  38755. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38757. */
  38758. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38759. /**
  38760. * Creates a new VRDeviceOrientationArcRotateCamera
  38761. * @param name defines camera name
  38762. * @param alpha defines the camera rotation along the logitudinal axis
  38763. * @param beta defines the camera rotation along the latitudinal axis
  38764. * @param radius defines the camera distance from its target
  38765. * @param target defines the camera target
  38766. * @param scene defines the scene the camera belongs to
  38767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38769. */
  38770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38771. /**
  38772. * Gets camera class name
  38773. * @returns VRDeviceOrientationArcRotateCamera
  38774. */
  38775. getClassName(): string;
  38776. }
  38777. }
  38778. declare module BABYLON {
  38779. /**
  38780. * Camera used to simulate VR rendering (based on FreeCamera)
  38781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38782. */
  38783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38784. /**
  38785. * Creates a new VRDeviceOrientationFreeCamera
  38786. * @param name defines camera name
  38787. * @param position defines the start position of the camera
  38788. * @param scene defines the scene the camera belongs to
  38789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38791. */
  38792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38793. /**
  38794. * Gets camera class name
  38795. * @returns VRDeviceOrientationFreeCamera
  38796. */
  38797. getClassName(): string;
  38798. }
  38799. }
  38800. declare module BABYLON {
  38801. /**
  38802. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38803. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38804. */
  38805. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38806. /**
  38807. * Creates a new VRDeviceOrientationGamepadCamera
  38808. * @param name defines camera name
  38809. * @param position defines the start position of the camera
  38810. * @param scene defines the scene the camera belongs to
  38811. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38812. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38813. */
  38814. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38815. /**
  38816. * Gets camera class name
  38817. * @returns VRDeviceOrientationGamepadCamera
  38818. */
  38819. getClassName(): string;
  38820. }
  38821. }
  38822. declare module BABYLON {
  38823. /**
  38824. * Base class of materials working in push mode in babylon JS
  38825. * @hidden
  38826. */
  38827. export class PushMaterial extends Material {
  38828. protected _activeEffect: Effect;
  38829. protected _normalMatrix: Matrix;
  38830. /**
  38831. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38832. * This means that the material can keep using a previous shader while a new one is being compiled.
  38833. * This is mostly used when shader parallel compilation is supported (true by default)
  38834. */
  38835. allowShaderHotSwapping: boolean;
  38836. constructor(name: string, scene: Scene);
  38837. getEffect(): Effect;
  38838. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38839. /**
  38840. * Binds the given world matrix to the active effect
  38841. *
  38842. * @param world the matrix to bind
  38843. */
  38844. bindOnlyWorldMatrix(world: Matrix): void;
  38845. /**
  38846. * Binds the given normal matrix to the active effect
  38847. *
  38848. * @param normalMatrix the matrix to bind
  38849. */
  38850. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38851. bind(world: Matrix, mesh?: Mesh): void;
  38852. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38853. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38854. }
  38855. }
  38856. declare module BABYLON {
  38857. /**
  38858. * This groups all the flags used to control the materials channel.
  38859. */
  38860. export class MaterialFlags {
  38861. private static _DiffuseTextureEnabled;
  38862. /**
  38863. * Are diffuse textures enabled in the application.
  38864. */
  38865. static DiffuseTextureEnabled: boolean;
  38866. private static _AmbientTextureEnabled;
  38867. /**
  38868. * Are ambient textures enabled in the application.
  38869. */
  38870. static AmbientTextureEnabled: boolean;
  38871. private static _OpacityTextureEnabled;
  38872. /**
  38873. * Are opacity textures enabled in the application.
  38874. */
  38875. static OpacityTextureEnabled: boolean;
  38876. private static _ReflectionTextureEnabled;
  38877. /**
  38878. * Are reflection textures enabled in the application.
  38879. */
  38880. static ReflectionTextureEnabled: boolean;
  38881. private static _EmissiveTextureEnabled;
  38882. /**
  38883. * Are emissive textures enabled in the application.
  38884. */
  38885. static EmissiveTextureEnabled: boolean;
  38886. private static _SpecularTextureEnabled;
  38887. /**
  38888. * Are specular textures enabled in the application.
  38889. */
  38890. static SpecularTextureEnabled: boolean;
  38891. private static _BumpTextureEnabled;
  38892. /**
  38893. * Are bump textures enabled in the application.
  38894. */
  38895. static BumpTextureEnabled: boolean;
  38896. private static _LightmapTextureEnabled;
  38897. /**
  38898. * Are lightmap textures enabled in the application.
  38899. */
  38900. static LightmapTextureEnabled: boolean;
  38901. private static _RefractionTextureEnabled;
  38902. /**
  38903. * Are refraction textures enabled in the application.
  38904. */
  38905. static RefractionTextureEnabled: boolean;
  38906. private static _ColorGradingTextureEnabled;
  38907. /**
  38908. * Are color grading textures enabled in the application.
  38909. */
  38910. static ColorGradingTextureEnabled: boolean;
  38911. private static _FresnelEnabled;
  38912. /**
  38913. * Are fresnels enabled in the application.
  38914. */
  38915. static FresnelEnabled: boolean;
  38916. private static _ClearCoatTextureEnabled;
  38917. /**
  38918. * Are clear coat textures enabled in the application.
  38919. */
  38920. static ClearCoatTextureEnabled: boolean;
  38921. private static _ClearCoatBumpTextureEnabled;
  38922. /**
  38923. * Are clear coat bump textures enabled in the application.
  38924. */
  38925. static ClearCoatBumpTextureEnabled: boolean;
  38926. private static _ClearCoatTintTextureEnabled;
  38927. /**
  38928. * Are clear coat tint textures enabled in the application.
  38929. */
  38930. static ClearCoatTintTextureEnabled: boolean;
  38931. private static _SheenTextureEnabled;
  38932. /**
  38933. * Are sheen textures enabled in the application.
  38934. */
  38935. static SheenTextureEnabled: boolean;
  38936. private static _AnisotropicTextureEnabled;
  38937. /**
  38938. * Are anisotropic textures enabled in the application.
  38939. */
  38940. static AnisotropicTextureEnabled: boolean;
  38941. private static _ThicknessTextureEnabled;
  38942. /**
  38943. * Are thickness textures enabled in the application.
  38944. */
  38945. static ThicknessTextureEnabled: boolean;
  38946. }
  38947. }
  38948. declare module BABYLON {
  38949. /** @hidden */
  38950. export var defaultFragmentDeclaration: {
  38951. name: string;
  38952. shader: string;
  38953. };
  38954. }
  38955. declare module BABYLON {
  38956. /** @hidden */
  38957. export var defaultUboDeclaration: {
  38958. name: string;
  38959. shader: string;
  38960. };
  38961. }
  38962. declare module BABYLON {
  38963. /** @hidden */
  38964. export var lightFragmentDeclaration: {
  38965. name: string;
  38966. shader: string;
  38967. };
  38968. }
  38969. declare module BABYLON {
  38970. /** @hidden */
  38971. export var lightUboDeclaration: {
  38972. name: string;
  38973. shader: string;
  38974. };
  38975. }
  38976. declare module BABYLON {
  38977. /** @hidden */
  38978. export var lightsFragmentFunctions: {
  38979. name: string;
  38980. shader: string;
  38981. };
  38982. }
  38983. declare module BABYLON {
  38984. /** @hidden */
  38985. export var shadowsFragmentFunctions: {
  38986. name: string;
  38987. shader: string;
  38988. };
  38989. }
  38990. declare module BABYLON {
  38991. /** @hidden */
  38992. export var fresnelFunction: {
  38993. name: string;
  38994. shader: string;
  38995. };
  38996. }
  38997. declare module BABYLON {
  38998. /** @hidden */
  38999. export var reflectionFunction: {
  39000. name: string;
  39001. shader: string;
  39002. };
  39003. }
  39004. declare module BABYLON {
  39005. /** @hidden */
  39006. export var bumpFragmentFunctions: {
  39007. name: string;
  39008. shader: string;
  39009. };
  39010. }
  39011. declare module BABYLON {
  39012. /** @hidden */
  39013. export var logDepthDeclaration: {
  39014. name: string;
  39015. shader: string;
  39016. };
  39017. }
  39018. declare module BABYLON {
  39019. /** @hidden */
  39020. export var bumpFragment: {
  39021. name: string;
  39022. shader: string;
  39023. };
  39024. }
  39025. declare module BABYLON {
  39026. /** @hidden */
  39027. export var depthPrePass: {
  39028. name: string;
  39029. shader: string;
  39030. };
  39031. }
  39032. declare module BABYLON {
  39033. /** @hidden */
  39034. export var lightFragment: {
  39035. name: string;
  39036. shader: string;
  39037. };
  39038. }
  39039. declare module BABYLON {
  39040. /** @hidden */
  39041. export var logDepthFragment: {
  39042. name: string;
  39043. shader: string;
  39044. };
  39045. }
  39046. declare module BABYLON {
  39047. /** @hidden */
  39048. export var defaultPixelShader: {
  39049. name: string;
  39050. shader: string;
  39051. };
  39052. }
  39053. declare module BABYLON {
  39054. /** @hidden */
  39055. export var defaultVertexDeclaration: {
  39056. name: string;
  39057. shader: string;
  39058. };
  39059. }
  39060. declare module BABYLON {
  39061. /** @hidden */
  39062. export var bumpVertexDeclaration: {
  39063. name: string;
  39064. shader: string;
  39065. };
  39066. }
  39067. declare module BABYLON {
  39068. /** @hidden */
  39069. export var bumpVertex: {
  39070. name: string;
  39071. shader: string;
  39072. };
  39073. }
  39074. declare module BABYLON {
  39075. /** @hidden */
  39076. export var fogVertex: {
  39077. name: string;
  39078. shader: string;
  39079. };
  39080. }
  39081. declare module BABYLON {
  39082. /** @hidden */
  39083. export var shadowsVertex: {
  39084. name: string;
  39085. shader: string;
  39086. };
  39087. }
  39088. declare module BABYLON {
  39089. /** @hidden */
  39090. export var pointCloudVertex: {
  39091. name: string;
  39092. shader: string;
  39093. };
  39094. }
  39095. declare module BABYLON {
  39096. /** @hidden */
  39097. export var logDepthVertex: {
  39098. name: string;
  39099. shader: string;
  39100. };
  39101. }
  39102. declare module BABYLON {
  39103. /** @hidden */
  39104. export var defaultVertexShader: {
  39105. name: string;
  39106. shader: string;
  39107. };
  39108. }
  39109. declare module BABYLON {
  39110. /** @hidden */
  39111. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39112. MAINUV1: boolean;
  39113. MAINUV2: boolean;
  39114. DIFFUSE: boolean;
  39115. DIFFUSEDIRECTUV: number;
  39116. AMBIENT: boolean;
  39117. AMBIENTDIRECTUV: number;
  39118. OPACITY: boolean;
  39119. OPACITYDIRECTUV: number;
  39120. OPACITYRGB: boolean;
  39121. REFLECTION: boolean;
  39122. EMISSIVE: boolean;
  39123. EMISSIVEDIRECTUV: number;
  39124. SPECULAR: boolean;
  39125. SPECULARDIRECTUV: number;
  39126. BUMP: boolean;
  39127. BUMPDIRECTUV: number;
  39128. PARALLAX: boolean;
  39129. PARALLAXOCCLUSION: boolean;
  39130. SPECULAROVERALPHA: boolean;
  39131. CLIPPLANE: boolean;
  39132. CLIPPLANE2: boolean;
  39133. CLIPPLANE3: boolean;
  39134. CLIPPLANE4: boolean;
  39135. ALPHATEST: boolean;
  39136. DEPTHPREPASS: boolean;
  39137. ALPHAFROMDIFFUSE: boolean;
  39138. POINTSIZE: boolean;
  39139. FOG: boolean;
  39140. SPECULARTERM: boolean;
  39141. DIFFUSEFRESNEL: boolean;
  39142. OPACITYFRESNEL: boolean;
  39143. REFLECTIONFRESNEL: boolean;
  39144. REFRACTIONFRESNEL: boolean;
  39145. EMISSIVEFRESNEL: boolean;
  39146. FRESNEL: boolean;
  39147. NORMAL: boolean;
  39148. UV1: boolean;
  39149. UV2: boolean;
  39150. VERTEXCOLOR: boolean;
  39151. VERTEXALPHA: boolean;
  39152. NUM_BONE_INFLUENCERS: number;
  39153. BonesPerMesh: number;
  39154. BONETEXTURE: boolean;
  39155. INSTANCES: boolean;
  39156. GLOSSINESS: boolean;
  39157. ROUGHNESS: boolean;
  39158. EMISSIVEASILLUMINATION: boolean;
  39159. LINKEMISSIVEWITHDIFFUSE: boolean;
  39160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39161. LIGHTMAP: boolean;
  39162. LIGHTMAPDIRECTUV: number;
  39163. OBJECTSPACE_NORMALMAP: boolean;
  39164. USELIGHTMAPASSHADOWMAP: boolean;
  39165. REFLECTIONMAP_3D: boolean;
  39166. REFLECTIONMAP_SPHERICAL: boolean;
  39167. REFLECTIONMAP_PLANAR: boolean;
  39168. REFLECTIONMAP_CUBIC: boolean;
  39169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39170. REFLECTIONMAP_PROJECTION: boolean;
  39171. REFLECTIONMAP_SKYBOX: boolean;
  39172. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39173. REFLECTIONMAP_EXPLICIT: boolean;
  39174. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39175. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39176. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39177. INVERTCUBICMAP: boolean;
  39178. LOGARITHMICDEPTH: boolean;
  39179. REFRACTION: boolean;
  39180. REFRACTIONMAP_3D: boolean;
  39181. REFLECTIONOVERALPHA: boolean;
  39182. TWOSIDEDLIGHTING: boolean;
  39183. SHADOWFLOAT: boolean;
  39184. MORPHTARGETS: boolean;
  39185. MORPHTARGETS_NORMAL: boolean;
  39186. MORPHTARGETS_TANGENT: boolean;
  39187. MORPHTARGETS_UV: boolean;
  39188. NUM_MORPH_INFLUENCERS: number;
  39189. NONUNIFORMSCALING: boolean;
  39190. PREMULTIPLYALPHA: boolean;
  39191. IMAGEPROCESSING: boolean;
  39192. VIGNETTE: boolean;
  39193. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39194. VIGNETTEBLENDMODEOPAQUE: boolean;
  39195. TONEMAPPING: boolean;
  39196. TONEMAPPING_ACES: boolean;
  39197. CONTRAST: boolean;
  39198. COLORCURVES: boolean;
  39199. COLORGRADING: boolean;
  39200. COLORGRADING3D: boolean;
  39201. SAMPLER3DGREENDEPTH: boolean;
  39202. SAMPLER3DBGRMAP: boolean;
  39203. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39204. MULTIVIEW: boolean;
  39205. /**
  39206. * If the reflection texture on this material is in linear color space
  39207. * @hidden
  39208. */
  39209. IS_REFLECTION_LINEAR: boolean;
  39210. /**
  39211. * If the refraction texture on this material is in linear color space
  39212. * @hidden
  39213. */
  39214. IS_REFRACTION_LINEAR: boolean;
  39215. EXPOSURE: boolean;
  39216. constructor();
  39217. setReflectionMode(modeToEnable: string): void;
  39218. }
  39219. /**
  39220. * This is the default material used in Babylon. It is the best trade off between quality
  39221. * and performances.
  39222. * @see http://doc.babylonjs.com/babylon101/materials
  39223. */
  39224. export class StandardMaterial extends PushMaterial {
  39225. private _diffuseTexture;
  39226. /**
  39227. * The basic texture of the material as viewed under a light.
  39228. */
  39229. diffuseTexture: Nullable<BaseTexture>;
  39230. private _ambientTexture;
  39231. /**
  39232. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39233. */
  39234. ambientTexture: Nullable<BaseTexture>;
  39235. private _opacityTexture;
  39236. /**
  39237. * Define the transparency of the material from a texture.
  39238. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39239. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39240. */
  39241. opacityTexture: Nullable<BaseTexture>;
  39242. private _reflectionTexture;
  39243. /**
  39244. * Define the texture used to display the reflection.
  39245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39246. */
  39247. reflectionTexture: Nullable<BaseTexture>;
  39248. private _emissiveTexture;
  39249. /**
  39250. * Define texture of the material as if self lit.
  39251. * This will be mixed in the final result even in the absence of light.
  39252. */
  39253. emissiveTexture: Nullable<BaseTexture>;
  39254. private _specularTexture;
  39255. /**
  39256. * Define how the color and intensity of the highlight given by the light in the material.
  39257. */
  39258. specularTexture: Nullable<BaseTexture>;
  39259. private _bumpTexture;
  39260. /**
  39261. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39262. * 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.
  39263. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39264. */
  39265. bumpTexture: Nullable<BaseTexture>;
  39266. private _lightmapTexture;
  39267. /**
  39268. * Complex lighting can be computationally expensive to compute at runtime.
  39269. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39270. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39271. */
  39272. lightmapTexture: Nullable<BaseTexture>;
  39273. private _refractionTexture;
  39274. /**
  39275. * Define the texture used to display the refraction.
  39276. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39277. */
  39278. refractionTexture: Nullable<BaseTexture>;
  39279. /**
  39280. * The color of the material lit by the environmental background lighting.
  39281. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39282. */
  39283. ambientColor: Color3;
  39284. /**
  39285. * The basic color of the material as viewed under a light.
  39286. */
  39287. diffuseColor: Color3;
  39288. /**
  39289. * Define how the color and intensity of the highlight given by the light in the material.
  39290. */
  39291. specularColor: Color3;
  39292. /**
  39293. * Define the color of the material as if self lit.
  39294. * This will be mixed in the final result even in the absence of light.
  39295. */
  39296. emissiveColor: Color3;
  39297. /**
  39298. * Defines how sharp are the highlights in the material.
  39299. * The bigger the value the sharper giving a more glossy feeling to the result.
  39300. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39301. */
  39302. specularPower: number;
  39303. private _useAlphaFromDiffuseTexture;
  39304. /**
  39305. * Does the transparency come from the diffuse texture alpha channel.
  39306. */
  39307. useAlphaFromDiffuseTexture: boolean;
  39308. private _useEmissiveAsIllumination;
  39309. /**
  39310. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39311. */
  39312. useEmissiveAsIllumination: boolean;
  39313. private _linkEmissiveWithDiffuse;
  39314. /**
  39315. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39316. * the emissive level when the final color is close to one.
  39317. */
  39318. linkEmissiveWithDiffuse: boolean;
  39319. private _useSpecularOverAlpha;
  39320. /**
  39321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39323. */
  39324. useSpecularOverAlpha: boolean;
  39325. private _useReflectionOverAlpha;
  39326. /**
  39327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39329. */
  39330. useReflectionOverAlpha: boolean;
  39331. private _disableLighting;
  39332. /**
  39333. * Does lights from the scene impacts this material.
  39334. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39335. */
  39336. disableLighting: boolean;
  39337. private _useObjectSpaceNormalMap;
  39338. /**
  39339. * Allows using an object space normal map (instead of tangent space).
  39340. */
  39341. useObjectSpaceNormalMap: boolean;
  39342. private _useParallax;
  39343. /**
  39344. * Is parallax enabled or not.
  39345. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39346. */
  39347. useParallax: boolean;
  39348. private _useParallaxOcclusion;
  39349. /**
  39350. * Is parallax occlusion enabled or not.
  39351. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39352. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39353. */
  39354. useParallaxOcclusion: boolean;
  39355. /**
  39356. * 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.
  39357. */
  39358. parallaxScaleBias: number;
  39359. private _roughness;
  39360. /**
  39361. * Helps to define how blurry the reflections should appears in the material.
  39362. */
  39363. roughness: number;
  39364. /**
  39365. * In case of refraction, define the value of the index of refraction.
  39366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39367. */
  39368. indexOfRefraction: number;
  39369. /**
  39370. * Invert the refraction texture alongside the y axis.
  39371. * It can be useful with procedural textures or probe for instance.
  39372. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39373. */
  39374. invertRefractionY: boolean;
  39375. /**
  39376. * Defines the alpha limits in alpha test mode.
  39377. */
  39378. alphaCutOff: number;
  39379. private _useLightmapAsShadowmap;
  39380. /**
  39381. * In case of light mapping, define whether the map contains light or shadow informations.
  39382. */
  39383. useLightmapAsShadowmap: boolean;
  39384. private _diffuseFresnelParameters;
  39385. /**
  39386. * Define the diffuse fresnel parameters of the material.
  39387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39388. */
  39389. diffuseFresnelParameters: FresnelParameters;
  39390. private _opacityFresnelParameters;
  39391. /**
  39392. * Define the opacity fresnel parameters of the material.
  39393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39394. */
  39395. opacityFresnelParameters: FresnelParameters;
  39396. private _reflectionFresnelParameters;
  39397. /**
  39398. * Define the reflection fresnel parameters of the material.
  39399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39400. */
  39401. reflectionFresnelParameters: FresnelParameters;
  39402. private _refractionFresnelParameters;
  39403. /**
  39404. * Define the refraction fresnel parameters of the material.
  39405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39406. */
  39407. refractionFresnelParameters: FresnelParameters;
  39408. private _emissiveFresnelParameters;
  39409. /**
  39410. * Define the emissive fresnel parameters of the material.
  39411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39412. */
  39413. emissiveFresnelParameters: FresnelParameters;
  39414. private _useReflectionFresnelFromSpecular;
  39415. /**
  39416. * If true automatically deducts the fresnels values from the material specularity.
  39417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39418. */
  39419. useReflectionFresnelFromSpecular: boolean;
  39420. private _useGlossinessFromSpecularMapAlpha;
  39421. /**
  39422. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39423. */
  39424. useGlossinessFromSpecularMapAlpha: boolean;
  39425. private _maxSimultaneousLights;
  39426. /**
  39427. * Defines the maximum number of lights that can be used in the material
  39428. */
  39429. maxSimultaneousLights: number;
  39430. private _invertNormalMapX;
  39431. /**
  39432. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39433. */
  39434. invertNormalMapX: boolean;
  39435. private _invertNormalMapY;
  39436. /**
  39437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39438. */
  39439. invertNormalMapY: boolean;
  39440. private _twoSidedLighting;
  39441. /**
  39442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39443. */
  39444. twoSidedLighting: boolean;
  39445. /**
  39446. * Default configuration related to image processing available in the standard Material.
  39447. */
  39448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39449. /**
  39450. * Gets the image processing configuration used either in this material.
  39451. */
  39452. /**
  39453. * Sets the Default image processing configuration used either in the this material.
  39454. *
  39455. * If sets to null, the scene one is in use.
  39456. */
  39457. imageProcessingConfiguration: ImageProcessingConfiguration;
  39458. /**
  39459. * Keep track of the image processing observer to allow dispose and replace.
  39460. */
  39461. private _imageProcessingObserver;
  39462. /**
  39463. * Attaches a new image processing configuration to the Standard Material.
  39464. * @param configuration
  39465. */
  39466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39467. /**
  39468. * Gets wether the color curves effect is enabled.
  39469. */
  39470. /**
  39471. * Sets wether the color curves effect is enabled.
  39472. */
  39473. cameraColorCurvesEnabled: boolean;
  39474. /**
  39475. * Gets wether the color grading effect is enabled.
  39476. */
  39477. /**
  39478. * Gets wether the color grading effect is enabled.
  39479. */
  39480. cameraColorGradingEnabled: boolean;
  39481. /**
  39482. * Gets wether tonemapping is enabled or not.
  39483. */
  39484. /**
  39485. * Sets wether tonemapping is enabled or not
  39486. */
  39487. cameraToneMappingEnabled: boolean;
  39488. /**
  39489. * The camera exposure used on this material.
  39490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39491. * This corresponds to a photographic exposure.
  39492. */
  39493. /**
  39494. * The camera exposure used on this material.
  39495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39496. * This corresponds to a photographic exposure.
  39497. */
  39498. cameraExposure: number;
  39499. /**
  39500. * Gets The camera contrast used on this material.
  39501. */
  39502. /**
  39503. * Sets The camera contrast used on this material.
  39504. */
  39505. cameraContrast: number;
  39506. /**
  39507. * Gets the Color Grading 2D Lookup Texture.
  39508. */
  39509. /**
  39510. * Sets the Color Grading 2D Lookup Texture.
  39511. */
  39512. cameraColorGradingTexture: Nullable<BaseTexture>;
  39513. /**
  39514. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39515. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39516. * 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;
  39517. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39518. */
  39519. /**
  39520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39522. * 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;
  39523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39524. */
  39525. cameraColorCurves: Nullable<ColorCurves>;
  39526. /**
  39527. * Custom callback helping to override the default shader used in the material.
  39528. */
  39529. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39530. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39531. protected _worldViewProjectionMatrix: Matrix;
  39532. protected _globalAmbientColor: Color3;
  39533. protected _useLogarithmicDepth: boolean;
  39534. protected _rebuildInParallel: boolean;
  39535. /**
  39536. * Instantiates a new standard material.
  39537. * This is the default material used in Babylon. It is the best trade off between quality
  39538. * and performances.
  39539. * @see http://doc.babylonjs.com/babylon101/materials
  39540. * @param name Define the name of the material in the scene
  39541. * @param scene Define the scene the material belong to
  39542. */
  39543. constructor(name: string, scene: Scene);
  39544. /**
  39545. * Gets a boolean indicating that current material needs to register RTT
  39546. */
  39547. readonly hasRenderTargetTextures: boolean;
  39548. /**
  39549. * Gets the current class name of the material e.g. "StandardMaterial"
  39550. * Mainly use in serialization.
  39551. * @returns the class name
  39552. */
  39553. getClassName(): string;
  39554. /**
  39555. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39556. * You can try switching to logarithmic depth.
  39557. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39558. */
  39559. useLogarithmicDepth: boolean;
  39560. /**
  39561. * Specifies if the material will require alpha blending
  39562. * @returns a boolean specifying if alpha blending is needed
  39563. */
  39564. needAlphaBlending(): boolean;
  39565. /**
  39566. * Specifies if this material should be rendered in alpha test mode
  39567. * @returns a boolean specifying if an alpha test is needed.
  39568. */
  39569. needAlphaTesting(): boolean;
  39570. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39571. /**
  39572. * Get the texture used for alpha test purpose.
  39573. * @returns the diffuse texture in case of the standard material.
  39574. */
  39575. getAlphaTestTexture(): Nullable<BaseTexture>;
  39576. /**
  39577. * Get if the submesh is ready to be used and all its information available.
  39578. * Child classes can use it to update shaders
  39579. * @param mesh defines the mesh to check
  39580. * @param subMesh defines which submesh to check
  39581. * @param useInstances specifies that instances should be used
  39582. * @returns a boolean indicating that the submesh is ready or not
  39583. */
  39584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39585. /**
  39586. * Builds the material UBO layouts.
  39587. * Used internally during the effect preparation.
  39588. */
  39589. buildUniformLayout(): void;
  39590. /**
  39591. * Unbinds the material from the mesh
  39592. */
  39593. unbind(): void;
  39594. /**
  39595. * Binds the submesh to this material by preparing the effect and shader to draw
  39596. * @param world defines the world transformation matrix
  39597. * @param mesh defines the mesh containing the submesh
  39598. * @param subMesh defines the submesh to bind the material to
  39599. */
  39600. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39601. /**
  39602. * Get the list of animatables in the material.
  39603. * @returns the list of animatables object used in the material
  39604. */
  39605. getAnimatables(): IAnimatable[];
  39606. /**
  39607. * Gets the active textures from the material
  39608. * @returns an array of textures
  39609. */
  39610. getActiveTextures(): BaseTexture[];
  39611. /**
  39612. * Specifies if the material uses a texture
  39613. * @param texture defines the texture to check against the material
  39614. * @returns a boolean specifying if the material uses the texture
  39615. */
  39616. hasTexture(texture: BaseTexture): boolean;
  39617. /**
  39618. * Disposes the material
  39619. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39620. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39621. */
  39622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39623. /**
  39624. * Makes a duplicate of the material, and gives it a new name
  39625. * @param name defines the new name for the duplicated material
  39626. * @returns the cloned material
  39627. */
  39628. clone(name: string): StandardMaterial;
  39629. /**
  39630. * Serializes this material in a JSON representation
  39631. * @returns the serialized material object
  39632. */
  39633. serialize(): any;
  39634. /**
  39635. * Creates a standard material from parsed material data
  39636. * @param source defines the JSON representation of the material
  39637. * @param scene defines the hosting scene
  39638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39639. * @returns a new standard material
  39640. */
  39641. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39642. /**
  39643. * Are diffuse textures enabled in the application.
  39644. */
  39645. static DiffuseTextureEnabled: boolean;
  39646. /**
  39647. * Are ambient textures enabled in the application.
  39648. */
  39649. static AmbientTextureEnabled: boolean;
  39650. /**
  39651. * Are opacity textures enabled in the application.
  39652. */
  39653. static OpacityTextureEnabled: boolean;
  39654. /**
  39655. * Are reflection textures enabled in the application.
  39656. */
  39657. static ReflectionTextureEnabled: boolean;
  39658. /**
  39659. * Are emissive textures enabled in the application.
  39660. */
  39661. static EmissiveTextureEnabled: boolean;
  39662. /**
  39663. * Are specular textures enabled in the application.
  39664. */
  39665. static SpecularTextureEnabled: boolean;
  39666. /**
  39667. * Are bump textures enabled in the application.
  39668. */
  39669. static BumpTextureEnabled: boolean;
  39670. /**
  39671. * Are lightmap textures enabled in the application.
  39672. */
  39673. static LightmapTextureEnabled: boolean;
  39674. /**
  39675. * Are refraction textures enabled in the application.
  39676. */
  39677. static RefractionTextureEnabled: boolean;
  39678. /**
  39679. * Are color grading textures enabled in the application.
  39680. */
  39681. static ColorGradingTextureEnabled: boolean;
  39682. /**
  39683. * Are fresnels enabled in the application.
  39684. */
  39685. static FresnelEnabled: boolean;
  39686. }
  39687. }
  39688. declare module BABYLON {
  39689. /**
  39690. * A class extending Texture allowing drawing on a texture
  39691. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39692. */
  39693. export class DynamicTexture extends Texture {
  39694. private _generateMipMaps;
  39695. private _canvas;
  39696. private _context;
  39697. private _engine;
  39698. /**
  39699. * Creates a DynamicTexture
  39700. * @param name defines the name of the texture
  39701. * @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
  39702. * @param scene defines the scene where you want the texture
  39703. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39704. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39705. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39706. */
  39707. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39708. /**
  39709. * Get the current class name of the texture useful for serialization or dynamic coding.
  39710. * @returns "DynamicTexture"
  39711. */
  39712. getClassName(): string;
  39713. /**
  39714. * Gets the current state of canRescale
  39715. */
  39716. readonly canRescale: boolean;
  39717. private _recreate;
  39718. /**
  39719. * Scales the texture
  39720. * @param ratio the scale factor to apply to both width and height
  39721. */
  39722. scale(ratio: number): void;
  39723. /**
  39724. * Resizes the texture
  39725. * @param width the new width
  39726. * @param height the new height
  39727. */
  39728. scaleTo(width: number, height: number): void;
  39729. /**
  39730. * Gets the context of the canvas used by the texture
  39731. * @returns the canvas context of the dynamic texture
  39732. */
  39733. getContext(): CanvasRenderingContext2D;
  39734. /**
  39735. * Clears the texture
  39736. */
  39737. clear(): void;
  39738. /**
  39739. * Updates the texture
  39740. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39741. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39742. */
  39743. update(invertY?: boolean, premulAlpha?: boolean): void;
  39744. /**
  39745. * Draws text onto the texture
  39746. * @param text defines the text to be drawn
  39747. * @param x defines the placement of the text from the left
  39748. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39749. * @param font defines the font to be used with font-style, font-size, font-name
  39750. * @param color defines the color used for the text
  39751. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39752. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39753. * @param update defines whether texture is immediately update (default is true)
  39754. */
  39755. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39756. /**
  39757. * Clones the texture
  39758. * @returns the clone of the texture.
  39759. */
  39760. clone(): DynamicTexture;
  39761. /**
  39762. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39763. * @returns a serialized dynamic texture object
  39764. */
  39765. serialize(): any;
  39766. /** @hidden */ private _rebuild(): void;
  39767. }
  39768. }
  39769. declare module BABYLON {
  39770. /** @hidden */
  39771. export var imageProcessingPixelShader: {
  39772. name: string;
  39773. shader: string;
  39774. };
  39775. }
  39776. declare module BABYLON {
  39777. /**
  39778. * ImageProcessingPostProcess
  39779. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39780. */
  39781. export class ImageProcessingPostProcess extends PostProcess {
  39782. /**
  39783. * Default configuration related to image processing available in the PBR Material.
  39784. */
  39785. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39786. /**
  39787. * Gets the image processing configuration used either in this material.
  39788. */
  39789. /**
  39790. * Sets the Default image processing configuration used either in the this material.
  39791. *
  39792. * If sets to null, the scene one is in use.
  39793. */
  39794. imageProcessingConfiguration: ImageProcessingConfiguration;
  39795. /**
  39796. * Keep track of the image processing observer to allow dispose and replace.
  39797. */
  39798. private _imageProcessingObserver;
  39799. /**
  39800. * Attaches a new image processing configuration to the PBR Material.
  39801. * @param configuration
  39802. */
  39803. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39804. /**
  39805. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39806. */
  39807. /**
  39808. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39809. */
  39810. colorCurves: Nullable<ColorCurves>;
  39811. /**
  39812. * Gets wether the color curves effect is enabled.
  39813. */
  39814. /**
  39815. * Sets wether the color curves effect is enabled.
  39816. */
  39817. colorCurvesEnabled: boolean;
  39818. /**
  39819. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39820. */
  39821. /**
  39822. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39823. */
  39824. colorGradingTexture: Nullable<BaseTexture>;
  39825. /**
  39826. * Gets wether the color grading effect is enabled.
  39827. */
  39828. /**
  39829. * Gets wether the color grading effect is enabled.
  39830. */
  39831. colorGradingEnabled: boolean;
  39832. /**
  39833. * Gets exposure used in the effect.
  39834. */
  39835. /**
  39836. * Sets exposure used in the effect.
  39837. */
  39838. exposure: number;
  39839. /**
  39840. * Gets wether tonemapping is enabled or not.
  39841. */
  39842. /**
  39843. * Sets wether tonemapping is enabled or not
  39844. */
  39845. toneMappingEnabled: boolean;
  39846. /**
  39847. * Gets the type of tone mapping effect.
  39848. */
  39849. /**
  39850. * Sets the type of tone mapping effect.
  39851. */
  39852. toneMappingType: number;
  39853. /**
  39854. * Gets contrast used in the effect.
  39855. */
  39856. /**
  39857. * Sets contrast used in the effect.
  39858. */
  39859. contrast: number;
  39860. /**
  39861. * Gets Vignette stretch size.
  39862. */
  39863. /**
  39864. * Sets Vignette stretch size.
  39865. */
  39866. vignetteStretch: number;
  39867. /**
  39868. * Gets Vignette centre X Offset.
  39869. */
  39870. /**
  39871. * Sets Vignette centre X Offset.
  39872. */
  39873. vignetteCentreX: number;
  39874. /**
  39875. * Gets Vignette centre Y Offset.
  39876. */
  39877. /**
  39878. * Sets Vignette centre Y Offset.
  39879. */
  39880. vignetteCentreY: number;
  39881. /**
  39882. * Gets Vignette weight or intensity of the vignette effect.
  39883. */
  39884. /**
  39885. * Sets Vignette weight or intensity of the vignette effect.
  39886. */
  39887. vignetteWeight: number;
  39888. /**
  39889. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39890. * if vignetteEnabled is set to true.
  39891. */
  39892. /**
  39893. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39894. * if vignetteEnabled is set to true.
  39895. */
  39896. vignetteColor: Color4;
  39897. /**
  39898. * Gets Camera field of view used by the Vignette effect.
  39899. */
  39900. /**
  39901. * Sets Camera field of view used by the Vignette effect.
  39902. */
  39903. vignetteCameraFov: number;
  39904. /**
  39905. * Gets the vignette blend mode allowing different kind of effect.
  39906. */
  39907. /**
  39908. * Sets the vignette blend mode allowing different kind of effect.
  39909. */
  39910. vignetteBlendMode: number;
  39911. /**
  39912. * Gets wether the vignette effect is enabled.
  39913. */
  39914. /**
  39915. * Sets wether the vignette effect is enabled.
  39916. */
  39917. vignetteEnabled: boolean;
  39918. private _fromLinearSpace;
  39919. /**
  39920. * Gets wether the input of the processing is in Gamma or Linear Space.
  39921. */
  39922. /**
  39923. * Sets wether the input of the processing is in Gamma or Linear Space.
  39924. */
  39925. fromLinearSpace: boolean;
  39926. /**
  39927. * Defines cache preventing GC.
  39928. */
  39929. private _defines;
  39930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39931. /**
  39932. * "ImageProcessingPostProcess"
  39933. * @returns "ImageProcessingPostProcess"
  39934. */
  39935. getClassName(): string;
  39936. protected _updateParameters(): void;
  39937. dispose(camera?: Camera): void;
  39938. }
  39939. }
  39940. declare module BABYLON {
  39941. /**
  39942. * Class containing static functions to help procedurally build meshes
  39943. */
  39944. export class GroundBuilder {
  39945. /**
  39946. * Creates a ground mesh
  39947. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39948. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39950. * @param name defines the name of the mesh
  39951. * @param options defines the options used to create the mesh
  39952. * @param scene defines the hosting scene
  39953. * @returns the ground mesh
  39954. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39955. */
  39956. static CreateGround(name: string, options: {
  39957. width?: number;
  39958. height?: number;
  39959. subdivisions?: number;
  39960. subdivisionsX?: number;
  39961. subdivisionsY?: number;
  39962. updatable?: boolean;
  39963. }, scene: any): Mesh;
  39964. /**
  39965. * Creates a tiled ground mesh
  39966. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39967. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39968. * * 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
  39969. * * 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
  39970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39971. * @param name defines the name of the mesh
  39972. * @param options defines the options used to create the mesh
  39973. * @param scene defines the hosting scene
  39974. * @returns the tiled ground mesh
  39975. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39976. */
  39977. static CreateTiledGround(name: string, options: {
  39978. xmin: number;
  39979. zmin: number;
  39980. xmax: number;
  39981. zmax: number;
  39982. subdivisions?: {
  39983. w: number;
  39984. h: number;
  39985. };
  39986. precision?: {
  39987. w: number;
  39988. h: number;
  39989. };
  39990. updatable?: boolean;
  39991. }, scene?: Nullable<Scene>): Mesh;
  39992. /**
  39993. * Creates a ground mesh from a height map
  39994. * * The parameter `url` sets the URL of the height map image resource.
  39995. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39996. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39997. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39998. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39999. * * 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.
  40000. * * 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).
  40001. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40003. * @param name defines the name of the mesh
  40004. * @param url defines the url to the height map
  40005. * @param options defines the options used to create the mesh
  40006. * @param scene defines the hosting scene
  40007. * @returns the ground mesh
  40008. * @see https://doc.babylonjs.com/babylon101/height_map
  40009. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40010. */
  40011. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40012. width?: number;
  40013. height?: number;
  40014. subdivisions?: number;
  40015. minHeight?: number;
  40016. maxHeight?: number;
  40017. colorFilter?: Color3;
  40018. alphaFilter?: number;
  40019. updatable?: boolean;
  40020. onReady?: (mesh: GroundMesh) => void;
  40021. }, scene?: Nullable<Scene>): GroundMesh;
  40022. }
  40023. }
  40024. declare module BABYLON {
  40025. /**
  40026. * Class containing static functions to help procedurally build meshes
  40027. */
  40028. export class TorusBuilder {
  40029. /**
  40030. * Creates a torus mesh
  40031. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40032. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40033. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40035. * * 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
  40036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40037. * @param name defines the name of the mesh
  40038. * @param options defines the options used to create the mesh
  40039. * @param scene defines the hosting scene
  40040. * @returns the torus mesh
  40041. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40042. */
  40043. static CreateTorus(name: string, options: {
  40044. diameter?: number;
  40045. thickness?: number;
  40046. tessellation?: number;
  40047. updatable?: boolean;
  40048. sideOrientation?: number;
  40049. frontUVs?: Vector4;
  40050. backUVs?: Vector4;
  40051. }, scene: any): Mesh;
  40052. }
  40053. }
  40054. declare module BABYLON {
  40055. /**
  40056. * Class containing static functions to help procedurally build meshes
  40057. */
  40058. export class CylinderBuilder {
  40059. /**
  40060. * Creates a cylinder or a cone mesh
  40061. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40062. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40063. * * 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.
  40064. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40065. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40066. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40067. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40068. * * 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).
  40069. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40070. * * 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).
  40071. * * 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
  40072. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40073. * * 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
  40074. * * 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.
  40075. * * If `enclose` is false, a ring surface is one element.
  40076. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40077. * * 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
  40078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40079. * * 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
  40080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40081. * @param name defines the name of the mesh
  40082. * @param options defines the options used to create the mesh
  40083. * @param scene defines the hosting scene
  40084. * @returns the cylinder mesh
  40085. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40086. */
  40087. static CreateCylinder(name: string, options: {
  40088. height?: number;
  40089. diameterTop?: number;
  40090. diameterBottom?: number;
  40091. diameter?: number;
  40092. tessellation?: number;
  40093. subdivisions?: number;
  40094. arc?: number;
  40095. faceColors?: Color4[];
  40096. faceUV?: Vector4[];
  40097. updatable?: boolean;
  40098. hasRings?: boolean;
  40099. enclose?: boolean;
  40100. cap?: number;
  40101. sideOrientation?: number;
  40102. frontUVs?: Vector4;
  40103. backUVs?: Vector4;
  40104. }, scene: any): Mesh;
  40105. }
  40106. }
  40107. declare module BABYLON {
  40108. /**
  40109. * Options to modify the vr teleportation behavior.
  40110. */
  40111. export interface VRTeleportationOptions {
  40112. /**
  40113. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40114. */
  40115. floorMeshName?: string;
  40116. /**
  40117. * A list of meshes to be used as the teleportation floor. (default: empty)
  40118. */
  40119. floorMeshes?: Mesh[];
  40120. }
  40121. /**
  40122. * Options to modify the vr experience helper's behavior.
  40123. */
  40124. export interface VRExperienceHelperOptions extends WebVROptions {
  40125. /**
  40126. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40127. */
  40128. createDeviceOrientationCamera?: boolean;
  40129. /**
  40130. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40131. */
  40132. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40133. /**
  40134. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40135. */
  40136. laserToggle?: boolean;
  40137. /**
  40138. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40139. */
  40140. floorMeshes?: Mesh[];
  40141. /**
  40142. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40143. */
  40144. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40145. }
  40146. /**
  40147. * Event containing information after VR has been entered
  40148. */
  40149. export class OnAfterEnteringVRObservableEvent {
  40150. /**
  40151. * If entering vr was successful
  40152. */
  40153. success: boolean;
  40154. }
  40155. /**
  40156. * Helps to quickly add VR support to an existing scene.
  40157. * See http://doc.babylonjs.com/how_to/webvr_helper
  40158. */
  40159. export class VRExperienceHelper {
  40160. /** Options to modify the vr experience helper's behavior. */
  40161. webVROptions: VRExperienceHelperOptions;
  40162. private _scene;
  40163. private _position;
  40164. private _btnVR;
  40165. private _btnVRDisplayed;
  40166. private _webVRsupported;
  40167. private _webVRready;
  40168. private _webVRrequesting;
  40169. private _webVRpresenting;
  40170. private _hasEnteredVR;
  40171. private _fullscreenVRpresenting;
  40172. private _canvas;
  40173. private _webVRCamera;
  40174. private _vrDeviceOrientationCamera;
  40175. private _deviceOrientationCamera;
  40176. private _existingCamera;
  40177. private _onKeyDown;
  40178. private _onVrDisplayPresentChange;
  40179. private _onVRDisplayChanged;
  40180. private _onVRRequestPresentStart;
  40181. private _onVRRequestPresentComplete;
  40182. /**
  40183. * 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)
  40184. */
  40185. enableGazeEvenWhenNoPointerLock: boolean;
  40186. /**
  40187. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40188. */
  40189. exitVROnDoubleTap: boolean;
  40190. /**
  40191. * Observable raised right before entering VR.
  40192. */
  40193. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40194. /**
  40195. * Observable raised when entering VR has completed.
  40196. */
  40197. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40198. /**
  40199. * Observable raised when exiting VR.
  40200. */
  40201. onExitingVRObservable: Observable<VRExperienceHelper>;
  40202. /**
  40203. * Observable raised when controller mesh is loaded.
  40204. */
  40205. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40206. /** Return this.onEnteringVRObservable
  40207. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40208. */
  40209. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40210. /** Return this.onExitingVRObservable
  40211. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40212. */
  40213. readonly onExitingVR: Observable<VRExperienceHelper>;
  40214. /** Return this.onControllerMeshLoadedObservable
  40215. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40216. */
  40217. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40218. private _rayLength;
  40219. private _useCustomVRButton;
  40220. private _teleportationRequested;
  40221. private _teleportActive;
  40222. private _floorMeshName;
  40223. private _floorMeshesCollection;
  40224. private _rotationAllowed;
  40225. private _teleportBackwardsVector;
  40226. private _teleportationTarget;
  40227. private _isDefaultTeleportationTarget;
  40228. private _postProcessMove;
  40229. private _teleportationFillColor;
  40230. private _teleportationBorderColor;
  40231. private _rotationAngle;
  40232. private _haloCenter;
  40233. private _cameraGazer;
  40234. private _padSensibilityUp;
  40235. private _padSensibilityDown;
  40236. private _leftController;
  40237. private _rightController;
  40238. /**
  40239. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40240. */
  40241. onNewMeshSelected: Observable<AbstractMesh>;
  40242. /**
  40243. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40244. * This observable will provide the mesh and the controller used to select the mesh
  40245. */
  40246. onMeshSelectedWithController: Observable<{
  40247. mesh: AbstractMesh;
  40248. controller: WebVRController;
  40249. }>;
  40250. /**
  40251. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40252. */
  40253. onNewMeshPicked: Observable<PickingInfo>;
  40254. private _circleEase;
  40255. /**
  40256. * Observable raised before camera teleportation
  40257. */
  40258. onBeforeCameraTeleport: Observable<Vector3>;
  40259. /**
  40260. * Observable raised after camera teleportation
  40261. */
  40262. onAfterCameraTeleport: Observable<Vector3>;
  40263. /**
  40264. * Observable raised when current selected mesh gets unselected
  40265. */
  40266. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40267. private _raySelectionPredicate;
  40268. /**
  40269. * To be optionaly changed by user to define custom ray selection
  40270. */
  40271. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40272. /**
  40273. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40274. */
  40275. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40276. /**
  40277. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40278. */
  40279. teleportationEnabled: boolean;
  40280. private _defaultHeight;
  40281. private _teleportationInitialized;
  40282. private _interactionsEnabled;
  40283. private _interactionsRequested;
  40284. private _displayGaze;
  40285. private _displayLaserPointer;
  40286. /**
  40287. * The mesh used to display where the user is going to teleport.
  40288. */
  40289. /**
  40290. * Sets the mesh to be used to display where the user is going to teleport.
  40291. */
  40292. teleportationTarget: Mesh;
  40293. /**
  40294. * 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
  40295. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40296. * See http://doc.babylonjs.com/resources/baking_transformations
  40297. */
  40298. gazeTrackerMesh: Mesh;
  40299. /**
  40300. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40301. */
  40302. updateGazeTrackerScale: boolean;
  40303. /**
  40304. * If the gaze trackers color should be updated when selecting meshes
  40305. */
  40306. updateGazeTrackerColor: boolean;
  40307. /**
  40308. * The gaze tracking mesh corresponding to the left controller
  40309. */
  40310. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40311. /**
  40312. * The gaze tracking mesh corresponding to the right controller
  40313. */
  40314. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40315. /**
  40316. * If the ray of the gaze should be displayed.
  40317. */
  40318. /**
  40319. * Sets if the ray of the gaze should be displayed.
  40320. */
  40321. displayGaze: boolean;
  40322. /**
  40323. * If the ray of the LaserPointer should be displayed.
  40324. */
  40325. /**
  40326. * Sets if the ray of the LaserPointer should be displayed.
  40327. */
  40328. displayLaserPointer: boolean;
  40329. /**
  40330. * The deviceOrientationCamera used as the camera when not in VR.
  40331. */
  40332. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40333. /**
  40334. * Based on the current WebVR support, returns the current VR camera used.
  40335. */
  40336. readonly currentVRCamera: Nullable<Camera>;
  40337. /**
  40338. * The webVRCamera which is used when in VR.
  40339. */
  40340. readonly webVRCamera: WebVRFreeCamera;
  40341. /**
  40342. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40343. */
  40344. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40345. /**
  40346. * The html button that is used to trigger entering into VR.
  40347. */
  40348. readonly vrButton: Nullable<HTMLButtonElement>;
  40349. private readonly _teleportationRequestInitiated;
  40350. /**
  40351. * Defines wether or not Pointer lock should be requested when switching to
  40352. * full screen.
  40353. */
  40354. requestPointerLockOnFullScreen: boolean;
  40355. /**
  40356. * Instantiates a VRExperienceHelper.
  40357. * Helps to quickly add VR support to an existing scene.
  40358. * @param scene The scene the VRExperienceHelper belongs to.
  40359. * @param webVROptions Options to modify the vr experience helper's behavior.
  40360. */
  40361. constructor(scene: Scene,
  40362. /** Options to modify the vr experience helper's behavior. */
  40363. webVROptions?: VRExperienceHelperOptions);
  40364. private _onDefaultMeshLoaded;
  40365. private _onResize;
  40366. private _onFullscreenChange;
  40367. /**
  40368. * Gets a value indicating if we are currently in VR mode.
  40369. */
  40370. readonly isInVRMode: boolean;
  40371. private onVrDisplayPresentChange;
  40372. private onVRDisplayChanged;
  40373. private moveButtonToBottomRight;
  40374. private displayVRButton;
  40375. private updateButtonVisibility;
  40376. private _cachedAngularSensibility;
  40377. /**
  40378. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40379. * Otherwise, will use the fullscreen API.
  40380. */
  40381. enterVR(): void;
  40382. /**
  40383. * Attempt to exit VR, or fullscreen.
  40384. */
  40385. exitVR(): void;
  40386. /**
  40387. * The position of the vr experience helper.
  40388. */
  40389. /**
  40390. * Sets the position of the vr experience helper.
  40391. */
  40392. position: Vector3;
  40393. /**
  40394. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40395. */
  40396. enableInteractions(): void;
  40397. private readonly _noControllerIsActive;
  40398. private beforeRender;
  40399. private _isTeleportationFloor;
  40400. /**
  40401. * Adds a floor mesh to be used for teleportation.
  40402. * @param floorMesh the mesh to be used for teleportation.
  40403. */
  40404. addFloorMesh(floorMesh: Mesh): void;
  40405. /**
  40406. * Removes a floor mesh from being used for teleportation.
  40407. * @param floorMesh the mesh to be removed.
  40408. */
  40409. removeFloorMesh(floorMesh: Mesh): void;
  40410. /**
  40411. * Enables interactions and teleportation using the VR controllers and gaze.
  40412. * @param vrTeleportationOptions options to modify teleportation behavior.
  40413. */
  40414. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40415. private _onNewGamepadConnected;
  40416. private _tryEnableInteractionOnController;
  40417. private _onNewGamepadDisconnected;
  40418. private _enableInteractionOnController;
  40419. private _checkTeleportWithRay;
  40420. private _checkRotate;
  40421. private _checkTeleportBackwards;
  40422. private _enableTeleportationOnController;
  40423. private _createTeleportationCircles;
  40424. private _displayTeleportationTarget;
  40425. private _hideTeleportationTarget;
  40426. private _rotateCamera;
  40427. private _moveTeleportationSelectorTo;
  40428. private _workingVector;
  40429. private _workingQuaternion;
  40430. private _workingMatrix;
  40431. /**
  40432. * Teleports the users feet to the desired location
  40433. * @param location The location where the user's feet should be placed
  40434. */
  40435. teleportCamera(location: Vector3): void;
  40436. private _convertNormalToDirectionOfRay;
  40437. private _castRayAndSelectObject;
  40438. private _notifySelectedMeshUnselected;
  40439. /**
  40440. * Sets the color of the laser ray from the vr controllers.
  40441. * @param color new color for the ray.
  40442. */
  40443. changeLaserColor(color: Color3): void;
  40444. /**
  40445. * Sets the color of the ray from the vr headsets gaze.
  40446. * @param color new color for the ray.
  40447. */
  40448. changeGazeColor(color: Color3): void;
  40449. /**
  40450. * Exits VR and disposes of the vr experience helper
  40451. */
  40452. dispose(): void;
  40453. /**
  40454. * Gets the name of the VRExperienceHelper class
  40455. * @returns "VRExperienceHelper"
  40456. */
  40457. getClassName(): string;
  40458. }
  40459. }
  40460. declare module BABYLON {
  40461. /**
  40462. * Manages an XRSession to work with Babylon's engine
  40463. * @see https://doc.babylonjs.com/how_to/webxr
  40464. */
  40465. export class WebXRSessionManager implements IDisposable {
  40466. private scene;
  40467. /**
  40468. * Fires every time a new xrFrame arrives which can be used to update the camera
  40469. */
  40470. onXRFrameObservable: Observable<any>;
  40471. /**
  40472. * Fires when the xr session is ended either by the device or manually done
  40473. */
  40474. onXRSessionEnded: Observable<any>;
  40475. /**
  40476. * Underlying xr session
  40477. */
  40478. session: XRSession;
  40479. /**
  40480. * Type of reference space used when creating the session
  40481. */
  40482. referenceSpace: XRReferenceSpace;
  40483. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40484. /**
  40485. * Current XR frame
  40486. */
  40487. currentFrame: Nullable<XRFrame>;
  40488. private _xrNavigator;
  40489. private baseLayer;
  40490. /**
  40491. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40492. * @param scene The scene which the session should be created for
  40493. */
  40494. constructor(scene: Scene);
  40495. /**
  40496. * Initializes the manager
  40497. * After initialization enterXR can be called to start an XR session
  40498. * @returns Promise which resolves after it is initialized
  40499. */
  40500. initializeAsync(): Promise<void>;
  40501. /**
  40502. * Initializes an xr session
  40503. * @param xrSessionMode mode to initialize
  40504. * @returns a promise which will resolve once the session has been initialized
  40505. */
  40506. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40507. /**
  40508. * Sets the reference space on the xr session
  40509. * @param referenceSpace space to set
  40510. * @returns a promise that will resolve once the reference space has been set
  40511. */
  40512. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40513. /**
  40514. * Updates the render state of the session
  40515. * @param state state to set
  40516. * @returns a promise that resolves once the render state has been updated
  40517. */
  40518. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40519. /**
  40520. * Starts rendering to the xr layer
  40521. * @returns a promise that will resolve once rendering has started
  40522. */
  40523. startRenderingToXRAsync(): Promise<void>;
  40524. /**
  40525. * Stops the xrSession and restores the renderloop
  40526. * @returns Promise which resolves after it exits XR
  40527. */
  40528. exitXRAsync(): Promise<unknown>;
  40529. /**
  40530. * Checks if a session would be supported for the creation options specified
  40531. * @param sessionMode session mode to check if supported eg. immersive-vr
  40532. * @returns true if supported
  40533. */
  40534. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40535. /**
  40536. * @hidden
  40537. * Converts the render layer of xrSession to a render target
  40538. * @param session session to create render target for
  40539. * @param scene scene the new render target should be created for
  40540. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40541. /**
  40542. * Disposes of the session manager
  40543. */
  40544. dispose(): void;
  40545. }
  40546. }
  40547. declare module BABYLON {
  40548. /**
  40549. * WebXR Camera which holds the views for the xrSession
  40550. * @see https://doc.babylonjs.com/how_to/webxr
  40551. */
  40552. export class WebXRCamera extends FreeCamera {
  40553. private static _TmpMatrix;
  40554. /**
  40555. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40556. * @param name the name of the camera
  40557. * @param scene the scene to add the camera to
  40558. */
  40559. constructor(name: string, scene: Scene);
  40560. private _updateNumberOfRigCameras;
  40561. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40562. /**
  40563. * Updates the cameras position from the current pose information of the XR session
  40564. * @param xrSessionManager the session containing pose information
  40565. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40566. */
  40567. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40568. }
  40569. }
  40570. declare module BABYLON {
  40571. /**
  40572. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40573. */
  40574. export class WebXRManagedOutputCanvas implements IDisposable {
  40575. private helper;
  40576. private _canvas;
  40577. /**
  40578. * xrpresent context of the canvas which can be used to display/mirror xr content
  40579. */
  40580. canvasContext: WebGLRenderingContext;
  40581. /**
  40582. * xr layer for the canvas
  40583. */
  40584. xrLayer: Nullable<XRWebGLLayer>;
  40585. /**
  40586. * Initializes the xr layer for the session
  40587. * @param xrSession xr session
  40588. * @returns a promise that will resolve once the XR Layer has been created
  40589. */
  40590. initializeXRLayerAsync(xrSession: any): any;
  40591. /**
  40592. * Initializes the canvas to be added/removed upon entering/exiting xr
  40593. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40594. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40595. */
  40596. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40597. /**
  40598. * Disposes of the object
  40599. */
  40600. dispose(): void;
  40601. private _setManagedOutputCanvas;
  40602. private _addCanvas;
  40603. private _removeCanvas;
  40604. }
  40605. }
  40606. declare module BABYLON {
  40607. /**
  40608. * States of the webXR experience
  40609. */
  40610. export enum WebXRState {
  40611. /**
  40612. * Transitioning to being in XR mode
  40613. */
  40614. ENTERING_XR = 0,
  40615. /**
  40616. * Transitioning to non XR mode
  40617. */
  40618. EXITING_XR = 1,
  40619. /**
  40620. * In XR mode and presenting
  40621. */
  40622. IN_XR = 2,
  40623. /**
  40624. * Not entered XR mode
  40625. */
  40626. NOT_IN_XR = 3
  40627. }
  40628. /**
  40629. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40630. * @see https://doc.babylonjs.com/how_to/webxr
  40631. */
  40632. export class WebXRExperienceHelper implements IDisposable {
  40633. private scene;
  40634. /**
  40635. * 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
  40636. */
  40637. container: AbstractMesh;
  40638. /**
  40639. * Camera used to render xr content
  40640. */
  40641. camera: WebXRCamera;
  40642. /**
  40643. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40644. */
  40645. state: WebXRState;
  40646. private _setState;
  40647. private static _TmpVector;
  40648. /**
  40649. * Fires when the state of the experience helper has changed
  40650. */
  40651. onStateChangedObservable: Observable<WebXRState>;
  40652. /** Session manager used to keep track of xr session */
  40653. sessionManager: WebXRSessionManager;
  40654. private _nonVRCamera;
  40655. private _originalSceneAutoClear;
  40656. private _supported;
  40657. /**
  40658. * Creates the experience helper
  40659. * @param scene the scene to attach the experience helper to
  40660. * @returns a promise for the experience helper
  40661. */
  40662. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40663. /**
  40664. * Creates a WebXRExperienceHelper
  40665. * @param scene The scene the helper should be created in
  40666. */
  40667. private constructor();
  40668. /**
  40669. * Exits XR mode and returns the scene to its original state
  40670. * @returns promise that resolves after xr mode has exited
  40671. */
  40672. exitXRAsync(): Promise<unknown>;
  40673. /**
  40674. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40675. * @param sessionCreationOptions options for the XR session
  40676. * @param referenceSpaceType frame of reference of the XR session
  40677. * @param outputCanvas the output canvas that will be used to enter XR mode
  40678. * @returns promise that resolves after xr mode has entered
  40679. */
  40680. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40681. /**
  40682. * Updates the global position of the camera by moving the camera's container
  40683. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40684. * @param position The desired global position of the camera
  40685. */
  40686. setPositionOfCameraUsingContainer(position: Vector3): void;
  40687. /**
  40688. * Rotates the xr camera by rotating the camera's container around the camera's position
  40689. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40690. * @param rotation the desired quaternion rotation to apply to the camera
  40691. */
  40692. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40693. /**
  40694. * Disposes of the experience helper
  40695. */
  40696. dispose(): void;
  40697. }
  40698. }
  40699. declare module BABYLON {
  40700. /**
  40701. * Button which can be used to enter a different mode of XR
  40702. */
  40703. export class WebXREnterExitUIButton {
  40704. /** button element */
  40705. element: HTMLElement;
  40706. /** XR initialization options for the button */
  40707. sessionMode: XRSessionMode;
  40708. /** Reference space type */
  40709. referenceSpaceType: XRReferenceSpaceType;
  40710. /**
  40711. * Creates a WebXREnterExitUIButton
  40712. * @param element button element
  40713. * @param sessionMode XR initialization session mode
  40714. * @param referenceSpaceType the type of reference space to be used
  40715. */
  40716. constructor(
  40717. /** button element */
  40718. element: HTMLElement,
  40719. /** XR initialization options for the button */
  40720. sessionMode: XRSessionMode,
  40721. /** Reference space type */
  40722. referenceSpaceType: XRReferenceSpaceType);
  40723. /**
  40724. * Overwritable function which can be used to update the button's visuals when the state changes
  40725. * @param activeButton the current active button in the UI
  40726. */
  40727. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40728. }
  40729. /**
  40730. * Options to create the webXR UI
  40731. */
  40732. export class WebXREnterExitUIOptions {
  40733. /**
  40734. * Context to enter xr with
  40735. */
  40736. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40737. /**
  40738. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40739. */
  40740. customButtons?: Array<WebXREnterExitUIButton>;
  40741. }
  40742. /**
  40743. * UI to allow the user to enter/exit XR mode
  40744. */
  40745. export class WebXREnterExitUI implements IDisposable {
  40746. private scene;
  40747. private _overlay;
  40748. private _buttons;
  40749. private _activeButton;
  40750. /**
  40751. * Fired every time the active button is changed.
  40752. *
  40753. * When xr is entered via a button that launches xr that button will be the callback parameter
  40754. *
  40755. * When exiting xr the callback parameter will be null)
  40756. */
  40757. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40758. /**
  40759. * Creates UI to allow the user to enter/exit XR mode
  40760. * @param scene the scene to add the ui to
  40761. * @param helper the xr experience helper to enter/exit xr with
  40762. * @param options options to configure the UI
  40763. * @returns the created ui
  40764. */
  40765. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40766. private constructor();
  40767. private _updateButtons;
  40768. /**
  40769. * Disposes of the object
  40770. */
  40771. dispose(): void;
  40772. }
  40773. }
  40774. declare module BABYLON {
  40775. /**
  40776. * Represents an XR input
  40777. */
  40778. export class WebXRController {
  40779. private scene;
  40780. /** The underlying input source for the controller */
  40781. inputSource: XRInputSource;
  40782. private parentContainer;
  40783. /**
  40784. * 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
  40785. */
  40786. grip?: AbstractMesh;
  40787. /**
  40788. * Pointer which can be used to select objects or attach a visible laser to
  40789. */
  40790. pointer: AbstractMesh;
  40791. /**
  40792. * Event that fires when the controller is removed/disposed
  40793. */
  40794. onDisposeObservable: Observable<{}>;
  40795. private _tmpMatrix;
  40796. private _tmpQuaternion;
  40797. private _tmpVector;
  40798. /**
  40799. * Creates the controller
  40800. * @see https://doc.babylonjs.com/how_to/webxr
  40801. * @param scene the scene which the controller should be associated to
  40802. * @param inputSource the underlying input source for the controller
  40803. * @param parentContainer parent that the controller meshes should be children of
  40804. */
  40805. constructor(scene: Scene,
  40806. /** The underlying input source for the controller */
  40807. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40808. /**
  40809. * Updates the controller pose based on the given XRFrame
  40810. * @param xrFrame xr frame to update the pose with
  40811. * @param referenceSpace reference space to use
  40812. */
  40813. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40814. /**
  40815. * Gets a world space ray coming from the controller
  40816. * @param result the resulting ray
  40817. */
  40818. getWorldPointerRayToRef(result: Ray): void;
  40819. /**
  40820. * Disposes of the object
  40821. */
  40822. dispose(): void;
  40823. }
  40824. }
  40825. declare module BABYLON {
  40826. /**
  40827. * XR input used to track XR inputs such as controllers/rays
  40828. */
  40829. export class WebXRInput implements IDisposable {
  40830. /**
  40831. * Base experience the input listens to
  40832. */
  40833. baseExperience: WebXRExperienceHelper;
  40834. /**
  40835. * XR controllers being tracked
  40836. */
  40837. controllers: Array<WebXRController>;
  40838. private _frameObserver;
  40839. private _stateObserver;
  40840. /**
  40841. * Event when a controller has been connected/added
  40842. */
  40843. onControllerAddedObservable: Observable<WebXRController>;
  40844. /**
  40845. * Event when a controller has been removed/disconnected
  40846. */
  40847. onControllerRemovedObservable: Observable<WebXRController>;
  40848. /**
  40849. * Initializes the WebXRInput
  40850. * @param baseExperience experience helper which the input should be created for
  40851. */
  40852. constructor(
  40853. /**
  40854. * Base experience the input listens to
  40855. */
  40856. baseExperience: WebXRExperienceHelper);
  40857. private _onInputSourcesChange;
  40858. private _addAndRemoveControllers;
  40859. /**
  40860. * Disposes of the object
  40861. */
  40862. dispose(): void;
  40863. }
  40864. }
  40865. declare module BABYLON {
  40866. /**
  40867. * Enables teleportation
  40868. */
  40869. export class WebXRControllerTeleportation {
  40870. private _teleportationFillColor;
  40871. private _teleportationBorderColor;
  40872. private _tmpRay;
  40873. private _tmpVector;
  40874. /**
  40875. * Creates a WebXRControllerTeleportation
  40876. * @param input input manager to add teleportation to
  40877. * @param floorMeshes floormeshes which can be teleported to
  40878. */
  40879. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40880. }
  40881. }
  40882. declare module BABYLON {
  40883. /**
  40884. * Handles pointer input automatically for the pointer of XR controllers
  40885. */
  40886. export class WebXRControllerPointerSelection {
  40887. private static _idCounter;
  40888. private _tmpRay;
  40889. /**
  40890. * Creates a WebXRControllerPointerSelection
  40891. * @param input input manager to setup pointer selection
  40892. */
  40893. constructor(input: WebXRInput);
  40894. private _convertNormalToDirectionOfRay;
  40895. private _updatePointerDistance;
  40896. }
  40897. }
  40898. declare module BABYLON {
  40899. /**
  40900. * Class used to represent data loading progression
  40901. */
  40902. export class SceneLoaderProgressEvent {
  40903. /** defines if data length to load can be evaluated */
  40904. readonly lengthComputable: boolean;
  40905. /** defines the loaded data length */
  40906. readonly loaded: number;
  40907. /** defines the data length to load */
  40908. readonly total: number;
  40909. /**
  40910. * Create a new progress event
  40911. * @param lengthComputable defines if data length to load can be evaluated
  40912. * @param loaded defines the loaded data length
  40913. * @param total defines the data length to load
  40914. */
  40915. constructor(
  40916. /** defines if data length to load can be evaluated */
  40917. lengthComputable: boolean,
  40918. /** defines the loaded data length */
  40919. loaded: number,
  40920. /** defines the data length to load */
  40921. total: number);
  40922. /**
  40923. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40924. * @param event defines the source event
  40925. * @returns a new SceneLoaderProgressEvent
  40926. */
  40927. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40928. }
  40929. /**
  40930. * Interface used by SceneLoader plugins to define supported file extensions
  40931. */
  40932. export interface ISceneLoaderPluginExtensions {
  40933. /**
  40934. * Defines the list of supported extensions
  40935. */
  40936. [extension: string]: {
  40937. isBinary: boolean;
  40938. };
  40939. }
  40940. /**
  40941. * Interface used by SceneLoader plugin factory
  40942. */
  40943. export interface ISceneLoaderPluginFactory {
  40944. /**
  40945. * Defines the name of the factory
  40946. */
  40947. name: string;
  40948. /**
  40949. * Function called to create a new plugin
  40950. * @return the new plugin
  40951. */
  40952. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40953. /**
  40954. * Boolean indicating if the plugin can direct load specific data
  40955. */
  40956. canDirectLoad?: (data: string) => boolean;
  40957. }
  40958. /**
  40959. * Interface used to define a SceneLoader plugin
  40960. */
  40961. export interface ISceneLoaderPlugin {
  40962. /**
  40963. * The friendly name of this plugin.
  40964. */
  40965. name: string;
  40966. /**
  40967. * The file extensions supported by this plugin.
  40968. */
  40969. extensions: string | ISceneLoaderPluginExtensions;
  40970. /**
  40971. * Import meshes into a scene.
  40972. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40973. * @param scene The scene to import into
  40974. * @param data The data to import
  40975. * @param rootUrl The root url for scene and resources
  40976. * @param meshes The meshes array to import into
  40977. * @param particleSystems The particle systems array to import into
  40978. * @param skeletons The skeletons array to import into
  40979. * @param onError The callback when import fails
  40980. * @returns True if successful or false otherwise
  40981. */
  40982. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40983. /**
  40984. * Load into a scene.
  40985. * @param scene The scene to load into
  40986. * @param data The data to import
  40987. * @param rootUrl The root url for scene and resources
  40988. * @param onError The callback when import fails
  40989. * @returns true if successful or false otherwise
  40990. */
  40991. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40992. /**
  40993. * The callback that returns true if the data can be directly loaded.
  40994. */
  40995. canDirectLoad?: (data: string) => boolean;
  40996. /**
  40997. * The callback that allows custom handling of the root url based on the response url.
  40998. */
  40999. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41000. /**
  41001. * Load into an asset container.
  41002. * @param scene The scene to load into
  41003. * @param data The data to import
  41004. * @param rootUrl The root url for scene and resources
  41005. * @param onError The callback when import fails
  41006. * @returns The loaded asset container
  41007. */
  41008. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41009. }
  41010. /**
  41011. * Interface used to define an async SceneLoader plugin
  41012. */
  41013. export interface ISceneLoaderPluginAsync {
  41014. /**
  41015. * The friendly name of this plugin.
  41016. */
  41017. name: string;
  41018. /**
  41019. * The file extensions supported by this plugin.
  41020. */
  41021. extensions: string | ISceneLoaderPluginExtensions;
  41022. /**
  41023. * Import meshes into a scene.
  41024. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41025. * @param scene The scene to import into
  41026. * @param data The data to import
  41027. * @param rootUrl The root url for scene and resources
  41028. * @param onProgress The callback when the load progresses
  41029. * @param fileName Defines the name of the file to load
  41030. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41031. */
  41032. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41033. meshes: AbstractMesh[];
  41034. particleSystems: IParticleSystem[];
  41035. skeletons: Skeleton[];
  41036. animationGroups: AnimationGroup[];
  41037. }>;
  41038. /**
  41039. * Load into a scene.
  41040. * @param scene The scene to load into
  41041. * @param data The data to import
  41042. * @param rootUrl The root url for scene and resources
  41043. * @param onProgress The callback when the load progresses
  41044. * @param fileName Defines the name of the file to load
  41045. * @returns Nothing
  41046. */
  41047. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41048. /**
  41049. * The callback that returns true if the data can be directly loaded.
  41050. */
  41051. canDirectLoad?: (data: string) => boolean;
  41052. /**
  41053. * The callback that allows custom handling of the root url based on the response url.
  41054. */
  41055. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41056. /**
  41057. * Load into an asset container.
  41058. * @param scene The scene to load into
  41059. * @param data The data to import
  41060. * @param rootUrl The root url for scene and resources
  41061. * @param onProgress The callback when the load progresses
  41062. * @param fileName Defines the name of the file to load
  41063. * @returns The loaded asset container
  41064. */
  41065. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41066. }
  41067. /**
  41068. * Class used to load scene from various file formats using registered plugins
  41069. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41070. */
  41071. export class SceneLoader {
  41072. /**
  41073. * No logging while loading
  41074. */
  41075. static readonly NO_LOGGING: number;
  41076. /**
  41077. * Minimal logging while loading
  41078. */
  41079. static readonly MINIMAL_LOGGING: number;
  41080. /**
  41081. * Summary logging while loading
  41082. */
  41083. static readonly SUMMARY_LOGGING: number;
  41084. /**
  41085. * Detailled logging while loading
  41086. */
  41087. static readonly DETAILED_LOGGING: number;
  41088. /**
  41089. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41090. */
  41091. static ForceFullSceneLoadingForIncremental: boolean;
  41092. /**
  41093. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41094. */
  41095. static ShowLoadingScreen: boolean;
  41096. /**
  41097. * Defines the current logging level (while loading the scene)
  41098. * @ignorenaming
  41099. */
  41100. static loggingLevel: number;
  41101. /**
  41102. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41103. */
  41104. static CleanBoneMatrixWeights: boolean;
  41105. /**
  41106. * Event raised when a plugin is used to load a scene
  41107. */
  41108. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41109. private static _registeredPlugins;
  41110. private static _getDefaultPlugin;
  41111. private static _getPluginForExtension;
  41112. private static _getPluginForDirectLoad;
  41113. private static _getPluginForFilename;
  41114. private static _getDirectLoad;
  41115. private static _loadData;
  41116. private static _getFileInfo;
  41117. /**
  41118. * Gets a plugin that can load the given extension
  41119. * @param extension defines the extension to load
  41120. * @returns a plugin or null if none works
  41121. */
  41122. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41123. /**
  41124. * Gets a boolean indicating that the given extension can be loaded
  41125. * @param extension defines the extension to load
  41126. * @returns true if the extension is supported
  41127. */
  41128. static IsPluginForExtensionAvailable(extension: string): boolean;
  41129. /**
  41130. * Adds a new plugin to the list of registered plugins
  41131. * @param plugin defines the plugin to add
  41132. */
  41133. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41134. /**
  41135. * Import meshes into a scene
  41136. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41137. * @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)
  41138. * @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)
  41139. * @param scene the instance of BABYLON.Scene to append to
  41140. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41141. * @param onProgress a callback with a progress event for each file being loaded
  41142. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41143. * @param pluginExtension the extension used to determine the plugin
  41144. * @returns The loaded plugin
  41145. */
  41146. 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>;
  41147. /**
  41148. * Import meshes into a scene
  41149. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41150. * @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)
  41151. * @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)
  41152. * @param scene the instance of BABYLON.Scene to append to
  41153. * @param onProgress a callback with a progress event for each file being loaded
  41154. * @param pluginExtension the extension used to determine the plugin
  41155. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41156. */
  41157. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41158. meshes: AbstractMesh[];
  41159. particleSystems: IParticleSystem[];
  41160. skeletons: Skeleton[];
  41161. animationGroups: AnimationGroup[];
  41162. }>;
  41163. /**
  41164. * Load a scene
  41165. * @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)
  41166. * @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)
  41167. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41168. * @param onSuccess a callback with the scene when import succeeds
  41169. * @param onProgress a callback with a progress event for each file being loaded
  41170. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41171. * @param pluginExtension the extension used to determine the plugin
  41172. * @returns The loaded plugin
  41173. */
  41174. 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>;
  41175. /**
  41176. * Load a scene
  41177. * @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)
  41178. * @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)
  41179. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41180. * @param onProgress a callback with a progress event for each file being loaded
  41181. * @param pluginExtension the extension used to determine the plugin
  41182. * @returns The loaded scene
  41183. */
  41184. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41185. /**
  41186. * Append a scene
  41187. * @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)
  41188. * @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)
  41189. * @param scene is the instance of BABYLON.Scene to append to
  41190. * @param onSuccess a callback with the scene when import succeeds
  41191. * @param onProgress a callback with a progress event for each file being loaded
  41192. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41193. * @param pluginExtension the extension used to determine the plugin
  41194. * @returns The loaded plugin
  41195. */
  41196. 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>;
  41197. /**
  41198. * Append a scene
  41199. * @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)
  41200. * @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)
  41201. * @param scene is the instance of BABYLON.Scene to append to
  41202. * @param onProgress a callback with a progress event for each file being loaded
  41203. * @param pluginExtension the extension used to determine the plugin
  41204. * @returns The given scene
  41205. */
  41206. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41207. /**
  41208. * Load a scene into an asset container
  41209. * @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)
  41210. * @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)
  41211. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41212. * @param onSuccess a callback with the scene when import succeeds
  41213. * @param onProgress a callback with a progress event for each file being loaded
  41214. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41215. * @param pluginExtension the extension used to determine the plugin
  41216. * @returns The loaded plugin
  41217. */
  41218. 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>;
  41219. /**
  41220. * Load a scene into an asset container
  41221. * @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)
  41222. * @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)
  41223. * @param scene is the instance of Scene to append to
  41224. * @param onProgress a callback with a progress event for each file being loaded
  41225. * @param pluginExtension the extension used to determine the plugin
  41226. * @returns The loaded asset container
  41227. */
  41228. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41229. }
  41230. }
  41231. declare module BABYLON {
  41232. /**
  41233. * Generic Controller
  41234. */
  41235. export class GenericController extends WebVRController {
  41236. /**
  41237. * Base Url for the controller model.
  41238. */
  41239. static readonly MODEL_BASE_URL: string;
  41240. /**
  41241. * File name for the controller model.
  41242. */
  41243. static readonly MODEL_FILENAME: string;
  41244. /**
  41245. * Creates a new GenericController from a gamepad
  41246. * @param vrGamepad the gamepad that the controller should be created from
  41247. */
  41248. constructor(vrGamepad: any);
  41249. /**
  41250. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41251. * @param scene scene in which to add meshes
  41252. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41253. */
  41254. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41255. /**
  41256. * Called once for each button that changed state since the last frame
  41257. * @param buttonIdx Which button index changed
  41258. * @param state New state of the button
  41259. * @param changes Which properties on the state changed since last frame
  41260. */
  41261. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41262. }
  41263. }
  41264. declare module BABYLON {
  41265. /**
  41266. * Defines the WindowsMotionController object that the state of the windows motion controller
  41267. */
  41268. export class WindowsMotionController extends WebVRController {
  41269. /**
  41270. * The base url used to load the left and right controller models
  41271. */
  41272. static MODEL_BASE_URL: string;
  41273. /**
  41274. * The name of the left controller model file
  41275. */
  41276. static MODEL_LEFT_FILENAME: string;
  41277. /**
  41278. * The name of the right controller model file
  41279. */
  41280. static MODEL_RIGHT_FILENAME: string;
  41281. /**
  41282. * The controller name prefix for this controller type
  41283. */
  41284. static readonly GAMEPAD_ID_PREFIX: string;
  41285. /**
  41286. * The controller id pattern for this controller type
  41287. */
  41288. private static readonly GAMEPAD_ID_PATTERN;
  41289. private _loadedMeshInfo;
  41290. private readonly _mapping;
  41291. /**
  41292. * Fired when the trackpad on this controller is clicked
  41293. */
  41294. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41295. /**
  41296. * Fired when the trackpad on this controller is modified
  41297. */
  41298. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41299. /**
  41300. * The current x and y values of this controller's trackpad
  41301. */
  41302. trackpad: StickValues;
  41303. /**
  41304. * Creates a new WindowsMotionController from a gamepad
  41305. * @param vrGamepad the gamepad that the controller should be created from
  41306. */
  41307. constructor(vrGamepad: any);
  41308. /**
  41309. * Fired when the trigger on this controller is modified
  41310. */
  41311. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41312. /**
  41313. * Fired when the menu button on this controller is modified
  41314. */
  41315. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41316. /**
  41317. * Fired when the grip button on this controller is modified
  41318. */
  41319. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41320. /**
  41321. * Fired when the thumbstick button on this controller is modified
  41322. */
  41323. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41324. /**
  41325. * Fired when the touchpad button on this controller is modified
  41326. */
  41327. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41328. /**
  41329. * Fired when the touchpad values on this controller are modified
  41330. */
  41331. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41332. private _updateTrackpad;
  41333. /**
  41334. * Called once per frame by the engine.
  41335. */
  41336. update(): void;
  41337. /**
  41338. * Called once for each button that changed state since the last frame
  41339. * @param buttonIdx Which button index changed
  41340. * @param state New state of the button
  41341. * @param changes Which properties on the state changed since last frame
  41342. */
  41343. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41344. /**
  41345. * Moves the buttons on the controller mesh based on their current state
  41346. * @param buttonName the name of the button to move
  41347. * @param buttonValue the value of the button which determines the buttons new position
  41348. */
  41349. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41350. /**
  41351. * Moves the axis on the controller mesh based on its current state
  41352. * @param axis the index of the axis
  41353. * @param axisValue the value of the axis which determines the meshes new position
  41354. * @hidden
  41355. */
  41356. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41357. /**
  41358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41359. * @param scene scene in which to add meshes
  41360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41361. */
  41362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41363. /**
  41364. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41365. * can be transformed by button presses and axes values, based on this._mapping.
  41366. *
  41367. * @param scene scene in which the meshes exist
  41368. * @param meshes list of meshes that make up the controller model to process
  41369. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41370. */
  41371. private processModel;
  41372. private createMeshInfo;
  41373. /**
  41374. * Gets the ray of the controller in the direction the controller is pointing
  41375. * @param length the length the resulting ray should be
  41376. * @returns a ray in the direction the controller is pointing
  41377. */
  41378. getForwardRay(length?: number): Ray;
  41379. /**
  41380. * Disposes of the controller
  41381. */
  41382. dispose(): void;
  41383. }
  41384. }
  41385. declare module BABYLON {
  41386. /**
  41387. * Oculus Touch Controller
  41388. */
  41389. export class OculusTouchController extends WebVRController {
  41390. /**
  41391. * Base Url for the controller model.
  41392. */
  41393. static MODEL_BASE_URL: string;
  41394. /**
  41395. * File name for the left controller model.
  41396. */
  41397. static MODEL_LEFT_FILENAME: string;
  41398. /**
  41399. * File name for the right controller model.
  41400. */
  41401. static MODEL_RIGHT_FILENAME: string;
  41402. /**
  41403. * Base Url for the Quest controller model.
  41404. */
  41405. static QUEST_MODEL_BASE_URL: string;
  41406. /**
  41407. * @hidden
  41408. * If the controllers are running on a device that needs the updated Quest controller models
  41409. */ private static _IsQuest: boolean;
  41410. /**
  41411. * Fired when the secondary trigger on this controller is modified
  41412. */
  41413. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41414. /**
  41415. * Fired when the thumb rest on this controller is modified
  41416. */
  41417. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41418. /**
  41419. * Creates a new OculusTouchController from a gamepad
  41420. * @param vrGamepad the gamepad that the controller should be created from
  41421. */
  41422. constructor(vrGamepad: any);
  41423. /**
  41424. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41425. * @param scene scene in which to add meshes
  41426. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41427. */
  41428. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41429. /**
  41430. * Fired when the A button on this controller is modified
  41431. */
  41432. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41433. /**
  41434. * Fired when the B button on this controller is modified
  41435. */
  41436. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41437. /**
  41438. * Fired when the X button on this controller is modified
  41439. */
  41440. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41441. /**
  41442. * Fired when the Y button on this controller is modified
  41443. */
  41444. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41445. /**
  41446. * Called once for each button that changed state since the last frame
  41447. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41448. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41449. * 2) secondary trigger (same)
  41450. * 3) A (right) X (left), touch, pressed = value
  41451. * 4) B / Y
  41452. * 5) thumb rest
  41453. * @param buttonIdx Which button index changed
  41454. * @param state New state of the button
  41455. * @param changes Which properties on the state changed since last frame
  41456. */
  41457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41458. }
  41459. }
  41460. declare module BABYLON {
  41461. /**
  41462. * Vive Controller
  41463. */
  41464. export class ViveController extends WebVRController {
  41465. /**
  41466. * Base Url for the controller model.
  41467. */
  41468. static MODEL_BASE_URL: string;
  41469. /**
  41470. * File name for the controller model.
  41471. */
  41472. static MODEL_FILENAME: string;
  41473. /**
  41474. * Creates a new ViveController from a gamepad
  41475. * @param vrGamepad the gamepad that the controller should be created from
  41476. */
  41477. constructor(vrGamepad: any);
  41478. /**
  41479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41480. * @param scene scene in which to add meshes
  41481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41482. */
  41483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41484. /**
  41485. * Fired when the left button on this controller is modified
  41486. */
  41487. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41488. /**
  41489. * Fired when the right button on this controller is modified
  41490. */
  41491. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41492. /**
  41493. * Fired when the menu button on this controller is modified
  41494. */
  41495. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41496. /**
  41497. * Called once for each button that changed state since the last frame
  41498. * Vive mapping:
  41499. * 0: touchpad
  41500. * 1: trigger
  41501. * 2: left AND right buttons
  41502. * 3: menu button
  41503. * @param buttonIdx Which button index changed
  41504. * @param state New state of the button
  41505. * @param changes Which properties on the state changed since last frame
  41506. */
  41507. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41508. }
  41509. }
  41510. declare module BABYLON {
  41511. /**
  41512. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41513. */
  41514. export class WebXRControllerModelLoader {
  41515. /**
  41516. * Creates the WebXRControllerModelLoader
  41517. * @param input xr input that creates the controllers
  41518. */
  41519. constructor(input: WebXRInput);
  41520. }
  41521. }
  41522. declare module BABYLON {
  41523. /**
  41524. * Contains an array of blocks representing the octree
  41525. */
  41526. export interface IOctreeContainer<T> {
  41527. /**
  41528. * Blocks within the octree
  41529. */
  41530. blocks: Array<OctreeBlock<T>>;
  41531. }
  41532. /**
  41533. * Class used to store a cell in an octree
  41534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41535. */
  41536. export class OctreeBlock<T> {
  41537. /**
  41538. * Gets the content of the current block
  41539. */
  41540. entries: T[];
  41541. /**
  41542. * Gets the list of block children
  41543. */
  41544. blocks: Array<OctreeBlock<T>>;
  41545. private _depth;
  41546. private _maxDepth;
  41547. private _capacity;
  41548. private _minPoint;
  41549. private _maxPoint;
  41550. private _boundingVectors;
  41551. private _creationFunc;
  41552. /**
  41553. * Creates a new block
  41554. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41555. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41556. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41557. * @param depth defines the current depth of this block in the octree
  41558. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41559. * @param creationFunc defines a callback to call when an element is added to the block
  41560. */
  41561. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41562. /**
  41563. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41564. */
  41565. readonly capacity: number;
  41566. /**
  41567. * Gets the minimum vector (in world space) of the block's bounding box
  41568. */
  41569. readonly minPoint: Vector3;
  41570. /**
  41571. * Gets the maximum vector (in world space) of the block's bounding box
  41572. */
  41573. readonly maxPoint: Vector3;
  41574. /**
  41575. * Add a new element to this block
  41576. * @param entry defines the element to add
  41577. */
  41578. addEntry(entry: T): void;
  41579. /**
  41580. * Remove an element from this block
  41581. * @param entry defines the element to remove
  41582. */
  41583. removeEntry(entry: T): void;
  41584. /**
  41585. * Add an array of elements to this block
  41586. * @param entries defines the array of elements to add
  41587. */
  41588. addEntries(entries: T[]): void;
  41589. /**
  41590. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41591. * @param frustumPlanes defines the frustum planes to test
  41592. * @param selection defines the array to store current content if selection is positive
  41593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41594. */
  41595. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41596. /**
  41597. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41598. * @param sphereCenter defines the bounding sphere center
  41599. * @param sphereRadius defines the bounding sphere radius
  41600. * @param selection defines the array to store current content if selection is positive
  41601. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41602. */
  41603. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41604. /**
  41605. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41606. * @param ray defines the ray to test with
  41607. * @param selection defines the array to store current content if selection is positive
  41608. */
  41609. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41610. /**
  41611. * Subdivide the content into child blocks (this block will then be empty)
  41612. */
  41613. createInnerBlocks(): void;
  41614. /**
  41615. * @hidden
  41616. */ 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;
  41617. }
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41623. */
  41624. export class Octree<T> {
  41625. /** 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.) */
  41626. maxDepth: number;
  41627. /**
  41628. * Blocks within the octree containing objects
  41629. */
  41630. blocks: Array<OctreeBlock<T>>;
  41631. /**
  41632. * Content stored in the octree
  41633. */
  41634. dynamicContent: T[];
  41635. private _maxBlockCapacity;
  41636. private _selectionContent;
  41637. private _creationFunc;
  41638. /**
  41639. * Creates a octree
  41640. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41641. * @param creationFunc function to be used to instatiate the octree
  41642. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41643. * @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.)
  41644. */
  41645. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41646. /** 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.) */
  41647. maxDepth?: number);
  41648. /**
  41649. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41650. * @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);
  41651. * @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);
  41652. * @param entries meshes to be added to the octree blocks
  41653. */
  41654. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41655. /**
  41656. * Adds a mesh to the octree
  41657. * @param entry Mesh to add to the octree
  41658. */
  41659. addMesh(entry: T): void;
  41660. /**
  41661. * Remove an element from the octree
  41662. * @param entry defines the element to remove
  41663. */
  41664. removeMesh(entry: T): void;
  41665. /**
  41666. * Selects an array of meshes within the frustum
  41667. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41668. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41669. * @returns array of meshes within the frustum
  41670. */
  41671. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41672. /**
  41673. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41674. * @param sphereCenter defines the bounding sphere center
  41675. * @param sphereRadius defines the bounding sphere radius
  41676. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41677. * @returns an array of objects that intersect the sphere
  41678. */
  41679. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41680. /**
  41681. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41682. * @param ray defines the ray to test with
  41683. * @returns array of intersected objects
  41684. */
  41685. intersectsRay(ray: Ray): SmartArray<T>;
  41686. /**
  41687. * Adds a mesh into the octree block if it intersects the block
  41688. */
  41689. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41690. /**
  41691. * Adds a submesh into the octree block if it intersects the block
  41692. */
  41693. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41694. }
  41695. }
  41696. declare module BABYLON {
  41697. interface Scene {
  41698. /**
  41699. * @hidden
  41700. * Backing Filed
  41701. */ private _selectionOctree: Octree<AbstractMesh>;
  41702. /**
  41703. * Gets the octree used to boost mesh selection (picking)
  41704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41705. */
  41706. selectionOctree: Octree<AbstractMesh>;
  41707. /**
  41708. * Creates or updates the octree used to boost selection (picking)
  41709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41710. * @param maxCapacity defines the maximum capacity per leaf
  41711. * @param maxDepth defines the maximum depth of the octree
  41712. * @returns an octree of AbstractMesh
  41713. */
  41714. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41715. }
  41716. interface AbstractMesh {
  41717. /**
  41718. * @hidden
  41719. * Backing Field
  41720. */ private _submeshesOctree: Octree<SubMesh>;
  41721. /**
  41722. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41723. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41724. * @param maxCapacity defines the maximum size of each block (64 by default)
  41725. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41726. * @returns the new octree
  41727. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41729. */
  41730. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41731. }
  41732. /**
  41733. * Defines the octree scene component responsible to manage any octrees
  41734. * in a given scene.
  41735. */
  41736. export class OctreeSceneComponent {
  41737. /**
  41738. * The component name help to identify the component in the list of scene components.
  41739. */
  41740. readonly name: string;
  41741. /**
  41742. * The scene the component belongs to.
  41743. */
  41744. scene: Scene;
  41745. /**
  41746. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41747. */
  41748. readonly checksIsEnabled: boolean;
  41749. /**
  41750. * Creates a new instance of the component for the given scene
  41751. * @param scene Defines the scene to register the component in
  41752. */
  41753. constructor(scene: Scene);
  41754. /**
  41755. * Registers the component in a given scene
  41756. */
  41757. register(): void;
  41758. /**
  41759. * Return the list of active meshes
  41760. * @returns the list of active meshes
  41761. */
  41762. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41763. /**
  41764. * Return the list of active sub meshes
  41765. * @param mesh The mesh to get the candidates sub meshes from
  41766. * @returns the list of active sub meshes
  41767. */
  41768. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41769. private _tempRay;
  41770. /**
  41771. * Return the list of sub meshes intersecting with a given local ray
  41772. * @param mesh defines the mesh to find the submesh for
  41773. * @param localRay defines the ray in local space
  41774. * @returns the list of intersecting sub meshes
  41775. */
  41776. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41777. /**
  41778. * Return the list of sub meshes colliding with a collider
  41779. * @param mesh defines the mesh to find the submesh for
  41780. * @param collider defines the collider to evaluate the collision against
  41781. * @returns the list of colliding sub meshes
  41782. */
  41783. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41784. /**
  41785. * Rebuilds the elements related to this component in case of
  41786. * context lost for instance.
  41787. */
  41788. rebuild(): void;
  41789. /**
  41790. * Disposes the component and the associated ressources.
  41791. */
  41792. dispose(): void;
  41793. }
  41794. }
  41795. declare module BABYLON {
  41796. /**
  41797. * Renders a layer on top of an existing scene
  41798. */
  41799. export class UtilityLayerRenderer implements IDisposable {
  41800. /** the original scene that will be rendered on top of */
  41801. originalScene: Scene;
  41802. private _pointerCaptures;
  41803. private _lastPointerEvents;
  41804. private static _DefaultUtilityLayer;
  41805. private static _DefaultKeepDepthUtilityLayer;
  41806. private _sharedGizmoLight;
  41807. private _renderCamera;
  41808. /**
  41809. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41810. * @returns the camera that is used when rendering the utility layer
  41811. */
  41812. getRenderCamera(): Nullable<Camera>;
  41813. /**
  41814. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41815. * @param cam the camera that should be used when rendering the utility layer
  41816. */
  41817. setRenderCamera(cam: Nullable<Camera>): void;
  41818. /**
  41819. * @hidden
  41820. * Light which used by gizmos to get light shading
  41821. */ private _getSharedGizmoLight(): HemisphericLight;
  41822. /**
  41823. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41824. */
  41825. pickUtilitySceneFirst: boolean;
  41826. /**
  41827. * 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)
  41828. */
  41829. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41830. /**
  41831. * 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)
  41832. */
  41833. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41834. /**
  41835. * The scene that is rendered on top of the original scene
  41836. */
  41837. utilityLayerScene: Scene;
  41838. /**
  41839. * If the utility layer should automatically be rendered on top of existing scene
  41840. */
  41841. shouldRender: boolean;
  41842. /**
  41843. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41844. */
  41845. onlyCheckPointerDownEvents: boolean;
  41846. /**
  41847. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41848. */
  41849. processAllEvents: boolean;
  41850. /**
  41851. * Observable raised when the pointer move from the utility layer scene to the main scene
  41852. */
  41853. onPointerOutObservable: Observable<number>;
  41854. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41855. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41856. private _afterRenderObserver;
  41857. private _sceneDisposeObserver;
  41858. private _originalPointerObserver;
  41859. /**
  41860. * Instantiates a UtilityLayerRenderer
  41861. * @param originalScene the original scene that will be rendered on top of
  41862. * @param handleEvents boolean indicating if the utility layer should handle events
  41863. */
  41864. constructor(
  41865. /** the original scene that will be rendered on top of */
  41866. originalScene: Scene, handleEvents?: boolean);
  41867. private _notifyObservers;
  41868. /**
  41869. * Renders the utility layers scene on top of the original scene
  41870. */
  41871. render(): void;
  41872. /**
  41873. * Disposes of the renderer
  41874. */
  41875. dispose(): void;
  41876. private _updateCamera;
  41877. }
  41878. }
  41879. declare module BABYLON {
  41880. /**
  41881. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41882. */
  41883. export class Gizmo implements IDisposable {
  41884. /** The utility layer the gizmo will be added to */
  41885. gizmoLayer: UtilityLayerRenderer;
  41886. /**
  41887. * The root mesh of the gizmo
  41888. */ private _rootMesh: Mesh;
  41889. private _attachedMesh;
  41890. /**
  41891. * Ratio for the scale of the gizmo (Default: 1)
  41892. */
  41893. scaleRatio: number;
  41894. /**
  41895. * If a custom mesh has been set (Default: false)
  41896. */
  41897. protected _customMeshSet: boolean;
  41898. /**
  41899. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41900. * * When set, interactions will be enabled
  41901. */
  41902. attachedMesh: Nullable<AbstractMesh>;
  41903. /**
  41904. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41905. * @param mesh The mesh to replace the default mesh of the gizmo
  41906. */
  41907. setCustomMesh(mesh: Mesh): void;
  41908. /**
  41909. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41910. */
  41911. updateGizmoRotationToMatchAttachedMesh: boolean;
  41912. /**
  41913. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41914. */
  41915. updateGizmoPositionToMatchAttachedMesh: boolean;
  41916. /**
  41917. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41918. */
  41919. updateScale: boolean;
  41920. protected _interactionsEnabled: boolean;
  41921. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41922. private _beforeRenderObserver;
  41923. private _tempVector;
  41924. /**
  41925. * Creates a gizmo
  41926. * @param gizmoLayer The utility layer the gizmo will be added to
  41927. */
  41928. constructor(
  41929. /** The utility layer the gizmo will be added to */
  41930. gizmoLayer?: UtilityLayerRenderer);
  41931. /**
  41932. * Updates the gizmo to match the attached mesh's position/rotation
  41933. */
  41934. protected _update(): void;
  41935. /**
  41936. * Disposes of the gizmo
  41937. */
  41938. dispose(): void;
  41939. }
  41940. }
  41941. declare module BABYLON {
  41942. /**
  41943. * Single plane drag gizmo
  41944. */
  41945. export class PlaneDragGizmo extends Gizmo {
  41946. /**
  41947. * Drag behavior responsible for the gizmos dragging interactions
  41948. */
  41949. dragBehavior: PointerDragBehavior;
  41950. private _pointerObserver;
  41951. /**
  41952. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41953. */
  41954. snapDistance: number;
  41955. /**
  41956. * Event that fires each time the gizmo snaps to a new location.
  41957. * * snapDistance is the the change in distance
  41958. */
  41959. onSnapObservable: Observable<{
  41960. snapDistance: number;
  41961. }>;
  41962. private _plane;
  41963. private _coloredMaterial;
  41964. private _hoverMaterial;
  41965. private _isEnabled;
  41966. private _parent;
  41967. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41968. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41969. /**
  41970. * Creates a PlaneDragGizmo
  41971. * @param gizmoLayer The utility layer the gizmo will be added to
  41972. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41973. * @param color The color of the gizmo
  41974. */
  41975. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41976. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41977. /**
  41978. * If the gizmo is enabled
  41979. */
  41980. isEnabled: boolean;
  41981. /**
  41982. * Disposes of the gizmo
  41983. */
  41984. dispose(): void;
  41985. }
  41986. }
  41987. declare module BABYLON {
  41988. /**
  41989. * Gizmo that enables dragging a mesh along 3 axis
  41990. */
  41991. export class PositionGizmo extends Gizmo {
  41992. /**
  41993. * Internal gizmo used for interactions on the x axis
  41994. */
  41995. xGizmo: AxisDragGizmo;
  41996. /**
  41997. * Internal gizmo used for interactions on the y axis
  41998. */
  41999. yGizmo: AxisDragGizmo;
  42000. /**
  42001. * Internal gizmo used for interactions on the z axis
  42002. */
  42003. zGizmo: AxisDragGizmo;
  42004. /**
  42005. * Internal gizmo used for interactions on the yz plane
  42006. */
  42007. xPlaneGizmo: PlaneDragGizmo;
  42008. /**
  42009. * Internal gizmo used for interactions on the xz plane
  42010. */
  42011. yPlaneGizmo: PlaneDragGizmo;
  42012. /**
  42013. * Internal gizmo used for interactions on the xy plane
  42014. */
  42015. zPlaneGizmo: PlaneDragGizmo;
  42016. /**
  42017. * private variables
  42018. */
  42019. private _meshAttached;
  42020. private _updateGizmoRotationToMatchAttachedMesh;
  42021. private _snapDistance;
  42022. private _scaleRatio;
  42023. /** Fires an event when any of it's sub gizmos are dragged */
  42024. onDragStartObservable: Observable<unknown>;
  42025. /** Fires an event when any of it's sub gizmos are released from dragging */
  42026. onDragEndObservable: Observable<unknown>;
  42027. /**
  42028. * If set to true, planar drag is enabled
  42029. */
  42030. private _planarGizmoEnabled;
  42031. attachedMesh: Nullable<AbstractMesh>;
  42032. /**
  42033. * Creates a PositionGizmo
  42034. * @param gizmoLayer The utility layer the gizmo will be added to
  42035. */
  42036. constructor(gizmoLayer?: UtilityLayerRenderer);
  42037. /**
  42038. * If the planar drag gizmo is enabled
  42039. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42040. */
  42041. planarGizmoEnabled: boolean;
  42042. updateGizmoRotationToMatchAttachedMesh: boolean;
  42043. /**
  42044. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42045. */
  42046. snapDistance: number;
  42047. /**
  42048. * Ratio for the scale of the gizmo (Default: 1)
  42049. */
  42050. scaleRatio: number;
  42051. /**
  42052. * Disposes of the gizmo
  42053. */
  42054. dispose(): void;
  42055. /**
  42056. * CustomMeshes are not supported by this gizmo
  42057. * @param mesh The mesh to replace the default mesh of the gizmo
  42058. */
  42059. setCustomMesh(mesh: Mesh): void;
  42060. }
  42061. }
  42062. declare module BABYLON {
  42063. /**
  42064. * Single axis drag gizmo
  42065. */
  42066. export class AxisDragGizmo extends Gizmo {
  42067. /**
  42068. * Drag behavior responsible for the gizmos dragging interactions
  42069. */
  42070. dragBehavior: PointerDragBehavior;
  42071. private _pointerObserver;
  42072. /**
  42073. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42074. */
  42075. snapDistance: number;
  42076. /**
  42077. * Event that fires each time the gizmo snaps to a new location.
  42078. * * snapDistance is the the change in distance
  42079. */
  42080. onSnapObservable: Observable<{
  42081. snapDistance: number;
  42082. }>;
  42083. private _isEnabled;
  42084. private _parent;
  42085. private _arrow;
  42086. private _coloredMaterial;
  42087. private _hoverMaterial;
  42088. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42089. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42090. /**
  42091. * Creates an AxisDragGizmo
  42092. * @param gizmoLayer The utility layer the gizmo will be added to
  42093. * @param dragAxis The axis which the gizmo will be able to drag on
  42094. * @param color The color of the gizmo
  42095. */
  42096. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42097. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42098. /**
  42099. * If the gizmo is enabled
  42100. */
  42101. isEnabled: boolean;
  42102. /**
  42103. * Disposes of the gizmo
  42104. */
  42105. dispose(): void;
  42106. }
  42107. }
  42108. declare module BABYLON.Debug {
  42109. /**
  42110. * The Axes viewer will show 3 axes in a specific point in space
  42111. */
  42112. export class AxesViewer {
  42113. private _xAxis;
  42114. private _yAxis;
  42115. private _zAxis;
  42116. private _scaleLinesFactor;
  42117. private _instanced;
  42118. /**
  42119. * Gets the hosting scene
  42120. */
  42121. scene: Scene;
  42122. /**
  42123. * Gets or sets a number used to scale line length
  42124. */
  42125. scaleLines: number;
  42126. /** Gets the node hierarchy used to render x-axis */
  42127. readonly xAxis: TransformNode;
  42128. /** Gets the node hierarchy used to render y-axis */
  42129. readonly yAxis: TransformNode;
  42130. /** Gets the node hierarchy used to render z-axis */
  42131. readonly zAxis: TransformNode;
  42132. /**
  42133. * Creates a new AxesViewer
  42134. * @param scene defines the hosting scene
  42135. * @param scaleLines defines a number used to scale line length (1 by default)
  42136. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42137. * @param xAxis defines the node hierarchy used to render the x-axis
  42138. * @param yAxis defines the node hierarchy used to render the y-axis
  42139. * @param zAxis defines the node hierarchy used to render the z-axis
  42140. */
  42141. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42142. /**
  42143. * Force the viewer to update
  42144. * @param position defines the position of the viewer
  42145. * @param xaxis defines the x axis of the viewer
  42146. * @param yaxis defines the y axis of the viewer
  42147. * @param zaxis defines the z axis of the viewer
  42148. */
  42149. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42150. /**
  42151. * Creates an instance of this axes viewer.
  42152. * @returns a new axes viewer with instanced meshes
  42153. */
  42154. createInstance(): AxesViewer;
  42155. /** Releases resources */
  42156. dispose(): void;
  42157. private static _SetRenderingGroupId;
  42158. }
  42159. }
  42160. declare module BABYLON.Debug {
  42161. /**
  42162. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42163. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42164. */
  42165. export class BoneAxesViewer extends AxesViewer {
  42166. /**
  42167. * Gets or sets the target mesh where to display the axes viewer
  42168. */
  42169. mesh: Nullable<Mesh>;
  42170. /**
  42171. * Gets or sets the target bone where to display the axes viewer
  42172. */
  42173. bone: Nullable<Bone>;
  42174. /** Gets current position */
  42175. pos: Vector3;
  42176. /** Gets direction of X axis */
  42177. xaxis: Vector3;
  42178. /** Gets direction of Y axis */
  42179. yaxis: Vector3;
  42180. /** Gets direction of Z axis */
  42181. zaxis: Vector3;
  42182. /**
  42183. * Creates a new BoneAxesViewer
  42184. * @param scene defines the hosting scene
  42185. * @param bone defines the target bone
  42186. * @param mesh defines the target mesh
  42187. * @param scaleLines defines a scaling factor for line length (1 by default)
  42188. */
  42189. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42190. /**
  42191. * Force the viewer to update
  42192. */
  42193. update(): void;
  42194. /** Releases resources */
  42195. dispose(): void;
  42196. }
  42197. }
  42198. declare module BABYLON {
  42199. /**
  42200. * Interface used to define scene explorer extensibility option
  42201. */
  42202. export interface IExplorerExtensibilityOption {
  42203. /**
  42204. * Define the option label
  42205. */
  42206. label: string;
  42207. /**
  42208. * Defines the action to execute on click
  42209. */
  42210. action: (entity: any) => void;
  42211. }
  42212. /**
  42213. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42214. */
  42215. export interface IExplorerExtensibilityGroup {
  42216. /**
  42217. * Defines a predicate to test if a given type mut be extended
  42218. */
  42219. predicate: (entity: any) => boolean;
  42220. /**
  42221. * Gets the list of options added to a type
  42222. */
  42223. entries: IExplorerExtensibilityOption[];
  42224. }
  42225. /**
  42226. * Interface used to define the options to use to create the Inspector
  42227. */
  42228. export interface IInspectorOptions {
  42229. /**
  42230. * Display in overlay mode (default: false)
  42231. */
  42232. overlay?: boolean;
  42233. /**
  42234. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42235. */
  42236. globalRoot?: HTMLElement;
  42237. /**
  42238. * Display the Scene explorer
  42239. */
  42240. showExplorer?: boolean;
  42241. /**
  42242. * Display the property inspector
  42243. */
  42244. showInspector?: boolean;
  42245. /**
  42246. * Display in embed mode (both panes on the right)
  42247. */
  42248. embedMode?: boolean;
  42249. /**
  42250. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42251. */
  42252. handleResize?: boolean;
  42253. /**
  42254. * Allow the panes to popup (default: true)
  42255. */
  42256. enablePopup?: boolean;
  42257. /**
  42258. * Allow the panes to be closed by users (default: true)
  42259. */
  42260. enableClose?: boolean;
  42261. /**
  42262. * Optional list of extensibility entries
  42263. */
  42264. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42265. /**
  42266. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42267. */
  42268. inspectorURL?: string;
  42269. }
  42270. interface Scene {
  42271. /**
  42272. * @hidden
  42273. * Backing field
  42274. */ private _debugLayer: DebugLayer;
  42275. /**
  42276. * Gets the debug layer (aka Inspector) associated with the scene
  42277. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42278. */
  42279. debugLayer: DebugLayer;
  42280. }
  42281. /**
  42282. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42283. * what is happening in your scene
  42284. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42285. */
  42286. export class DebugLayer {
  42287. /**
  42288. * Define the url to get the inspector script from.
  42289. * By default it uses the babylonjs CDN.
  42290. * @ignoreNaming
  42291. */
  42292. static InspectorURL: string;
  42293. private _scene;
  42294. private BJSINSPECTOR;
  42295. private _onPropertyChangedObservable?;
  42296. /**
  42297. * Observable triggered when a property is changed through the inspector.
  42298. */
  42299. readonly onPropertyChangedObservable: any;
  42300. /**
  42301. * Instantiates a new debug layer.
  42302. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42303. * what is happening in your scene
  42304. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42305. * @param scene Defines the scene to inspect
  42306. */
  42307. constructor(scene: Scene);
  42308. /** Creates the inspector window. */
  42309. private _createInspector;
  42310. /**
  42311. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42312. * @param entity defines the entity to select
  42313. * @param lineContainerTitle defines the specific block to highlight
  42314. */
  42315. select(entity: any, lineContainerTitle?: string): void;
  42316. /** Get the inspector from bundle or global */
  42317. private _getGlobalInspector;
  42318. /**
  42319. * Get if the inspector is visible or not.
  42320. * @returns true if visible otherwise, false
  42321. */
  42322. isVisible(): boolean;
  42323. /**
  42324. * Hide the inspector and close its window.
  42325. */
  42326. hide(): void;
  42327. /**
  42328. * Launch the debugLayer.
  42329. * @param config Define the configuration of the inspector
  42330. * @return a promise fulfilled when the debug layer is visible
  42331. */
  42332. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42333. }
  42334. }
  42335. declare module BABYLON {
  42336. /**
  42337. * Class containing static functions to help procedurally build meshes
  42338. */
  42339. export class BoxBuilder {
  42340. /**
  42341. * Creates a box mesh
  42342. * * The parameter `size` sets the size (float) of each box side (default 1)
  42343. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42344. * * 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)
  42345. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42347. * * 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
  42348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42349. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42350. * @param name defines the name of the mesh
  42351. * @param options defines the options used to create the mesh
  42352. * @param scene defines the hosting scene
  42353. * @returns the box mesh
  42354. */
  42355. static CreateBox(name: string, options: {
  42356. size?: number;
  42357. width?: number;
  42358. height?: number;
  42359. depth?: number;
  42360. faceUV?: Vector4[];
  42361. faceColors?: Color4[];
  42362. sideOrientation?: number;
  42363. frontUVs?: Vector4;
  42364. backUVs?: Vector4;
  42365. wrap?: boolean;
  42366. topBaseAt?: number;
  42367. bottomBaseAt?: number;
  42368. updatable?: boolean;
  42369. }, scene?: Nullable<Scene>): Mesh;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. /**
  42374. * Class containing static functions to help procedurally build meshes
  42375. */
  42376. export class SphereBuilder {
  42377. /**
  42378. * Creates a sphere mesh
  42379. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42380. * * 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`)
  42381. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42382. * * 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
  42383. * * 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)
  42384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42385. * * 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
  42386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42387. * @param name defines the name of the mesh
  42388. * @param options defines the options used to create the mesh
  42389. * @param scene defines the hosting scene
  42390. * @returns the sphere mesh
  42391. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42392. */
  42393. static CreateSphere(name: string, options: {
  42394. segments?: number;
  42395. diameter?: number;
  42396. diameterX?: number;
  42397. diameterY?: number;
  42398. diameterZ?: number;
  42399. arc?: number;
  42400. slice?: number;
  42401. sideOrientation?: number;
  42402. frontUVs?: Vector4;
  42403. backUVs?: Vector4;
  42404. updatable?: boolean;
  42405. }, scene?: Nullable<Scene>): Mesh;
  42406. }
  42407. }
  42408. declare module BABYLON.Debug {
  42409. /**
  42410. * Used to show the physics impostor around the specific mesh
  42411. */
  42412. export class PhysicsViewer {
  42413. /** @hidden */
  42414. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42415. /** @hidden */
  42416. protected _meshes: Array<Nullable<AbstractMesh>>;
  42417. /** @hidden */
  42418. protected _scene: Nullable<Scene>;
  42419. /** @hidden */
  42420. protected _numMeshes: number;
  42421. /** @hidden */
  42422. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42423. private _renderFunction;
  42424. private _utilityLayer;
  42425. private _debugBoxMesh;
  42426. private _debugSphereMesh;
  42427. private _debugCylinderMesh;
  42428. private _debugMaterial;
  42429. private _debugMeshMeshes;
  42430. /**
  42431. * Creates a new PhysicsViewer
  42432. * @param scene defines the hosting scene
  42433. */
  42434. constructor(scene: Scene);
  42435. /** @hidden */
  42436. protected _updateDebugMeshes(): void;
  42437. /**
  42438. * Renders a specified physic impostor
  42439. * @param impostor defines the impostor to render
  42440. * @param targetMesh defines the mesh represented by the impostor
  42441. * @returns the new debug mesh used to render the impostor
  42442. */
  42443. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42444. /**
  42445. * Hides a specified physic impostor
  42446. * @param impostor defines the impostor to hide
  42447. */
  42448. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42449. private _getDebugMaterial;
  42450. private _getDebugBoxMesh;
  42451. private _getDebugSphereMesh;
  42452. private _getDebugCylinderMesh;
  42453. private _getDebugMeshMesh;
  42454. private _getDebugMesh;
  42455. /** Releases all resources */
  42456. dispose(): void;
  42457. }
  42458. }
  42459. declare module BABYLON {
  42460. /**
  42461. * Class containing static functions to help procedurally build meshes
  42462. */
  42463. export class LinesBuilder {
  42464. /**
  42465. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42466. * * 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
  42467. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42468. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42469. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42470. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42471. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42472. * * 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
  42473. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42476. * @param name defines the name of the new line system
  42477. * @param options defines the options used to create the line system
  42478. * @param scene defines the hosting scene
  42479. * @returns a new line system mesh
  42480. */
  42481. static CreateLineSystem(name: string, options: {
  42482. lines: Vector3[][];
  42483. updatable?: boolean;
  42484. instance?: Nullable<LinesMesh>;
  42485. colors?: Nullable<Color4[][]>;
  42486. useVertexAlpha?: boolean;
  42487. }, scene: Nullable<Scene>): LinesMesh;
  42488. /**
  42489. * Creates a line mesh
  42490. * 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
  42491. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42492. * * The parameter `points` is an array successive Vector3
  42493. * * 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
  42494. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42495. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42496. * * When updating an instance, remember that only point positions can change, not the number of points
  42497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42499. * @param name defines the name of the new line system
  42500. * @param options defines the options used to create the line system
  42501. * @param scene defines the hosting scene
  42502. * @returns a new line mesh
  42503. */
  42504. static CreateLines(name: string, options: {
  42505. points: Vector3[];
  42506. updatable?: boolean;
  42507. instance?: Nullable<LinesMesh>;
  42508. colors?: Color4[];
  42509. useVertexAlpha?: boolean;
  42510. }, scene?: Nullable<Scene>): LinesMesh;
  42511. /**
  42512. * Creates a dashed line mesh
  42513. * * 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
  42514. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42515. * * The parameter `points` is an array successive Vector3
  42516. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42517. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42518. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42519. * * 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
  42520. * * When updating an instance, remember that only point positions can change, not the number of points
  42521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42522. * @param name defines the name of the mesh
  42523. * @param options defines the options used to create the mesh
  42524. * @param scene defines the hosting scene
  42525. * @returns the dashed line mesh
  42526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42527. */
  42528. static CreateDashedLines(name: string, options: {
  42529. points: Vector3[];
  42530. dashSize?: number;
  42531. gapSize?: number;
  42532. dashNb?: number;
  42533. updatable?: boolean;
  42534. instance?: LinesMesh;
  42535. }, scene?: Nullable<Scene>): LinesMesh;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /**
  42540. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42541. * in order to better appreciate the issue one might have.
  42542. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42543. */
  42544. export class RayHelper {
  42545. /**
  42546. * Defines the ray we are currently tryin to visualize.
  42547. */
  42548. ray: Nullable<Ray>;
  42549. private _renderPoints;
  42550. private _renderLine;
  42551. private _renderFunction;
  42552. private _scene;
  42553. private _updateToMeshFunction;
  42554. private _attachedToMesh;
  42555. private _meshSpaceDirection;
  42556. private _meshSpaceOrigin;
  42557. /**
  42558. * Helper function to create a colored helper in a scene in one line.
  42559. * @param ray Defines the ray we are currently tryin to visualize
  42560. * @param scene Defines the scene the ray is used in
  42561. * @param color Defines the color we want to see the ray in
  42562. * @returns The newly created ray helper.
  42563. */
  42564. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42565. /**
  42566. * Instantiate a new ray helper.
  42567. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42568. * in order to better appreciate the issue one might have.
  42569. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42570. * @param ray Defines the ray we are currently tryin to visualize
  42571. */
  42572. constructor(ray: Ray);
  42573. /**
  42574. * Shows the ray we are willing to debug.
  42575. * @param scene Defines the scene the ray needs to be rendered in
  42576. * @param color Defines the color the ray needs to be rendered in
  42577. */
  42578. show(scene: Scene, color?: Color3): void;
  42579. /**
  42580. * Hides the ray we are debugging.
  42581. */
  42582. hide(): void;
  42583. private _render;
  42584. /**
  42585. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42586. * @param mesh Defines the mesh we want the helper attached to
  42587. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42588. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42589. * @param length Defines the length of the ray
  42590. */
  42591. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42592. /**
  42593. * Detach the ray helper from the mesh it has previously been attached to.
  42594. */
  42595. detachFromMesh(): void;
  42596. private _updateToMesh;
  42597. /**
  42598. * Dispose the helper and release its associated resources.
  42599. */
  42600. dispose(): void;
  42601. }
  42602. }
  42603. declare module BABYLON.Debug {
  42604. /**
  42605. * Class used to render a debug view of a given skeleton
  42606. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42607. */
  42608. export class SkeletonViewer {
  42609. /** defines the skeleton to render */
  42610. skeleton: Skeleton;
  42611. /** defines the mesh attached to the skeleton */
  42612. mesh: AbstractMesh;
  42613. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42614. autoUpdateBonesMatrices: boolean;
  42615. /** defines the rendering group id to use with the viewer */
  42616. renderingGroupId: number;
  42617. /** Gets or sets the color used to render the skeleton */
  42618. color: Color3;
  42619. private _scene;
  42620. private _debugLines;
  42621. private _debugMesh;
  42622. private _isEnabled;
  42623. private _renderFunction;
  42624. private _utilityLayer;
  42625. /**
  42626. * Returns the mesh used to render the bones
  42627. */
  42628. readonly debugMesh: Nullable<LinesMesh>;
  42629. /**
  42630. * Creates a new SkeletonViewer
  42631. * @param skeleton defines the skeleton to render
  42632. * @param mesh defines the mesh attached to the skeleton
  42633. * @param scene defines the hosting scene
  42634. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42635. * @param renderingGroupId defines the rendering group id to use with the viewer
  42636. */
  42637. constructor(
  42638. /** defines the skeleton to render */
  42639. skeleton: Skeleton,
  42640. /** defines the mesh attached to the skeleton */
  42641. mesh: AbstractMesh, scene: Scene,
  42642. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42643. autoUpdateBonesMatrices?: boolean,
  42644. /** defines the rendering group id to use with the viewer */
  42645. renderingGroupId?: number);
  42646. /** Gets or sets a boolean indicating if the viewer is enabled */
  42647. isEnabled: boolean;
  42648. private _getBonePosition;
  42649. private _getLinesForBonesWithLength;
  42650. private _getLinesForBonesNoLength;
  42651. /** Update the viewer to sync with current skeleton state */
  42652. update(): void;
  42653. /** Release associated resources */
  42654. dispose(): void;
  42655. }
  42656. }
  42657. declare module BABYLON {
  42658. /**
  42659. * Options to create the null engine
  42660. */
  42661. export class NullEngineOptions {
  42662. /**
  42663. * Render width (Default: 512)
  42664. */
  42665. renderWidth: number;
  42666. /**
  42667. * Render height (Default: 256)
  42668. */
  42669. renderHeight: number;
  42670. /**
  42671. * Texture size (Default: 512)
  42672. */
  42673. textureSize: number;
  42674. /**
  42675. * If delta time between frames should be constant
  42676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42677. */
  42678. deterministicLockstep: boolean;
  42679. /**
  42680. * Maximum about of steps between frames (Default: 4)
  42681. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42682. */
  42683. lockstepMaxSteps: number;
  42684. }
  42685. /**
  42686. * The null engine class provides support for headless version of babylon.js.
  42687. * This can be used in server side scenario or for testing purposes
  42688. */
  42689. export class NullEngine extends Engine {
  42690. private _options;
  42691. /**
  42692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42693. */
  42694. isDeterministicLockStep(): boolean;
  42695. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42696. getLockstepMaxSteps(): number;
  42697. /**
  42698. * Sets hardware scaling, used to save performance if needed
  42699. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42700. */
  42701. getHardwareScalingLevel(): number;
  42702. constructor(options?: NullEngineOptions);
  42703. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42704. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42705. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42706. getRenderWidth(useScreen?: boolean): number;
  42707. getRenderHeight(useScreen?: boolean): number;
  42708. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42709. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42710. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42711. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42712. bindSamplers(effect: Effect): void;
  42713. enableEffect(effect: Effect): void;
  42714. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42715. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42716. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42717. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42718. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42719. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42720. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42721. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42722. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42723. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42724. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42725. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42726. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42727. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42728. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42729. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42730. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42731. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42732. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42733. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42734. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42735. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42736. bindBuffers(vertexBuffers: {
  42737. [key: string]: VertexBuffer;
  42738. }, indexBuffer: DataBuffer, effect: Effect): void;
  42739. wipeCaches(bruteForce?: boolean): void;
  42740. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42741. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42742. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42743. /** @hidden */ private _createTexture(): WebGLTexture;
  42744. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42745. 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;
  42746. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42747. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42748. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42749. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42750. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42751. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42752. areAllEffectsReady(): boolean;
  42753. /**
  42754. * @hidden
  42755. * Get the current error code of the webGL context
  42756. * @returns the error code
  42757. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42758. */
  42759. getError(): number;
  42760. /** @hidden */ private _getUnpackAlignement(): number;
  42761. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42762. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42763. /**
  42764. * Updates a dynamic vertex buffer.
  42765. * @param vertexBuffer the vertex buffer to update
  42766. * @param data the data used to update the vertex buffer
  42767. * @param byteOffset the byte offset of the data (optional)
  42768. * @param byteLength the byte length of the data (optional)
  42769. */
  42770. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42771. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42772. protected _deleteBuffer(buffer: WebGLBuffer): void;
  42773. releaseEffects(): void;
  42774. displayLoadingUI(): void;
  42775. hideLoadingUI(): void;
  42776. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42777. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42778. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42779. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42780. }
  42781. }
  42782. declare module BABYLON {
  42783. /** @hidden */
  42784. export class _OcclusionDataStorage {
  42785. /** @hidden */
  42786. occlusionInternalRetryCounter: number;
  42787. /** @hidden */
  42788. isOcclusionQueryInProgress: boolean;
  42789. /** @hidden */
  42790. isOccluded: boolean;
  42791. /** @hidden */
  42792. occlusionRetryCount: number;
  42793. /** @hidden */
  42794. occlusionType: number;
  42795. /** @hidden */
  42796. occlusionQueryAlgorithmType: number;
  42797. }
  42798. interface Engine {
  42799. /**
  42800. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42801. * @return the new query
  42802. */
  42803. createQuery(): WebGLQuery;
  42804. /**
  42805. * Delete and release a webGL query
  42806. * @param query defines the query to delete
  42807. * @return the current engine
  42808. */
  42809. deleteQuery(query: WebGLQuery): Engine;
  42810. /**
  42811. * Check if a given query has resolved and got its value
  42812. * @param query defines the query to check
  42813. * @returns true if the query got its value
  42814. */
  42815. isQueryResultAvailable(query: WebGLQuery): boolean;
  42816. /**
  42817. * Gets the value of a given query
  42818. * @param query defines the query to check
  42819. * @returns the value of the query
  42820. */
  42821. getQueryResult(query: WebGLQuery): number;
  42822. /**
  42823. * Initiates an occlusion query
  42824. * @param algorithmType defines the algorithm to use
  42825. * @param query defines the query to use
  42826. * @returns the current engine
  42827. * @see http://doc.babylonjs.com/features/occlusionquery
  42828. */
  42829. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42830. /**
  42831. * Ends an occlusion query
  42832. * @see http://doc.babylonjs.com/features/occlusionquery
  42833. * @param algorithmType defines the algorithm to use
  42834. * @returns the current engine
  42835. */
  42836. endOcclusionQuery(algorithmType: number): Engine;
  42837. /**
  42838. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42839. * Please note that only one query can be issued at a time
  42840. * @returns a time token used to track the time span
  42841. */
  42842. startTimeQuery(): Nullable<_TimeToken>;
  42843. /**
  42844. * Ends a time query
  42845. * @param token defines the token used to measure the time span
  42846. * @returns the time spent (in ns)
  42847. */
  42848. endTimeQuery(token: _TimeToken): int;
  42849. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42850. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42851. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42852. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42853. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42854. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42855. }
  42856. interface AbstractMesh {
  42857. /**
  42858. * Backing filed
  42859. * @hidden
  42860. */ private __occlusionDataStorage: _OcclusionDataStorage;
  42861. /**
  42862. * Access property
  42863. * @hidden
  42864. */ private _occlusionDataStorage: _OcclusionDataStorage;
  42865. /**
  42866. * 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.
  42867. * The default value is -1 which means don't break the query and wait till the result
  42868. * @see http://doc.babylonjs.com/features/occlusionquery
  42869. */
  42870. occlusionRetryCount: number;
  42871. /**
  42872. * 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:
  42873. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42874. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42875. * * 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.
  42876. * @see http://doc.babylonjs.com/features/occlusionquery
  42877. */
  42878. occlusionType: number;
  42879. /**
  42880. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42881. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42882. * * 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.
  42883. * @see http://doc.babylonjs.com/features/occlusionquery
  42884. */
  42885. occlusionQueryAlgorithmType: number;
  42886. /**
  42887. * 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
  42888. * @see http://doc.babylonjs.com/features/occlusionquery
  42889. */
  42890. isOccluded: boolean;
  42891. /**
  42892. * Flag to check the progress status of the query
  42893. * @see http://doc.babylonjs.com/features/occlusionquery
  42894. */
  42895. isOcclusionQueryInProgress: boolean;
  42896. }
  42897. }
  42898. declare module BABYLON {
  42899. /** @hidden */
  42900. export var _forceTransformFeedbackToBundle: boolean;
  42901. interface Engine {
  42902. /**
  42903. * Creates a webGL transform feedback object
  42904. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42905. * @returns the webGL transform feedback object
  42906. */
  42907. createTransformFeedback(): WebGLTransformFeedback;
  42908. /**
  42909. * Delete a webGL transform feedback object
  42910. * @param value defines the webGL transform feedback object to delete
  42911. */
  42912. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42913. /**
  42914. * Bind a webGL transform feedback object to the webgl context
  42915. * @param value defines the webGL transform feedback object to bind
  42916. */
  42917. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42918. /**
  42919. * Begins a transform feedback operation
  42920. * @param usePoints defines if points or triangles must be used
  42921. */
  42922. beginTransformFeedback(usePoints: boolean): void;
  42923. /**
  42924. * Ends a transform feedback operation
  42925. */
  42926. endTransformFeedback(): void;
  42927. /**
  42928. * Specify the varyings to use with transform feedback
  42929. * @param program defines the associated webGL program
  42930. * @param value defines the list of strings representing the varying names
  42931. */
  42932. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42933. /**
  42934. * Bind a webGL buffer for a transform feedback operation
  42935. * @param value defines the webGL buffer to bind
  42936. */
  42937. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42938. }
  42939. }
  42940. declare module BABYLON {
  42941. /**
  42942. * Creation options of the multi render target texture.
  42943. */
  42944. export interface IMultiRenderTargetOptions {
  42945. /**
  42946. * Define if the texture needs to create mip maps after render.
  42947. */
  42948. generateMipMaps?: boolean;
  42949. /**
  42950. * Define the types of all the draw buffers we want to create
  42951. */
  42952. types?: number[];
  42953. /**
  42954. * Define the sampling modes of all the draw buffers we want to create
  42955. */
  42956. samplingModes?: number[];
  42957. /**
  42958. * Define if a depth buffer is required
  42959. */
  42960. generateDepthBuffer?: boolean;
  42961. /**
  42962. * Define if a stencil buffer is required
  42963. */
  42964. generateStencilBuffer?: boolean;
  42965. /**
  42966. * Define if a depth texture is required instead of a depth buffer
  42967. */
  42968. generateDepthTexture?: boolean;
  42969. /**
  42970. * Define the number of desired draw buffers
  42971. */
  42972. textureCount?: number;
  42973. /**
  42974. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42975. */
  42976. doNotChangeAspectRatio?: boolean;
  42977. /**
  42978. * Define the default type of the buffers we are creating
  42979. */
  42980. defaultType?: number;
  42981. }
  42982. /**
  42983. * A multi render target, like a render target provides the ability to render to a texture.
  42984. * Unlike the render target, it can render to several draw buffers in one draw.
  42985. * This is specially interesting in deferred rendering or for any effects requiring more than
  42986. * just one color from a single pass.
  42987. */
  42988. export class MultiRenderTarget extends RenderTargetTexture {
  42989. private _internalTextures;
  42990. private _textures;
  42991. private _multiRenderTargetOptions;
  42992. /**
  42993. * Get if draw buffers are currently supported by the used hardware and browser.
  42994. */
  42995. readonly isSupported: boolean;
  42996. /**
  42997. * Get the list of textures generated by the multi render target.
  42998. */
  42999. readonly textures: Texture[];
  43000. /**
  43001. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43002. */
  43003. readonly depthTexture: Texture;
  43004. /**
  43005. * Set the wrapping mode on U of all the textures we are rendering to.
  43006. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43007. */
  43008. wrapU: number;
  43009. /**
  43010. * Set the wrapping mode on V of all the textures we are rendering to.
  43011. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43012. */
  43013. wrapV: number;
  43014. /**
  43015. * Instantiate a new multi render target texture.
  43016. * A multi render target, like a render target provides the ability to render to a texture.
  43017. * Unlike the render target, it can render to several draw buffers in one draw.
  43018. * This is specially interesting in deferred rendering or for any effects requiring more than
  43019. * just one color from a single pass.
  43020. * @param name Define the name of the texture
  43021. * @param size Define the size of the buffers to render to
  43022. * @param count Define the number of target we are rendering into
  43023. * @param scene Define the scene the texture belongs to
  43024. * @param options Define the options used to create the multi render target
  43025. */
  43026. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43027. /** @hidden */ private _rebuild(): void;
  43028. private _createInternalTextures;
  43029. private _createTextures;
  43030. /**
  43031. * Define the number of samples used if MSAA is enabled.
  43032. */
  43033. samples: number;
  43034. /**
  43035. * Resize all the textures in the multi render target.
  43036. * Be carrefull as it will recreate all the data in the new texture.
  43037. * @param size Define the new size
  43038. */
  43039. resize(size: any): void;
  43040. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43041. /**
  43042. * Dispose the render targets and their associated resources
  43043. */
  43044. dispose(): void;
  43045. /**
  43046. * Release all the underlying texture used as draw buffers.
  43047. */
  43048. releaseInternalTextures(): void;
  43049. }
  43050. }
  43051. declare module BABYLON {
  43052. interface Engine {
  43053. /**
  43054. * Unbind a list of render target textures from the webGL context
  43055. * This is used only when drawBuffer extension or webGL2 are active
  43056. * @param textures defines the render target textures to unbind
  43057. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43058. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43059. */
  43060. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43061. /**
  43062. * Create a multi render target texture
  43063. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43064. * @param size defines the size of the texture
  43065. * @param options defines the creation options
  43066. * @returns the cube texture as an InternalTexture
  43067. */
  43068. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43069. /**
  43070. * Update the sample count for a given multiple render target texture
  43071. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43072. * @param textures defines the textures to update
  43073. * @param samples defines the sample count to set
  43074. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43075. */
  43076. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43077. }
  43078. }
  43079. declare module BABYLON {
  43080. /** @hidden */
  43081. export var rgbdEncodePixelShader: {
  43082. name: string;
  43083. shader: string;
  43084. };
  43085. }
  43086. declare module BABYLON {
  43087. /** @hidden */
  43088. export var rgbdDecodePixelShader: {
  43089. name: string;
  43090. shader: string;
  43091. };
  43092. }
  43093. declare module BABYLON {
  43094. /**
  43095. * Raw texture data and descriptor sufficient for WebGL texture upload
  43096. */
  43097. export interface EnvironmentTextureInfo {
  43098. /**
  43099. * Version of the environment map
  43100. */
  43101. version: number;
  43102. /**
  43103. * Width of image
  43104. */
  43105. width: number;
  43106. /**
  43107. * Irradiance information stored in the file.
  43108. */
  43109. irradiance: any;
  43110. /**
  43111. * Specular information stored in the file.
  43112. */
  43113. specular: any;
  43114. }
  43115. /**
  43116. * Defines One Image in the file. It requires only the position in the file
  43117. * as well as the length.
  43118. */
  43119. interface BufferImageData {
  43120. /**
  43121. * Length of the image data.
  43122. */
  43123. length: number;
  43124. /**
  43125. * Position of the data from the null terminator delimiting the end of the JSON.
  43126. */
  43127. position: number;
  43128. }
  43129. /**
  43130. * Defines the specular data enclosed in the file.
  43131. * This corresponds to the version 1 of the data.
  43132. */
  43133. export interface EnvironmentTextureSpecularInfoV1 {
  43134. /**
  43135. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43136. */
  43137. specularDataPosition?: number;
  43138. /**
  43139. * This contains all the images data needed to reconstruct the cubemap.
  43140. */
  43141. mipmaps: Array<BufferImageData>;
  43142. /**
  43143. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43144. */
  43145. lodGenerationScale: number;
  43146. }
  43147. /**
  43148. * Sets of helpers addressing the serialization and deserialization of environment texture
  43149. * stored in a BabylonJS env file.
  43150. * Those files are usually stored as .env files.
  43151. */
  43152. export class EnvironmentTextureTools {
  43153. /**
  43154. * Magic number identifying the env file.
  43155. */
  43156. private static _MagicBytes;
  43157. /**
  43158. * Gets the environment info from an env file.
  43159. * @param data The array buffer containing the .env bytes.
  43160. * @returns the environment file info (the json header) if successfully parsed.
  43161. */
  43162. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43163. /**
  43164. * Creates an environment texture from a loaded cube texture.
  43165. * @param texture defines the cube texture to convert in env file
  43166. * @return a promise containing the environment data if succesfull.
  43167. */
  43168. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43169. /**
  43170. * Creates a JSON representation of the spherical data.
  43171. * @param texture defines the texture containing the polynomials
  43172. * @return the JSON representation of the spherical info
  43173. */
  43174. private static _CreateEnvTextureIrradiance;
  43175. /**
  43176. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43177. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43178. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43179. * @return the views described by info providing access to the underlying buffer
  43180. */
  43181. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43182. /**
  43183. * Uploads the texture info contained in the env file to the GPU.
  43184. * @param texture defines the internal texture to upload to
  43185. * @param arrayBuffer defines the buffer cotaining the data to load
  43186. * @param info defines the texture info retrieved through the GetEnvInfo method
  43187. * @returns a promise
  43188. */
  43189. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43190. /**
  43191. * Uploads the levels of image data to the GPU.
  43192. * @param texture defines the internal texture to upload to
  43193. * @param imageData defines the array buffer views of image data [mipmap][face]
  43194. * @returns a promise
  43195. */
  43196. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43197. /**
  43198. * Uploads spherical polynomials information to the texture.
  43199. * @param texture defines the texture we are trying to upload the information to
  43200. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43201. */
  43202. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43203. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43204. }
  43205. }
  43206. declare module BABYLON {
  43207. /**
  43208. * Contains position and normal vectors for a vertex
  43209. */
  43210. export class PositionNormalVertex {
  43211. /** the position of the vertex (defaut: 0,0,0) */
  43212. position: Vector3;
  43213. /** the normal of the vertex (defaut: 0,1,0) */
  43214. normal: Vector3;
  43215. /**
  43216. * Creates a PositionNormalVertex
  43217. * @param position the position of the vertex (defaut: 0,0,0)
  43218. * @param normal the normal of the vertex (defaut: 0,1,0)
  43219. */
  43220. constructor(
  43221. /** the position of the vertex (defaut: 0,0,0) */
  43222. position?: Vector3,
  43223. /** the normal of the vertex (defaut: 0,1,0) */
  43224. normal?: Vector3);
  43225. /**
  43226. * Clones the PositionNormalVertex
  43227. * @returns the cloned PositionNormalVertex
  43228. */
  43229. clone(): PositionNormalVertex;
  43230. }
  43231. /**
  43232. * Contains position, normal and uv vectors for a vertex
  43233. */
  43234. export class PositionNormalTextureVertex {
  43235. /** the position of the vertex (defaut: 0,0,0) */
  43236. position: Vector3;
  43237. /** the normal of the vertex (defaut: 0,1,0) */
  43238. normal: Vector3;
  43239. /** the uv of the vertex (default: 0,0) */
  43240. uv: Vector2;
  43241. /**
  43242. * Creates a PositionNormalTextureVertex
  43243. * @param position the position of the vertex (defaut: 0,0,0)
  43244. * @param normal the normal of the vertex (defaut: 0,1,0)
  43245. * @param uv the uv of the vertex (default: 0,0)
  43246. */
  43247. constructor(
  43248. /** the position of the vertex (defaut: 0,0,0) */
  43249. position?: Vector3,
  43250. /** the normal of the vertex (defaut: 0,1,0) */
  43251. normal?: Vector3,
  43252. /** the uv of the vertex (default: 0,0) */
  43253. uv?: Vector2);
  43254. /**
  43255. * Clones the PositionNormalTextureVertex
  43256. * @returns the cloned PositionNormalTextureVertex
  43257. */
  43258. clone(): PositionNormalTextureVertex;
  43259. }
  43260. }
  43261. declare module BABYLON {
  43262. /** @hidden */
  43263. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43264. private _genericAttributeLocation;
  43265. private _varyingLocationCount;
  43266. private _varyingLocationMap;
  43267. private _replacements;
  43268. private _textureCount;
  43269. private _uniforms;
  43270. lineProcessor(line: string): string;
  43271. attributeProcessor(attribute: string): string;
  43272. varyingProcessor(varying: string, isFragment: boolean): string;
  43273. uniformProcessor(uniform: string): string;
  43274. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43275. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * Container for accessors for natively-stored mesh data buffers.
  43281. */
  43282. class NativeDataBuffer extends DataBuffer {
  43283. /**
  43284. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43285. */
  43286. nativeIndexBuffer?: any;
  43287. /**
  43288. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43289. */
  43290. nativeVertexBuffer?: any;
  43291. }
  43292. /** @hidden */
  43293. export class NativeEngine extends Engine {
  43294. private readonly _native;
  43295. getHardwareScalingLevel(): number;
  43296. constructor();
  43297. /**
  43298. * Can be used to override the current requestAnimationFrame requester.
  43299. * @hidden
  43300. */
  43301. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43302. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43303. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43304. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43305. recordVertexArrayObject(vertexBuffers: {
  43306. [key: string]: VertexBuffer;
  43307. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43308. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43309. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43310. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43311. /**
  43312. * Draw a list of indexed primitives
  43313. * @param fillMode defines the primitive to use
  43314. * @param indexStart defines the starting index
  43315. * @param indexCount defines the number of index to draw
  43316. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43317. */
  43318. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43319. /**
  43320. * Draw a list of unindexed primitives
  43321. * @param fillMode defines the primitive to use
  43322. * @param verticesStart defines the index of first vertex to draw
  43323. * @param verticesCount defines the count of vertices to draw
  43324. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43325. */
  43326. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43327. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43328. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43329. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43330. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43331. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43332. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43333. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43334. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43335. bindSamplers(effect: Effect): void;
  43336. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43337. getRenderWidth(useScreen?: boolean): number;
  43338. getRenderHeight(useScreen?: boolean): number;
  43339. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43340. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43341. /**
  43342. * Set the z offset to apply to current rendering
  43343. * @param value defines the offset to apply
  43344. */
  43345. setZOffset(value: number): void;
  43346. /**
  43347. * Gets the current value of the zOffset
  43348. * @returns the current zOffset state
  43349. */
  43350. getZOffset(): number;
  43351. /**
  43352. * Enable or disable depth buffering
  43353. * @param enable defines the state to set
  43354. */
  43355. setDepthBuffer(enable: boolean): void;
  43356. /**
  43357. * Gets a boolean indicating if depth writing is enabled
  43358. * @returns the current depth writing state
  43359. */
  43360. getDepthWrite(): boolean;
  43361. /**
  43362. * Enable or disable depth writing
  43363. * @param enable defines the state to set
  43364. */
  43365. setDepthWrite(enable: boolean): void;
  43366. /**
  43367. * Enable or disable color writing
  43368. * @param enable defines the state to set
  43369. */
  43370. setColorWrite(enable: boolean): void;
  43371. /**
  43372. * Gets a boolean indicating if color writing is enabled
  43373. * @returns the current color writing state
  43374. */
  43375. getColorWrite(): boolean;
  43376. /**
  43377. * Sets alpha constants used by some alpha blending modes
  43378. * @param r defines the red component
  43379. * @param g defines the green component
  43380. * @param b defines the blue component
  43381. * @param a defines the alpha component
  43382. */
  43383. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43384. /**
  43385. * Sets the current alpha mode
  43386. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  43387. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43389. */
  43390. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43391. /**
  43392. * Gets the current alpha mode
  43393. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43394. * @returns the current alpha mode
  43395. */
  43396. getAlphaMode(): number;
  43397. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43398. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43399. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43400. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43401. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43402. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43403. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43404. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43405. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43406. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43407. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43408. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43410. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43411. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43412. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43413. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43414. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43415. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43416. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43417. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43418. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43419. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43420. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43421. /**
  43422. * Usually called from BABYLON.Texture.ts.
  43423. * Passed information to create a WebGLTexture
  43424. * @param urlArg defines a value which contains one of the following:
  43425. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43426. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43427. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43428. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43429. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43430. * @param scene needed for loading to the correct scene
  43431. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43432. * @param onLoad optional callback to be called upon successful completion
  43433. * @param onError optional callback to be called upon failure
  43434. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43435. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43436. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43437. * @param forcedExtension defines the extension to use to pick the right loader
  43438. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43439. */
  43440. 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;
  43441. /**
  43442. * Creates a cube texture
  43443. * @param rootUrl defines the url where the files to load is located
  43444. * @param scene defines the current scene
  43445. * @param files defines the list of files to load (1 per face)
  43446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43447. * @param onLoad defines an optional callback raised when the texture is loaded
  43448. * @param onError defines an optional callback raised if there is an issue to load the texture
  43449. * @param format defines the format of the data
  43450. * @param forcedExtension defines the extension to use to pick the right loader
  43451. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  43452. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43453. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43454. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  43455. * @returns the cube texture as an InternalTexture
  43456. */
  43457. 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;
  43458. private _getSamplingFilter;
  43459. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43462. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  43464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  43465. /**
  43466. * Updates a dynamic vertex buffer.
  43467. * @param vertexBuffer the vertex buffer to update
  43468. * @param data the data used to update the vertex buffer
  43469. * @param byteOffset the byte offset of the data (optional)
  43470. * @param byteLength the byte length of the data (optional)
  43471. */
  43472. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  43473. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  43474. private _updateAnisotropicLevel;
  43475. private _getAddressMode;
  43476. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43477. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  43478. releaseEffects(): void;
  43479. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43480. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43481. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43482. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43483. }
  43484. }
  43485. declare module BABYLON {
  43486. /**
  43487. * Gather the list of clipboard event types as constants.
  43488. */
  43489. export class ClipboardEventTypes {
  43490. /**
  43491. * The clipboard event is fired when a copy command is active (pressed).
  43492. */
  43493. static readonly COPY: number;
  43494. /**
  43495. * The clipboard event is fired when a cut command is active (pressed).
  43496. */
  43497. static readonly CUT: number;
  43498. /**
  43499. * The clipboard event is fired when a paste command is active (pressed).
  43500. */
  43501. static readonly PASTE: number;
  43502. }
  43503. /**
  43504. * This class is used to store clipboard related info for the onClipboardObservable event.
  43505. */
  43506. export class ClipboardInfo {
  43507. /**
  43508. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43509. */
  43510. type: number;
  43511. /**
  43512. * Defines the related dom event
  43513. */
  43514. event: ClipboardEvent;
  43515. /**
  43516. *Creates an instance of ClipboardInfo.
  43517. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43518. * @param event Defines the related dom event
  43519. */
  43520. constructor(
  43521. /**
  43522. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43523. */
  43524. type: number,
  43525. /**
  43526. * Defines the related dom event
  43527. */
  43528. event: ClipboardEvent);
  43529. /**
  43530. * Get the clipboard event's type from the keycode.
  43531. * @param keyCode Defines the keyCode for the current keyboard event.
  43532. * @return {number}
  43533. */
  43534. static GetTypeFromCharacter(keyCode: number): number;
  43535. }
  43536. }
  43537. declare module BABYLON {
  43538. /**
  43539. * Google Daydream controller
  43540. */
  43541. export class DaydreamController extends WebVRController {
  43542. /**
  43543. * Base Url for the controller model.
  43544. */
  43545. static MODEL_BASE_URL: string;
  43546. /**
  43547. * File name for the controller model.
  43548. */
  43549. static MODEL_FILENAME: string;
  43550. /**
  43551. * Gamepad Id prefix used to identify Daydream Controller.
  43552. */
  43553. static readonly GAMEPAD_ID_PREFIX: string;
  43554. /**
  43555. * Creates a new DaydreamController from a gamepad
  43556. * @param vrGamepad the gamepad that the controller should be created from
  43557. */
  43558. constructor(vrGamepad: any);
  43559. /**
  43560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43561. * @param scene scene in which to add meshes
  43562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43563. */
  43564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43565. /**
  43566. * Called once for each button that changed state since the last frame
  43567. * @param buttonIdx Which button index changed
  43568. * @param state New state of the button
  43569. * @param changes Which properties on the state changed since last frame
  43570. */
  43571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43572. }
  43573. }
  43574. declare module BABYLON {
  43575. /**
  43576. * Gear VR Controller
  43577. */
  43578. export class GearVRController extends WebVRController {
  43579. /**
  43580. * Base Url for the controller model.
  43581. */
  43582. static MODEL_BASE_URL: string;
  43583. /**
  43584. * File name for the controller model.
  43585. */
  43586. static MODEL_FILENAME: string;
  43587. /**
  43588. * Gamepad Id prefix used to identify this controller.
  43589. */
  43590. static readonly GAMEPAD_ID_PREFIX: string;
  43591. private readonly _buttonIndexToObservableNameMap;
  43592. /**
  43593. * Creates a new GearVRController from a gamepad
  43594. * @param vrGamepad the gamepad that the controller should be created from
  43595. */
  43596. constructor(vrGamepad: any);
  43597. /**
  43598. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43599. * @param scene scene in which to add meshes
  43600. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43601. */
  43602. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43603. /**
  43604. * Called once for each button that changed state since the last frame
  43605. * @param buttonIdx Which button index changed
  43606. * @param state New state of the button
  43607. * @param changes Which properties on the state changed since last frame
  43608. */
  43609. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43610. }
  43611. }
  43612. declare module BABYLON {
  43613. /**
  43614. * Class containing static functions to help procedurally build meshes
  43615. */
  43616. export class PolyhedronBuilder {
  43617. /**
  43618. * Creates a polyhedron mesh
  43619. * * 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
  43620. * * The parameter `size` (positive float, default 1) sets the polygon size
  43621. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43622. * * 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`
  43623. * * 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
  43624. * * 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)`)
  43625. * * 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
  43626. * * 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
  43627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43628. * * 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
  43629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43630. * @param name defines the name of the mesh
  43631. * @param options defines the options used to create the mesh
  43632. * @param scene defines the hosting scene
  43633. * @returns the polyhedron mesh
  43634. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43635. */
  43636. static CreatePolyhedron(name: string, options: {
  43637. type?: number;
  43638. size?: number;
  43639. sizeX?: number;
  43640. sizeY?: number;
  43641. sizeZ?: number;
  43642. custom?: any;
  43643. faceUV?: Vector4[];
  43644. faceColors?: Color4[];
  43645. flat?: boolean;
  43646. updatable?: boolean;
  43647. sideOrientation?: number;
  43648. frontUVs?: Vector4;
  43649. backUVs?: Vector4;
  43650. }, scene?: Nullable<Scene>): Mesh;
  43651. }
  43652. }
  43653. declare module BABYLON {
  43654. /**
  43655. * Gizmo that enables scaling a mesh along 3 axis
  43656. */
  43657. export class ScaleGizmo extends Gizmo {
  43658. /**
  43659. * Internal gizmo used for interactions on the x axis
  43660. */
  43661. xGizmo: AxisScaleGizmo;
  43662. /**
  43663. * Internal gizmo used for interactions on the y axis
  43664. */
  43665. yGizmo: AxisScaleGizmo;
  43666. /**
  43667. * Internal gizmo used for interactions on the z axis
  43668. */
  43669. zGizmo: AxisScaleGizmo;
  43670. /**
  43671. * Internal gizmo used to scale all axis equally
  43672. */
  43673. uniformScaleGizmo: AxisScaleGizmo;
  43674. private _meshAttached;
  43675. private _updateGizmoRotationToMatchAttachedMesh;
  43676. private _snapDistance;
  43677. private _scaleRatio;
  43678. private _uniformScalingMesh;
  43679. private _octahedron;
  43680. /** Fires an event when any of it's sub gizmos are dragged */
  43681. onDragStartObservable: Observable<unknown>;
  43682. /** Fires an event when any of it's sub gizmos are released from dragging */
  43683. onDragEndObservable: Observable<unknown>;
  43684. attachedMesh: Nullable<AbstractMesh>;
  43685. /**
  43686. * Creates a ScaleGizmo
  43687. * @param gizmoLayer The utility layer the gizmo will be added to
  43688. */
  43689. constructor(gizmoLayer?: UtilityLayerRenderer);
  43690. updateGizmoRotationToMatchAttachedMesh: boolean;
  43691. /**
  43692. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43693. */
  43694. snapDistance: number;
  43695. /**
  43696. * Ratio for the scale of the gizmo (Default: 1)
  43697. */
  43698. scaleRatio: number;
  43699. /**
  43700. * Disposes of the gizmo
  43701. */
  43702. dispose(): void;
  43703. }
  43704. }
  43705. declare module BABYLON {
  43706. /**
  43707. * Single axis scale gizmo
  43708. */
  43709. export class AxisScaleGizmo extends Gizmo {
  43710. /**
  43711. * Drag behavior responsible for the gizmos dragging interactions
  43712. */
  43713. dragBehavior: PointerDragBehavior;
  43714. private _pointerObserver;
  43715. /**
  43716. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43717. */
  43718. snapDistance: number;
  43719. /**
  43720. * Event that fires each time the gizmo snaps to a new location.
  43721. * * snapDistance is the the change in distance
  43722. */
  43723. onSnapObservable: Observable<{
  43724. snapDistance: number;
  43725. }>;
  43726. /**
  43727. * If the scaling operation should be done on all axis (default: false)
  43728. */
  43729. uniformScaling: boolean;
  43730. private _isEnabled;
  43731. private _parent;
  43732. private _arrow;
  43733. private _coloredMaterial;
  43734. private _hoverMaterial;
  43735. /**
  43736. * Creates an AxisScaleGizmo
  43737. * @param gizmoLayer The utility layer the gizmo will be added to
  43738. * @param dragAxis The axis which the gizmo will be able to scale on
  43739. * @param color The color of the gizmo
  43740. */
  43741. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43742. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43743. /**
  43744. * If the gizmo is enabled
  43745. */
  43746. isEnabled: boolean;
  43747. /**
  43748. * Disposes of the gizmo
  43749. */
  43750. dispose(): void;
  43751. /**
  43752. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43753. * @param mesh The mesh to replace the default mesh of the gizmo
  43754. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43755. */
  43756. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43757. }
  43758. }
  43759. declare module BABYLON {
  43760. /**
  43761. * Bounding box gizmo
  43762. */
  43763. export class BoundingBoxGizmo extends Gizmo {
  43764. private _lineBoundingBox;
  43765. private _rotateSpheresParent;
  43766. private _scaleBoxesParent;
  43767. private _boundingDimensions;
  43768. private _renderObserver;
  43769. private _pointerObserver;
  43770. private _scaleDragSpeed;
  43771. private _tmpQuaternion;
  43772. private _tmpVector;
  43773. private _tmpRotationMatrix;
  43774. /**
  43775. * 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)
  43776. */
  43777. ignoreChildren: boolean;
  43778. /**
  43779. * 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)
  43780. */
  43781. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43782. /**
  43783. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43784. */
  43785. rotationSphereSize: number;
  43786. /**
  43787. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43788. */
  43789. scaleBoxSize: number;
  43790. /**
  43791. * 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)
  43792. */
  43793. fixedDragMeshScreenSize: boolean;
  43794. /**
  43795. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43796. */
  43797. fixedDragMeshScreenSizeDistanceFactor: number;
  43798. /**
  43799. * Fired when a rotation sphere or scale box is dragged
  43800. */
  43801. onDragStartObservable: Observable<{}>;
  43802. /**
  43803. * Fired when a scale box is dragged
  43804. */
  43805. onScaleBoxDragObservable: Observable<{}>;
  43806. /**
  43807. * Fired when a scale box drag is ended
  43808. */
  43809. onScaleBoxDragEndObservable: Observable<{}>;
  43810. /**
  43811. * Fired when a rotation sphere is dragged
  43812. */
  43813. onRotationSphereDragObservable: Observable<{}>;
  43814. /**
  43815. * Fired when a rotation sphere drag is ended
  43816. */
  43817. onRotationSphereDragEndObservable: Observable<{}>;
  43818. /**
  43819. * 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)
  43820. */
  43821. scalePivot: Nullable<Vector3>;
  43822. /**
  43823. * Mesh used as a pivot to rotate the attached mesh
  43824. */
  43825. private _anchorMesh;
  43826. private _existingMeshScale;
  43827. private _dragMesh;
  43828. private pointerDragBehavior;
  43829. private coloredMaterial;
  43830. private hoverColoredMaterial;
  43831. /**
  43832. * Sets the color of the bounding box gizmo
  43833. * @param color the color to set
  43834. */
  43835. setColor(color: Color3): void;
  43836. /**
  43837. * Creates an BoundingBoxGizmo
  43838. * @param gizmoLayer The utility layer the gizmo will be added to
  43839. * @param color The color of the gizmo
  43840. */
  43841. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43842. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43843. private _selectNode;
  43844. /**
  43845. * Updates the bounding box information for the Gizmo
  43846. */
  43847. updateBoundingBox(): void;
  43848. private _updateRotationSpheres;
  43849. private _updateScaleBoxes;
  43850. /**
  43851. * Enables rotation on the specified axis and disables rotation on the others
  43852. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43853. */
  43854. setEnabledRotationAxis(axis: string): void;
  43855. /**
  43856. * Enables/disables scaling
  43857. * @param enable if scaling should be enabled
  43858. */
  43859. setEnabledScaling(enable: boolean): void;
  43860. private _updateDummy;
  43861. /**
  43862. * Enables a pointer drag behavior on the bounding box of the gizmo
  43863. */
  43864. enableDragBehavior(): void;
  43865. /**
  43866. * Disposes of the gizmo
  43867. */
  43868. dispose(): void;
  43869. /**
  43870. * 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)
  43871. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43872. * @returns the bounding box mesh with the passed in mesh as a child
  43873. */
  43874. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43875. /**
  43876. * CustomMeshes are not supported by this gizmo
  43877. * @param mesh The mesh to replace the default mesh of the gizmo
  43878. */
  43879. setCustomMesh(mesh: Mesh): void;
  43880. }
  43881. }
  43882. declare module BABYLON {
  43883. /**
  43884. * Single plane rotation gizmo
  43885. */
  43886. export class PlaneRotationGizmo extends Gizmo {
  43887. /**
  43888. * Drag behavior responsible for the gizmos dragging interactions
  43889. */
  43890. dragBehavior: PointerDragBehavior;
  43891. private _pointerObserver;
  43892. /**
  43893. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43894. */
  43895. snapDistance: number;
  43896. /**
  43897. * Event that fires each time the gizmo snaps to a new location.
  43898. * * snapDistance is the the change in distance
  43899. */
  43900. onSnapObservable: Observable<{
  43901. snapDistance: number;
  43902. }>;
  43903. private _isEnabled;
  43904. private _parent;
  43905. /**
  43906. * Creates a PlaneRotationGizmo
  43907. * @param gizmoLayer The utility layer the gizmo will be added to
  43908. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43909. * @param color The color of the gizmo
  43910. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43911. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43912. */
  43913. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  43914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43915. /**
  43916. * If the gizmo is enabled
  43917. */
  43918. isEnabled: boolean;
  43919. /**
  43920. * Disposes of the gizmo
  43921. */
  43922. dispose(): void;
  43923. }
  43924. }
  43925. declare module BABYLON {
  43926. /**
  43927. * Gizmo that enables rotating a mesh along 3 axis
  43928. */
  43929. export class RotationGizmo extends Gizmo {
  43930. /**
  43931. * Internal gizmo used for interactions on the x axis
  43932. */
  43933. xGizmo: PlaneRotationGizmo;
  43934. /**
  43935. * Internal gizmo used for interactions on the y axis
  43936. */
  43937. yGizmo: PlaneRotationGizmo;
  43938. /**
  43939. * Internal gizmo used for interactions on the z axis
  43940. */
  43941. zGizmo: PlaneRotationGizmo;
  43942. /** Fires an event when any of it's sub gizmos are dragged */
  43943. onDragStartObservable: Observable<unknown>;
  43944. /** Fires an event when any of it's sub gizmos are released from dragging */
  43945. onDragEndObservable: Observable<unknown>;
  43946. private _meshAttached;
  43947. attachedMesh: Nullable<AbstractMesh>;
  43948. /**
  43949. * Creates a RotationGizmo
  43950. * @param gizmoLayer The utility layer the gizmo will be added to
  43951. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43952. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43953. */
  43954. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  43955. updateGizmoRotationToMatchAttachedMesh: boolean;
  43956. /**
  43957. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43958. */
  43959. snapDistance: number;
  43960. /**
  43961. * Ratio for the scale of the gizmo (Default: 1)
  43962. */
  43963. scaleRatio: number;
  43964. /**
  43965. * Disposes of the gizmo
  43966. */
  43967. dispose(): void;
  43968. /**
  43969. * CustomMeshes are not supported by this gizmo
  43970. * @param mesh The mesh to replace the default mesh of the gizmo
  43971. */
  43972. setCustomMesh(mesh: Mesh): void;
  43973. }
  43974. }
  43975. declare module BABYLON {
  43976. /**
  43977. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43978. */
  43979. export class GizmoManager implements IDisposable {
  43980. private scene;
  43981. /**
  43982. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43983. */
  43984. gizmos: {
  43985. positionGizmo: Nullable<PositionGizmo>;
  43986. rotationGizmo: Nullable<RotationGizmo>;
  43987. scaleGizmo: Nullable<ScaleGizmo>;
  43988. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43989. };
  43990. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43991. clearGizmoOnEmptyPointerEvent: boolean;
  43992. /** Fires an event when the manager is attached to a mesh */
  43993. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43994. private _gizmosEnabled;
  43995. private _pointerObserver;
  43996. private _attachedMesh;
  43997. private _boundingBoxColor;
  43998. private _defaultUtilityLayer;
  43999. private _defaultKeepDepthUtilityLayer;
  44000. /**
  44001. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44002. */
  44003. boundingBoxDragBehavior: SixDofDragBehavior;
  44004. /**
  44005. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44006. */
  44007. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44008. /**
  44009. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44010. */
  44011. usePointerToAttachGizmos: boolean;
  44012. /**
  44013. * Utility layer that the bounding box gizmo belongs to
  44014. */
  44015. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44016. /**
  44017. * Utility layer that all gizmos besides bounding box belong to
  44018. */
  44019. readonly utilityLayer: UtilityLayerRenderer;
  44020. /**
  44021. * Instatiates a gizmo manager
  44022. * @param scene the scene to overlay the gizmos on top of
  44023. */
  44024. constructor(scene: Scene);
  44025. /**
  44026. * Attaches a set of gizmos to the specified mesh
  44027. * @param mesh The mesh the gizmo's should be attached to
  44028. */
  44029. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44030. /**
  44031. * If the position gizmo is enabled
  44032. */
  44033. positionGizmoEnabled: boolean;
  44034. /**
  44035. * If the rotation gizmo is enabled
  44036. */
  44037. rotationGizmoEnabled: boolean;
  44038. /**
  44039. * If the scale gizmo is enabled
  44040. */
  44041. scaleGizmoEnabled: boolean;
  44042. /**
  44043. * If the boundingBox gizmo is enabled
  44044. */
  44045. boundingBoxGizmoEnabled: boolean;
  44046. /**
  44047. * Disposes of the gizmo manager
  44048. */
  44049. dispose(): void;
  44050. }
  44051. }
  44052. declare module BABYLON {
  44053. /**
  44054. * A directional light is defined by a direction (what a surprise!).
  44055. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44056. * 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.
  44057. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44058. */
  44059. export class DirectionalLight extends ShadowLight {
  44060. private _shadowFrustumSize;
  44061. /**
  44062. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44063. */
  44064. /**
  44065. * Specifies a fix frustum size for the shadow generation.
  44066. */
  44067. shadowFrustumSize: number;
  44068. private _shadowOrthoScale;
  44069. /**
  44070. * Gets the shadow projection scale against the optimal computed one.
  44071. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44072. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44073. */
  44074. /**
  44075. * Sets the shadow projection scale against the optimal computed one.
  44076. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44077. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44078. */
  44079. shadowOrthoScale: number;
  44080. /**
  44081. * Automatically compute the projection matrix to best fit (including all the casters)
  44082. * on each frame.
  44083. */
  44084. autoUpdateExtends: boolean;
  44085. private _orthoLeft;
  44086. private _orthoRight;
  44087. private _orthoTop;
  44088. private _orthoBottom;
  44089. /**
  44090. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44091. * The directional light is emitted from everywhere in the given direction.
  44092. * It can cast shadows.
  44093. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44094. * @param name The friendly name of the light
  44095. * @param direction The direction of the light
  44096. * @param scene The scene the light belongs to
  44097. */
  44098. constructor(name: string, direction: Vector3, scene: Scene);
  44099. /**
  44100. * Returns the string "DirectionalLight".
  44101. * @return The class name
  44102. */
  44103. getClassName(): string;
  44104. /**
  44105. * Returns the integer 1.
  44106. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44107. */
  44108. getTypeID(): number;
  44109. /**
  44110. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44111. * Returns the DirectionalLight Shadow projection matrix.
  44112. */
  44113. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44114. /**
  44115. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44116. * Returns the DirectionalLight Shadow projection matrix.
  44117. */
  44118. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44119. /**
  44120. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44121. * Returns the DirectionalLight Shadow projection matrix.
  44122. */
  44123. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44124. protected _buildUniformLayout(): void;
  44125. /**
  44126. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44127. * @param effect The effect to update
  44128. * @param lightIndex The index of the light in the effect to update
  44129. * @returns The directional light
  44130. */
  44131. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44132. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44133. /**
  44134. * Gets the minZ used for shadow according to both the scene and the light.
  44135. *
  44136. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44137. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44138. * @param activeCamera The camera we are returning the min for
  44139. * @returns the depth min z
  44140. */
  44141. getDepthMinZ(activeCamera: Camera): number;
  44142. /**
  44143. * Gets the maxZ used for shadow according to both the scene and the light.
  44144. *
  44145. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44146. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44147. * @param activeCamera The camera we are returning the max for
  44148. * @returns the depth max z
  44149. */
  44150. getDepthMaxZ(activeCamera: Camera): number;
  44151. /**
  44152. * Prepares the list of defines specific to the light type.
  44153. * @param defines the list of defines
  44154. * @param lightIndex defines the index of the light for the effect
  44155. */
  44156. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44157. }
  44158. }
  44159. declare module BABYLON {
  44160. /**
  44161. * Class containing static functions to help procedurally build meshes
  44162. */
  44163. export class HemisphereBuilder {
  44164. /**
  44165. * Creates a hemisphere mesh
  44166. * @param name defines the name of the mesh
  44167. * @param options defines the options used to create the mesh
  44168. * @param scene defines the hosting scene
  44169. * @returns the hemisphere mesh
  44170. */
  44171. static CreateHemisphere(name: string, options: {
  44172. segments?: number;
  44173. diameter?: number;
  44174. sideOrientation?: number;
  44175. }, scene: any): Mesh;
  44176. }
  44177. }
  44178. declare module BABYLON {
  44179. /**
  44180. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44181. * These values define a cone of light starting from the position, emitting toward the direction.
  44182. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44183. * and the exponent defines the speed of the decay of the light with distance (reach).
  44184. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44185. */
  44186. export class SpotLight extends ShadowLight {
  44187. private _angle;
  44188. private _innerAngle;
  44189. private _cosHalfAngle;
  44190. private _lightAngleScale;
  44191. private _lightAngleOffset;
  44192. /**
  44193. * Gets the cone angle of the spot light in Radians.
  44194. */
  44195. /**
  44196. * Sets the cone angle of the spot light in Radians.
  44197. */
  44198. angle: number;
  44199. /**
  44200. * Only used in gltf falloff mode, this defines the angle where
  44201. * the directional falloff will start before cutting at angle which could be seen
  44202. * as outer angle.
  44203. */
  44204. /**
  44205. * Only used in gltf falloff mode, this defines the angle where
  44206. * the directional falloff will start before cutting at angle which could be seen
  44207. * as outer angle.
  44208. */
  44209. innerAngle: number;
  44210. private _shadowAngleScale;
  44211. /**
  44212. * Allows scaling the angle of the light for shadow generation only.
  44213. */
  44214. /**
  44215. * Allows scaling the angle of the light for shadow generation only.
  44216. */
  44217. shadowAngleScale: number;
  44218. /**
  44219. * The light decay speed with the distance from the emission spot.
  44220. */
  44221. exponent: number;
  44222. private _projectionTextureMatrix;
  44223. /**
  44224. * Allows reading the projecton texture
  44225. */
  44226. readonly projectionTextureMatrix: Matrix;
  44227. protected _projectionTextureLightNear: number;
  44228. /**
  44229. * Gets the near clip of the Spotlight for texture projection.
  44230. */
  44231. /**
  44232. * Sets the near clip of the Spotlight for texture projection.
  44233. */
  44234. projectionTextureLightNear: number;
  44235. protected _projectionTextureLightFar: number;
  44236. /**
  44237. * Gets the far clip of the Spotlight for texture projection.
  44238. */
  44239. /**
  44240. * Sets the far clip of the Spotlight for texture projection.
  44241. */
  44242. projectionTextureLightFar: number;
  44243. protected _projectionTextureUpDirection: Vector3;
  44244. /**
  44245. * Gets the Up vector of the Spotlight for texture projection.
  44246. */
  44247. /**
  44248. * Sets the Up vector of the Spotlight for texture projection.
  44249. */
  44250. projectionTextureUpDirection: Vector3;
  44251. private _projectionTexture;
  44252. /**
  44253. * Gets the projection texture of the light.
  44254. */
  44255. /**
  44256. * Sets the projection texture of the light.
  44257. */
  44258. projectionTexture: Nullable<BaseTexture>;
  44259. private _projectionTextureViewLightDirty;
  44260. private _projectionTextureProjectionLightDirty;
  44261. private _projectionTextureDirty;
  44262. private _projectionTextureViewTargetVector;
  44263. private _projectionTextureViewLightMatrix;
  44264. private _projectionTextureProjectionLightMatrix;
  44265. private _projectionTextureScalingMatrix;
  44266. /**
  44267. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44268. * It can cast shadows.
  44269. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44270. * @param name The light friendly name
  44271. * @param position The position of the spot light in the scene
  44272. * @param direction The direction of the light in the scene
  44273. * @param angle The cone angle of the light in Radians
  44274. * @param exponent The light decay speed with the distance from the emission spot
  44275. * @param scene The scene the lights belongs to
  44276. */
  44277. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44278. /**
  44279. * Returns the string "SpotLight".
  44280. * @returns the class name
  44281. */
  44282. getClassName(): string;
  44283. /**
  44284. * Returns the integer 2.
  44285. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44286. */
  44287. getTypeID(): number;
  44288. /**
  44289. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44290. */
  44291. protected _setDirection(value: Vector3): void;
  44292. /**
  44293. * Overrides the position setter to recompute the projection texture view light Matrix.
  44294. */
  44295. protected _setPosition(value: Vector3): void;
  44296. /**
  44297. * 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.
  44298. * Returns the SpotLight.
  44299. */
  44300. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44301. protected _computeProjectionTextureViewLightMatrix(): void;
  44302. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44303. /**
  44304. * Main function for light texture projection matrix computing.
  44305. */
  44306. protected _computeProjectionTextureMatrix(): void;
  44307. protected _buildUniformLayout(): void;
  44308. private _computeAngleValues;
  44309. /**
  44310. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44311. * @param effect The effect to update
  44312. * @param lightIndex The index of the light in the effect to update
  44313. * @returns The spot light
  44314. */
  44315. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44316. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44317. /**
  44318. * Disposes the light and the associated resources.
  44319. */
  44320. dispose(): void;
  44321. /**
  44322. * Prepares the list of defines specific to the light type.
  44323. * @param defines the list of defines
  44324. * @param lightIndex defines the index of the light for the effect
  44325. */
  44326. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44327. }
  44328. }
  44329. declare module BABYLON {
  44330. /**
  44331. * Gizmo that enables viewing a light
  44332. */
  44333. export class LightGizmo extends Gizmo {
  44334. private _lightMesh;
  44335. private _material;
  44336. private cachedPosition;
  44337. private cachedForward;
  44338. /**
  44339. * Creates a LightGizmo
  44340. * @param gizmoLayer The utility layer the gizmo will be added to
  44341. */
  44342. constructor(gizmoLayer?: UtilityLayerRenderer);
  44343. private _light;
  44344. /**
  44345. * The light that the gizmo is attached to
  44346. */
  44347. light: Nullable<Light>;
  44348. /**
  44349. * Gets the material used to render the light gizmo
  44350. */
  44351. readonly material: StandardMaterial;
  44352. /**
  44353. * @hidden
  44354. * Updates the gizmo to match the attached mesh's position/rotation
  44355. */
  44356. protected _update(): void;
  44357. private static _Scale;
  44358. /**
  44359. * Creates the lines for a light mesh
  44360. */
  44361. private static _createLightLines;
  44362. /**
  44363. * Disposes of the light gizmo
  44364. */
  44365. dispose(): void;
  44366. private static _CreateHemisphericLightMesh;
  44367. private static _CreatePointLightMesh;
  44368. private static _CreateSpotLightMesh;
  44369. private static _CreateDirectionalLightMesh;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /** @hidden */
  44374. export var backgroundFragmentDeclaration: {
  44375. name: string;
  44376. shader: string;
  44377. };
  44378. }
  44379. declare module BABYLON {
  44380. /** @hidden */
  44381. export var backgroundUboDeclaration: {
  44382. name: string;
  44383. shader: string;
  44384. };
  44385. }
  44386. declare module BABYLON {
  44387. /** @hidden */
  44388. export var backgroundPixelShader: {
  44389. name: string;
  44390. shader: string;
  44391. };
  44392. }
  44393. declare module BABYLON {
  44394. /** @hidden */
  44395. export var backgroundVertexDeclaration: {
  44396. name: string;
  44397. shader: string;
  44398. };
  44399. }
  44400. declare module BABYLON {
  44401. /** @hidden */
  44402. export var backgroundVertexShader: {
  44403. name: string;
  44404. shader: string;
  44405. };
  44406. }
  44407. declare module BABYLON {
  44408. /**
  44409. * Background material used to create an efficient environement around your scene.
  44410. */
  44411. export class BackgroundMaterial extends PushMaterial {
  44412. /**
  44413. * Standard reflectance value at parallel view angle.
  44414. */
  44415. static StandardReflectance0: number;
  44416. /**
  44417. * Standard reflectance value at grazing angle.
  44418. */
  44419. static StandardReflectance90: number;
  44420. protected _primaryColor: Color3;
  44421. /**
  44422. * Key light Color (multiply against the environement texture)
  44423. */
  44424. primaryColor: Color3;
  44425. protected __perceptualColor: Nullable<Color3>;
  44426. /**
  44427. * Experimental Internal Use Only.
  44428. *
  44429. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44430. * This acts as a helper to set the primary color to a more "human friendly" value.
  44431. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44432. * output color as close as possible from the chosen value.
  44433. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44434. * part of lighting setup.)
  44435. */ private _perceptualColor: Nullable<Color3>;
  44436. protected _primaryColorShadowLevel: float;
  44437. /**
  44438. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44439. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44440. */
  44441. primaryColorShadowLevel: float;
  44442. protected _primaryColorHighlightLevel: float;
  44443. /**
  44444. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44445. * The primary color is used at the level chosen to define what the white area would look.
  44446. */
  44447. primaryColorHighlightLevel: float;
  44448. protected _reflectionTexture: Nullable<BaseTexture>;
  44449. /**
  44450. * Reflection Texture used in the material.
  44451. * Should be author in a specific way for the best result (refer to the documentation).
  44452. */
  44453. reflectionTexture: Nullable<BaseTexture>;
  44454. protected _reflectionBlur: float;
  44455. /**
  44456. * Reflection Texture level of blur.
  44457. *
  44458. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44459. * texture twice.
  44460. */
  44461. reflectionBlur: float;
  44462. protected _diffuseTexture: Nullable<BaseTexture>;
  44463. /**
  44464. * Diffuse Texture used in the material.
  44465. * Should be author in a specific way for the best result (refer to the documentation).
  44466. */
  44467. diffuseTexture: Nullable<BaseTexture>;
  44468. protected _shadowLights: Nullable<IShadowLight[]>;
  44469. /**
  44470. * Specify the list of lights casting shadow on the material.
  44471. * All scene shadow lights will be included if null.
  44472. */
  44473. shadowLights: Nullable<IShadowLight[]>;
  44474. protected _shadowLevel: float;
  44475. /**
  44476. * Helps adjusting the shadow to a softer level if required.
  44477. * 0 means black shadows and 1 means no shadows.
  44478. */
  44479. shadowLevel: float;
  44480. protected _sceneCenter: Vector3;
  44481. /**
  44482. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44483. * It is usually zero but might be interesting to modify according to your setup.
  44484. */
  44485. sceneCenter: Vector3;
  44486. protected _opacityFresnel: boolean;
  44487. /**
  44488. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44489. * This helps ensuring a nice transition when the camera goes under the ground.
  44490. */
  44491. opacityFresnel: boolean;
  44492. protected _reflectionFresnel: boolean;
  44493. /**
  44494. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44495. * This helps adding a mirror texture on the ground.
  44496. */
  44497. reflectionFresnel: boolean;
  44498. protected _reflectionFalloffDistance: number;
  44499. /**
  44500. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44501. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44502. */
  44503. reflectionFalloffDistance: number;
  44504. protected _reflectionAmount: number;
  44505. /**
  44506. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44507. */
  44508. reflectionAmount: number;
  44509. protected _reflectionReflectance0: number;
  44510. /**
  44511. * This specifies the weight of the reflection at grazing angle.
  44512. */
  44513. reflectionReflectance0: number;
  44514. protected _reflectionReflectance90: number;
  44515. /**
  44516. * This specifies the weight of the reflection at a perpendicular point of view.
  44517. */
  44518. reflectionReflectance90: number;
  44519. /**
  44520. * Sets the reflection reflectance fresnel values according to the default standard
  44521. * empirically know to work well :-)
  44522. */
  44523. reflectionStandardFresnelWeight: number;
  44524. protected _useRGBColor: boolean;
  44525. /**
  44526. * Helps to directly use the maps channels instead of their level.
  44527. */
  44528. useRGBColor: boolean;
  44529. protected _enableNoise: boolean;
  44530. /**
  44531. * This helps reducing the banding effect that could occur on the background.
  44532. */
  44533. enableNoise: boolean;
  44534. /**
  44535. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44536. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44537. * Recommended to be keep at 1.0 except for special cases.
  44538. */
  44539. fovMultiplier: number;
  44540. private _fovMultiplier;
  44541. /**
  44542. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44543. */
  44544. useEquirectangularFOV: boolean;
  44545. private _maxSimultaneousLights;
  44546. /**
  44547. * Number of Simultaneous lights allowed on the material.
  44548. */
  44549. maxSimultaneousLights: int;
  44550. /**
  44551. * Default configuration related to image processing available in the Background Material.
  44552. */
  44553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44554. /**
  44555. * Keep track of the image processing observer to allow dispose and replace.
  44556. */
  44557. private _imageProcessingObserver;
  44558. /**
  44559. * Attaches a new image processing configuration to the PBR Material.
  44560. * @param configuration (if null the scene configuration will be use)
  44561. */
  44562. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44563. /**
  44564. * Gets the image processing configuration used either in this material.
  44565. */
  44566. /**
  44567. * Sets the Default image processing configuration used either in the this material.
  44568. *
  44569. * If sets to null, the scene one is in use.
  44570. */
  44571. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44572. /**
  44573. * Gets wether the color curves effect is enabled.
  44574. */
  44575. /**
  44576. * Sets wether the color curves effect is enabled.
  44577. */
  44578. cameraColorCurvesEnabled: boolean;
  44579. /**
  44580. * Gets wether the color grading effect is enabled.
  44581. */
  44582. /**
  44583. * Gets wether the color grading effect is enabled.
  44584. */
  44585. cameraColorGradingEnabled: boolean;
  44586. /**
  44587. * Gets wether tonemapping is enabled or not.
  44588. */
  44589. /**
  44590. * Sets wether tonemapping is enabled or not
  44591. */
  44592. cameraToneMappingEnabled: boolean;
  44593. /**
  44594. * The camera exposure used on this material.
  44595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44596. * This corresponds to a photographic exposure.
  44597. */
  44598. /**
  44599. * The camera exposure used on this material.
  44600. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44601. * This corresponds to a photographic exposure.
  44602. */
  44603. cameraExposure: float;
  44604. /**
  44605. * Gets The camera contrast used on this material.
  44606. */
  44607. /**
  44608. * Sets The camera contrast used on this material.
  44609. */
  44610. cameraContrast: float;
  44611. /**
  44612. * Gets the Color Grading 2D Lookup Texture.
  44613. */
  44614. /**
  44615. * Sets the Color Grading 2D Lookup Texture.
  44616. */
  44617. cameraColorGradingTexture: Nullable<BaseTexture>;
  44618. /**
  44619. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44620. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44621. * 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;
  44622. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44623. */
  44624. /**
  44625. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44626. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44627. * 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;
  44628. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44629. */
  44630. cameraColorCurves: Nullable<ColorCurves>;
  44631. /**
  44632. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44633. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44634. */
  44635. switchToBGR: boolean;
  44636. private _renderTargets;
  44637. private _reflectionControls;
  44638. private _white;
  44639. private _primaryShadowColor;
  44640. private _primaryHighlightColor;
  44641. /**
  44642. * Instantiates a Background Material in the given scene
  44643. * @param name The friendly name of the material
  44644. * @param scene The scene to add the material to
  44645. */
  44646. constructor(name: string, scene: Scene);
  44647. /**
  44648. * Gets a boolean indicating that current material needs to register RTT
  44649. */
  44650. readonly hasRenderTargetTextures: boolean;
  44651. /**
  44652. * The entire material has been created in order to prevent overdraw.
  44653. * @returns false
  44654. */
  44655. needAlphaTesting(): boolean;
  44656. /**
  44657. * The entire material has been created in order to prevent overdraw.
  44658. * @returns true if blending is enable
  44659. */
  44660. needAlphaBlending(): boolean;
  44661. /**
  44662. * Checks wether the material is ready to be rendered for a given mesh.
  44663. * @param mesh The mesh to render
  44664. * @param subMesh The submesh to check against
  44665. * @param useInstances Specify wether or not the material is used with instances
  44666. * @returns true if all the dependencies are ready (Textures, Effects...)
  44667. */
  44668. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44669. /**
  44670. * Compute the primary color according to the chosen perceptual color.
  44671. */
  44672. private _computePrimaryColorFromPerceptualColor;
  44673. /**
  44674. * Compute the highlights and shadow colors according to their chosen levels.
  44675. */
  44676. private _computePrimaryColors;
  44677. /**
  44678. * Build the uniform buffer used in the material.
  44679. */
  44680. buildUniformLayout(): void;
  44681. /**
  44682. * Unbind the material.
  44683. */
  44684. unbind(): void;
  44685. /**
  44686. * Bind only the world matrix to the material.
  44687. * @param world The world matrix to bind.
  44688. */
  44689. bindOnlyWorldMatrix(world: Matrix): void;
  44690. /**
  44691. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44692. * @param world The world matrix to bind.
  44693. * @param subMesh The submesh to bind for.
  44694. */
  44695. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44696. /**
  44697. * Checks to see if a texture is used in the material.
  44698. * @param texture - Base texture to use.
  44699. * @returns - Boolean specifying if a texture is used in the material.
  44700. */
  44701. hasTexture(texture: BaseTexture): boolean;
  44702. /**
  44703. * Dispose the material.
  44704. * @param forceDisposeEffect Force disposal of the associated effect.
  44705. * @param forceDisposeTextures Force disposal of the associated textures.
  44706. */
  44707. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44708. /**
  44709. * Clones the material.
  44710. * @param name The cloned name.
  44711. * @returns The cloned material.
  44712. */
  44713. clone(name: string): BackgroundMaterial;
  44714. /**
  44715. * Serializes the current material to its JSON representation.
  44716. * @returns The JSON representation.
  44717. */
  44718. serialize(): any;
  44719. /**
  44720. * Gets the class name of the material
  44721. * @returns "BackgroundMaterial"
  44722. */
  44723. getClassName(): string;
  44724. /**
  44725. * Parse a JSON input to create back a background material.
  44726. * @param source The JSON data to parse
  44727. * @param scene The scene to create the parsed material in
  44728. * @param rootUrl The root url of the assets the material depends upon
  44729. * @returns the instantiated BackgroundMaterial.
  44730. */
  44731. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44732. }
  44733. }
  44734. declare module BABYLON {
  44735. /**
  44736. * Represents the different options available during the creation of
  44737. * a Environment helper.
  44738. *
  44739. * This can control the default ground, skybox and image processing setup of your scene.
  44740. */
  44741. export interface IEnvironmentHelperOptions {
  44742. /**
  44743. * Specifies wether or not to create a ground.
  44744. * True by default.
  44745. */
  44746. createGround: boolean;
  44747. /**
  44748. * Specifies the ground size.
  44749. * 15 by default.
  44750. */
  44751. groundSize: number;
  44752. /**
  44753. * The texture used on the ground for the main color.
  44754. * Comes from the BabylonJS CDN by default.
  44755. *
  44756. * Remarks: Can be either a texture or a url.
  44757. */
  44758. groundTexture: string | BaseTexture;
  44759. /**
  44760. * The color mixed in the ground texture by default.
  44761. * BabylonJS clearColor by default.
  44762. */
  44763. groundColor: Color3;
  44764. /**
  44765. * Specifies the ground opacity.
  44766. * 1 by default.
  44767. */
  44768. groundOpacity: number;
  44769. /**
  44770. * Enables the ground to receive shadows.
  44771. * True by default.
  44772. */
  44773. enableGroundShadow: boolean;
  44774. /**
  44775. * Helps preventing the shadow to be fully black on the ground.
  44776. * 0.5 by default.
  44777. */
  44778. groundShadowLevel: number;
  44779. /**
  44780. * Creates a mirror texture attach to the ground.
  44781. * false by default.
  44782. */
  44783. enableGroundMirror: boolean;
  44784. /**
  44785. * Specifies the ground mirror size ratio.
  44786. * 0.3 by default as the default kernel is 64.
  44787. */
  44788. groundMirrorSizeRatio: number;
  44789. /**
  44790. * Specifies the ground mirror blur kernel size.
  44791. * 64 by default.
  44792. */
  44793. groundMirrorBlurKernel: number;
  44794. /**
  44795. * Specifies the ground mirror visibility amount.
  44796. * 1 by default
  44797. */
  44798. groundMirrorAmount: number;
  44799. /**
  44800. * Specifies the ground mirror reflectance weight.
  44801. * This uses the standard weight of the background material to setup the fresnel effect
  44802. * of the mirror.
  44803. * 1 by default.
  44804. */
  44805. groundMirrorFresnelWeight: number;
  44806. /**
  44807. * Specifies the ground mirror Falloff distance.
  44808. * This can helps reducing the size of the reflection.
  44809. * 0 by Default.
  44810. */
  44811. groundMirrorFallOffDistance: number;
  44812. /**
  44813. * Specifies the ground mirror texture type.
  44814. * Unsigned Int by Default.
  44815. */
  44816. groundMirrorTextureType: number;
  44817. /**
  44818. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44819. * the shown objects.
  44820. */
  44821. groundYBias: number;
  44822. /**
  44823. * Specifies wether or not to create a skybox.
  44824. * True by default.
  44825. */
  44826. createSkybox: boolean;
  44827. /**
  44828. * Specifies the skybox size.
  44829. * 20 by default.
  44830. */
  44831. skyboxSize: number;
  44832. /**
  44833. * The texture used on the skybox for the main color.
  44834. * Comes from the BabylonJS CDN by default.
  44835. *
  44836. * Remarks: Can be either a texture or a url.
  44837. */
  44838. skyboxTexture: string | BaseTexture;
  44839. /**
  44840. * The color mixed in the skybox texture by default.
  44841. * BabylonJS clearColor by default.
  44842. */
  44843. skyboxColor: Color3;
  44844. /**
  44845. * The background rotation around the Y axis of the scene.
  44846. * This helps aligning the key lights of your scene with the background.
  44847. * 0 by default.
  44848. */
  44849. backgroundYRotation: number;
  44850. /**
  44851. * Compute automatically the size of the elements to best fit with the scene.
  44852. */
  44853. sizeAuto: boolean;
  44854. /**
  44855. * Default position of the rootMesh if autoSize is not true.
  44856. */
  44857. rootPosition: Vector3;
  44858. /**
  44859. * Sets up the image processing in the scene.
  44860. * true by default.
  44861. */
  44862. setupImageProcessing: boolean;
  44863. /**
  44864. * The texture used as your environment texture in the scene.
  44865. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44866. *
  44867. * Remarks: Can be either a texture or a url.
  44868. */
  44869. environmentTexture: string | BaseTexture;
  44870. /**
  44871. * The value of the exposure to apply to the scene.
  44872. * 0.6 by default if setupImageProcessing is true.
  44873. */
  44874. cameraExposure: number;
  44875. /**
  44876. * The value of the contrast to apply to the scene.
  44877. * 1.6 by default if setupImageProcessing is true.
  44878. */
  44879. cameraContrast: number;
  44880. /**
  44881. * Specifies wether or not tonemapping should be enabled in the scene.
  44882. * true by default if setupImageProcessing is true.
  44883. */
  44884. toneMappingEnabled: boolean;
  44885. }
  44886. /**
  44887. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44888. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44889. * It also helps with the default setup of your imageProcessing configuration.
  44890. */
  44891. export class EnvironmentHelper {
  44892. /**
  44893. * Default ground texture URL.
  44894. */
  44895. private static _groundTextureCDNUrl;
  44896. /**
  44897. * Default skybox texture URL.
  44898. */
  44899. private static _skyboxTextureCDNUrl;
  44900. /**
  44901. * Default environment texture URL.
  44902. */
  44903. private static _environmentTextureCDNUrl;
  44904. /**
  44905. * Creates the default options for the helper.
  44906. */
  44907. private static _getDefaultOptions;
  44908. private _rootMesh;
  44909. /**
  44910. * Gets the root mesh created by the helper.
  44911. */
  44912. readonly rootMesh: Mesh;
  44913. private _skybox;
  44914. /**
  44915. * Gets the skybox created by the helper.
  44916. */
  44917. readonly skybox: Nullable<Mesh>;
  44918. private _skyboxTexture;
  44919. /**
  44920. * Gets the skybox texture created by the helper.
  44921. */
  44922. readonly skyboxTexture: Nullable<BaseTexture>;
  44923. private _skyboxMaterial;
  44924. /**
  44925. * Gets the skybox material created by the helper.
  44926. */
  44927. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44928. private _ground;
  44929. /**
  44930. * Gets the ground mesh created by the helper.
  44931. */
  44932. readonly ground: Nullable<Mesh>;
  44933. private _groundTexture;
  44934. /**
  44935. * Gets the ground texture created by the helper.
  44936. */
  44937. readonly groundTexture: Nullable<BaseTexture>;
  44938. private _groundMirror;
  44939. /**
  44940. * Gets the ground mirror created by the helper.
  44941. */
  44942. readonly groundMirror: Nullable<MirrorTexture>;
  44943. /**
  44944. * Gets the ground mirror render list to helps pushing the meshes
  44945. * you wish in the ground reflection.
  44946. */
  44947. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44948. private _groundMaterial;
  44949. /**
  44950. * Gets the ground material created by the helper.
  44951. */
  44952. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44953. /**
  44954. * Stores the creation options.
  44955. */
  44956. private readonly _scene;
  44957. private _options;
  44958. /**
  44959. * This observable will be notified with any error during the creation of the environment,
  44960. * mainly texture creation errors.
  44961. */
  44962. onErrorObservable: Observable<{
  44963. message?: string;
  44964. exception?: any;
  44965. }>;
  44966. /**
  44967. * constructor
  44968. * @param options Defines the options we want to customize the helper
  44969. * @param scene The scene to add the material to
  44970. */
  44971. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44972. /**
  44973. * Updates the background according to the new options
  44974. * @param options
  44975. */
  44976. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44977. /**
  44978. * Sets the primary color of all the available elements.
  44979. * @param color the main color to affect to the ground and the background
  44980. */
  44981. setMainColor(color: Color3): void;
  44982. /**
  44983. * Setup the image processing according to the specified options.
  44984. */
  44985. private _setupImageProcessing;
  44986. /**
  44987. * Setup the environment texture according to the specified options.
  44988. */
  44989. private _setupEnvironmentTexture;
  44990. /**
  44991. * Setup the background according to the specified options.
  44992. */
  44993. private _setupBackground;
  44994. /**
  44995. * Get the scene sizes according to the setup.
  44996. */
  44997. private _getSceneSize;
  44998. /**
  44999. * Setup the ground according to the specified options.
  45000. */
  45001. private _setupGround;
  45002. /**
  45003. * Setup the ground material according to the specified options.
  45004. */
  45005. private _setupGroundMaterial;
  45006. /**
  45007. * Setup the ground diffuse texture according to the specified options.
  45008. */
  45009. private _setupGroundDiffuseTexture;
  45010. /**
  45011. * Setup the ground mirror texture according to the specified options.
  45012. */
  45013. private _setupGroundMirrorTexture;
  45014. /**
  45015. * Setup the ground to receive the mirror texture.
  45016. */
  45017. private _setupMirrorInGroundMaterial;
  45018. /**
  45019. * Setup the skybox according to the specified options.
  45020. */
  45021. private _setupSkybox;
  45022. /**
  45023. * Setup the skybox material according to the specified options.
  45024. */
  45025. private _setupSkyboxMaterial;
  45026. /**
  45027. * Setup the skybox reflection texture according to the specified options.
  45028. */
  45029. private _setupSkyboxReflectionTexture;
  45030. private _errorHandler;
  45031. /**
  45032. * Dispose all the elements created by the Helper.
  45033. */
  45034. dispose(): void;
  45035. }
  45036. }
  45037. declare module BABYLON {
  45038. /**
  45039. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45040. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45041. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45042. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45043. */
  45044. export class PhotoDome extends TransformNode {
  45045. /**
  45046. * Define the image as a Monoscopic panoramic 360 image.
  45047. */
  45048. static readonly MODE_MONOSCOPIC: number;
  45049. /**
  45050. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45051. */
  45052. static readonly MODE_TOPBOTTOM: number;
  45053. /**
  45054. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45055. */
  45056. static readonly MODE_SIDEBYSIDE: number;
  45057. private _useDirectMapping;
  45058. /**
  45059. * The texture being displayed on the sphere
  45060. */
  45061. protected _photoTexture: Texture;
  45062. /**
  45063. * Gets or sets the texture being displayed on the sphere
  45064. */
  45065. photoTexture: Texture;
  45066. /**
  45067. * Observable raised when an error occured while loading the 360 image
  45068. */
  45069. onLoadErrorObservable: Observable<string>;
  45070. /**
  45071. * The skybox material
  45072. */
  45073. protected _material: BackgroundMaterial;
  45074. /**
  45075. * The surface used for the skybox
  45076. */
  45077. protected _mesh: Mesh;
  45078. /**
  45079. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45080. * Also see the options.resolution property.
  45081. */
  45082. fovMultiplier: number;
  45083. private _imageMode;
  45084. /**
  45085. * Gets or set the current video mode for the video. It can be:
  45086. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45087. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45088. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45089. */
  45090. imageMode: number;
  45091. /**
  45092. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45093. * @param name Element's name, child elements will append suffixes for their own names.
  45094. * @param urlsOfPhoto defines the url of the photo to display
  45095. * @param options defines an object containing optional or exposed sub element properties
  45096. * @param onError defines a callback called when an error occured while loading the texture
  45097. */
  45098. constructor(name: string, urlOfPhoto: string, options: {
  45099. resolution?: number;
  45100. size?: number;
  45101. useDirectMapping?: boolean;
  45102. faceForward?: boolean;
  45103. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45104. private _onBeforeCameraRenderObserver;
  45105. private _changeImageMode;
  45106. /**
  45107. * Releases resources associated with this node.
  45108. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45109. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45110. */
  45111. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45112. }
  45113. }
  45114. declare module BABYLON {
  45115. /**
  45116. * Class used to host texture specific utilities
  45117. */
  45118. export class BRDFTextureTools {
  45119. /**
  45120. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45121. * @param texture the texture to expand.
  45122. */
  45123. private static _ExpandDefaultBRDFTexture;
  45124. /**
  45125. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45126. * @param scene defines the hosting scene
  45127. * @returns the environment BRDF texture
  45128. */
  45129. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45130. private static _environmentBRDFBase64Texture;
  45131. }
  45132. }
  45133. declare module BABYLON {
  45134. /**
  45135. * @hidden
  45136. */
  45137. export interface IMaterialClearCoatDefines {
  45138. CLEARCOAT: boolean;
  45139. CLEARCOAT_DEFAULTIOR: boolean;
  45140. CLEARCOAT_TEXTURE: boolean;
  45141. CLEARCOAT_TEXTUREDIRECTUV: number;
  45142. CLEARCOAT_BUMP: boolean;
  45143. CLEARCOAT_BUMPDIRECTUV: number;
  45144. CLEARCOAT_TINT: boolean;
  45145. CLEARCOAT_TINT_TEXTURE: boolean;
  45146. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45147. /** @hidden */ private _areTexturesDirty: boolean;
  45148. }
  45149. /**
  45150. * Define the code related to the clear coat parameters of the pbr material.
  45151. */
  45152. export class PBRClearCoatConfiguration {
  45153. /**
  45154. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45155. * The default fits with a polyurethane material.
  45156. */
  45157. private static readonly _DefaultIndexOfRefraction;
  45158. private _isEnabled;
  45159. /**
  45160. * Defines if the clear coat is enabled in the material.
  45161. */
  45162. isEnabled: boolean;
  45163. /**
  45164. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45165. */
  45166. intensity: number;
  45167. /**
  45168. * Defines the clear coat layer roughness.
  45169. */
  45170. roughness: number;
  45171. private _indexOfRefraction;
  45172. /**
  45173. * Defines the index of refraction of the clear coat.
  45174. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45175. * The default fits with a polyurethane material.
  45176. * Changing the default value is more performance intensive.
  45177. */
  45178. indexOfRefraction: number;
  45179. private _texture;
  45180. /**
  45181. * Stores the clear coat values in a texture.
  45182. */
  45183. texture: Nullable<BaseTexture>;
  45184. private _bumpTexture;
  45185. /**
  45186. * Define the clear coat specific bump texture.
  45187. */
  45188. bumpTexture: Nullable<BaseTexture>;
  45189. private _isTintEnabled;
  45190. /**
  45191. * Defines if the clear coat tint is enabled in the material.
  45192. */
  45193. isTintEnabled: boolean;
  45194. /**
  45195. * Defines the clear coat tint of the material.
  45196. * This is only use if tint is enabled
  45197. */
  45198. tintColor: Color3;
  45199. /**
  45200. * Defines the distance at which the tint color should be found in the
  45201. * clear coat media.
  45202. * This is only use if tint is enabled
  45203. */
  45204. tintColorAtDistance: number;
  45205. /**
  45206. * Defines the clear coat layer thickness.
  45207. * This is only use if tint is enabled
  45208. */
  45209. tintThickness: number;
  45210. private _tintTexture;
  45211. /**
  45212. * Stores the clear tint values in a texture.
  45213. * rgb is tint
  45214. * a is a thickness factor
  45215. */
  45216. tintTexture: Nullable<BaseTexture>;
  45217. /** @hidden */
  45218. private _internalMarkAllSubMeshesAsTexturesDirty;
  45219. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45220. /**
  45221. * Instantiate a new istance of clear coat configuration.
  45222. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45223. */
  45224. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45225. /**
  45226. * Gets wehter the submesh is ready to be used or not.
  45227. * @param defines the list of "defines" to update.
  45228. * @param scene defines the scene the material belongs to.
  45229. * @param engine defines the engine the material belongs to.
  45230. * @param disableBumpMap defines wether the material disables bump or not.
  45231. * @returns - boolean indicating that the submesh is ready or not.
  45232. */
  45233. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45234. /**
  45235. * Checks to see if a texture is used in the material.
  45236. * @param defines the list of "defines" to update.
  45237. * @param scene defines the scene to the material belongs to.
  45238. */
  45239. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45240. /**
  45241. * Binds the material data.
  45242. * @param uniformBuffer defines the Uniform buffer to fill in.
  45243. * @param scene defines the scene the material belongs to.
  45244. * @param engine defines the engine the material belongs to.
  45245. * @param disableBumpMap defines wether the material disables bump or not.
  45246. * @param isFrozen defines wether the material is frozen or not.
  45247. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45248. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45249. */
  45250. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45251. /**
  45252. * Checks to see if a texture is used in the material.
  45253. * @param texture - Base texture to use.
  45254. * @returns - Boolean specifying if a texture is used in the material.
  45255. */
  45256. hasTexture(texture: BaseTexture): boolean;
  45257. /**
  45258. * Returns an array of the actively used textures.
  45259. * @param activeTextures Array of BaseTextures
  45260. */
  45261. getActiveTextures(activeTextures: BaseTexture[]): void;
  45262. /**
  45263. * Returns the animatable textures.
  45264. * @param animatables Array of animatable textures.
  45265. */
  45266. getAnimatables(animatables: IAnimatable[]): void;
  45267. /**
  45268. * Disposes the resources of the material.
  45269. * @param forceDisposeTextures - Forces the disposal of all textures.
  45270. */
  45271. dispose(forceDisposeTextures?: boolean): void;
  45272. /**
  45273. * Get the current class name of the texture useful for serialization or dynamic coding.
  45274. * @returns "PBRClearCoatConfiguration"
  45275. */
  45276. getClassName(): string;
  45277. /**
  45278. * Add fallbacks to the effect fallbacks list.
  45279. * @param defines defines the Base texture to use.
  45280. * @param fallbacks defines the current fallback list.
  45281. * @param currentRank defines the current fallback rank.
  45282. * @returns the new fallback rank.
  45283. */
  45284. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45285. /**
  45286. * Add the required uniforms to the current list.
  45287. * @param uniforms defines the current uniform list.
  45288. */
  45289. static AddUniforms(uniforms: string[]): void;
  45290. /**
  45291. * Add the required samplers to the current list.
  45292. * @param samplers defines the current sampler list.
  45293. */
  45294. static AddSamplers(samplers: string[]): void;
  45295. /**
  45296. * Add the required uniforms to the current buffer.
  45297. * @param uniformBuffer defines the current uniform buffer.
  45298. */
  45299. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45300. /**
  45301. * Makes a duplicate of the current configuration into another one.
  45302. * @param clearCoatConfiguration define the config where to copy the info
  45303. */
  45304. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45305. /**
  45306. * Serializes this clear coat configuration.
  45307. * @returns - An object with the serialized config.
  45308. */
  45309. serialize(): any;
  45310. /**
  45311. * Parses a anisotropy Configuration from a serialized object.
  45312. * @param source - Serialized object.
  45313. * @param scene Defines the scene we are parsing for
  45314. * @param rootUrl Defines the rootUrl to load from
  45315. */
  45316. parse(source: any, scene: Scene, rootUrl: string): void;
  45317. }
  45318. }
  45319. declare module BABYLON {
  45320. /**
  45321. * @hidden
  45322. */
  45323. export interface IMaterialAnisotropicDefines {
  45324. ANISOTROPIC: boolean;
  45325. ANISOTROPIC_TEXTURE: boolean;
  45326. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45327. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45328. }
  45329. /**
  45330. * Define the code related to the anisotropic parameters of the pbr material.
  45331. */
  45332. export class PBRAnisotropicConfiguration {
  45333. private _isEnabled;
  45334. /**
  45335. * Defines if the anisotropy is enabled in the material.
  45336. */
  45337. isEnabled: boolean;
  45338. /**
  45339. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45340. */
  45341. intensity: number;
  45342. /**
  45343. * Defines if the effect is along the tangents, bitangents or in between.
  45344. * By default, the effect is "strectching" the highlights along the tangents.
  45345. */
  45346. direction: Vector2;
  45347. private _texture;
  45348. /**
  45349. * Stores the anisotropy values in a texture.
  45350. * rg is direction (like normal from -1 to 1)
  45351. * b is a intensity
  45352. */
  45353. texture: Nullable<BaseTexture>;
  45354. /** @hidden */
  45355. private _internalMarkAllSubMeshesAsTexturesDirty;
  45356. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45357. /**
  45358. * Instantiate a new istance of anisotropy configuration.
  45359. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45360. */
  45361. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45362. /**
  45363. * Specifies that the submesh is ready to be used.
  45364. * @param defines the list of "defines" to update.
  45365. * @param scene defines the scene the material belongs to.
  45366. * @returns - boolean indicating that the submesh is ready or not.
  45367. */
  45368. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45369. /**
  45370. * Checks to see if a texture is used in the material.
  45371. * @param defines the list of "defines" to update.
  45372. * @param mesh the mesh we are preparing the defines for.
  45373. * @param scene defines the scene the material belongs to.
  45374. */
  45375. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45376. /**
  45377. * Binds the material data.
  45378. * @param uniformBuffer defines the Uniform buffer to fill in.
  45379. * @param scene defines the scene the material belongs to.
  45380. * @param isFrozen defines wether the material is frozen or not.
  45381. */
  45382. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45383. /**
  45384. * Checks to see if a texture is used in the material.
  45385. * @param texture - Base texture to use.
  45386. * @returns - Boolean specifying if a texture is used in the material.
  45387. */
  45388. hasTexture(texture: BaseTexture): boolean;
  45389. /**
  45390. * Returns an array of the actively used textures.
  45391. * @param activeTextures Array of BaseTextures
  45392. */
  45393. getActiveTextures(activeTextures: BaseTexture[]): void;
  45394. /**
  45395. * Returns the animatable textures.
  45396. * @param animatables Array of animatable textures.
  45397. */
  45398. getAnimatables(animatables: IAnimatable[]): void;
  45399. /**
  45400. * Disposes the resources of the material.
  45401. * @param forceDisposeTextures - Forces the disposal of all textures.
  45402. */
  45403. dispose(forceDisposeTextures?: boolean): void;
  45404. /**
  45405. * Get the current class name of the texture useful for serialization or dynamic coding.
  45406. * @returns "PBRAnisotropicConfiguration"
  45407. */
  45408. getClassName(): string;
  45409. /**
  45410. * Add fallbacks to the effect fallbacks list.
  45411. * @param defines defines the Base texture to use.
  45412. * @param fallbacks defines the current fallback list.
  45413. * @param currentRank defines the current fallback rank.
  45414. * @returns the new fallback rank.
  45415. */
  45416. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45417. /**
  45418. * Add the required uniforms to the current list.
  45419. * @param uniforms defines the current uniform list.
  45420. */
  45421. static AddUniforms(uniforms: string[]): void;
  45422. /**
  45423. * Add the required uniforms to the current buffer.
  45424. * @param uniformBuffer defines the current uniform buffer.
  45425. */
  45426. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45427. /**
  45428. * Add the required samplers to the current list.
  45429. * @param samplers defines the current sampler list.
  45430. */
  45431. static AddSamplers(samplers: string[]): void;
  45432. /**
  45433. * Makes a duplicate of the current configuration into another one.
  45434. * @param anisotropicConfiguration define the config where to copy the info
  45435. */
  45436. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45437. /**
  45438. * Serializes this anisotropy configuration.
  45439. * @returns - An object with the serialized config.
  45440. */
  45441. serialize(): any;
  45442. /**
  45443. * Parses a anisotropy Configuration from a serialized object.
  45444. * @param source - Serialized object.
  45445. * @param scene Defines the scene we are parsing for
  45446. * @param rootUrl Defines the rootUrl to load from
  45447. */
  45448. parse(source: any, scene: Scene, rootUrl: string): void;
  45449. }
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * @hidden
  45454. */
  45455. export interface IMaterialBRDFDefines {
  45456. BRDF_V_HEIGHT_CORRELATED: boolean;
  45457. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45458. SPHERICAL_HARMONICS: boolean;
  45459. /** @hidden */ private _areMiscDirty: boolean;
  45460. }
  45461. /**
  45462. * Define the code related to the BRDF parameters of the pbr material.
  45463. */
  45464. export class PBRBRDFConfiguration {
  45465. /**
  45466. * Default value used for the energy conservation.
  45467. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45468. */
  45469. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45470. /**
  45471. * Default value used for the Smith Visibility Height Correlated mode.
  45472. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45473. */
  45474. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45475. /**
  45476. * Default value used for the IBL diffuse part.
  45477. * This can help switching back to the polynomials mode globally which is a tiny bit
  45478. * less GPU intensive at the drawback of a lower quality.
  45479. */
  45480. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45481. private _useEnergyConservation;
  45482. /**
  45483. * Defines if the material uses energy conservation.
  45484. */
  45485. useEnergyConservation: boolean;
  45486. private _useSmithVisibilityHeightCorrelated;
  45487. /**
  45488. * LEGACY Mode set to false
  45489. * Defines if the material uses height smith correlated visibility term.
  45490. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45491. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45492. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45493. * Not relying on height correlated will also disable energy conservation.
  45494. */
  45495. useSmithVisibilityHeightCorrelated: boolean;
  45496. private _useSphericalHarmonics;
  45497. /**
  45498. * LEGACY Mode set to false
  45499. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45500. * diffuse part of the IBL.
  45501. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45502. * to the ground truth.
  45503. */
  45504. useSphericalHarmonics: boolean;
  45505. /** @hidden */
  45506. private _internalMarkAllSubMeshesAsMiscDirty;
  45507. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  45508. /**
  45509. * Instantiate a new istance of clear coat configuration.
  45510. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45511. */
  45512. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45513. /**
  45514. * Checks to see if a texture is used in the material.
  45515. * @param defines the list of "defines" to update.
  45516. */
  45517. prepareDefines(defines: IMaterialBRDFDefines): void;
  45518. /**
  45519. * Get the current class name of the texture useful for serialization or dynamic coding.
  45520. * @returns "PBRClearCoatConfiguration"
  45521. */
  45522. getClassName(): string;
  45523. /**
  45524. * Makes a duplicate of the current configuration into another one.
  45525. * @param brdfConfiguration define the config where to copy the info
  45526. */
  45527. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45528. /**
  45529. * Serializes this BRDF configuration.
  45530. * @returns - An object with the serialized config.
  45531. */
  45532. serialize(): any;
  45533. /**
  45534. * Parses a anisotropy Configuration from a serialized object.
  45535. * @param source - Serialized object.
  45536. * @param scene Defines the scene we are parsing for
  45537. * @param rootUrl Defines the rootUrl to load from
  45538. */
  45539. parse(source: any, scene: Scene, rootUrl: string): void;
  45540. }
  45541. }
  45542. declare module BABYLON {
  45543. /**
  45544. * @hidden
  45545. */
  45546. export interface IMaterialSheenDefines {
  45547. SHEEN: boolean;
  45548. SHEEN_TEXTURE: boolean;
  45549. SHEEN_TEXTUREDIRECTUV: number;
  45550. SHEEN_LINKWITHALBEDO: boolean;
  45551. /** @hidden */ private _areTexturesDirty: boolean;
  45552. }
  45553. /**
  45554. * Define the code related to the Sheen parameters of the pbr material.
  45555. */
  45556. export class PBRSheenConfiguration {
  45557. private _isEnabled;
  45558. /**
  45559. * Defines if the material uses sheen.
  45560. */
  45561. isEnabled: boolean;
  45562. private _linkSheenWithAlbedo;
  45563. /**
  45564. * Defines if the sheen is linked to the sheen color.
  45565. */
  45566. linkSheenWithAlbedo: boolean;
  45567. /**
  45568. * Defines the sheen intensity.
  45569. */
  45570. intensity: number;
  45571. /**
  45572. * Defines the sheen color.
  45573. */
  45574. color: Color3;
  45575. private _texture;
  45576. /**
  45577. * Stores the sheen tint values in a texture.
  45578. * rgb is tint
  45579. * a is a intensity
  45580. */
  45581. texture: Nullable<BaseTexture>;
  45582. /** @hidden */
  45583. private _internalMarkAllSubMeshesAsTexturesDirty;
  45584. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45585. /**
  45586. * Instantiate a new istance of clear coat configuration.
  45587. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45588. */
  45589. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45590. /**
  45591. * Specifies that the submesh is ready to be used.
  45592. * @param defines the list of "defines" to update.
  45593. * @param scene defines the scene the material belongs to.
  45594. * @returns - boolean indicating that the submesh is ready or not.
  45595. */
  45596. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45597. /**
  45598. * Checks to see if a texture is used in the material.
  45599. * @param defines the list of "defines" to update.
  45600. * @param scene defines the scene the material belongs to.
  45601. */
  45602. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45603. /**
  45604. * Binds the material data.
  45605. * @param uniformBuffer defines the Uniform buffer to fill in.
  45606. * @param scene defines the scene the material belongs to.
  45607. * @param isFrozen defines wether the material is frozen or not.
  45608. */
  45609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45610. /**
  45611. * Checks to see if a texture is used in the material.
  45612. * @param texture - Base texture to use.
  45613. * @returns - Boolean specifying if a texture is used in the material.
  45614. */
  45615. hasTexture(texture: BaseTexture): boolean;
  45616. /**
  45617. * Returns an array of the actively used textures.
  45618. * @param activeTextures Array of BaseTextures
  45619. */
  45620. getActiveTextures(activeTextures: BaseTexture[]): void;
  45621. /**
  45622. * Returns the animatable textures.
  45623. * @param animatables Array of animatable textures.
  45624. */
  45625. getAnimatables(animatables: IAnimatable[]): void;
  45626. /**
  45627. * Disposes the resources of the material.
  45628. * @param forceDisposeTextures - Forces the disposal of all textures.
  45629. */
  45630. dispose(forceDisposeTextures?: boolean): void;
  45631. /**
  45632. * Get the current class name of the texture useful for serialization or dynamic coding.
  45633. * @returns "PBRSheenConfiguration"
  45634. */
  45635. getClassName(): string;
  45636. /**
  45637. * Add fallbacks to the effect fallbacks list.
  45638. * @param defines defines the Base texture to use.
  45639. * @param fallbacks defines the current fallback list.
  45640. * @param currentRank defines the current fallback rank.
  45641. * @returns the new fallback rank.
  45642. */
  45643. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45644. /**
  45645. * Add the required uniforms to the current list.
  45646. * @param uniforms defines the current uniform list.
  45647. */
  45648. static AddUniforms(uniforms: string[]): void;
  45649. /**
  45650. * Add the required uniforms to the current buffer.
  45651. * @param uniformBuffer defines the current uniform buffer.
  45652. */
  45653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45654. /**
  45655. * Add the required samplers to the current list.
  45656. * @param samplers defines the current sampler list.
  45657. */
  45658. static AddSamplers(samplers: string[]): void;
  45659. /**
  45660. * Makes a duplicate of the current configuration into another one.
  45661. * @param sheenConfiguration define the config where to copy the info
  45662. */
  45663. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45664. /**
  45665. * Serializes this BRDF configuration.
  45666. * @returns - An object with the serialized config.
  45667. */
  45668. serialize(): any;
  45669. /**
  45670. * Parses a anisotropy Configuration from a serialized object.
  45671. * @param source - Serialized object.
  45672. * @param scene Defines the scene we are parsing for
  45673. * @param rootUrl Defines the rootUrl to load from
  45674. */
  45675. parse(source: any, scene: Scene, rootUrl: string): void;
  45676. }
  45677. }
  45678. declare module BABYLON {
  45679. /**
  45680. * @hidden
  45681. */
  45682. export interface IMaterialSubSurfaceDefines {
  45683. SUBSURFACE: boolean;
  45684. SS_REFRACTION: boolean;
  45685. SS_TRANSLUCENCY: boolean;
  45686. SS_SCATERRING: boolean;
  45687. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45688. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45689. SS_REFRACTIONMAP_3D: boolean;
  45690. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45691. SS_LODINREFRACTIONALPHA: boolean;
  45692. SS_GAMMAREFRACTION: boolean;
  45693. SS_RGBDREFRACTION: boolean;
  45694. SS_LINEARSPECULARREFRACTION: boolean;
  45695. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45696. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45697. /** @hidden */ private _areTexturesDirty: boolean;
  45698. }
  45699. /**
  45700. * Define the code related to the sub surface parameters of the pbr material.
  45701. */
  45702. export class PBRSubSurfaceConfiguration {
  45703. private _isRefractionEnabled;
  45704. /**
  45705. * Defines if the refraction is enabled in the material.
  45706. */
  45707. isRefractionEnabled: boolean;
  45708. private _isTranslucencyEnabled;
  45709. /**
  45710. * Defines if the translucency is enabled in the material.
  45711. */
  45712. isTranslucencyEnabled: boolean;
  45713. private _isScatteringEnabled;
  45714. /**
  45715. * Defines the refraction intensity of the material.
  45716. * The refraction when enabled replaces the Diffuse part of the material.
  45717. * The intensity helps transitionning between diffuse and refraction.
  45718. */
  45719. refractionIntensity: number;
  45720. /**
  45721. * Defines the translucency intensity of the material.
  45722. * When translucency has been enabled, this defines how much of the "translucency"
  45723. * is addded to the diffuse part of the material.
  45724. */
  45725. translucencyIntensity: number;
  45726. /**
  45727. * Defines the scattering intensity of the material.
  45728. * When scattering has been enabled, this defines how much of the "scattered light"
  45729. * is addded to the diffuse part of the material.
  45730. */
  45731. scatteringIntensity: number;
  45732. private _thicknessTexture;
  45733. /**
  45734. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45735. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45736. * 0 would mean minimumThickness
  45737. * 1 would mean maximumThickness
  45738. * The other channels might be use as a mask to vary the different effects intensity.
  45739. */
  45740. thicknessTexture: Nullable<BaseTexture>;
  45741. private _refractionTexture;
  45742. /**
  45743. * Defines the texture to use for refraction.
  45744. */
  45745. refractionTexture: Nullable<BaseTexture>;
  45746. private _indexOfRefraction;
  45747. /**
  45748. * Defines the index of refraction used in the material.
  45749. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45750. */
  45751. indexOfRefraction: number;
  45752. private _invertRefractionY;
  45753. /**
  45754. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45755. */
  45756. invertRefractionY: boolean;
  45757. private _linkRefractionWithTransparency;
  45758. /**
  45759. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45760. * Materials half opaque for instance using refraction could benefit from this control.
  45761. */
  45762. linkRefractionWithTransparency: boolean;
  45763. /**
  45764. * Defines the minimum thickness stored in the thickness map.
  45765. * If no thickness map is defined, this value will be used to simulate thickness.
  45766. */
  45767. minimumThickness: number;
  45768. /**
  45769. * Defines the maximum thickness stored in the thickness map.
  45770. */
  45771. maximumThickness: number;
  45772. /**
  45773. * Defines the volume tint of the material.
  45774. * This is used for both translucency and scattering.
  45775. */
  45776. tintColor: Color3;
  45777. /**
  45778. * Defines the distance at which the tint color should be found in the media.
  45779. * This is used for refraction only.
  45780. */
  45781. tintColorAtDistance: number;
  45782. /**
  45783. * Defines how far each channel transmit through the media.
  45784. * It is defined as a color to simplify it selection.
  45785. */
  45786. diffusionDistance: Color3;
  45787. private _useMaskFromThicknessTexture;
  45788. /**
  45789. * Stores the intensity of the different subsurface effects in the thickness texture.
  45790. * * the green channel is the translucency intensity.
  45791. * * the blue channel is the scattering intensity.
  45792. * * the alpha channel is the refraction intensity.
  45793. */
  45794. useMaskFromThicknessTexture: boolean;
  45795. /** @hidden */
  45796. private _internalMarkAllSubMeshesAsTexturesDirty;
  45797. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45798. /**
  45799. * Instantiate a new istance of sub surface configuration.
  45800. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45801. */
  45802. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45803. /**
  45804. * Gets wehter the submesh is ready to be used or not.
  45805. * @param defines the list of "defines" to update.
  45806. * @param scene defines the scene the material belongs to.
  45807. * @returns - boolean indicating that the submesh is ready or not.
  45808. */
  45809. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45810. /**
  45811. * Checks to see if a texture is used in the material.
  45812. * @param defines the list of "defines" to update.
  45813. * @param scene defines the scene to the material belongs to.
  45814. */
  45815. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45816. /**
  45817. * Binds the material data.
  45818. * @param uniformBuffer defines the Uniform buffer to fill in.
  45819. * @param scene defines the scene the material belongs to.
  45820. * @param engine defines the engine the material belongs to.
  45821. * @param isFrozen defines wether the material is frozen or not.
  45822. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45823. */
  45824. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45825. /**
  45826. * Unbinds the material from the mesh.
  45827. * @param activeEffect defines the effect that should be unbound from.
  45828. * @returns true if unbound, otherwise false
  45829. */
  45830. unbind(activeEffect: Effect): boolean;
  45831. /**
  45832. * Returns the texture used for refraction or null if none is used.
  45833. * @param scene defines the scene the material belongs to.
  45834. * @returns - Refraction texture if present. If no refraction texture and refraction
  45835. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45836. */
  45837. private _getRefractionTexture;
  45838. /**
  45839. * Returns true if alpha blending should be disabled.
  45840. */
  45841. readonly disableAlphaBlending: boolean;
  45842. /**
  45843. * Fills the list of render target textures.
  45844. * @param renderTargets the list of render targets to update
  45845. */
  45846. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45847. /**
  45848. * Checks to see if a texture is used in the material.
  45849. * @param texture - Base texture to use.
  45850. * @returns - Boolean specifying if a texture is used in the material.
  45851. */
  45852. hasTexture(texture: BaseTexture): boolean;
  45853. /**
  45854. * Gets a boolean indicating that current material needs to register RTT
  45855. * @returns true if this uses a render target otherwise false.
  45856. */
  45857. hasRenderTargetTextures(): boolean;
  45858. /**
  45859. * Returns an array of the actively used textures.
  45860. * @param activeTextures Array of BaseTextures
  45861. */
  45862. getActiveTextures(activeTextures: BaseTexture[]): void;
  45863. /**
  45864. * Returns the animatable textures.
  45865. * @param animatables Array of animatable textures.
  45866. */
  45867. getAnimatables(animatables: IAnimatable[]): void;
  45868. /**
  45869. * Disposes the resources of the material.
  45870. * @param forceDisposeTextures - Forces the disposal of all textures.
  45871. */
  45872. dispose(forceDisposeTextures?: boolean): void;
  45873. /**
  45874. * Get the current class name of the texture useful for serialization or dynamic coding.
  45875. * @returns "PBRSubSurfaceConfiguration"
  45876. */
  45877. getClassName(): string;
  45878. /**
  45879. * Add fallbacks to the effect fallbacks list.
  45880. * @param defines defines the Base texture to use.
  45881. * @param fallbacks defines the current fallback list.
  45882. * @param currentRank defines the current fallback rank.
  45883. * @returns the new fallback rank.
  45884. */
  45885. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45886. /**
  45887. * Add the required uniforms to the current list.
  45888. * @param uniforms defines the current uniform list.
  45889. */
  45890. static AddUniforms(uniforms: string[]): void;
  45891. /**
  45892. * Add the required samplers to the current list.
  45893. * @param samplers defines the current sampler list.
  45894. */
  45895. static AddSamplers(samplers: string[]): void;
  45896. /**
  45897. * Add the required uniforms to the current buffer.
  45898. * @param uniformBuffer defines the current uniform buffer.
  45899. */
  45900. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45901. /**
  45902. * Makes a duplicate of the current configuration into another one.
  45903. * @param configuration define the config where to copy the info
  45904. */
  45905. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45906. /**
  45907. * Serializes this Sub Surface configuration.
  45908. * @returns - An object with the serialized config.
  45909. */
  45910. serialize(): any;
  45911. /**
  45912. * Parses a anisotropy Configuration from a serialized object.
  45913. * @param source - Serialized object.
  45914. * @param scene Defines the scene we are parsing for
  45915. * @param rootUrl Defines the rootUrl to load from
  45916. */
  45917. parse(source: any, scene: Scene, rootUrl: string): void;
  45918. }
  45919. }
  45920. declare module BABYLON {
  45921. /** @hidden */
  45922. export var pbrFragmentDeclaration: {
  45923. name: string;
  45924. shader: string;
  45925. };
  45926. }
  45927. declare module BABYLON {
  45928. /** @hidden */
  45929. export var pbrUboDeclaration: {
  45930. name: string;
  45931. shader: string;
  45932. };
  45933. }
  45934. declare module BABYLON {
  45935. /** @hidden */
  45936. export var pbrFragmentExtraDeclaration: {
  45937. name: string;
  45938. shader: string;
  45939. };
  45940. }
  45941. declare module BABYLON {
  45942. /** @hidden */
  45943. export var pbrFragmentSamplersDeclaration: {
  45944. name: string;
  45945. shader: string;
  45946. };
  45947. }
  45948. declare module BABYLON {
  45949. /** @hidden */
  45950. export var pbrHelperFunctions: {
  45951. name: string;
  45952. shader: string;
  45953. };
  45954. }
  45955. declare module BABYLON {
  45956. /** @hidden */
  45957. export var harmonicsFunctions: {
  45958. name: string;
  45959. shader: string;
  45960. };
  45961. }
  45962. declare module BABYLON {
  45963. /** @hidden */
  45964. export var pbrDirectLightingSetupFunctions: {
  45965. name: string;
  45966. shader: string;
  45967. };
  45968. }
  45969. declare module BABYLON {
  45970. /** @hidden */
  45971. export var pbrDirectLightingFalloffFunctions: {
  45972. name: string;
  45973. shader: string;
  45974. };
  45975. }
  45976. declare module BABYLON {
  45977. /** @hidden */
  45978. export var pbrBRDFFunctions: {
  45979. name: string;
  45980. shader: string;
  45981. };
  45982. }
  45983. declare module BABYLON {
  45984. /** @hidden */
  45985. export var pbrDirectLightingFunctions: {
  45986. name: string;
  45987. shader: string;
  45988. };
  45989. }
  45990. declare module BABYLON {
  45991. /** @hidden */
  45992. export var pbrIBLFunctions: {
  45993. name: string;
  45994. shader: string;
  45995. };
  45996. }
  45997. declare module BABYLON {
  45998. /** @hidden */
  45999. export var pbrDebug: {
  46000. name: string;
  46001. shader: string;
  46002. };
  46003. }
  46004. declare module BABYLON {
  46005. /** @hidden */
  46006. export var pbrPixelShader: {
  46007. name: string;
  46008. shader: string;
  46009. };
  46010. }
  46011. declare module BABYLON {
  46012. /** @hidden */
  46013. export var pbrVertexDeclaration: {
  46014. name: string;
  46015. shader: string;
  46016. };
  46017. }
  46018. declare module BABYLON {
  46019. /** @hidden */
  46020. export var pbrVertexShader: {
  46021. name: string;
  46022. shader: string;
  46023. };
  46024. }
  46025. declare module BABYLON {
  46026. /**
  46027. * Manages the defines for the PBR Material.
  46028. * @hidden
  46029. */
  46030. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46031. PBR: boolean;
  46032. MAINUV1: boolean;
  46033. MAINUV2: boolean;
  46034. UV1: boolean;
  46035. UV2: boolean;
  46036. ALBEDO: boolean;
  46037. ALBEDODIRECTUV: number;
  46038. VERTEXCOLOR: boolean;
  46039. AMBIENT: boolean;
  46040. AMBIENTDIRECTUV: number;
  46041. AMBIENTINGRAYSCALE: boolean;
  46042. OPACITY: boolean;
  46043. VERTEXALPHA: boolean;
  46044. OPACITYDIRECTUV: number;
  46045. OPACITYRGB: boolean;
  46046. ALPHATEST: boolean;
  46047. DEPTHPREPASS: boolean;
  46048. ALPHABLEND: boolean;
  46049. ALPHAFROMALBEDO: boolean;
  46050. ALPHATESTVALUE: string;
  46051. SPECULAROVERALPHA: boolean;
  46052. RADIANCEOVERALPHA: boolean;
  46053. ALPHAFRESNEL: boolean;
  46054. LINEARALPHAFRESNEL: boolean;
  46055. PREMULTIPLYALPHA: boolean;
  46056. EMISSIVE: boolean;
  46057. EMISSIVEDIRECTUV: number;
  46058. REFLECTIVITY: boolean;
  46059. REFLECTIVITYDIRECTUV: number;
  46060. SPECULARTERM: boolean;
  46061. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46062. MICROSURFACEAUTOMATIC: boolean;
  46063. LODBASEDMICROSFURACE: boolean;
  46064. MICROSURFACEMAP: boolean;
  46065. MICROSURFACEMAPDIRECTUV: number;
  46066. METALLICWORKFLOW: boolean;
  46067. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46068. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46069. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46070. AOSTOREINMETALMAPRED: boolean;
  46071. ENVIRONMENTBRDF: boolean;
  46072. ENVIRONMENTBRDF_RGBD: boolean;
  46073. NORMAL: boolean;
  46074. TANGENT: boolean;
  46075. BUMP: boolean;
  46076. BUMPDIRECTUV: number;
  46077. OBJECTSPACE_NORMALMAP: boolean;
  46078. PARALLAX: boolean;
  46079. PARALLAXOCCLUSION: boolean;
  46080. NORMALXYSCALE: boolean;
  46081. LIGHTMAP: boolean;
  46082. LIGHTMAPDIRECTUV: number;
  46083. USELIGHTMAPASSHADOWMAP: boolean;
  46084. GAMMALIGHTMAP: boolean;
  46085. REFLECTION: boolean;
  46086. REFLECTIONMAP_3D: boolean;
  46087. REFLECTIONMAP_SPHERICAL: boolean;
  46088. REFLECTIONMAP_PLANAR: boolean;
  46089. REFLECTIONMAP_CUBIC: boolean;
  46090. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46091. REFLECTIONMAP_PROJECTION: boolean;
  46092. REFLECTIONMAP_SKYBOX: boolean;
  46093. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46094. REFLECTIONMAP_EXPLICIT: boolean;
  46095. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46096. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46097. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46098. INVERTCUBICMAP: boolean;
  46099. USESPHERICALFROMREFLECTIONMAP: boolean;
  46100. USEIRRADIANCEMAP: boolean;
  46101. SPHERICAL_HARMONICS: boolean;
  46102. USESPHERICALINVERTEX: boolean;
  46103. REFLECTIONMAP_OPPOSITEZ: boolean;
  46104. LODINREFLECTIONALPHA: boolean;
  46105. GAMMAREFLECTION: boolean;
  46106. RGBDREFLECTION: boolean;
  46107. LINEARSPECULARREFLECTION: boolean;
  46108. RADIANCEOCCLUSION: boolean;
  46109. HORIZONOCCLUSION: boolean;
  46110. INSTANCES: boolean;
  46111. NUM_BONE_INFLUENCERS: number;
  46112. BonesPerMesh: number;
  46113. BONETEXTURE: boolean;
  46114. NONUNIFORMSCALING: boolean;
  46115. MORPHTARGETS: boolean;
  46116. MORPHTARGETS_NORMAL: boolean;
  46117. MORPHTARGETS_TANGENT: boolean;
  46118. MORPHTARGETS_UV: boolean;
  46119. NUM_MORPH_INFLUENCERS: number;
  46120. IMAGEPROCESSING: boolean;
  46121. VIGNETTE: boolean;
  46122. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46123. VIGNETTEBLENDMODEOPAQUE: boolean;
  46124. TONEMAPPING: boolean;
  46125. TONEMAPPING_ACES: boolean;
  46126. CONTRAST: boolean;
  46127. COLORCURVES: boolean;
  46128. COLORGRADING: boolean;
  46129. COLORGRADING3D: boolean;
  46130. SAMPLER3DGREENDEPTH: boolean;
  46131. SAMPLER3DBGRMAP: boolean;
  46132. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46133. EXPOSURE: boolean;
  46134. MULTIVIEW: boolean;
  46135. USEPHYSICALLIGHTFALLOFF: boolean;
  46136. USEGLTFLIGHTFALLOFF: boolean;
  46137. TWOSIDEDLIGHTING: boolean;
  46138. SHADOWFLOAT: boolean;
  46139. CLIPPLANE: boolean;
  46140. CLIPPLANE2: boolean;
  46141. CLIPPLANE3: boolean;
  46142. CLIPPLANE4: boolean;
  46143. POINTSIZE: boolean;
  46144. FOG: boolean;
  46145. LOGARITHMICDEPTH: boolean;
  46146. FORCENORMALFORWARD: boolean;
  46147. SPECULARAA: boolean;
  46148. CLEARCOAT: boolean;
  46149. CLEARCOAT_DEFAULTIOR: boolean;
  46150. CLEARCOAT_TEXTURE: boolean;
  46151. CLEARCOAT_TEXTUREDIRECTUV: number;
  46152. CLEARCOAT_BUMP: boolean;
  46153. CLEARCOAT_BUMPDIRECTUV: number;
  46154. CLEARCOAT_TINT: boolean;
  46155. CLEARCOAT_TINT_TEXTURE: boolean;
  46156. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46157. ANISOTROPIC: boolean;
  46158. ANISOTROPIC_TEXTURE: boolean;
  46159. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46160. BRDF_V_HEIGHT_CORRELATED: boolean;
  46161. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46162. SHEEN: boolean;
  46163. SHEEN_TEXTURE: boolean;
  46164. SHEEN_TEXTUREDIRECTUV: number;
  46165. SHEEN_LINKWITHALBEDO: boolean;
  46166. SUBSURFACE: boolean;
  46167. SS_REFRACTION: boolean;
  46168. SS_TRANSLUCENCY: boolean;
  46169. SS_SCATERRING: boolean;
  46170. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46171. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46172. SS_REFRACTIONMAP_3D: boolean;
  46173. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46174. SS_LODINREFRACTIONALPHA: boolean;
  46175. SS_GAMMAREFRACTION: boolean;
  46176. SS_RGBDREFRACTION: boolean;
  46177. SS_LINEARSPECULARREFRACTION: boolean;
  46178. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46179. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46180. UNLIT: boolean;
  46181. DEBUGMODE: number;
  46182. /**
  46183. * Initializes the PBR Material defines.
  46184. */
  46185. constructor();
  46186. /**
  46187. * Resets the PBR Material defines.
  46188. */
  46189. reset(): void;
  46190. }
  46191. /**
  46192. * The Physically based material base class of BJS.
  46193. *
  46194. * This offers the main features of a standard PBR material.
  46195. * For more information, please refer to the documentation :
  46196. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46197. */
  46198. export abstract class PBRBaseMaterial extends PushMaterial {
  46199. /**
  46200. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46201. */
  46202. static readonly PBRMATERIAL_OPAQUE: number;
  46203. /**
  46204. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46205. */
  46206. static readonly PBRMATERIAL_ALPHATEST: number;
  46207. /**
  46208. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46209. */
  46210. static readonly PBRMATERIAL_ALPHABLEND: number;
  46211. /**
  46212. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46213. * They are also discarded below the alpha cutoff threshold to improve performances.
  46214. */
  46215. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46216. /**
  46217. * Defines the default value of how much AO map is occluding the analytical lights
  46218. * (point spot...).
  46219. */
  46220. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46221. /**
  46222. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46223. */
  46224. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46225. /**
  46226. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46227. * to enhance interoperability with other engines.
  46228. */
  46229. static readonly LIGHTFALLOFF_GLTF: number;
  46230. /**
  46231. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46232. * to enhance interoperability with other materials.
  46233. */
  46234. static readonly LIGHTFALLOFF_STANDARD: number;
  46235. /**
  46236. * Intensity of the direct lights e.g. the four lights available in your scene.
  46237. * This impacts both the direct diffuse and specular highlights.
  46238. */
  46239. protected _directIntensity: number;
  46240. /**
  46241. * Intensity of the emissive part of the material.
  46242. * This helps controlling the emissive effect without modifying the emissive color.
  46243. */
  46244. protected _emissiveIntensity: number;
  46245. /**
  46246. * Intensity of the environment e.g. how much the environment will light the object
  46247. * either through harmonics for rough material or through the refelction for shiny ones.
  46248. */
  46249. protected _environmentIntensity: number;
  46250. /**
  46251. * This is a special control allowing the reduction of the specular highlights coming from the
  46252. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46253. */
  46254. protected _specularIntensity: number;
  46255. /**
  46256. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46257. */
  46258. private _lightingInfos;
  46259. /**
  46260. * Debug Control allowing disabling the bump map on this material.
  46261. */
  46262. protected _disableBumpMap: boolean;
  46263. /**
  46264. * AKA Diffuse Texture in standard nomenclature.
  46265. */
  46266. protected _albedoTexture: Nullable<BaseTexture>;
  46267. /**
  46268. * AKA Occlusion Texture in other nomenclature.
  46269. */
  46270. protected _ambientTexture: Nullable<BaseTexture>;
  46271. /**
  46272. * AKA Occlusion Texture Intensity in other nomenclature.
  46273. */
  46274. protected _ambientTextureStrength: number;
  46275. /**
  46276. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46277. * 1 means it completely occludes it
  46278. * 0 mean it has no impact
  46279. */
  46280. protected _ambientTextureImpactOnAnalyticalLights: number;
  46281. /**
  46282. * Stores the alpha values in a texture.
  46283. */
  46284. protected _opacityTexture: Nullable<BaseTexture>;
  46285. /**
  46286. * Stores the reflection values in a texture.
  46287. */
  46288. protected _reflectionTexture: Nullable<BaseTexture>;
  46289. /**
  46290. * Stores the emissive values in a texture.
  46291. */
  46292. protected _emissiveTexture: Nullable<BaseTexture>;
  46293. /**
  46294. * AKA Specular texture in other nomenclature.
  46295. */
  46296. protected _reflectivityTexture: Nullable<BaseTexture>;
  46297. /**
  46298. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46299. */
  46300. protected _metallicTexture: Nullable<BaseTexture>;
  46301. /**
  46302. * Specifies the metallic scalar of the metallic/roughness workflow.
  46303. * Can also be used to scale the metalness values of the metallic texture.
  46304. */
  46305. protected _metallic: Nullable<number>;
  46306. /**
  46307. * Specifies the roughness scalar of the metallic/roughness workflow.
  46308. * Can also be used to scale the roughness values of the metallic texture.
  46309. */
  46310. protected _roughness: Nullable<number>;
  46311. /**
  46312. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46313. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46314. */
  46315. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46316. /**
  46317. * Stores surface normal data used to displace a mesh in a texture.
  46318. */
  46319. protected _bumpTexture: Nullable<BaseTexture>;
  46320. /**
  46321. * Stores the pre-calculated light information of a mesh in a texture.
  46322. */
  46323. protected _lightmapTexture: Nullable<BaseTexture>;
  46324. /**
  46325. * The color of a material in ambient lighting.
  46326. */
  46327. protected _ambientColor: Color3;
  46328. /**
  46329. * AKA Diffuse Color in other nomenclature.
  46330. */
  46331. protected _albedoColor: Color3;
  46332. /**
  46333. * AKA Specular Color in other nomenclature.
  46334. */
  46335. protected _reflectivityColor: Color3;
  46336. /**
  46337. * The color applied when light is reflected from a material.
  46338. */
  46339. protected _reflectionColor: Color3;
  46340. /**
  46341. * The color applied when light is emitted from a material.
  46342. */
  46343. protected _emissiveColor: Color3;
  46344. /**
  46345. * AKA Glossiness in other nomenclature.
  46346. */
  46347. protected _microSurface: number;
  46348. /**
  46349. * Specifies that the material will use the light map as a show map.
  46350. */
  46351. protected _useLightmapAsShadowmap: boolean;
  46352. /**
  46353. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46354. * makes the reflect vector face the model (under horizon).
  46355. */
  46356. protected _useHorizonOcclusion: boolean;
  46357. /**
  46358. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46359. * too much the area relying on ambient texture to define their ambient occlusion.
  46360. */
  46361. protected _useRadianceOcclusion: boolean;
  46362. /**
  46363. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46364. */
  46365. protected _useAlphaFromAlbedoTexture: boolean;
  46366. /**
  46367. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46368. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46369. */
  46370. protected _useSpecularOverAlpha: boolean;
  46371. /**
  46372. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46373. */
  46374. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46375. /**
  46376. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46377. */
  46378. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46379. /**
  46380. * Specifies if the metallic texture contains the roughness information in its green channel.
  46381. */
  46382. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46383. /**
  46384. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46385. */
  46386. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46387. /**
  46388. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46389. */
  46390. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46391. /**
  46392. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46393. */
  46394. protected _useAmbientInGrayScale: boolean;
  46395. /**
  46396. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46397. * The material will try to infer what glossiness each pixel should be.
  46398. */
  46399. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46400. /**
  46401. * Defines the falloff type used in this material.
  46402. * It by default is Physical.
  46403. */
  46404. protected _lightFalloff: number;
  46405. /**
  46406. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46407. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46408. */
  46409. protected _useRadianceOverAlpha: boolean;
  46410. /**
  46411. * Allows using an object space normal map (instead of tangent space).
  46412. */
  46413. protected _useObjectSpaceNormalMap: boolean;
  46414. /**
  46415. * Allows using the bump map in parallax mode.
  46416. */
  46417. protected _useParallax: boolean;
  46418. /**
  46419. * Allows using the bump map in parallax occlusion mode.
  46420. */
  46421. protected _useParallaxOcclusion: boolean;
  46422. /**
  46423. * Controls the scale bias of the parallax mode.
  46424. */
  46425. protected _parallaxScaleBias: number;
  46426. /**
  46427. * If sets to true, disables all the lights affecting the material.
  46428. */
  46429. protected _disableLighting: boolean;
  46430. /**
  46431. * Number of Simultaneous lights allowed on the material.
  46432. */
  46433. protected _maxSimultaneousLights: number;
  46434. /**
  46435. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46436. */
  46437. protected _invertNormalMapX: boolean;
  46438. /**
  46439. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46440. */
  46441. protected _invertNormalMapY: boolean;
  46442. /**
  46443. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46444. */
  46445. protected _twoSidedLighting: boolean;
  46446. /**
  46447. * Defines the alpha limits in alpha test mode.
  46448. */
  46449. protected _alphaCutOff: number;
  46450. /**
  46451. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46452. */
  46453. protected _forceAlphaTest: boolean;
  46454. /**
  46455. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46456. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46457. */
  46458. protected _useAlphaFresnel: boolean;
  46459. /**
  46460. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46461. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46462. */
  46463. protected _useLinearAlphaFresnel: boolean;
  46464. /**
  46465. * The transparency mode of the material.
  46466. */
  46467. protected _transparencyMode: Nullable<number>;
  46468. /**
  46469. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46470. * from cos thetav and roughness:
  46471. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46472. */
  46473. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46474. /**
  46475. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46476. */
  46477. protected _forceIrradianceInFragment: boolean;
  46478. /**
  46479. * Force normal to face away from face.
  46480. */
  46481. protected _forceNormalForward: boolean;
  46482. /**
  46483. * Enables specular anti aliasing in the PBR shader.
  46484. * It will both interacts on the Geometry for analytical and IBL lighting.
  46485. * It also prefilter the roughness map based on the bump values.
  46486. */
  46487. protected _enableSpecularAntiAliasing: boolean;
  46488. /**
  46489. * Default configuration related to image processing available in the PBR Material.
  46490. */
  46491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46492. /**
  46493. * Keep track of the image processing observer to allow dispose and replace.
  46494. */
  46495. private _imageProcessingObserver;
  46496. /**
  46497. * Attaches a new image processing configuration to the PBR Material.
  46498. * @param configuration
  46499. */
  46500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46501. /**
  46502. * Stores the available render targets.
  46503. */
  46504. private _renderTargets;
  46505. /**
  46506. * Sets the global ambient color for the material used in lighting calculations.
  46507. */
  46508. private _globalAmbientColor;
  46509. /**
  46510. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46511. */
  46512. private _useLogarithmicDepth;
  46513. /**
  46514. * If set to true, no lighting calculations will be applied.
  46515. */
  46516. private _unlit;
  46517. private _debugMode;
  46518. /**
  46519. * @hidden
  46520. * This is reserved for the inspector.
  46521. * Defines the material debug mode.
  46522. * It helps seeing only some components of the material while troubleshooting.
  46523. */
  46524. debugMode: number;
  46525. /**
  46526. * @hidden
  46527. * This is reserved for the inspector.
  46528. * Specify from where on screen the debug mode should start.
  46529. * The value goes from -1 (full screen) to 1 (not visible)
  46530. * It helps with side by side comparison against the final render
  46531. * This defaults to -1
  46532. */
  46533. private debugLimit;
  46534. /**
  46535. * @hidden
  46536. * This is reserved for the inspector.
  46537. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46538. * You can use the factor to better multiply the final value.
  46539. */
  46540. private debugFactor;
  46541. /**
  46542. * Defines the clear coat layer parameters for the material.
  46543. */
  46544. readonly clearCoat: PBRClearCoatConfiguration;
  46545. /**
  46546. * Defines the anisotropic parameters for the material.
  46547. */
  46548. readonly anisotropy: PBRAnisotropicConfiguration;
  46549. /**
  46550. * Defines the BRDF parameters for the material.
  46551. */
  46552. readonly brdf: PBRBRDFConfiguration;
  46553. /**
  46554. * Defines the Sheen parameters for the material.
  46555. */
  46556. readonly sheen: PBRSheenConfiguration;
  46557. /**
  46558. * Defines the SubSurface parameters for the material.
  46559. */
  46560. readonly subSurface: PBRSubSurfaceConfiguration;
  46561. /**
  46562. * Custom callback helping to override the default shader used in the material.
  46563. */
  46564. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46565. protected _rebuildInParallel: boolean;
  46566. /**
  46567. * Instantiates a new PBRMaterial instance.
  46568. *
  46569. * @param name The material name
  46570. * @param scene The scene the material will be use in.
  46571. */
  46572. constructor(name: string, scene: Scene);
  46573. /**
  46574. * Gets a boolean indicating that current material needs to register RTT
  46575. */
  46576. readonly hasRenderTargetTextures: boolean;
  46577. /**
  46578. * Gets the name of the material class.
  46579. */
  46580. getClassName(): string;
  46581. /**
  46582. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46583. */
  46584. /**
  46585. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46586. */
  46587. useLogarithmicDepth: boolean;
  46588. /**
  46589. * Gets the current transparency mode.
  46590. */
  46591. /**
  46592. * Sets the transparency mode of the material.
  46593. *
  46594. * | Value | Type | Description |
  46595. * | ----- | ----------------------------------- | ----------- |
  46596. * | 0 | OPAQUE | |
  46597. * | 1 | ALPHATEST | |
  46598. * | 2 | ALPHABLEND | |
  46599. * | 3 | ALPHATESTANDBLEND | |
  46600. *
  46601. */
  46602. transparencyMode: Nullable<number>;
  46603. /**
  46604. * Returns true if alpha blending should be disabled.
  46605. */
  46606. private readonly _disableAlphaBlending;
  46607. /**
  46608. * Specifies whether or not this material should be rendered in alpha blend mode.
  46609. */
  46610. needAlphaBlending(): boolean;
  46611. /**
  46612. * Specifies if the mesh will require alpha blending.
  46613. * @param mesh - BJS mesh.
  46614. */
  46615. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46616. /**
  46617. * Specifies whether or not this material should be rendered in alpha test mode.
  46618. */
  46619. needAlphaTesting(): boolean;
  46620. /**
  46621. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46622. */
  46623. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46624. /**
  46625. * Gets the texture used for the alpha test.
  46626. */
  46627. getAlphaTestTexture(): Nullable<BaseTexture>;
  46628. /**
  46629. * Specifies that the submesh is ready to be used.
  46630. * @param mesh - BJS mesh.
  46631. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46632. * @param useInstances - Specifies that instances should be used.
  46633. * @returns - boolean indicating that the submesh is ready or not.
  46634. */
  46635. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46636. /**
  46637. * Specifies if the material uses metallic roughness workflow.
  46638. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46639. */
  46640. isMetallicWorkflow(): boolean;
  46641. private _prepareEffect;
  46642. private _prepareDefines;
  46643. /**
  46644. * Force shader compilation
  46645. */
  46646. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46647. clipPlane: boolean;
  46648. }>): void;
  46649. /**
  46650. * Initializes the uniform buffer layout for the shader.
  46651. */
  46652. buildUniformLayout(): void;
  46653. /**
  46654. * Unbinds the material from the mesh
  46655. */
  46656. unbind(): void;
  46657. /**
  46658. * Binds the submesh data.
  46659. * @param world - The world matrix.
  46660. * @param mesh - The BJS mesh.
  46661. * @param subMesh - A submesh of the BJS mesh.
  46662. */
  46663. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46664. /**
  46665. * Returns the animatable textures.
  46666. * @returns - Array of animatable textures.
  46667. */
  46668. getAnimatables(): IAnimatable[];
  46669. /**
  46670. * Returns the texture used for reflections.
  46671. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46672. */
  46673. private _getReflectionTexture;
  46674. /**
  46675. * Returns an array of the actively used textures.
  46676. * @returns - Array of BaseTextures
  46677. */
  46678. getActiveTextures(): BaseTexture[];
  46679. /**
  46680. * Checks to see if a texture is used in the material.
  46681. * @param texture - Base texture to use.
  46682. * @returns - Boolean specifying if a texture is used in the material.
  46683. */
  46684. hasTexture(texture: BaseTexture): boolean;
  46685. /**
  46686. * Disposes the resources of the material.
  46687. * @param forceDisposeEffect - Forces the disposal of effects.
  46688. * @param forceDisposeTextures - Forces the disposal of all textures.
  46689. */
  46690. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46691. }
  46692. }
  46693. declare module BABYLON {
  46694. /**
  46695. * The Physically based material of BJS.
  46696. *
  46697. * This offers the main features of a standard PBR material.
  46698. * For more information, please refer to the documentation :
  46699. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46700. */
  46701. export class PBRMaterial extends PBRBaseMaterial {
  46702. /**
  46703. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46704. */
  46705. static readonly PBRMATERIAL_OPAQUE: number;
  46706. /**
  46707. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46708. */
  46709. static readonly PBRMATERIAL_ALPHATEST: number;
  46710. /**
  46711. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46712. */
  46713. static readonly PBRMATERIAL_ALPHABLEND: number;
  46714. /**
  46715. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46716. * They are also discarded below the alpha cutoff threshold to improve performances.
  46717. */
  46718. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46719. /**
  46720. * Defines the default value of how much AO map is occluding the analytical lights
  46721. * (point spot...).
  46722. */
  46723. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46724. /**
  46725. * Intensity of the direct lights e.g. the four lights available in your scene.
  46726. * This impacts both the direct diffuse and specular highlights.
  46727. */
  46728. directIntensity: number;
  46729. /**
  46730. * Intensity of the emissive part of the material.
  46731. * This helps controlling the emissive effect without modifying the emissive color.
  46732. */
  46733. emissiveIntensity: number;
  46734. /**
  46735. * Intensity of the environment e.g. how much the environment will light the object
  46736. * either through harmonics for rough material or through the refelction for shiny ones.
  46737. */
  46738. environmentIntensity: number;
  46739. /**
  46740. * This is a special control allowing the reduction of the specular highlights coming from the
  46741. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46742. */
  46743. specularIntensity: number;
  46744. /**
  46745. * Debug Control allowing disabling the bump map on this material.
  46746. */
  46747. disableBumpMap: boolean;
  46748. /**
  46749. * AKA Diffuse Texture in standard nomenclature.
  46750. */
  46751. albedoTexture: BaseTexture;
  46752. /**
  46753. * AKA Occlusion Texture in other nomenclature.
  46754. */
  46755. ambientTexture: BaseTexture;
  46756. /**
  46757. * AKA Occlusion Texture Intensity in other nomenclature.
  46758. */
  46759. ambientTextureStrength: number;
  46760. /**
  46761. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46762. * 1 means it completely occludes it
  46763. * 0 mean it has no impact
  46764. */
  46765. ambientTextureImpactOnAnalyticalLights: number;
  46766. /**
  46767. * Stores the alpha values in a texture.
  46768. */
  46769. opacityTexture: BaseTexture;
  46770. /**
  46771. * Stores the reflection values in a texture.
  46772. */
  46773. reflectionTexture: Nullable<BaseTexture>;
  46774. /**
  46775. * Stores the emissive values in a texture.
  46776. */
  46777. emissiveTexture: BaseTexture;
  46778. /**
  46779. * AKA Specular texture in other nomenclature.
  46780. */
  46781. reflectivityTexture: BaseTexture;
  46782. /**
  46783. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46784. */
  46785. metallicTexture: BaseTexture;
  46786. /**
  46787. * Specifies the metallic scalar of the metallic/roughness workflow.
  46788. * Can also be used to scale the metalness values of the metallic texture.
  46789. */
  46790. metallic: Nullable<number>;
  46791. /**
  46792. * Specifies the roughness scalar of the metallic/roughness workflow.
  46793. * Can also be used to scale the roughness values of the metallic texture.
  46794. */
  46795. roughness: Nullable<number>;
  46796. /**
  46797. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46798. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46799. */
  46800. microSurfaceTexture: BaseTexture;
  46801. /**
  46802. * Stores surface normal data used to displace a mesh in a texture.
  46803. */
  46804. bumpTexture: BaseTexture;
  46805. /**
  46806. * Stores the pre-calculated light information of a mesh in a texture.
  46807. */
  46808. lightmapTexture: BaseTexture;
  46809. /**
  46810. * Stores the refracted light information in a texture.
  46811. */
  46812. refractionTexture: Nullable<BaseTexture>;
  46813. /**
  46814. * The color of a material in ambient lighting.
  46815. */
  46816. ambientColor: Color3;
  46817. /**
  46818. * AKA Diffuse Color in other nomenclature.
  46819. */
  46820. albedoColor: Color3;
  46821. /**
  46822. * AKA Specular Color in other nomenclature.
  46823. */
  46824. reflectivityColor: Color3;
  46825. /**
  46826. * The color reflected from the material.
  46827. */
  46828. reflectionColor: Color3;
  46829. /**
  46830. * The color emitted from the material.
  46831. */
  46832. emissiveColor: Color3;
  46833. /**
  46834. * AKA Glossiness in other nomenclature.
  46835. */
  46836. microSurface: number;
  46837. /**
  46838. * source material index of refraction (IOR)' / 'destination material IOR.
  46839. */
  46840. indexOfRefraction: number;
  46841. /**
  46842. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46843. */
  46844. invertRefractionY: boolean;
  46845. /**
  46846. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46847. * Materials half opaque for instance using refraction could benefit from this control.
  46848. */
  46849. linkRefractionWithTransparency: boolean;
  46850. /**
  46851. * If true, the light map contains occlusion information instead of lighting info.
  46852. */
  46853. useLightmapAsShadowmap: boolean;
  46854. /**
  46855. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46856. */
  46857. useAlphaFromAlbedoTexture: boolean;
  46858. /**
  46859. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46860. */
  46861. forceAlphaTest: boolean;
  46862. /**
  46863. * Defines the alpha limits in alpha test mode.
  46864. */
  46865. alphaCutOff: number;
  46866. /**
  46867. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46868. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46869. */
  46870. useSpecularOverAlpha: boolean;
  46871. /**
  46872. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46873. */
  46874. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46875. /**
  46876. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46877. */
  46878. useRoughnessFromMetallicTextureAlpha: boolean;
  46879. /**
  46880. * Specifies if the metallic texture contains the roughness information in its green channel.
  46881. */
  46882. useRoughnessFromMetallicTextureGreen: boolean;
  46883. /**
  46884. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46885. */
  46886. useMetallnessFromMetallicTextureBlue: boolean;
  46887. /**
  46888. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46889. */
  46890. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46891. /**
  46892. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46893. */
  46894. useAmbientInGrayScale: boolean;
  46895. /**
  46896. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46897. * The material will try to infer what glossiness each pixel should be.
  46898. */
  46899. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46900. /**
  46901. * BJS is using an harcoded light falloff based on a manually sets up range.
  46902. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46903. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46904. */
  46905. /**
  46906. * BJS is using an harcoded light falloff based on a manually sets up range.
  46907. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46908. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46909. */
  46910. usePhysicalLightFalloff: boolean;
  46911. /**
  46912. * In order to support the falloff compatibility with gltf, a special mode has been added
  46913. * to reproduce the gltf light falloff.
  46914. */
  46915. /**
  46916. * In order to support the falloff compatibility with gltf, a special mode has been added
  46917. * to reproduce the gltf light falloff.
  46918. */
  46919. useGLTFLightFalloff: boolean;
  46920. /**
  46921. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46922. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46923. */
  46924. useRadianceOverAlpha: boolean;
  46925. /**
  46926. * Allows using an object space normal map (instead of tangent space).
  46927. */
  46928. useObjectSpaceNormalMap: boolean;
  46929. /**
  46930. * Allows using the bump map in parallax mode.
  46931. */
  46932. useParallax: boolean;
  46933. /**
  46934. * Allows using the bump map in parallax occlusion mode.
  46935. */
  46936. useParallaxOcclusion: boolean;
  46937. /**
  46938. * Controls the scale bias of the parallax mode.
  46939. */
  46940. parallaxScaleBias: number;
  46941. /**
  46942. * If sets to true, disables all the lights affecting the material.
  46943. */
  46944. disableLighting: boolean;
  46945. /**
  46946. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46947. */
  46948. forceIrradianceInFragment: boolean;
  46949. /**
  46950. * Number of Simultaneous lights allowed on the material.
  46951. */
  46952. maxSimultaneousLights: number;
  46953. /**
  46954. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46955. */
  46956. invertNormalMapX: boolean;
  46957. /**
  46958. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46959. */
  46960. invertNormalMapY: boolean;
  46961. /**
  46962. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46963. */
  46964. twoSidedLighting: boolean;
  46965. /**
  46966. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46967. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46968. */
  46969. useAlphaFresnel: boolean;
  46970. /**
  46971. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46972. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46973. */
  46974. useLinearAlphaFresnel: boolean;
  46975. /**
  46976. * Let user defines the brdf lookup texture used for IBL.
  46977. * A default 8bit version is embedded but you could point at :
  46978. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46979. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46980. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46981. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46982. */
  46983. environmentBRDFTexture: Nullable<BaseTexture>;
  46984. /**
  46985. * Force normal to face away from face.
  46986. */
  46987. forceNormalForward: boolean;
  46988. /**
  46989. * Enables specular anti aliasing in the PBR shader.
  46990. * It will both interacts on the Geometry for analytical and IBL lighting.
  46991. * It also prefilter the roughness map based on the bump values.
  46992. */
  46993. enableSpecularAntiAliasing: boolean;
  46994. /**
  46995. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46996. * makes the reflect vector face the model (under horizon).
  46997. */
  46998. useHorizonOcclusion: boolean;
  46999. /**
  47000. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47001. * too much the area relying on ambient texture to define their ambient occlusion.
  47002. */
  47003. useRadianceOcclusion: boolean;
  47004. /**
  47005. * If set to true, no lighting calculations will be applied.
  47006. */
  47007. unlit: boolean;
  47008. /**
  47009. * Gets the image processing configuration used either in this material.
  47010. */
  47011. /**
  47012. * Sets the Default image processing configuration used either in the this material.
  47013. *
  47014. * If sets to null, the scene one is in use.
  47015. */
  47016. imageProcessingConfiguration: ImageProcessingConfiguration;
  47017. /**
  47018. * Gets wether the color curves effect is enabled.
  47019. */
  47020. /**
  47021. * Sets wether the color curves effect is enabled.
  47022. */
  47023. cameraColorCurvesEnabled: boolean;
  47024. /**
  47025. * Gets wether the color grading effect is enabled.
  47026. */
  47027. /**
  47028. * Gets wether the color grading effect is enabled.
  47029. */
  47030. cameraColorGradingEnabled: boolean;
  47031. /**
  47032. * Gets wether tonemapping is enabled or not.
  47033. */
  47034. /**
  47035. * Sets wether tonemapping is enabled or not
  47036. */
  47037. cameraToneMappingEnabled: boolean;
  47038. /**
  47039. * The camera exposure used on this material.
  47040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47041. * This corresponds to a photographic exposure.
  47042. */
  47043. /**
  47044. * The camera exposure used on this material.
  47045. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47046. * This corresponds to a photographic exposure.
  47047. */
  47048. cameraExposure: number;
  47049. /**
  47050. * Gets The camera contrast used on this material.
  47051. */
  47052. /**
  47053. * Sets The camera contrast used on this material.
  47054. */
  47055. cameraContrast: number;
  47056. /**
  47057. * Gets the Color Grading 2D Lookup Texture.
  47058. */
  47059. /**
  47060. * Sets the Color Grading 2D Lookup Texture.
  47061. */
  47062. cameraColorGradingTexture: Nullable<BaseTexture>;
  47063. /**
  47064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47066. * 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;
  47067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47068. */
  47069. /**
  47070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47072. * 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;
  47073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47074. */
  47075. cameraColorCurves: Nullable<ColorCurves>;
  47076. /**
  47077. * Instantiates a new PBRMaterial instance.
  47078. *
  47079. * @param name The material name
  47080. * @param scene The scene the material will be use in.
  47081. */
  47082. constructor(name: string, scene: Scene);
  47083. /**
  47084. * Returns the name of this material class.
  47085. */
  47086. getClassName(): string;
  47087. /**
  47088. * Makes a duplicate of the current material.
  47089. * @param name - name to use for the new material.
  47090. */
  47091. clone(name: string): PBRMaterial;
  47092. /**
  47093. * Serializes this PBR Material.
  47094. * @returns - An object with the serialized material.
  47095. */
  47096. serialize(): any;
  47097. /**
  47098. * Parses a PBR Material from a serialized object.
  47099. * @param source - Serialized object.
  47100. * @param scene - BJS scene instance.
  47101. * @param rootUrl - url for the scene object
  47102. * @returns - PBRMaterial
  47103. */
  47104. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47105. }
  47106. }
  47107. declare module BABYLON {
  47108. /**
  47109. * Direct draw surface info
  47110. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47111. */
  47112. export interface DDSInfo {
  47113. /**
  47114. * Width of the texture
  47115. */
  47116. width: number;
  47117. /**
  47118. * Width of the texture
  47119. */
  47120. height: number;
  47121. /**
  47122. * Number of Mipmaps for the texture
  47123. * @see https://en.wikipedia.org/wiki/Mipmap
  47124. */
  47125. mipmapCount: number;
  47126. /**
  47127. * If the textures format is a known fourCC format
  47128. * @see https://www.fourcc.org/
  47129. */
  47130. isFourCC: boolean;
  47131. /**
  47132. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47133. */
  47134. isRGB: boolean;
  47135. /**
  47136. * If the texture is a lumincance format
  47137. */
  47138. isLuminance: boolean;
  47139. /**
  47140. * If this is a cube texture
  47141. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47142. */
  47143. isCube: boolean;
  47144. /**
  47145. * If the texture is a compressed format eg. FOURCC_DXT1
  47146. */
  47147. isCompressed: boolean;
  47148. /**
  47149. * The dxgiFormat of the texture
  47150. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47151. */
  47152. dxgiFormat: number;
  47153. /**
  47154. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47155. */
  47156. textureType: number;
  47157. /**
  47158. * Sphericle polynomial created for the dds texture
  47159. */
  47160. sphericalPolynomial?: SphericalPolynomial;
  47161. }
  47162. /**
  47163. * Class used to provide DDS decompression tools
  47164. */
  47165. export class DDSTools {
  47166. /**
  47167. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47168. */
  47169. static StoreLODInAlphaChannel: boolean;
  47170. /**
  47171. * Gets DDS information from an array buffer
  47172. * @param arrayBuffer defines the array buffer to read data from
  47173. * @returns the DDS information
  47174. */
  47175. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47176. private static _FloatView;
  47177. private static _Int32View;
  47178. private static _ToHalfFloat;
  47179. private static _FromHalfFloat;
  47180. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47181. private static _GetHalfFloatRGBAArrayBuffer;
  47182. private static _GetFloatRGBAArrayBuffer;
  47183. private static _GetFloatAsUIntRGBAArrayBuffer;
  47184. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47185. private static _GetRGBAArrayBuffer;
  47186. private static _ExtractLongWordOrder;
  47187. private static _GetRGBArrayBuffer;
  47188. private static _GetLuminanceArrayBuffer;
  47189. /**
  47190. * Uploads DDS Levels to a Babylon Texture
  47191. * @hidden
  47192. */
  47193. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47194. }
  47195. interface Engine {
  47196. /**
  47197. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47198. * @param rootUrl defines the url where the file to load is located
  47199. * @param scene defines the current scene
  47200. * @param lodScale defines scale to apply to the mip map selection
  47201. * @param lodOffset defines offset to apply to the mip map selection
  47202. * @param onLoad defines an optional callback raised when the texture is loaded
  47203. * @param onError defines an optional callback raised if there is an issue to load the texture
  47204. * @param format defines the format of the data
  47205. * @param forcedExtension defines the extension to use to pick the right loader
  47206. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47207. * @returns the cube texture as an InternalTexture
  47208. */
  47209. 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;
  47210. }
  47211. }
  47212. declare module BABYLON {
  47213. /**
  47214. * Implementation of the DDS Texture Loader.
  47215. * @hidden
  47216. */
  47217. export class _DDSTextureLoader implements IInternalTextureLoader {
  47218. /**
  47219. * Defines wether the loader supports cascade loading the different faces.
  47220. */
  47221. readonly supportCascades: boolean;
  47222. /**
  47223. * This returns if the loader support the current file information.
  47224. * @param extension defines the file extension of the file being loaded
  47225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47226. * @param fallback defines the fallback internal texture if any
  47227. * @param isBase64 defines whether the texture is encoded as a base64
  47228. * @param isBuffer defines whether the texture data are stored as a buffer
  47229. * @returns true if the loader can load the specified file
  47230. */
  47231. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47232. /**
  47233. * Transform the url before loading if required.
  47234. * @param rootUrl the url of the texture
  47235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47236. * @returns the transformed texture
  47237. */
  47238. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47239. /**
  47240. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47241. * @param rootUrl the url of the texture
  47242. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47243. * @returns the fallback texture
  47244. */
  47245. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47246. /**
  47247. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47248. * @param data contains the texture data
  47249. * @param texture defines the BabylonJS internal texture
  47250. * @param createPolynomials will be true if polynomials have been requested
  47251. * @param onLoad defines the callback to trigger once the texture is ready
  47252. * @param onError defines the callback to trigger in case of error
  47253. */
  47254. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47255. /**
  47256. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47257. * @param data contains the texture data
  47258. * @param texture defines the BabylonJS internal texture
  47259. * @param callback defines the method to call once ready to upload
  47260. */
  47261. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47262. }
  47263. }
  47264. declare module BABYLON {
  47265. /**
  47266. * Implementation of the ENV Texture Loader.
  47267. * @hidden
  47268. */
  47269. export class _ENVTextureLoader implements IInternalTextureLoader {
  47270. /**
  47271. * Defines wether the loader supports cascade loading the different faces.
  47272. */
  47273. readonly supportCascades: boolean;
  47274. /**
  47275. * This returns if the loader support the current file information.
  47276. * @param extension defines the file extension of the file being loaded
  47277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47278. * @param fallback defines the fallback internal texture if any
  47279. * @param isBase64 defines whether the texture is encoded as a base64
  47280. * @param isBuffer defines whether the texture data are stored as a buffer
  47281. * @returns true if the loader can load the specified file
  47282. */
  47283. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47284. /**
  47285. * Transform the url before loading if required.
  47286. * @param rootUrl the url of the texture
  47287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47288. * @returns the transformed texture
  47289. */
  47290. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47291. /**
  47292. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47293. * @param rootUrl the url of the texture
  47294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47295. * @returns the fallback texture
  47296. */
  47297. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47298. /**
  47299. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47300. * @param data contains the texture data
  47301. * @param texture defines the BabylonJS internal texture
  47302. * @param createPolynomials will be true if polynomials have been requested
  47303. * @param onLoad defines the callback to trigger once the texture is ready
  47304. * @param onError defines the callback to trigger in case of error
  47305. */
  47306. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47307. /**
  47308. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47309. * @param data contains the texture data
  47310. * @param texture defines the BabylonJS internal texture
  47311. * @param callback defines the method to call once ready to upload
  47312. */
  47313. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47314. }
  47315. }
  47316. declare module BABYLON {
  47317. /**
  47318. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47319. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47320. */
  47321. export class KhronosTextureContainer {
  47322. /** contents of the KTX container file */
  47323. arrayBuffer: any;
  47324. private static HEADER_LEN;
  47325. private static COMPRESSED_2D;
  47326. private static COMPRESSED_3D;
  47327. private static TEX_2D;
  47328. private static TEX_3D;
  47329. /**
  47330. * Gets the openGL type
  47331. */
  47332. glType: number;
  47333. /**
  47334. * Gets the openGL type size
  47335. */
  47336. glTypeSize: number;
  47337. /**
  47338. * Gets the openGL format
  47339. */
  47340. glFormat: number;
  47341. /**
  47342. * Gets the openGL internal format
  47343. */
  47344. glInternalFormat: number;
  47345. /**
  47346. * Gets the base internal format
  47347. */
  47348. glBaseInternalFormat: number;
  47349. /**
  47350. * Gets image width in pixel
  47351. */
  47352. pixelWidth: number;
  47353. /**
  47354. * Gets image height in pixel
  47355. */
  47356. pixelHeight: number;
  47357. /**
  47358. * Gets image depth in pixels
  47359. */
  47360. pixelDepth: number;
  47361. /**
  47362. * Gets the number of array elements
  47363. */
  47364. numberOfArrayElements: number;
  47365. /**
  47366. * Gets the number of faces
  47367. */
  47368. numberOfFaces: number;
  47369. /**
  47370. * Gets the number of mipmap levels
  47371. */
  47372. numberOfMipmapLevels: number;
  47373. /**
  47374. * Gets the bytes of key value data
  47375. */
  47376. bytesOfKeyValueData: number;
  47377. /**
  47378. * Gets the load type
  47379. */
  47380. loadType: number;
  47381. /**
  47382. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47383. */
  47384. isInvalid: boolean;
  47385. /**
  47386. * Creates a new KhronosTextureContainer
  47387. * @param arrayBuffer contents of the KTX container file
  47388. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47389. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47390. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47391. */
  47392. constructor(
  47393. /** contents of the KTX container file */
  47394. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47395. /**
  47396. * Uploads KTX content to a Babylon Texture.
  47397. * It is assumed that the texture has already been created & is currently bound
  47398. * @hidden
  47399. */
  47400. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47401. private _upload2DCompressedLevels;
  47402. }
  47403. }
  47404. declare module BABYLON {
  47405. /**
  47406. * Implementation of the KTX Texture Loader.
  47407. * @hidden
  47408. */
  47409. export class _KTXTextureLoader implements IInternalTextureLoader {
  47410. /**
  47411. * Defines wether the loader supports cascade loading the different faces.
  47412. */
  47413. readonly supportCascades: boolean;
  47414. /**
  47415. * This returns if the loader support the current file information.
  47416. * @param extension defines the file extension of the file being loaded
  47417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47418. * @param fallback defines the fallback internal texture if any
  47419. * @param isBase64 defines whether the texture is encoded as a base64
  47420. * @param isBuffer defines whether the texture data are stored as a buffer
  47421. * @returns true if the loader can load the specified file
  47422. */
  47423. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47424. /**
  47425. * Transform the url before loading if required.
  47426. * @param rootUrl the url of the texture
  47427. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47428. * @returns the transformed texture
  47429. */
  47430. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47431. /**
  47432. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47433. * @param rootUrl the url of the texture
  47434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47435. * @returns the fallback texture
  47436. */
  47437. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47438. /**
  47439. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47440. * @param data contains the texture data
  47441. * @param texture defines the BabylonJS internal texture
  47442. * @param createPolynomials will be true if polynomials have been requested
  47443. * @param onLoad defines the callback to trigger once the texture is ready
  47444. * @param onError defines the callback to trigger in case of error
  47445. */
  47446. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47447. /**
  47448. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47449. * @param data contains the texture data
  47450. * @param texture defines the BabylonJS internal texture
  47451. * @param callback defines the method to call once ready to upload
  47452. */
  47453. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47454. }
  47455. }
  47456. declare module BABYLON {
  47457. /**
  47458. * Options for the default xr helper
  47459. */
  47460. export class WebXRDefaultExperienceOptions {
  47461. /**
  47462. * Floor meshes that should be used for teleporting
  47463. */
  47464. floorMeshes: Array<AbstractMesh>;
  47465. }
  47466. /**
  47467. * Default experience which provides a similar setup to the previous webVRExperience
  47468. */
  47469. export class WebXRDefaultExperience {
  47470. /**
  47471. * Base experience
  47472. */
  47473. baseExperience: WebXRExperienceHelper;
  47474. /**
  47475. * Input experience extension
  47476. */
  47477. input: WebXRInput;
  47478. /**
  47479. * Loads the controller models
  47480. */
  47481. controllerModelLoader: WebXRControllerModelLoader;
  47482. /**
  47483. * Enables laser pointer and selection
  47484. */
  47485. pointerSelection: WebXRControllerPointerSelection;
  47486. /**
  47487. * Enables teleportation
  47488. */
  47489. teleportation: WebXRControllerTeleportation;
  47490. /**
  47491. * Enables ui for enetering/exiting xr
  47492. */
  47493. enterExitUI: WebXREnterExitUI;
  47494. /**
  47495. * Default output canvas xr should render to
  47496. */
  47497. outputCanvas: WebXRManagedOutputCanvas;
  47498. /**
  47499. * Creates the default xr experience
  47500. * @param scene scene
  47501. * @param options options for basic configuration
  47502. * @returns resulting WebXRDefaultExperience
  47503. */
  47504. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47505. private constructor();
  47506. /**
  47507. * DIsposes of the experience helper
  47508. */
  47509. dispose(): void;
  47510. }
  47511. }
  47512. declare module BABYLON {
  47513. /** @hidden */
  47514. export var _forceSceneHelpersToBundle: boolean;
  47515. interface Scene {
  47516. /**
  47517. * Creates a default light for the scene.
  47518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47519. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47520. */
  47521. createDefaultLight(replace?: boolean): void;
  47522. /**
  47523. * Creates a default camera for the scene.
  47524. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47525. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47526. * @param replace has default false, when true replaces the active camera in the scene
  47527. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47528. */
  47529. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47530. /**
  47531. * Creates a default camera and a default light.
  47532. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47533. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47534. * @param replace has the default false, when true replaces the active camera/light in the scene
  47535. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47536. */
  47537. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47538. /**
  47539. * Creates a new sky box
  47540. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47541. * @param environmentTexture defines the texture to use as environment texture
  47542. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47543. * @param scale defines the overall scale of the skybox
  47544. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47545. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47546. * @returns a new mesh holding the sky box
  47547. */
  47548. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47549. /**
  47550. * Creates a new environment
  47551. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47552. * @param options defines the options you can use to configure the environment
  47553. * @returns the new EnvironmentHelper
  47554. */
  47555. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47556. /**
  47557. * Creates a new VREXperienceHelper
  47558. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47559. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47560. * @returns a new VREXperienceHelper
  47561. */
  47562. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47563. /**
  47564. * Creates a new WebXRDefaultExperience
  47565. * @see http://doc.babylonjs.com/how_to/webxr
  47566. * @param options experience options
  47567. * @returns a promise for a new WebXRDefaultExperience
  47568. */
  47569. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47570. }
  47571. }
  47572. declare module BABYLON {
  47573. /**
  47574. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47575. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47576. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47577. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47578. */
  47579. export class VideoDome extends TransformNode {
  47580. /**
  47581. * Define the video source as a Monoscopic panoramic 360 video.
  47582. */
  47583. static readonly MODE_MONOSCOPIC: number;
  47584. /**
  47585. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47586. */
  47587. static readonly MODE_TOPBOTTOM: number;
  47588. /**
  47589. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47590. */
  47591. static readonly MODE_SIDEBYSIDE: number;
  47592. private _halfDome;
  47593. private _useDirectMapping;
  47594. /**
  47595. * The video texture being displayed on the sphere
  47596. */
  47597. protected _videoTexture: VideoTexture;
  47598. /**
  47599. * Gets the video texture being displayed on the sphere
  47600. */
  47601. readonly videoTexture: VideoTexture;
  47602. /**
  47603. * The skybox material
  47604. */
  47605. protected _material: BackgroundMaterial;
  47606. /**
  47607. * The surface used for the skybox
  47608. */
  47609. protected _mesh: Mesh;
  47610. /**
  47611. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47612. */
  47613. private _halfDomeMask;
  47614. /**
  47615. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47616. * Also see the options.resolution property.
  47617. */
  47618. fovMultiplier: number;
  47619. private _videoMode;
  47620. /**
  47621. * Gets or set the current video mode for the video. It can be:
  47622. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47623. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47624. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47625. */
  47626. videoMode: number;
  47627. /**
  47628. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  47629. *
  47630. */
  47631. /**
  47632. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  47633. */
  47634. halfDome: boolean;
  47635. /**
  47636. * Oberserver used in Stereoscopic VR Mode.
  47637. */
  47638. private _onBeforeCameraRenderObserver;
  47639. /**
  47640. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47641. * @param name Element's name, child elements will append suffixes for their own names.
  47642. * @param urlsOrVideo defines the url(s) or the video element to use
  47643. * @param options An object containing optional or exposed sub element properties
  47644. */
  47645. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47646. resolution?: number;
  47647. clickToPlay?: boolean;
  47648. autoPlay?: boolean;
  47649. loop?: boolean;
  47650. size?: number;
  47651. poster?: string;
  47652. faceForward?: boolean;
  47653. useDirectMapping?: boolean;
  47654. halfDomeMode?: boolean;
  47655. }, scene: Scene);
  47656. private _changeVideoMode;
  47657. /**
  47658. * Releases resources associated with this node.
  47659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47661. */
  47662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47663. }
  47664. }
  47665. declare module BABYLON {
  47666. /**
  47667. * This class can be used to get instrumentation data from a Babylon engine
  47668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47669. */
  47670. export class EngineInstrumentation implements IDisposable {
  47671. /**
  47672. * Define the instrumented engine.
  47673. */
  47674. engine: Engine;
  47675. private _captureGPUFrameTime;
  47676. private _gpuFrameTimeToken;
  47677. private _gpuFrameTime;
  47678. private _captureShaderCompilationTime;
  47679. private _shaderCompilationTime;
  47680. private _onBeginFrameObserver;
  47681. private _onEndFrameObserver;
  47682. private _onBeforeShaderCompilationObserver;
  47683. private _onAfterShaderCompilationObserver;
  47684. /**
  47685. * Gets the perf counter used for GPU frame time
  47686. */
  47687. readonly gpuFrameTimeCounter: PerfCounter;
  47688. /**
  47689. * Gets the GPU frame time capture status
  47690. */
  47691. /**
  47692. * Enable or disable the GPU frame time capture
  47693. */
  47694. captureGPUFrameTime: boolean;
  47695. /**
  47696. * Gets the perf counter used for shader compilation time
  47697. */
  47698. readonly shaderCompilationTimeCounter: PerfCounter;
  47699. /**
  47700. * Gets the shader compilation time capture status
  47701. */
  47702. /**
  47703. * Enable or disable the shader compilation time capture
  47704. */
  47705. captureShaderCompilationTime: boolean;
  47706. /**
  47707. * Instantiates a new engine instrumentation.
  47708. * This class can be used to get instrumentation data from a Babylon engine
  47709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47710. * @param engine Defines the engine to instrument
  47711. */
  47712. constructor(
  47713. /**
  47714. * Define the instrumented engine.
  47715. */
  47716. engine: Engine);
  47717. /**
  47718. * Dispose and release associated resources.
  47719. */
  47720. dispose(): void;
  47721. }
  47722. }
  47723. declare module BABYLON {
  47724. /**
  47725. * This class can be used to get instrumentation data from a Babylon engine
  47726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47727. */
  47728. export class SceneInstrumentation implements IDisposable {
  47729. /**
  47730. * Defines the scene to instrument
  47731. */
  47732. scene: Scene;
  47733. private _captureActiveMeshesEvaluationTime;
  47734. private _activeMeshesEvaluationTime;
  47735. private _captureRenderTargetsRenderTime;
  47736. private _renderTargetsRenderTime;
  47737. private _captureFrameTime;
  47738. private _frameTime;
  47739. private _captureRenderTime;
  47740. private _renderTime;
  47741. private _captureInterFrameTime;
  47742. private _interFrameTime;
  47743. private _captureParticlesRenderTime;
  47744. private _particlesRenderTime;
  47745. private _captureSpritesRenderTime;
  47746. private _spritesRenderTime;
  47747. private _capturePhysicsTime;
  47748. private _physicsTime;
  47749. private _captureAnimationsTime;
  47750. private _animationsTime;
  47751. private _captureCameraRenderTime;
  47752. private _cameraRenderTime;
  47753. private _onBeforeActiveMeshesEvaluationObserver;
  47754. private _onAfterActiveMeshesEvaluationObserver;
  47755. private _onBeforeRenderTargetsRenderObserver;
  47756. private _onAfterRenderTargetsRenderObserver;
  47757. private _onAfterRenderObserver;
  47758. private _onBeforeDrawPhaseObserver;
  47759. private _onAfterDrawPhaseObserver;
  47760. private _onBeforeAnimationsObserver;
  47761. private _onBeforeParticlesRenderingObserver;
  47762. private _onAfterParticlesRenderingObserver;
  47763. private _onBeforeSpritesRenderingObserver;
  47764. private _onAfterSpritesRenderingObserver;
  47765. private _onBeforePhysicsObserver;
  47766. private _onAfterPhysicsObserver;
  47767. private _onAfterAnimationsObserver;
  47768. private _onBeforeCameraRenderObserver;
  47769. private _onAfterCameraRenderObserver;
  47770. /**
  47771. * Gets the perf counter used for active meshes evaluation time
  47772. */
  47773. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47774. /**
  47775. * Gets the active meshes evaluation time capture status
  47776. */
  47777. /**
  47778. * Enable or disable the active meshes evaluation time capture
  47779. */
  47780. captureActiveMeshesEvaluationTime: boolean;
  47781. /**
  47782. * Gets the perf counter used for render targets render time
  47783. */
  47784. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47785. /**
  47786. * Gets the render targets render time capture status
  47787. */
  47788. /**
  47789. * Enable or disable the render targets render time capture
  47790. */
  47791. captureRenderTargetsRenderTime: boolean;
  47792. /**
  47793. * Gets the perf counter used for particles render time
  47794. */
  47795. readonly particlesRenderTimeCounter: PerfCounter;
  47796. /**
  47797. * Gets the particles render time capture status
  47798. */
  47799. /**
  47800. * Enable or disable the particles render time capture
  47801. */
  47802. captureParticlesRenderTime: boolean;
  47803. /**
  47804. * Gets the perf counter used for sprites render time
  47805. */
  47806. readonly spritesRenderTimeCounter: PerfCounter;
  47807. /**
  47808. * Gets the sprites render time capture status
  47809. */
  47810. /**
  47811. * Enable or disable the sprites render time capture
  47812. */
  47813. captureSpritesRenderTime: boolean;
  47814. /**
  47815. * Gets the perf counter used for physics time
  47816. */
  47817. readonly physicsTimeCounter: PerfCounter;
  47818. /**
  47819. * Gets the physics time capture status
  47820. */
  47821. /**
  47822. * Enable or disable the physics time capture
  47823. */
  47824. capturePhysicsTime: boolean;
  47825. /**
  47826. * Gets the perf counter used for animations time
  47827. */
  47828. readonly animationsTimeCounter: PerfCounter;
  47829. /**
  47830. * Gets the animations time capture status
  47831. */
  47832. /**
  47833. * Enable or disable the animations time capture
  47834. */
  47835. captureAnimationsTime: boolean;
  47836. /**
  47837. * Gets the perf counter used for frame time capture
  47838. */
  47839. readonly frameTimeCounter: PerfCounter;
  47840. /**
  47841. * Gets the frame time capture status
  47842. */
  47843. /**
  47844. * Enable or disable the frame time capture
  47845. */
  47846. captureFrameTime: boolean;
  47847. /**
  47848. * Gets the perf counter used for inter-frames time capture
  47849. */
  47850. readonly interFrameTimeCounter: PerfCounter;
  47851. /**
  47852. * Gets the inter-frames time capture status
  47853. */
  47854. /**
  47855. * Enable or disable the inter-frames time capture
  47856. */
  47857. captureInterFrameTime: boolean;
  47858. /**
  47859. * Gets the perf counter used for render time capture
  47860. */
  47861. readonly renderTimeCounter: PerfCounter;
  47862. /**
  47863. * Gets the render time capture status
  47864. */
  47865. /**
  47866. * Enable or disable the render time capture
  47867. */
  47868. captureRenderTime: boolean;
  47869. /**
  47870. * Gets the perf counter used for camera render time capture
  47871. */
  47872. readonly cameraRenderTimeCounter: PerfCounter;
  47873. /**
  47874. * Gets the camera render time capture status
  47875. */
  47876. /**
  47877. * Enable or disable the camera render time capture
  47878. */
  47879. captureCameraRenderTime: boolean;
  47880. /**
  47881. * Gets the perf counter used for draw calls
  47882. */
  47883. readonly drawCallsCounter: PerfCounter;
  47884. /**
  47885. * Instantiates a new scene instrumentation.
  47886. * This class can be used to get instrumentation data from a Babylon engine
  47887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47888. * @param scene Defines the scene to instrument
  47889. */
  47890. constructor(
  47891. /**
  47892. * Defines the scene to instrument
  47893. */
  47894. scene: Scene);
  47895. /**
  47896. * Dispose and release associated resources.
  47897. */
  47898. dispose(): void;
  47899. }
  47900. }
  47901. declare module BABYLON {
  47902. /** @hidden */
  47903. export var glowMapGenerationPixelShader: {
  47904. name: string;
  47905. shader: string;
  47906. };
  47907. }
  47908. declare module BABYLON {
  47909. /** @hidden */
  47910. export var glowMapGenerationVertexShader: {
  47911. name: string;
  47912. shader: string;
  47913. };
  47914. }
  47915. declare module BABYLON {
  47916. /**
  47917. * Effect layer options. This helps customizing the behaviour
  47918. * of the effect layer.
  47919. */
  47920. export interface IEffectLayerOptions {
  47921. /**
  47922. * Multiplication factor apply to the canvas size to compute the render target size
  47923. * used to generated the objects (the smaller the faster).
  47924. */
  47925. mainTextureRatio: number;
  47926. /**
  47927. * Enforces a fixed size texture to ensure effect stability across devices.
  47928. */
  47929. mainTextureFixedSize?: number;
  47930. /**
  47931. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47932. */
  47933. alphaBlendingMode: number;
  47934. /**
  47935. * The camera attached to the layer.
  47936. */
  47937. camera: Nullable<Camera>;
  47938. /**
  47939. * The rendering group to draw the layer in.
  47940. */
  47941. renderingGroupId: number;
  47942. }
  47943. /**
  47944. * The effect layer Helps adding post process effect blended with the main pass.
  47945. *
  47946. * This can be for instance use to generate glow or higlight effects on the scene.
  47947. *
  47948. * The effect layer class can not be used directly and is intented to inherited from to be
  47949. * customized per effects.
  47950. */
  47951. export abstract class EffectLayer {
  47952. private _vertexBuffers;
  47953. private _indexBuffer;
  47954. private _cachedDefines;
  47955. private _effectLayerMapGenerationEffect;
  47956. private _effectLayerOptions;
  47957. private _mergeEffect;
  47958. protected _scene: Scene;
  47959. protected _engine: Engine;
  47960. protected _maxSize: number;
  47961. protected _mainTextureDesiredSize: ISize;
  47962. protected _mainTexture: RenderTargetTexture;
  47963. protected _shouldRender: boolean;
  47964. protected _postProcesses: PostProcess[];
  47965. protected _textures: BaseTexture[];
  47966. protected _emissiveTextureAndColor: {
  47967. texture: Nullable<BaseTexture>;
  47968. color: Color4;
  47969. };
  47970. /**
  47971. * The name of the layer
  47972. */
  47973. name: string;
  47974. /**
  47975. * The clear color of the texture used to generate the glow map.
  47976. */
  47977. neutralColor: Color4;
  47978. /**
  47979. * Specifies wether the highlight layer is enabled or not.
  47980. */
  47981. isEnabled: boolean;
  47982. /**
  47983. * Gets the camera attached to the layer.
  47984. */
  47985. readonly camera: Nullable<Camera>;
  47986. /**
  47987. * Gets the rendering group id the layer should render in.
  47988. */
  47989. renderingGroupId: number;
  47990. /**
  47991. * An event triggered when the effect layer has been disposed.
  47992. */
  47993. onDisposeObservable: Observable<EffectLayer>;
  47994. /**
  47995. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47996. */
  47997. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47998. /**
  47999. * An event triggered when the generated texture is being merged in the scene.
  48000. */
  48001. onBeforeComposeObservable: Observable<EffectLayer>;
  48002. /**
  48003. * An event triggered when the generated texture has been merged in the scene.
  48004. */
  48005. onAfterComposeObservable: Observable<EffectLayer>;
  48006. /**
  48007. * An event triggered when the efffect layer changes its size.
  48008. */
  48009. onSizeChangedObservable: Observable<EffectLayer>;
  48010. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48011. /**
  48012. * Instantiates a new effect Layer and references it in the scene.
  48013. * @param name The name of the layer
  48014. * @param scene The scene to use the layer in
  48015. */
  48016. constructor(
  48017. /** The Friendly of the effect in the scene */
  48018. name: string, scene: Scene);
  48019. /**
  48020. * Get the effect name of the layer.
  48021. * @return The effect name
  48022. */
  48023. abstract getEffectName(): string;
  48024. /**
  48025. * Checks for the readiness of the element composing the layer.
  48026. * @param subMesh the mesh to check for
  48027. * @param useInstances specify wether or not to use instances to render the mesh
  48028. * @return true if ready otherwise, false
  48029. */
  48030. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48031. /**
  48032. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48033. * @returns true if the effect requires stencil during the main canvas render pass.
  48034. */
  48035. abstract needStencil(): boolean;
  48036. /**
  48037. * Create the merge effect. This is the shader use to blit the information back
  48038. * to the main canvas at the end of the scene rendering.
  48039. * @returns The effect containing the shader used to merge the effect on the main canvas
  48040. */
  48041. protected abstract _createMergeEffect(): Effect;
  48042. /**
  48043. * Creates the render target textures and post processes used in the effect layer.
  48044. */
  48045. protected abstract _createTextureAndPostProcesses(): void;
  48046. /**
  48047. * Implementation specific of rendering the generating effect on the main canvas.
  48048. * @param effect The effect used to render through
  48049. */
  48050. protected abstract _internalRender(effect: Effect): void;
  48051. /**
  48052. * Sets the required values for both the emissive texture and and the main color.
  48053. */
  48054. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48055. /**
  48056. * Free any resources and references associated to a mesh.
  48057. * Internal use
  48058. * @param mesh The mesh to free.
  48059. */
  48060. abstract _disposeMesh(mesh: Mesh): void;
  48061. /**
  48062. * Serializes this layer (Glow or Highlight for example)
  48063. * @returns a serialized layer object
  48064. */
  48065. abstract serialize?(): any;
  48066. /**
  48067. * Initializes the effect layer with the required options.
  48068. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48069. */
  48070. protected _init(options: Partial<IEffectLayerOptions>): void;
  48071. /**
  48072. * Generates the index buffer of the full screen quad blending to the main canvas.
  48073. */
  48074. private _generateIndexBuffer;
  48075. /**
  48076. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48077. */
  48078. private _generateVertexBuffer;
  48079. /**
  48080. * Sets the main texture desired size which is the closest power of two
  48081. * of the engine canvas size.
  48082. */
  48083. private _setMainTextureSize;
  48084. /**
  48085. * Creates the main texture for the effect layer.
  48086. */
  48087. protected _createMainTexture(): void;
  48088. /**
  48089. * Adds specific effects defines.
  48090. * @param defines The defines to add specifics to.
  48091. */
  48092. protected _addCustomEffectDefines(defines: string[]): void;
  48093. /**
  48094. * Checks for the readiness of the element composing the layer.
  48095. * @param subMesh the mesh to check for
  48096. * @param useInstances specify wether or not to use instances to render the mesh
  48097. * @param emissiveTexture the associated emissive texture used to generate the glow
  48098. * @return true if ready otherwise, false
  48099. */
  48100. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48101. /**
  48102. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48103. */
  48104. render(): void;
  48105. /**
  48106. * Determine if a given mesh will be used in the current effect.
  48107. * @param mesh mesh to test
  48108. * @returns true if the mesh will be used
  48109. */
  48110. hasMesh(mesh: AbstractMesh): boolean;
  48111. /**
  48112. * Returns true if the layer contains information to display, otherwise false.
  48113. * @returns true if the glow layer should be rendered
  48114. */
  48115. shouldRender(): boolean;
  48116. /**
  48117. * Returns true if the mesh should render, otherwise false.
  48118. * @param mesh The mesh to render
  48119. * @returns true if it should render otherwise false
  48120. */
  48121. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48122. /**
  48123. * Returns true if the mesh can be rendered, otherwise false.
  48124. * @param mesh The mesh to render
  48125. * @param material The material used on the mesh
  48126. * @returns true if it can be rendered otherwise false
  48127. */
  48128. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48129. /**
  48130. * Returns true if the mesh should render, otherwise false.
  48131. * @param mesh The mesh to render
  48132. * @returns true if it should render otherwise false
  48133. */
  48134. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48135. /**
  48136. * Renders the submesh passed in parameter to the generation map.
  48137. */
  48138. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48139. /**
  48140. * Rebuild the required buffers.
  48141. * @hidden Internal use only.
  48142. */ private _rebuild(): void;
  48143. /**
  48144. * Dispose only the render target textures and post process.
  48145. */
  48146. private _disposeTextureAndPostProcesses;
  48147. /**
  48148. * Dispose the highlight layer and free resources.
  48149. */
  48150. dispose(): void;
  48151. /**
  48152. * Gets the class name of the effect layer
  48153. * @returns the string with the class name of the effect layer
  48154. */
  48155. getClassName(): string;
  48156. /**
  48157. * Creates an effect layer from parsed effect layer data
  48158. * @param parsedEffectLayer defines effect layer data
  48159. * @param scene defines the current scene
  48160. * @param rootUrl defines the root URL containing the effect layer information
  48161. * @returns a parsed effect Layer
  48162. */
  48163. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48164. }
  48165. }
  48166. declare module BABYLON {
  48167. interface AbstractScene {
  48168. /**
  48169. * The list of effect layers (highlights/glow) added to the scene
  48170. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48171. * @see http://doc.babylonjs.com/how_to/glow_layer
  48172. */
  48173. effectLayers: Array<EffectLayer>;
  48174. /**
  48175. * Removes the given effect layer from this scene.
  48176. * @param toRemove defines the effect layer to remove
  48177. * @returns the index of the removed effect layer
  48178. */
  48179. removeEffectLayer(toRemove: EffectLayer): number;
  48180. /**
  48181. * Adds the given effect layer to this scene
  48182. * @param newEffectLayer defines the effect layer to add
  48183. */
  48184. addEffectLayer(newEffectLayer: EffectLayer): void;
  48185. }
  48186. /**
  48187. * Defines the layer scene component responsible to manage any effect layers
  48188. * in a given scene.
  48189. */
  48190. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48191. /**
  48192. * The component name helpfull to identify the component in the list of scene components.
  48193. */
  48194. readonly name: string;
  48195. /**
  48196. * The scene the component belongs to.
  48197. */
  48198. scene: Scene;
  48199. private _engine;
  48200. private _renderEffects;
  48201. private _needStencil;
  48202. private _previousStencilState;
  48203. /**
  48204. * Creates a new instance of the component for the given scene
  48205. * @param scene Defines the scene to register the component in
  48206. */
  48207. constructor(scene: Scene);
  48208. /**
  48209. * Registers the component in a given scene
  48210. */
  48211. register(): void;
  48212. /**
  48213. * Rebuilds the elements related to this component in case of
  48214. * context lost for instance.
  48215. */
  48216. rebuild(): void;
  48217. /**
  48218. * Serializes the component data to the specified json object
  48219. * @param serializationObject The object to serialize to
  48220. */
  48221. serialize(serializationObject: any): void;
  48222. /**
  48223. * Adds all the elements from the container to the scene
  48224. * @param container the container holding the elements
  48225. */
  48226. addFromContainer(container: AbstractScene): void;
  48227. /**
  48228. * Removes all the elements in the container from the scene
  48229. * @param container contains the elements to remove
  48230. * @param dispose if the removed element should be disposed (default: false)
  48231. */
  48232. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48233. /**
  48234. * Disposes the component and the associated ressources.
  48235. */
  48236. dispose(): void;
  48237. private _isReadyForMesh;
  48238. private _renderMainTexture;
  48239. private _setStencil;
  48240. private _setStencilBack;
  48241. private _draw;
  48242. private _drawCamera;
  48243. private _drawRenderingGroup;
  48244. }
  48245. }
  48246. declare module BABYLON {
  48247. /** @hidden */
  48248. export var glowMapMergePixelShader: {
  48249. name: string;
  48250. shader: string;
  48251. };
  48252. }
  48253. declare module BABYLON {
  48254. /** @hidden */
  48255. export var glowMapMergeVertexShader: {
  48256. name: string;
  48257. shader: string;
  48258. };
  48259. }
  48260. declare module BABYLON {
  48261. interface AbstractScene {
  48262. /**
  48263. * Return a the first highlight layer of the scene with a given name.
  48264. * @param name The name of the highlight layer to look for.
  48265. * @return The highlight layer if found otherwise null.
  48266. */
  48267. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48268. }
  48269. /**
  48270. * Glow layer options. This helps customizing the behaviour
  48271. * of the glow layer.
  48272. */
  48273. export interface IGlowLayerOptions {
  48274. /**
  48275. * Multiplication factor apply to the canvas size to compute the render target size
  48276. * used to generated the glowing objects (the smaller the faster).
  48277. */
  48278. mainTextureRatio: number;
  48279. /**
  48280. * Enforces a fixed size texture to ensure resize independant blur.
  48281. */
  48282. mainTextureFixedSize?: number;
  48283. /**
  48284. * How big is the kernel of the blur texture.
  48285. */
  48286. blurKernelSize: number;
  48287. /**
  48288. * The camera attached to the layer.
  48289. */
  48290. camera: Nullable<Camera>;
  48291. /**
  48292. * Enable MSAA by chosing the number of samples.
  48293. */
  48294. mainTextureSamples?: number;
  48295. /**
  48296. * The rendering group to draw the layer in.
  48297. */
  48298. renderingGroupId: number;
  48299. }
  48300. /**
  48301. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48302. *
  48303. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48304. * glowy meshes to your scene.
  48305. *
  48306. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48307. */
  48308. export class GlowLayer extends EffectLayer {
  48309. /**
  48310. * Effect Name of the layer.
  48311. */
  48312. static readonly EffectName: string;
  48313. /**
  48314. * The default blur kernel size used for the glow.
  48315. */
  48316. static DefaultBlurKernelSize: number;
  48317. /**
  48318. * The default texture size ratio used for the glow.
  48319. */
  48320. static DefaultTextureRatio: number;
  48321. /**
  48322. * Sets the kernel size of the blur.
  48323. */
  48324. /**
  48325. * Gets the kernel size of the blur.
  48326. */
  48327. blurKernelSize: number;
  48328. /**
  48329. * Sets the glow intensity.
  48330. */
  48331. /**
  48332. * Gets the glow intensity.
  48333. */
  48334. intensity: number;
  48335. private _options;
  48336. private _intensity;
  48337. private _horizontalBlurPostprocess1;
  48338. private _verticalBlurPostprocess1;
  48339. private _horizontalBlurPostprocess2;
  48340. private _verticalBlurPostprocess2;
  48341. private _blurTexture1;
  48342. private _blurTexture2;
  48343. private _postProcesses1;
  48344. private _postProcesses2;
  48345. private _includedOnlyMeshes;
  48346. private _excludedMeshes;
  48347. /**
  48348. * Callback used to let the user override the color selection on a per mesh basis
  48349. */
  48350. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48351. /**
  48352. * Callback used to let the user override the texture selection on a per mesh basis
  48353. */
  48354. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48355. /**
  48356. * Instantiates a new glow Layer and references it to the scene.
  48357. * @param name The name of the layer
  48358. * @param scene The scene to use the layer in
  48359. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48360. */
  48361. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48362. /**
  48363. * Get the effect name of the layer.
  48364. * @return The effect name
  48365. */
  48366. getEffectName(): string;
  48367. /**
  48368. * Create the merge effect. This is the shader use to blit the information back
  48369. * to the main canvas at the end of the scene rendering.
  48370. */
  48371. protected _createMergeEffect(): Effect;
  48372. /**
  48373. * Creates the render target textures and post processes used in the glow layer.
  48374. */
  48375. protected _createTextureAndPostProcesses(): void;
  48376. /**
  48377. * Checks for the readiness of the element composing the layer.
  48378. * @param subMesh the mesh to check for
  48379. * @param useInstances specify wether or not to use instances to render the mesh
  48380. * @param emissiveTexture the associated emissive texture used to generate the glow
  48381. * @return true if ready otherwise, false
  48382. */
  48383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48384. /**
  48385. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48386. */
  48387. needStencil(): boolean;
  48388. /**
  48389. * Returns true if the mesh can be rendered, otherwise false.
  48390. * @param mesh The mesh to render
  48391. * @param material The material used on the mesh
  48392. * @returns true if it can be rendered otherwise false
  48393. */
  48394. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48395. /**
  48396. * Implementation specific of rendering the generating effect on the main canvas.
  48397. * @param effect The effect used to render through
  48398. */
  48399. protected _internalRender(effect: Effect): void;
  48400. /**
  48401. * Sets the required values for both the emissive texture and and the main color.
  48402. */
  48403. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48404. /**
  48405. * Returns true if the mesh should render, otherwise false.
  48406. * @param mesh The mesh to render
  48407. * @returns true if it should render otherwise false
  48408. */
  48409. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48410. /**
  48411. * Adds specific effects defines.
  48412. * @param defines The defines to add specifics to.
  48413. */
  48414. protected _addCustomEffectDefines(defines: string[]): void;
  48415. /**
  48416. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48417. * @param mesh The mesh to exclude from the glow layer
  48418. */
  48419. addExcludedMesh(mesh: Mesh): void;
  48420. /**
  48421. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48422. * @param mesh The mesh to remove
  48423. */
  48424. removeExcludedMesh(mesh: Mesh): void;
  48425. /**
  48426. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48427. * @param mesh The mesh to include in the glow layer
  48428. */
  48429. addIncludedOnlyMesh(mesh: Mesh): void;
  48430. /**
  48431. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48432. * @param mesh The mesh to remove
  48433. */
  48434. removeIncludedOnlyMesh(mesh: Mesh): void;
  48435. /**
  48436. * Determine if a given mesh will be used in the glow layer
  48437. * @param mesh The mesh to test
  48438. * @returns true if the mesh will be highlighted by the current glow layer
  48439. */
  48440. hasMesh(mesh: AbstractMesh): boolean;
  48441. /**
  48442. * Free any resources and references associated to a mesh.
  48443. * Internal use
  48444. * @param mesh The mesh to free.
  48445. * @hidden
  48446. */ private _disposeMesh(mesh: Mesh): void;
  48447. /**
  48448. * Gets the class name of the effect layer
  48449. * @returns the string with the class name of the effect layer
  48450. */
  48451. getClassName(): string;
  48452. /**
  48453. * Serializes this glow layer
  48454. * @returns a serialized glow layer object
  48455. */
  48456. serialize(): any;
  48457. /**
  48458. * Creates a Glow Layer from parsed glow layer data
  48459. * @param parsedGlowLayer defines glow layer data
  48460. * @param scene defines the current scene
  48461. * @param rootUrl defines the root URL containing the glow layer information
  48462. * @returns a parsed Glow Layer
  48463. */
  48464. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48465. }
  48466. }
  48467. declare module BABYLON {
  48468. /** @hidden */
  48469. export var glowBlurPostProcessPixelShader: {
  48470. name: string;
  48471. shader: string;
  48472. };
  48473. }
  48474. declare module BABYLON {
  48475. interface AbstractScene {
  48476. /**
  48477. * Return a the first highlight layer of the scene with a given name.
  48478. * @param name The name of the highlight layer to look for.
  48479. * @return The highlight layer if found otherwise null.
  48480. */
  48481. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48482. }
  48483. /**
  48484. * Highlight layer options. This helps customizing the behaviour
  48485. * of the highlight layer.
  48486. */
  48487. export interface IHighlightLayerOptions {
  48488. /**
  48489. * Multiplication factor apply to the canvas size to compute the render target size
  48490. * used to generated the glowing objects (the smaller the faster).
  48491. */
  48492. mainTextureRatio: number;
  48493. /**
  48494. * Enforces a fixed size texture to ensure resize independant blur.
  48495. */
  48496. mainTextureFixedSize?: number;
  48497. /**
  48498. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48499. * of the picture to blur (the smaller the faster).
  48500. */
  48501. blurTextureSizeRatio: number;
  48502. /**
  48503. * How big in texel of the blur texture is the vertical blur.
  48504. */
  48505. blurVerticalSize: number;
  48506. /**
  48507. * How big in texel of the blur texture is the horizontal blur.
  48508. */
  48509. blurHorizontalSize: number;
  48510. /**
  48511. * Alpha blending mode used to apply the blur. Default is combine.
  48512. */
  48513. alphaBlendingMode: number;
  48514. /**
  48515. * The camera attached to the layer.
  48516. */
  48517. camera: Nullable<Camera>;
  48518. /**
  48519. * Should we display highlight as a solid stroke?
  48520. */
  48521. isStroke?: boolean;
  48522. /**
  48523. * The rendering group to draw the layer in.
  48524. */
  48525. renderingGroupId: number;
  48526. }
  48527. /**
  48528. * The highlight layer Helps adding a glow effect around a mesh.
  48529. *
  48530. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48531. * glowy meshes to your scene.
  48532. *
  48533. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48534. */
  48535. export class HighlightLayer extends EffectLayer {
  48536. name: string;
  48537. /**
  48538. * Effect Name of the highlight layer.
  48539. */
  48540. static readonly EffectName: string;
  48541. /**
  48542. * The neutral color used during the preparation of the glow effect.
  48543. * This is black by default as the blend operation is a blend operation.
  48544. */
  48545. static NeutralColor: Color4;
  48546. /**
  48547. * Stencil value used for glowing meshes.
  48548. */
  48549. static GlowingMeshStencilReference: number;
  48550. /**
  48551. * Stencil value used for the other meshes in the scene.
  48552. */
  48553. static NormalMeshStencilReference: number;
  48554. /**
  48555. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48556. */
  48557. innerGlow: boolean;
  48558. /**
  48559. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48560. */
  48561. outerGlow: boolean;
  48562. /**
  48563. * Specifies the horizontal size of the blur.
  48564. */
  48565. /**
  48566. * Gets the horizontal size of the blur.
  48567. */
  48568. blurHorizontalSize: number;
  48569. /**
  48570. * Specifies the vertical size of the blur.
  48571. */
  48572. /**
  48573. * Gets the vertical size of the blur.
  48574. */
  48575. blurVerticalSize: number;
  48576. /**
  48577. * An event triggered when the highlight layer is being blurred.
  48578. */
  48579. onBeforeBlurObservable: Observable<HighlightLayer>;
  48580. /**
  48581. * An event triggered when the highlight layer has been blurred.
  48582. */
  48583. onAfterBlurObservable: Observable<HighlightLayer>;
  48584. private _instanceGlowingMeshStencilReference;
  48585. private _options;
  48586. private _downSamplePostprocess;
  48587. private _horizontalBlurPostprocess;
  48588. private _verticalBlurPostprocess;
  48589. private _blurTexture;
  48590. private _meshes;
  48591. private _excludedMeshes;
  48592. /**
  48593. * Instantiates a new highlight Layer and references it to the scene..
  48594. * @param name The name of the layer
  48595. * @param scene The scene to use the layer in
  48596. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48597. */
  48598. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48599. /**
  48600. * Get the effect name of the layer.
  48601. * @return The effect name
  48602. */
  48603. getEffectName(): string;
  48604. /**
  48605. * Create the merge effect. This is the shader use to blit the information back
  48606. * to the main canvas at the end of the scene rendering.
  48607. */
  48608. protected _createMergeEffect(): Effect;
  48609. /**
  48610. * Creates the render target textures and post processes used in the highlight layer.
  48611. */
  48612. protected _createTextureAndPostProcesses(): void;
  48613. /**
  48614. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48615. */
  48616. needStencil(): boolean;
  48617. /**
  48618. * Checks for the readiness of the element composing the layer.
  48619. * @param subMesh the mesh to check for
  48620. * @param useInstances specify wether or not to use instances to render the mesh
  48621. * @param emissiveTexture the associated emissive texture used to generate the glow
  48622. * @return true if ready otherwise, false
  48623. */
  48624. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48625. /**
  48626. * Implementation specific of rendering the generating effect on the main canvas.
  48627. * @param effect The effect used to render through
  48628. */
  48629. protected _internalRender(effect: Effect): void;
  48630. /**
  48631. * Returns true if the layer contains information to display, otherwise false.
  48632. */
  48633. shouldRender(): boolean;
  48634. /**
  48635. * Returns true if the mesh should render, otherwise false.
  48636. * @param mesh The mesh to render
  48637. * @returns true if it should render otherwise false
  48638. */
  48639. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48640. /**
  48641. * Sets the required values for both the emissive texture and and the main color.
  48642. */
  48643. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48644. /**
  48645. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48646. * @param mesh The mesh to exclude from the highlight layer
  48647. */
  48648. addExcludedMesh(mesh: Mesh): void;
  48649. /**
  48650. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48651. * @param mesh The mesh to highlight
  48652. */
  48653. removeExcludedMesh(mesh: Mesh): void;
  48654. /**
  48655. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48656. * @param mesh mesh to test
  48657. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48658. */
  48659. hasMesh(mesh: AbstractMesh): boolean;
  48660. /**
  48661. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48662. * @param mesh The mesh to highlight
  48663. * @param color The color of the highlight
  48664. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48665. */
  48666. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48667. /**
  48668. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48669. * @param mesh The mesh to highlight
  48670. */
  48671. removeMesh(mesh: Mesh): void;
  48672. /**
  48673. * Force the stencil to the normal expected value for none glowing parts
  48674. */
  48675. private _defaultStencilReference;
  48676. /**
  48677. * Free any resources and references associated to a mesh.
  48678. * Internal use
  48679. * @param mesh The mesh to free.
  48680. * @hidden
  48681. */ private _disposeMesh(mesh: Mesh): void;
  48682. /**
  48683. * Dispose the highlight layer and free resources.
  48684. */
  48685. dispose(): void;
  48686. /**
  48687. * Gets the class name of the effect layer
  48688. * @returns the string with the class name of the effect layer
  48689. */
  48690. getClassName(): string;
  48691. /**
  48692. * Serializes this Highlight layer
  48693. * @returns a serialized Highlight layer object
  48694. */
  48695. serialize(): any;
  48696. /**
  48697. * Creates a Highlight layer from parsed Highlight layer data
  48698. * @param parsedHightlightLayer defines the Highlight layer data
  48699. * @param scene defines the current scene
  48700. * @param rootUrl defines the root URL containing the Highlight layer information
  48701. * @returns a parsed Highlight layer
  48702. */
  48703. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48704. }
  48705. }
  48706. declare module BABYLON {
  48707. interface AbstractScene {
  48708. /**
  48709. * The list of layers (background and foreground) of the scene
  48710. */
  48711. layers: Array<Layer>;
  48712. }
  48713. /**
  48714. * Defines the layer scene component responsible to manage any layers
  48715. * in a given scene.
  48716. */
  48717. export class LayerSceneComponent implements ISceneComponent {
  48718. /**
  48719. * The component name helpfull to identify the component in the list of scene components.
  48720. */
  48721. readonly name: string;
  48722. /**
  48723. * The scene the component belongs to.
  48724. */
  48725. scene: Scene;
  48726. private _engine;
  48727. /**
  48728. * Creates a new instance of the component for the given scene
  48729. * @param scene Defines the scene to register the component in
  48730. */
  48731. constructor(scene: Scene);
  48732. /**
  48733. * Registers the component in a given scene
  48734. */
  48735. register(): void;
  48736. /**
  48737. * Rebuilds the elements related to this component in case of
  48738. * context lost for instance.
  48739. */
  48740. rebuild(): void;
  48741. /**
  48742. * Disposes the component and the associated ressources.
  48743. */
  48744. dispose(): void;
  48745. private _draw;
  48746. private _drawCameraPredicate;
  48747. private _drawCameraBackground;
  48748. private _drawCameraForeground;
  48749. private _drawRenderTargetPredicate;
  48750. private _drawRenderTargetBackground;
  48751. private _drawRenderTargetForeground;
  48752. /**
  48753. * Adds all the elements from the container to the scene
  48754. * @param container the container holding the elements
  48755. */
  48756. addFromContainer(container: AbstractScene): void;
  48757. /**
  48758. * Removes all the elements in the container from the scene
  48759. * @param container contains the elements to remove
  48760. * @param dispose if the removed element should be disposed (default: false)
  48761. */
  48762. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48763. }
  48764. }
  48765. declare module BABYLON {
  48766. /** @hidden */
  48767. export var layerPixelShader: {
  48768. name: string;
  48769. shader: string;
  48770. };
  48771. }
  48772. declare module BABYLON {
  48773. /** @hidden */
  48774. export var layerVertexShader: {
  48775. name: string;
  48776. shader: string;
  48777. };
  48778. }
  48779. declare module BABYLON {
  48780. /**
  48781. * This represents a full screen 2d layer.
  48782. * This can be useful to display a picture in the background of your scene for instance.
  48783. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48784. */
  48785. export class Layer {
  48786. /**
  48787. * Define the name of the layer.
  48788. */
  48789. name: string;
  48790. /**
  48791. * Define the texture the layer should display.
  48792. */
  48793. texture: Nullable<Texture>;
  48794. /**
  48795. * Is the layer in background or foreground.
  48796. */
  48797. isBackground: boolean;
  48798. /**
  48799. * Define the color of the layer (instead of texture).
  48800. */
  48801. color: Color4;
  48802. /**
  48803. * Define the scale of the layer in order to zoom in out of the texture.
  48804. */
  48805. scale: Vector2;
  48806. /**
  48807. * Define an offset for the layer in order to shift the texture.
  48808. */
  48809. offset: Vector2;
  48810. /**
  48811. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48812. */
  48813. alphaBlendingMode: number;
  48814. /**
  48815. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48816. * Alpha test will not mix with the background color in case of transparency.
  48817. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48818. */
  48819. alphaTest: boolean;
  48820. /**
  48821. * Define a mask to restrict the layer to only some of the scene cameras.
  48822. */
  48823. layerMask: number;
  48824. /**
  48825. * Define the list of render target the layer is visible into.
  48826. */
  48827. renderTargetTextures: RenderTargetTexture[];
  48828. /**
  48829. * Define if the layer is only used in renderTarget or if it also
  48830. * renders in the main frame buffer of the canvas.
  48831. */
  48832. renderOnlyInRenderTargetTextures: boolean;
  48833. private _scene;
  48834. private _vertexBuffers;
  48835. private _indexBuffer;
  48836. private _effect;
  48837. private _alphaTestEffect;
  48838. /**
  48839. * An event triggered when the layer is disposed.
  48840. */
  48841. onDisposeObservable: Observable<Layer>;
  48842. private _onDisposeObserver;
  48843. /**
  48844. * Back compatibility with callback before the onDisposeObservable existed.
  48845. * The set callback will be triggered when the layer has been disposed.
  48846. */
  48847. onDispose: () => void;
  48848. /**
  48849. * An event triggered before rendering the scene
  48850. */
  48851. onBeforeRenderObservable: Observable<Layer>;
  48852. private _onBeforeRenderObserver;
  48853. /**
  48854. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48855. * The set callback will be triggered just before rendering the layer.
  48856. */
  48857. onBeforeRender: () => void;
  48858. /**
  48859. * An event triggered after rendering the scene
  48860. */
  48861. onAfterRenderObservable: Observable<Layer>;
  48862. private _onAfterRenderObserver;
  48863. /**
  48864. * Back compatibility with callback before the onAfterRenderObservable existed.
  48865. * The set callback will be triggered just after rendering the layer.
  48866. */
  48867. onAfterRender: () => void;
  48868. /**
  48869. * Instantiates a new layer.
  48870. * This represents a full screen 2d layer.
  48871. * This can be useful to display a picture in the background of your scene for instance.
  48872. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48873. * @param name Define the name of the layer in the scene
  48874. * @param imgUrl Define the url of the texture to display in the layer
  48875. * @param scene Define the scene the layer belongs to
  48876. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48877. * @param color Defines a color for the layer
  48878. */
  48879. constructor(
  48880. /**
  48881. * Define the name of the layer.
  48882. */
  48883. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48884. private _createIndexBuffer;
  48885. /** @hidden */ private _rebuild(): void;
  48886. /**
  48887. * Renders the layer in the scene.
  48888. */
  48889. render(): void;
  48890. /**
  48891. * Disposes and releases the associated ressources.
  48892. */
  48893. dispose(): void;
  48894. }
  48895. }
  48896. declare module BABYLON {
  48897. /** @hidden */
  48898. export var lensFlarePixelShader: {
  48899. name: string;
  48900. shader: string;
  48901. };
  48902. }
  48903. declare module BABYLON {
  48904. /** @hidden */
  48905. export var lensFlareVertexShader: {
  48906. name: string;
  48907. shader: string;
  48908. };
  48909. }
  48910. declare module BABYLON {
  48911. /**
  48912. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48913. * It is usually composed of several `lensFlare`.
  48914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48915. */
  48916. export class LensFlareSystem {
  48917. /**
  48918. * Define the name of the lens flare system
  48919. */
  48920. name: string;
  48921. /**
  48922. * List of lens flares used in this system.
  48923. */
  48924. lensFlares: LensFlare[];
  48925. /**
  48926. * Define a limit from the border the lens flare can be visible.
  48927. */
  48928. borderLimit: number;
  48929. /**
  48930. * Define a viewport border we do not want to see the lens flare in.
  48931. */
  48932. viewportBorder: number;
  48933. /**
  48934. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48935. */
  48936. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48937. /**
  48938. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48939. */
  48940. layerMask: number;
  48941. /**
  48942. * Define the id of the lens flare system in the scene.
  48943. * (equal to name by default)
  48944. */
  48945. id: string;
  48946. private _scene;
  48947. private _emitter;
  48948. private _vertexBuffers;
  48949. private _indexBuffer;
  48950. private _effect;
  48951. private _positionX;
  48952. private _positionY;
  48953. private _isEnabled;
  48954. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48955. /**
  48956. * Instantiates a lens flare system.
  48957. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48958. * It is usually composed of several `lensFlare`.
  48959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48960. * @param name Define the name of the lens flare system in the scene
  48961. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48962. * @param scene Define the scene the lens flare system belongs to
  48963. */
  48964. constructor(
  48965. /**
  48966. * Define the name of the lens flare system
  48967. */
  48968. name: string, emitter: any, scene: Scene);
  48969. /**
  48970. * Define if the lens flare system is enabled.
  48971. */
  48972. isEnabled: boolean;
  48973. /**
  48974. * Get the scene the effects belongs to.
  48975. * @returns the scene holding the lens flare system
  48976. */
  48977. getScene(): Scene;
  48978. /**
  48979. * Get the emitter of the lens flare system.
  48980. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48981. * @returns the emitter of the lens flare system
  48982. */
  48983. getEmitter(): any;
  48984. /**
  48985. * Set the emitter of the lens flare system.
  48986. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48987. * @param newEmitter Define the new emitter of the system
  48988. */
  48989. setEmitter(newEmitter: any): void;
  48990. /**
  48991. * Get the lens flare system emitter position.
  48992. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48993. * @returns the position
  48994. */
  48995. getEmitterPosition(): Vector3;
  48996. /**
  48997. * @hidden
  48998. */
  48999. computeEffectivePosition(globalViewport: Viewport): boolean;
  49000. /** @hidden */ private _isVisible(): boolean;
  49001. /**
  49002. * @hidden
  49003. */
  49004. render(): boolean;
  49005. /**
  49006. * Dispose and release the lens flare with its associated resources.
  49007. */
  49008. dispose(): void;
  49009. /**
  49010. * Parse a lens flare system from a JSON repressentation
  49011. * @param parsedLensFlareSystem Define the JSON to parse
  49012. * @param scene Define the scene the parsed system should be instantiated in
  49013. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49014. * @returns the parsed system
  49015. */
  49016. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49017. /**
  49018. * Serialize the current Lens Flare System into a JSON representation.
  49019. * @returns the serialized JSON
  49020. */
  49021. serialize(): any;
  49022. }
  49023. }
  49024. declare module BABYLON {
  49025. /**
  49026. * This represents one of the lens effect in a `lensFlareSystem`.
  49027. * It controls one of the indiviual texture used in the effect.
  49028. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49029. */
  49030. export class LensFlare {
  49031. /**
  49032. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49033. */
  49034. size: number;
  49035. /**
  49036. * 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.
  49037. */
  49038. position: number;
  49039. /**
  49040. * Define the lens color.
  49041. */
  49042. color: Color3;
  49043. /**
  49044. * Define the lens texture.
  49045. */
  49046. texture: Nullable<Texture>;
  49047. /**
  49048. * Define the alpha mode to render this particular lens.
  49049. */
  49050. alphaMode: number;
  49051. private _system;
  49052. /**
  49053. * Creates a new Lens Flare.
  49054. * This represents one of the lens effect in a `lensFlareSystem`.
  49055. * It controls one of the indiviual texture used in the effect.
  49056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49057. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49058. * @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.
  49059. * @param color Define the lens color
  49060. * @param imgUrl Define the lens texture url
  49061. * @param system Define the `lensFlareSystem` this flare is part of
  49062. * @returns The newly created Lens Flare
  49063. */
  49064. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49065. /**
  49066. * Instantiates a new Lens Flare.
  49067. * This represents one of the lens effect in a `lensFlareSystem`.
  49068. * It controls one of the indiviual texture used in the effect.
  49069. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49070. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49071. * @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.
  49072. * @param color Define the lens color
  49073. * @param imgUrl Define the lens texture url
  49074. * @param system Define the `lensFlareSystem` this flare is part of
  49075. */
  49076. constructor(
  49077. /**
  49078. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49079. */
  49080. size: number,
  49081. /**
  49082. * 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.
  49083. */
  49084. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49085. /**
  49086. * Dispose and release the lens flare with its associated resources.
  49087. */
  49088. dispose(): void;
  49089. }
  49090. }
  49091. declare module BABYLON {
  49092. interface AbstractScene {
  49093. /**
  49094. * The list of lens flare system added to the scene
  49095. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49096. */
  49097. lensFlareSystems: Array<LensFlareSystem>;
  49098. /**
  49099. * Removes the given lens flare system from this scene.
  49100. * @param toRemove The lens flare system to remove
  49101. * @returns The index of the removed lens flare system
  49102. */
  49103. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49104. /**
  49105. * Adds the given lens flare system to this scene
  49106. * @param newLensFlareSystem The lens flare system to add
  49107. */
  49108. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49109. /**
  49110. * Gets a lens flare system using its name
  49111. * @param name defines the name to look for
  49112. * @returns the lens flare system or null if not found
  49113. */
  49114. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49115. /**
  49116. * Gets a lens flare system using its id
  49117. * @param id defines the id to look for
  49118. * @returns the lens flare system or null if not found
  49119. */
  49120. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49121. }
  49122. /**
  49123. * Defines the lens flare scene component responsible to manage any lens flares
  49124. * in a given scene.
  49125. */
  49126. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49127. /**
  49128. * The component name helpfull to identify the component in the list of scene components.
  49129. */
  49130. readonly name: string;
  49131. /**
  49132. * The scene the component belongs to.
  49133. */
  49134. scene: Scene;
  49135. /**
  49136. * Creates a new instance of the component for the given scene
  49137. * @param scene Defines the scene to register the component in
  49138. */
  49139. constructor(scene: Scene);
  49140. /**
  49141. * Registers the component in a given scene
  49142. */
  49143. register(): void;
  49144. /**
  49145. * Rebuilds the elements related to this component in case of
  49146. * context lost for instance.
  49147. */
  49148. rebuild(): void;
  49149. /**
  49150. * Adds all the elements from the container to the scene
  49151. * @param container the container holding the elements
  49152. */
  49153. addFromContainer(container: AbstractScene): void;
  49154. /**
  49155. * Removes all the elements in the container from the scene
  49156. * @param container contains the elements to remove
  49157. * @param dispose if the removed element should be disposed (default: false)
  49158. */
  49159. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49160. /**
  49161. * Serializes the component data to the specified json object
  49162. * @param serializationObject The object to serialize to
  49163. */
  49164. serialize(serializationObject: any): void;
  49165. /**
  49166. * Disposes the component and the associated ressources.
  49167. */
  49168. dispose(): void;
  49169. private _draw;
  49170. }
  49171. }
  49172. declare module BABYLON {
  49173. /**
  49174. * Defines the shadow generator component responsible to manage any shadow generators
  49175. * in a given scene.
  49176. */
  49177. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49178. /**
  49179. * The component name helpfull to identify the component in the list of scene components.
  49180. */
  49181. readonly name: string;
  49182. /**
  49183. * The scene the component belongs to.
  49184. */
  49185. scene: Scene;
  49186. /**
  49187. * Creates a new instance of the component for the given scene
  49188. * @param scene Defines the scene to register the component in
  49189. */
  49190. constructor(scene: Scene);
  49191. /**
  49192. * Registers the component in a given scene
  49193. */
  49194. register(): void;
  49195. /**
  49196. * Rebuilds the elements related to this component in case of
  49197. * context lost for instance.
  49198. */
  49199. rebuild(): void;
  49200. /**
  49201. * Serializes the component data to the specified json object
  49202. * @param serializationObject The object to serialize to
  49203. */
  49204. serialize(serializationObject: any): void;
  49205. /**
  49206. * Adds all the elements from the container to the scene
  49207. * @param container the container holding the elements
  49208. */
  49209. addFromContainer(container: AbstractScene): void;
  49210. /**
  49211. * Removes all the elements in the container from the scene
  49212. * @param container contains the elements to remove
  49213. * @param dispose if the removed element should be disposed (default: false)
  49214. */
  49215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49216. /**
  49217. * Rebuilds the elements related to this component in case of
  49218. * context lost for instance.
  49219. */
  49220. dispose(): void;
  49221. private _gatherRenderTargets;
  49222. }
  49223. }
  49224. declare module BABYLON {
  49225. /**
  49226. * A point light is a light defined by an unique point in world space.
  49227. * The light is emitted in every direction from this point.
  49228. * A good example of a point light is a standard light bulb.
  49229. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49230. */
  49231. export class PointLight extends ShadowLight {
  49232. private _shadowAngle;
  49233. /**
  49234. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49235. * This specifies what angle the shadow will use to be created.
  49236. *
  49237. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49238. */
  49239. /**
  49240. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49241. * This specifies what angle the shadow will use to be created.
  49242. *
  49243. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49244. */
  49245. shadowAngle: number;
  49246. /**
  49247. * Gets the direction if it has been set.
  49248. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49249. */
  49250. /**
  49251. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49252. */
  49253. direction: Vector3;
  49254. /**
  49255. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49256. * A PointLight emits the light in every direction.
  49257. * It can cast shadows.
  49258. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49259. * ```javascript
  49260. * var pointLight = new PointLight("pl", camera.position, scene);
  49261. * ```
  49262. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49263. * @param name The light friendly name
  49264. * @param position The position of the point light in the scene
  49265. * @param scene The scene the lights belongs to
  49266. */
  49267. constructor(name: string, position: Vector3, scene: Scene);
  49268. /**
  49269. * Returns the string "PointLight"
  49270. * @returns the class name
  49271. */
  49272. getClassName(): string;
  49273. /**
  49274. * Returns the integer 0.
  49275. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49276. */
  49277. getTypeID(): number;
  49278. /**
  49279. * Specifies wether or not the shadowmap should be a cube texture.
  49280. * @returns true if the shadowmap needs to be a cube texture.
  49281. */
  49282. needCube(): boolean;
  49283. /**
  49284. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49285. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49286. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49287. */
  49288. getShadowDirection(faceIndex?: number): Vector3;
  49289. /**
  49290. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49291. * - fov = PI / 2
  49292. * - aspect ratio : 1.0
  49293. * - z-near and far equal to the active camera minZ and maxZ.
  49294. * Returns the PointLight.
  49295. */
  49296. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49297. protected _buildUniformLayout(): void;
  49298. /**
  49299. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49300. * @param effect The effect to update
  49301. * @param lightIndex The index of the light in the effect to update
  49302. * @returns The point light
  49303. */
  49304. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49305. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49306. /**
  49307. * Prepares the list of defines specific to the light type.
  49308. * @param defines the list of defines
  49309. * @param lightIndex defines the index of the light for the effect
  49310. */
  49311. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * Header information of HDR texture files.
  49317. */
  49318. export interface HDRInfo {
  49319. /**
  49320. * The height of the texture in pixels.
  49321. */
  49322. height: number;
  49323. /**
  49324. * The width of the texture in pixels.
  49325. */
  49326. width: number;
  49327. /**
  49328. * The index of the beginning of the data in the binary file.
  49329. */
  49330. dataPosition: number;
  49331. }
  49332. /**
  49333. * This groups tools to convert HDR texture to native colors array.
  49334. */
  49335. export class HDRTools {
  49336. private static Ldexp;
  49337. private static Rgbe2float;
  49338. private static readStringLine;
  49339. /**
  49340. * Reads header information from an RGBE texture stored in a native array.
  49341. * More information on this format are available here:
  49342. * https://en.wikipedia.org/wiki/RGBE_image_format
  49343. *
  49344. * @param uint8array The binary file stored in native array.
  49345. * @return The header information.
  49346. */
  49347. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49348. /**
  49349. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49350. * This RGBE texture needs to store the information as a panorama.
  49351. *
  49352. * More information on this format are available here:
  49353. * https://en.wikipedia.org/wiki/RGBE_image_format
  49354. *
  49355. * @param buffer The binary file stored in an array buffer.
  49356. * @param size The expected size of the extracted cubemap.
  49357. * @return The Cube Map information.
  49358. */
  49359. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49360. /**
  49361. * Returns the pixels data extracted from an RGBE texture.
  49362. * This pixels will be stored left to right up to down in the R G B order in one array.
  49363. *
  49364. * More information on this format are available here:
  49365. * https://en.wikipedia.org/wiki/RGBE_image_format
  49366. *
  49367. * @param uint8array The binary file stored in an array buffer.
  49368. * @param hdrInfo The header information of the file.
  49369. * @return The pixels data in RGB right to left up to down order.
  49370. */
  49371. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49372. private static RGBE_ReadPixels_RLE;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * This represents a texture coming from an HDR input.
  49378. *
  49379. * The only supported format is currently panorama picture stored in RGBE format.
  49380. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49381. */
  49382. export class HDRCubeTexture extends BaseTexture {
  49383. private static _facesMapping;
  49384. private _generateHarmonics;
  49385. private _noMipmap;
  49386. private _textureMatrix;
  49387. private _size;
  49388. private _onLoad;
  49389. private _onError;
  49390. /**
  49391. * The texture URL.
  49392. */
  49393. url: string;
  49394. /**
  49395. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49396. */
  49397. coordinatesMode: number;
  49398. protected _isBlocking: boolean;
  49399. /**
  49400. * Sets wether or not the texture is blocking during loading.
  49401. */
  49402. /**
  49403. * Gets wether or not the texture is blocking during loading.
  49404. */
  49405. isBlocking: boolean;
  49406. protected _rotationY: number;
  49407. /**
  49408. * Sets texture matrix rotation angle around Y axis in radians.
  49409. */
  49410. /**
  49411. * Gets texture matrix rotation angle around Y axis radians.
  49412. */
  49413. rotationY: number;
  49414. /**
  49415. * Gets or sets the center of the bounding box associated with the cube texture
  49416. * It must define where the camera used to render the texture was set
  49417. */
  49418. boundingBoxPosition: Vector3;
  49419. private _boundingBoxSize;
  49420. /**
  49421. * Gets or sets the size of the bounding box associated with the cube texture
  49422. * When defined, the cubemap will switch to local mode
  49423. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49424. * @example https://www.babylonjs-playground.com/#RNASML
  49425. */
  49426. boundingBoxSize: Vector3;
  49427. /**
  49428. * Instantiates an HDRTexture from the following parameters.
  49429. *
  49430. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49431. * @param scene The scene the texture will be used in
  49432. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49433. * @param noMipmap Forces to not generate the mipmap if true
  49434. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49435. * @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)
  49436. * @param reserved Reserved flag for internal use.
  49437. */
  49438. 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>);
  49439. /**
  49440. * Get the current class name of the texture useful for serialization or dynamic coding.
  49441. * @returns "HDRCubeTexture"
  49442. */
  49443. getClassName(): string;
  49444. /**
  49445. * Occurs when the file is raw .hdr file.
  49446. */
  49447. private loadTexture;
  49448. clone(): HDRCubeTexture;
  49449. delayLoad(): void;
  49450. /**
  49451. * Get the texture reflection matrix used to rotate/transform the reflection.
  49452. * @returns the reflection matrix
  49453. */
  49454. getReflectionTextureMatrix(): Matrix;
  49455. /**
  49456. * Set the texture reflection matrix used to rotate/transform the reflection.
  49457. * @param value Define the reflection matrix to set
  49458. */
  49459. setReflectionTextureMatrix(value: Matrix): void;
  49460. /**
  49461. * Parses a JSON representation of an HDR Texture in order to create the texture
  49462. * @param parsedTexture Define the JSON representation
  49463. * @param scene Define the scene the texture should be created in
  49464. * @param rootUrl Define the root url in case we need to load relative dependencies
  49465. * @returns the newly created texture after parsing
  49466. */
  49467. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49468. serialize(): any;
  49469. }
  49470. }
  49471. declare module BABYLON {
  49472. /**
  49473. * Class used to control physics engine
  49474. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49475. */
  49476. export class PhysicsEngine implements IPhysicsEngine {
  49477. private _physicsPlugin;
  49478. /**
  49479. * Global value used to control the smallest number supported by the simulation
  49480. */
  49481. static Epsilon: number;
  49482. private _impostors;
  49483. private _joints;
  49484. /**
  49485. * Gets the gravity vector used by the simulation
  49486. */
  49487. gravity: Vector3;
  49488. /**
  49489. * Factory used to create the default physics plugin.
  49490. * @returns The default physics plugin
  49491. */
  49492. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49493. /**
  49494. * Creates a new Physics Engine
  49495. * @param gravity defines the gravity vector used by the simulation
  49496. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49497. */
  49498. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49499. /**
  49500. * Sets the gravity vector used by the simulation
  49501. * @param gravity defines the gravity vector to use
  49502. */
  49503. setGravity(gravity: Vector3): void;
  49504. /**
  49505. * Set the time step of the physics engine.
  49506. * Default is 1/60.
  49507. * To slow it down, enter 1/600 for example.
  49508. * To speed it up, 1/30
  49509. * @param newTimeStep defines the new timestep to apply to this world.
  49510. */
  49511. setTimeStep(newTimeStep?: number): void;
  49512. /**
  49513. * Get the time step of the physics engine.
  49514. * @returns the current time step
  49515. */
  49516. getTimeStep(): number;
  49517. /**
  49518. * Release all resources
  49519. */
  49520. dispose(): void;
  49521. /**
  49522. * Gets the name of the current physics plugin
  49523. * @returns the name of the plugin
  49524. */
  49525. getPhysicsPluginName(): string;
  49526. /**
  49527. * Adding a new impostor for the impostor tracking.
  49528. * This will be done by the impostor itself.
  49529. * @param impostor the impostor to add
  49530. */
  49531. addImpostor(impostor: PhysicsImpostor): void;
  49532. /**
  49533. * Remove an impostor from the engine.
  49534. * This impostor and its mesh will not longer be updated by the physics engine.
  49535. * @param impostor the impostor to remove
  49536. */
  49537. removeImpostor(impostor: PhysicsImpostor): void;
  49538. /**
  49539. * Add a joint to the physics engine
  49540. * @param mainImpostor defines the main impostor to which the joint is added.
  49541. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49542. * @param joint defines the joint that will connect both impostors.
  49543. */
  49544. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49545. /**
  49546. * Removes a joint from the simulation
  49547. * @param mainImpostor defines the impostor used with the joint
  49548. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49549. * @param joint defines the joint to remove
  49550. */
  49551. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49552. /**
  49553. * Called by the scene. No need to call it.
  49554. * @param delta defines the timespam between frames
  49555. */ private _step(delta: number): void;
  49556. /**
  49557. * Gets the current plugin used to run the simulation
  49558. * @returns current plugin
  49559. */
  49560. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49561. /**
  49562. * Gets the list of physic impostors
  49563. * @returns an array of PhysicsImpostor
  49564. */
  49565. getImpostors(): Array<PhysicsImpostor>;
  49566. /**
  49567. * Gets the impostor for a physics enabled object
  49568. * @param object defines the object impersonated by the impostor
  49569. * @returns the PhysicsImpostor or null if not found
  49570. */
  49571. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49572. /**
  49573. * Gets the impostor for a physics body object
  49574. * @param body defines physics body used by the impostor
  49575. * @returns the PhysicsImpostor or null if not found
  49576. */
  49577. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49578. /**
  49579. * Does a raycast in the physics world
  49580. * @param from when should the ray start?
  49581. * @param to when should the ray end?
  49582. * @returns PhysicsRaycastResult
  49583. */
  49584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49585. }
  49586. }
  49587. declare module BABYLON {
  49588. /** @hidden */
  49589. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49590. private _useDeltaForWorldStep;
  49591. world: any;
  49592. name: string;
  49593. private _physicsMaterials;
  49594. private _fixedTimeStep;
  49595. private _cannonRaycastResult;
  49596. private _raycastResult;
  49597. private _physicsBodysToRemoveAfterStep;
  49598. BJSCANNON: any;
  49599. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49600. setGravity(gravity: Vector3): void;
  49601. setTimeStep(timeStep: number): void;
  49602. getTimeStep(): number;
  49603. executeStep(delta: number): void;
  49604. private _removeMarkedPhysicsBodiesFromWorld;
  49605. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49606. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49607. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49608. private _processChildMeshes;
  49609. removePhysicsBody(impostor: PhysicsImpostor): void;
  49610. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49611. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49612. private _addMaterial;
  49613. private _checkWithEpsilon;
  49614. private _createShape;
  49615. private _createHeightmap;
  49616. private _minus90X;
  49617. private _plus90X;
  49618. private _tmpPosition;
  49619. private _tmpDeltaPosition;
  49620. private _tmpUnityRotation;
  49621. private _updatePhysicsBodyTransformation;
  49622. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49623. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49624. isSupported(): boolean;
  49625. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49626. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49627. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49628. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49629. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49630. getBodyMass(impostor: PhysicsImpostor): number;
  49631. getBodyFriction(impostor: PhysicsImpostor): number;
  49632. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49633. getBodyRestitution(impostor: PhysicsImpostor): number;
  49634. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49635. sleepBody(impostor: PhysicsImpostor): void;
  49636. wakeUpBody(impostor: PhysicsImpostor): void;
  49637. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49638. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49639. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49640. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49641. getRadius(impostor: PhysicsImpostor): number;
  49642. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49643. dispose(): void;
  49644. private _extendNamespace;
  49645. /**
  49646. * Does a raycast in the physics world
  49647. * @param from when should the ray start?
  49648. * @param to when should the ray end?
  49649. * @returns PhysicsRaycastResult
  49650. */
  49651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49652. }
  49653. }
  49654. declare module BABYLON {
  49655. /** @hidden */
  49656. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49657. world: any;
  49658. name: string;
  49659. BJSOIMO: any;
  49660. private _raycastResult;
  49661. constructor(iterations?: number, oimoInjection?: any);
  49662. setGravity(gravity: Vector3): void;
  49663. setTimeStep(timeStep: number): void;
  49664. getTimeStep(): number;
  49665. private _tmpImpostorsArray;
  49666. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49667. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49668. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49669. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49670. private _tmpPositionVector;
  49671. removePhysicsBody(impostor: PhysicsImpostor): void;
  49672. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49673. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49674. isSupported(): boolean;
  49675. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49676. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49677. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49678. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49681. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49682. getBodyMass(impostor: PhysicsImpostor): number;
  49683. getBodyFriction(impostor: PhysicsImpostor): number;
  49684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49685. getBodyRestitution(impostor: PhysicsImpostor): number;
  49686. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49687. sleepBody(impostor: PhysicsImpostor): void;
  49688. wakeUpBody(impostor: PhysicsImpostor): void;
  49689. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49690. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49691. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49693. getRadius(impostor: PhysicsImpostor): number;
  49694. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49695. dispose(): void;
  49696. /**
  49697. * Does a raycast in the physics world
  49698. * @param from when should the ray start?
  49699. * @param to when should the ray end?
  49700. * @returns PhysicsRaycastResult
  49701. */
  49702. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49703. }
  49704. }
  49705. declare module BABYLON {
  49706. /**
  49707. * Class containing static functions to help procedurally build meshes
  49708. */
  49709. export class RibbonBuilder {
  49710. /**
  49711. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49712. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49713. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49714. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49715. * * 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
  49716. * * 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
  49717. * * 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
  49718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49719. * * 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
  49720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49721. * * 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
  49722. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49723. * * 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
  49724. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49726. * @param name defines the name of the mesh
  49727. * @param options defines the options used to create the mesh
  49728. * @param scene defines the hosting scene
  49729. * @returns the ribbon mesh
  49730. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49731. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49732. */
  49733. static CreateRibbon(name: string, options: {
  49734. pathArray: Vector3[][];
  49735. closeArray?: boolean;
  49736. closePath?: boolean;
  49737. offset?: number;
  49738. updatable?: boolean;
  49739. sideOrientation?: number;
  49740. frontUVs?: Vector4;
  49741. backUVs?: Vector4;
  49742. instance?: Mesh;
  49743. invertUV?: boolean;
  49744. uvs?: Vector2[];
  49745. colors?: Color4[];
  49746. }, scene?: Nullable<Scene>): Mesh;
  49747. }
  49748. }
  49749. declare module BABYLON {
  49750. /**
  49751. * Class containing static functions to help procedurally build meshes
  49752. */
  49753. export class ShapeBuilder {
  49754. /**
  49755. * 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.
  49756. * * 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.
  49757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49758. * * 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.
  49759. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49760. * * 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
  49761. * * 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
  49762. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49764. * * 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
  49765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49767. * @param name defines the name of the mesh
  49768. * @param options defines the options used to create the mesh
  49769. * @param scene defines the hosting scene
  49770. * @returns the extruded shape mesh
  49771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49773. */
  49774. static ExtrudeShape(name: string, options: {
  49775. shape: Vector3[];
  49776. path: Vector3[];
  49777. scale?: number;
  49778. rotation?: number;
  49779. cap?: number;
  49780. updatable?: boolean;
  49781. sideOrientation?: number;
  49782. frontUVs?: Vector4;
  49783. backUVs?: Vector4;
  49784. instance?: Mesh;
  49785. invertUV?: boolean;
  49786. }, scene?: Nullable<Scene>): Mesh;
  49787. /**
  49788. * Creates an custom extruded shape mesh.
  49789. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49790. * * 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.
  49791. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49792. * * 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
  49793. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49794. * * 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
  49795. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49796. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49797. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49798. * * 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
  49799. * * 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
  49800. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49802. * * 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
  49803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49805. * @param name defines the name of the mesh
  49806. * @param options defines the options used to create the mesh
  49807. * @param scene defines the hosting scene
  49808. * @returns the custom extruded shape mesh
  49809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49812. */
  49813. static ExtrudeShapeCustom(name: string, options: {
  49814. shape: Vector3[];
  49815. path: Vector3[];
  49816. scaleFunction?: any;
  49817. rotationFunction?: any;
  49818. ribbonCloseArray?: boolean;
  49819. ribbonClosePath?: boolean;
  49820. cap?: number;
  49821. updatable?: boolean;
  49822. sideOrientation?: number;
  49823. frontUVs?: Vector4;
  49824. backUVs?: Vector4;
  49825. instance?: Mesh;
  49826. invertUV?: boolean;
  49827. }, scene?: Nullable<Scene>): Mesh;
  49828. private static _ExtrudeShapeGeneric;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * AmmoJS Physics plugin
  49834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49835. * @see https://github.com/kripken/ammo.js/
  49836. */
  49837. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49838. private _useDeltaForWorldStep;
  49839. /**
  49840. * Reference to the Ammo library
  49841. */
  49842. bjsAMMO: any;
  49843. /**
  49844. * Created ammoJS world which physics bodies are added to
  49845. */
  49846. world: any;
  49847. /**
  49848. * Name of the plugin
  49849. */
  49850. name: string;
  49851. private _timeStep;
  49852. private _fixedTimeStep;
  49853. private _maxSteps;
  49854. private _tmpQuaternion;
  49855. private _tmpAmmoTransform;
  49856. private _tmpAmmoQuaternion;
  49857. private _tmpAmmoConcreteContactResultCallback;
  49858. private _collisionConfiguration;
  49859. private _dispatcher;
  49860. private _overlappingPairCache;
  49861. private _solver;
  49862. private _softBodySolver;
  49863. private _tmpAmmoVectorA;
  49864. private _tmpAmmoVectorB;
  49865. private _tmpAmmoVectorC;
  49866. private _tmpAmmoVectorD;
  49867. private _tmpContactCallbackResult;
  49868. private _tmpAmmoVectorRCA;
  49869. private _tmpAmmoVectorRCB;
  49870. private _raycastResult;
  49871. private static readonly DISABLE_COLLISION_FLAG;
  49872. private static readonly KINEMATIC_FLAG;
  49873. private static readonly DISABLE_DEACTIVATION_FLAG;
  49874. /**
  49875. * Initializes the ammoJS plugin
  49876. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49877. * @param ammoInjection can be used to inject your own ammo reference
  49878. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49879. */
  49880. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49881. /**
  49882. * Sets the gravity of the physics world (m/(s^2))
  49883. * @param gravity Gravity to set
  49884. */
  49885. setGravity(gravity: Vector3): void;
  49886. /**
  49887. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49888. * @param timeStep timestep to use in seconds
  49889. */
  49890. setTimeStep(timeStep: number): void;
  49891. /**
  49892. * 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)
  49893. * @param fixedTimeStep fixedTimeStep to use in seconds
  49894. */
  49895. setFixedTimeStep(fixedTimeStep: number): void;
  49896. /**
  49897. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49898. * @param maxSteps the maximum number of steps by the physics engine per frame
  49899. */
  49900. setMaxSteps(maxSteps: number): void;
  49901. /**
  49902. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49903. * @returns the current timestep in seconds
  49904. */
  49905. getTimeStep(): number;
  49906. private _isImpostorInContact;
  49907. private _isImpostorPairInContact;
  49908. private _stepSimulation;
  49909. /**
  49910. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49911. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49912. * After the step the babylon meshes are set to the position of the physics imposters
  49913. * @param delta amount of time to step forward
  49914. * @param impostors array of imposters to update before/after the step
  49915. */
  49916. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49917. /**
  49918. * Update babylon mesh to match physics world object
  49919. * @param impostor imposter to match
  49920. */
  49921. private _afterSoftStep;
  49922. /**
  49923. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49924. * @param impostor imposter to match
  49925. */
  49926. private _ropeStep;
  49927. /**
  49928. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49929. * @param impostor imposter to match
  49930. */
  49931. private _softbodyOrClothStep;
  49932. private _tmpVector;
  49933. private _tmpMatrix;
  49934. /**
  49935. * Applies an impulse on the imposter
  49936. * @param impostor imposter to apply impulse to
  49937. * @param force amount of force to be applied to the imposter
  49938. * @param contactPoint the location to apply the impulse on the imposter
  49939. */
  49940. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49941. /**
  49942. * Applies a force on the imposter
  49943. * @param impostor imposter to apply force
  49944. * @param force amount of force to be applied to the imposter
  49945. * @param contactPoint the location to apply the force on the imposter
  49946. */
  49947. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49948. /**
  49949. * Creates a physics body using the plugin
  49950. * @param impostor the imposter to create the physics body on
  49951. */
  49952. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49953. /**
  49954. * Removes the physics body from the imposter and disposes of the body's memory
  49955. * @param impostor imposter to remove the physics body from
  49956. */
  49957. removePhysicsBody(impostor: PhysicsImpostor): void;
  49958. /**
  49959. * Generates a joint
  49960. * @param impostorJoint the imposter joint to create the joint with
  49961. */
  49962. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49963. /**
  49964. * Removes a joint
  49965. * @param impostorJoint the imposter joint to remove the joint from
  49966. */
  49967. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49968. private _addMeshVerts;
  49969. /**
  49970. * Initialise the soft body vertices to match its object's (mesh) vertices
  49971. * Softbody vertices (nodes) are in world space and to match this
  49972. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49973. * @param impostor to create the softbody for
  49974. */
  49975. private _softVertexData;
  49976. /**
  49977. * Create an impostor's soft body
  49978. * @param impostor to create the softbody for
  49979. */
  49980. private _createSoftbody;
  49981. /**
  49982. * Create cloth for an impostor
  49983. * @param impostor to create the softbody for
  49984. */
  49985. private _createCloth;
  49986. /**
  49987. * Create rope for an impostor
  49988. * @param impostor to create the softbody for
  49989. */
  49990. private _createRope;
  49991. private _addHullVerts;
  49992. private _createShape;
  49993. /**
  49994. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49995. * @param impostor imposter containing the physics body and babylon object
  49996. */
  49997. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49998. /**
  49999. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50000. * @param impostor imposter containing the physics body and babylon object
  50001. * @param newPosition new position
  50002. * @param newRotation new rotation
  50003. */
  50004. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50005. /**
  50006. * If this plugin is supported
  50007. * @returns true if its supported
  50008. */
  50009. isSupported(): boolean;
  50010. /**
  50011. * Sets the linear velocity of the physics body
  50012. * @param impostor imposter to set the velocity on
  50013. * @param velocity velocity to set
  50014. */
  50015. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50016. /**
  50017. * Sets the angular velocity of the physics body
  50018. * @param impostor imposter to set the velocity on
  50019. * @param velocity velocity to set
  50020. */
  50021. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50022. /**
  50023. * gets the linear velocity
  50024. * @param impostor imposter to get linear velocity from
  50025. * @returns linear velocity
  50026. */
  50027. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50028. /**
  50029. * gets the angular velocity
  50030. * @param impostor imposter to get angular velocity from
  50031. * @returns angular velocity
  50032. */
  50033. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50034. /**
  50035. * Sets the mass of physics body
  50036. * @param impostor imposter to set the mass on
  50037. * @param mass mass to set
  50038. */
  50039. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50040. /**
  50041. * Gets the mass of the physics body
  50042. * @param impostor imposter to get the mass from
  50043. * @returns mass
  50044. */
  50045. getBodyMass(impostor: PhysicsImpostor): number;
  50046. /**
  50047. * Gets friction of the impostor
  50048. * @param impostor impostor to get friction from
  50049. * @returns friction value
  50050. */
  50051. getBodyFriction(impostor: PhysicsImpostor): number;
  50052. /**
  50053. * Sets friction of the impostor
  50054. * @param impostor impostor to set friction on
  50055. * @param friction friction value
  50056. */
  50057. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50058. /**
  50059. * Gets restitution of the impostor
  50060. * @param impostor impostor to get restitution from
  50061. * @returns restitution value
  50062. */
  50063. getBodyRestitution(impostor: PhysicsImpostor): number;
  50064. /**
  50065. * Sets resitution of the impostor
  50066. * @param impostor impostor to set resitution on
  50067. * @param restitution resitution value
  50068. */
  50069. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50070. /**
  50071. * Gets pressure inside the impostor
  50072. * @param impostor impostor to get pressure from
  50073. * @returns pressure value
  50074. */
  50075. getBodyPressure(impostor: PhysicsImpostor): number;
  50076. /**
  50077. * Sets pressure inside a soft body impostor
  50078. * Cloth and rope must remain 0 pressure
  50079. * @param impostor impostor to set pressure on
  50080. * @param pressure pressure value
  50081. */
  50082. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50083. /**
  50084. * Gets stiffness of the impostor
  50085. * @param impostor impostor to get stiffness from
  50086. * @returns pressure value
  50087. */
  50088. getBodyStiffness(impostor: PhysicsImpostor): number;
  50089. /**
  50090. * Sets stiffness of the impostor
  50091. * @param impostor impostor to set stiffness on
  50092. * @param stiffness stiffness value from 0 to 1
  50093. */
  50094. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50095. /**
  50096. * Gets velocityIterations of the impostor
  50097. * @param impostor impostor to get velocity iterations from
  50098. * @returns velocityIterations value
  50099. */
  50100. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50101. /**
  50102. * Sets velocityIterations of the impostor
  50103. * @param impostor impostor to set velocity iterations on
  50104. * @param velocityIterations velocityIterations value
  50105. */
  50106. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50107. /**
  50108. * Gets positionIterations of the impostor
  50109. * @param impostor impostor to get position iterations from
  50110. * @returns positionIterations value
  50111. */
  50112. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50113. /**
  50114. * Sets positionIterations of the impostor
  50115. * @param impostor impostor to set position on
  50116. * @param positionIterations positionIterations value
  50117. */
  50118. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50119. /**
  50120. * Append an anchor to a cloth object
  50121. * @param impostor is the cloth impostor to add anchor to
  50122. * @param otherImpostor is the rigid impostor to anchor to
  50123. * @param width ratio across width from 0 to 1
  50124. * @param height ratio up height from 0 to 1
  50125. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50126. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50127. */
  50128. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50129. /**
  50130. * Append an hook to a rope object
  50131. * @param impostor is the rope impostor to add hook to
  50132. * @param otherImpostor is the rigid impostor to hook to
  50133. * @param length ratio along the rope from 0 to 1
  50134. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50135. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50136. */
  50137. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50138. /**
  50139. * Sleeps the physics body and stops it from being active
  50140. * @param impostor impostor to sleep
  50141. */
  50142. sleepBody(impostor: PhysicsImpostor): void;
  50143. /**
  50144. * Activates the physics body
  50145. * @param impostor impostor to activate
  50146. */
  50147. wakeUpBody(impostor: PhysicsImpostor): void;
  50148. /**
  50149. * Updates the distance parameters of the joint
  50150. * @param joint joint to update
  50151. * @param maxDistance maximum distance of the joint
  50152. * @param minDistance minimum distance of the joint
  50153. */
  50154. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50155. /**
  50156. * Sets a motor on the joint
  50157. * @param joint joint to set motor on
  50158. * @param speed speed of the motor
  50159. * @param maxForce maximum force of the motor
  50160. * @param motorIndex index of the motor
  50161. */
  50162. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50163. /**
  50164. * Sets the motors limit
  50165. * @param joint joint to set limit on
  50166. * @param upperLimit upper limit
  50167. * @param lowerLimit lower limit
  50168. */
  50169. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50170. /**
  50171. * Syncs the position and rotation of a mesh with the impostor
  50172. * @param mesh mesh to sync
  50173. * @param impostor impostor to update the mesh with
  50174. */
  50175. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50176. /**
  50177. * Gets the radius of the impostor
  50178. * @param impostor impostor to get radius from
  50179. * @returns the radius
  50180. */
  50181. getRadius(impostor: PhysicsImpostor): number;
  50182. /**
  50183. * Gets the box size of the impostor
  50184. * @param impostor impostor to get box size from
  50185. * @param result the resulting box size
  50186. */
  50187. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50188. /**
  50189. * Disposes of the impostor
  50190. */
  50191. dispose(): void;
  50192. /**
  50193. * Does a raycast in the physics world
  50194. * @param from when should the ray start?
  50195. * @param to when should the ray end?
  50196. * @returns PhysicsRaycastResult
  50197. */
  50198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50199. }
  50200. }
  50201. declare module BABYLON {
  50202. interface AbstractScene {
  50203. /**
  50204. * The list of reflection probes added to the scene
  50205. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50206. */
  50207. reflectionProbes: Array<ReflectionProbe>;
  50208. /**
  50209. * Removes the given reflection probe from this scene.
  50210. * @param toRemove The reflection probe to remove
  50211. * @returns The index of the removed reflection probe
  50212. */
  50213. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50214. /**
  50215. * Adds the given reflection probe to this scene.
  50216. * @param newReflectionProbe The reflection probe to add
  50217. */
  50218. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50219. }
  50220. /**
  50221. * Class used to generate realtime reflection / refraction cube textures
  50222. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50223. */
  50224. export class ReflectionProbe {
  50225. /** defines the name of the probe */
  50226. name: string;
  50227. private _scene;
  50228. private _renderTargetTexture;
  50229. private _projectionMatrix;
  50230. private _viewMatrix;
  50231. private _target;
  50232. private _add;
  50233. private _attachedMesh;
  50234. private _invertYAxis;
  50235. /** Gets or sets probe position (center of the cube map) */
  50236. position: Vector3;
  50237. /**
  50238. * Creates a new reflection probe
  50239. * @param name defines the name of the probe
  50240. * @param size defines the texture resolution (for each face)
  50241. * @param scene defines the hosting scene
  50242. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50243. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50244. */
  50245. constructor(
  50246. /** defines the name of the probe */
  50247. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50248. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50249. samples: number;
  50250. /** Gets or sets the refresh rate to use (on every frame by default) */
  50251. refreshRate: number;
  50252. /**
  50253. * Gets the hosting scene
  50254. * @returns a Scene
  50255. */
  50256. getScene(): Scene;
  50257. /** Gets the internal CubeTexture used to render to */
  50258. readonly cubeTexture: RenderTargetTexture;
  50259. /** Gets the list of meshes to render */
  50260. readonly renderList: Nullable<AbstractMesh[]>;
  50261. /**
  50262. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50263. * @param mesh defines the mesh to attach to
  50264. */
  50265. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50266. /**
  50267. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50268. * @param renderingGroupId The rendering group id corresponding to its index
  50269. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50270. */
  50271. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50272. /**
  50273. * Clean all associated resources
  50274. */
  50275. dispose(): void;
  50276. /**
  50277. * Converts the reflection probe information to a readable string for debug purpose.
  50278. * @param fullDetails Supports for multiple levels of logging within scene loading
  50279. * @returns the human readable reflection probe info
  50280. */
  50281. toString(fullDetails?: boolean): string;
  50282. /**
  50283. * Get the class name of the relfection probe.
  50284. * @returns "ReflectionProbe"
  50285. */
  50286. getClassName(): string;
  50287. /**
  50288. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50289. * @returns The JSON representation of the texture
  50290. */
  50291. serialize(): any;
  50292. /**
  50293. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50294. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50295. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50296. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50297. * @returns The parsed reflection probe if successful
  50298. */
  50299. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50300. }
  50301. }
  50302. declare module BABYLON {
  50303. /** @hidden */
  50304. export var _BabylonLoaderRegistered: boolean;
  50305. }
  50306. declare module BABYLON {
  50307. /**
  50308. * The Physically based simple base material of BJS.
  50309. *
  50310. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50311. * It is used as the base class for both the specGloss and metalRough conventions.
  50312. */
  50313. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50314. /**
  50315. * Number of Simultaneous lights allowed on the material.
  50316. */
  50317. maxSimultaneousLights: number;
  50318. /**
  50319. * If sets to true, disables all the lights affecting the material.
  50320. */
  50321. disableLighting: boolean;
  50322. /**
  50323. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50324. */
  50325. environmentTexture: BaseTexture;
  50326. /**
  50327. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50328. */
  50329. invertNormalMapX: boolean;
  50330. /**
  50331. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50332. */
  50333. invertNormalMapY: boolean;
  50334. /**
  50335. * Normal map used in the model.
  50336. */
  50337. normalTexture: BaseTexture;
  50338. /**
  50339. * Emissivie color used to self-illuminate the model.
  50340. */
  50341. emissiveColor: Color3;
  50342. /**
  50343. * Emissivie texture used to self-illuminate the model.
  50344. */
  50345. emissiveTexture: BaseTexture;
  50346. /**
  50347. * Occlusion Channel Strenght.
  50348. */
  50349. occlusionStrength: number;
  50350. /**
  50351. * Occlusion Texture of the material (adding extra occlusion effects).
  50352. */
  50353. occlusionTexture: BaseTexture;
  50354. /**
  50355. * Defines the alpha limits in alpha test mode.
  50356. */
  50357. alphaCutOff: number;
  50358. /**
  50359. * Gets the current double sided mode.
  50360. */
  50361. /**
  50362. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50363. */
  50364. doubleSided: boolean;
  50365. /**
  50366. * Stores the pre-calculated light information of a mesh in a texture.
  50367. */
  50368. lightmapTexture: BaseTexture;
  50369. /**
  50370. * If true, the light map contains occlusion information instead of lighting info.
  50371. */
  50372. useLightmapAsShadowmap: boolean;
  50373. /**
  50374. * Instantiates a new PBRMaterial instance.
  50375. *
  50376. * @param name The material name
  50377. * @param scene The scene the material will be use in.
  50378. */
  50379. constructor(name: string, scene: Scene);
  50380. getClassName(): string;
  50381. }
  50382. }
  50383. declare module BABYLON {
  50384. /**
  50385. * The PBR material of BJS following the metal roughness convention.
  50386. *
  50387. * This fits to the PBR convention in the GLTF definition:
  50388. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50389. */
  50390. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50391. /**
  50392. * The base color has two different interpretations depending on the value of metalness.
  50393. * When the material is a metal, the base color is the specific measured reflectance value
  50394. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50395. * of the material.
  50396. */
  50397. baseColor: Color3;
  50398. /**
  50399. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50400. * well as opacity information in the alpha channel.
  50401. */
  50402. baseTexture: BaseTexture;
  50403. /**
  50404. * Specifies the metallic scalar value of the material.
  50405. * Can also be used to scale the metalness values of the metallic texture.
  50406. */
  50407. metallic: number;
  50408. /**
  50409. * Specifies the roughness scalar value of the material.
  50410. * Can also be used to scale the roughness values of the metallic texture.
  50411. */
  50412. roughness: number;
  50413. /**
  50414. * Texture containing both the metallic value in the B channel and the
  50415. * roughness value in the G channel to keep better precision.
  50416. */
  50417. metallicRoughnessTexture: BaseTexture;
  50418. /**
  50419. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50420. *
  50421. * @param name The material name
  50422. * @param scene The scene the material will be use in.
  50423. */
  50424. constructor(name: string, scene: Scene);
  50425. /**
  50426. * Return the currrent class name of the material.
  50427. */
  50428. getClassName(): string;
  50429. /**
  50430. * Makes a duplicate of the current material.
  50431. * @param name - name to use for the new material.
  50432. */
  50433. clone(name: string): PBRMetallicRoughnessMaterial;
  50434. /**
  50435. * Serialize the material to a parsable JSON object.
  50436. */
  50437. serialize(): any;
  50438. /**
  50439. * Parses a JSON object correponding to the serialize function.
  50440. */
  50441. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50442. }
  50443. }
  50444. declare module BABYLON {
  50445. /**
  50446. * The PBR material of BJS following the specular glossiness convention.
  50447. *
  50448. * This fits to the PBR convention in the GLTF definition:
  50449. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50450. */
  50451. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50452. /**
  50453. * Specifies the diffuse color of the material.
  50454. */
  50455. diffuseColor: Color3;
  50456. /**
  50457. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50458. * channel.
  50459. */
  50460. diffuseTexture: BaseTexture;
  50461. /**
  50462. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50463. */
  50464. specularColor: Color3;
  50465. /**
  50466. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50467. */
  50468. glossiness: number;
  50469. /**
  50470. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50471. */
  50472. specularGlossinessTexture: BaseTexture;
  50473. /**
  50474. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50475. *
  50476. * @param name The material name
  50477. * @param scene The scene the material will be use in.
  50478. */
  50479. constructor(name: string, scene: Scene);
  50480. /**
  50481. * Return the currrent class name of the material.
  50482. */
  50483. getClassName(): string;
  50484. /**
  50485. * Makes a duplicate of the current material.
  50486. * @param name - name to use for the new material.
  50487. */
  50488. clone(name: string): PBRSpecularGlossinessMaterial;
  50489. /**
  50490. * Serialize the material to a parsable JSON object.
  50491. */
  50492. serialize(): any;
  50493. /**
  50494. * Parses a JSON object correponding to the serialize function.
  50495. */
  50496. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50497. }
  50498. }
  50499. declare module BABYLON {
  50500. /**
  50501. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50502. * It can help converting any input color in a desired output one. This can then be used to create effects
  50503. * from sepia, black and white to sixties or futuristic rendering...
  50504. *
  50505. * The only supported format is currently 3dl.
  50506. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50507. */
  50508. export class ColorGradingTexture extends BaseTexture {
  50509. /**
  50510. * The current texture matrix. (will always be identity in color grading texture)
  50511. */
  50512. private _textureMatrix;
  50513. /**
  50514. * The texture URL.
  50515. */
  50516. url: string;
  50517. /**
  50518. * Empty line regex stored for GC.
  50519. */
  50520. private static _noneEmptyLineRegex;
  50521. private _engine;
  50522. /**
  50523. * Instantiates a ColorGradingTexture from the following parameters.
  50524. *
  50525. * @param url The location of the color gradind data (currently only supporting 3dl)
  50526. * @param scene The scene the texture will be used in
  50527. */
  50528. constructor(url: string, scene: Scene);
  50529. /**
  50530. * Returns the texture matrix used in most of the material.
  50531. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50532. */
  50533. getTextureMatrix(): Matrix;
  50534. /**
  50535. * Occurs when the file being loaded is a .3dl LUT file.
  50536. */
  50537. private load3dlTexture;
  50538. /**
  50539. * Starts the loading process of the texture.
  50540. */
  50541. private loadTexture;
  50542. /**
  50543. * Clones the color gradind texture.
  50544. */
  50545. clone(): ColorGradingTexture;
  50546. /**
  50547. * Called during delayed load for textures.
  50548. */
  50549. delayLoad(): void;
  50550. /**
  50551. * Parses a color grading texture serialized by Babylon.
  50552. * @param parsedTexture The texture information being parsedTexture
  50553. * @param scene The scene to load the texture in
  50554. * @param rootUrl The root url of the data assets to load
  50555. * @return A color gradind texture
  50556. */
  50557. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50558. /**
  50559. * Serializes the LUT texture to json format.
  50560. */
  50561. serialize(): any;
  50562. }
  50563. }
  50564. declare module BABYLON {
  50565. /**
  50566. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50567. */
  50568. export class EquiRectangularCubeTexture extends BaseTexture {
  50569. /** The six faces of the cube. */
  50570. private static _FacesMapping;
  50571. private _noMipmap;
  50572. private _onLoad;
  50573. private _onError;
  50574. /** The size of the cubemap. */
  50575. private _size;
  50576. /** The buffer of the image. */
  50577. private _buffer;
  50578. /** The width of the input image. */
  50579. private _width;
  50580. /** The height of the input image. */
  50581. private _height;
  50582. /** The URL to the image. */
  50583. url: string;
  50584. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50585. coordinatesMode: number;
  50586. /**
  50587. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50588. * @param url The location of the image
  50589. * @param scene The scene the texture will be used in
  50590. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50591. * @param noMipmap Forces to not generate the mipmap if true
  50592. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50593. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50594. * @param onLoad — defines a callback called when texture is loaded
  50595. * @param onError — defines a callback called if there is an error
  50596. */
  50597. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50598. /**
  50599. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50600. */
  50601. private loadImage;
  50602. /**
  50603. * Convert the image buffer into a cubemap and create a CubeTexture.
  50604. */
  50605. private loadTexture;
  50606. /**
  50607. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50608. * @param buffer The ArrayBuffer that should be converted.
  50609. * @returns The buffer as Float32Array.
  50610. */
  50611. private getFloat32ArrayFromArrayBuffer;
  50612. /**
  50613. * Get the current class name of the texture useful for serialization or dynamic coding.
  50614. * @returns "EquiRectangularCubeTexture"
  50615. */
  50616. getClassName(): string;
  50617. /**
  50618. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50619. * @returns A clone of the current EquiRectangularCubeTexture.
  50620. */
  50621. clone(): EquiRectangularCubeTexture;
  50622. }
  50623. }
  50624. declare module BABYLON {
  50625. /**
  50626. * Based on jsTGALoader - Javascript loader for TGA file
  50627. * By Vincent Thibault
  50628. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50629. */
  50630. export class TGATools {
  50631. private static _TYPE_INDEXED;
  50632. private static _TYPE_RGB;
  50633. private static _TYPE_GREY;
  50634. private static _TYPE_RLE_INDEXED;
  50635. private static _TYPE_RLE_RGB;
  50636. private static _TYPE_RLE_GREY;
  50637. private static _ORIGIN_MASK;
  50638. private static _ORIGIN_SHIFT;
  50639. private static _ORIGIN_BL;
  50640. private static _ORIGIN_BR;
  50641. private static _ORIGIN_UL;
  50642. private static _ORIGIN_UR;
  50643. /**
  50644. * Gets the header of a TGA file
  50645. * @param data defines the TGA data
  50646. * @returns the header
  50647. */
  50648. static GetTGAHeader(data: Uint8Array): any;
  50649. /**
  50650. * Uploads TGA content to a Babylon Texture
  50651. * @hidden
  50652. */
  50653. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50654. /** @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;
  50655. /** @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;
  50656. /** @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;
  50657. /** @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;
  50658. /** @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;
  50659. /** @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;
  50660. }
  50661. }
  50662. declare module BABYLON {
  50663. /**
  50664. * Implementation of the TGA Texture Loader.
  50665. * @hidden
  50666. */
  50667. export class _TGATextureLoader implements IInternalTextureLoader {
  50668. /**
  50669. * Defines wether the loader supports cascade loading the different faces.
  50670. */
  50671. readonly supportCascades: boolean;
  50672. /**
  50673. * This returns if the loader support the current file information.
  50674. * @param extension defines the file extension of the file being loaded
  50675. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50676. * @param fallback defines the fallback internal texture if any
  50677. * @param isBase64 defines whether the texture is encoded as a base64
  50678. * @param isBuffer defines whether the texture data are stored as a buffer
  50679. * @returns true if the loader can load the specified file
  50680. */
  50681. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50682. /**
  50683. * Transform the url before loading if required.
  50684. * @param rootUrl the url of the texture
  50685. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50686. * @returns the transformed texture
  50687. */
  50688. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50689. /**
  50690. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50691. * @param rootUrl the url of the texture
  50692. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50693. * @returns the fallback texture
  50694. */
  50695. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50696. /**
  50697. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50698. * @param data contains the texture data
  50699. * @param texture defines the BabylonJS internal texture
  50700. * @param createPolynomials will be true if polynomials have been requested
  50701. * @param onLoad defines the callback to trigger once the texture is ready
  50702. * @param onError defines the callback to trigger in case of error
  50703. */
  50704. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50705. /**
  50706. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50707. * @param data contains the texture data
  50708. * @param texture defines the BabylonJS internal texture
  50709. * @param callback defines the method to call once ready to upload
  50710. */
  50711. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. /**
  50716. * Info about the .basis files
  50717. */
  50718. class BasisFileInfo {
  50719. /**
  50720. * If the file has alpha
  50721. */
  50722. hasAlpha: boolean;
  50723. /**
  50724. * Info about each image of the basis file
  50725. */
  50726. images: Array<{
  50727. levels: Array<{
  50728. width: number;
  50729. height: number;
  50730. transcodedPixels: ArrayBufferView;
  50731. }>;
  50732. }>;
  50733. }
  50734. /**
  50735. * Result of transcoding a basis file
  50736. */
  50737. class TranscodeResult {
  50738. /**
  50739. * Info about the .basis file
  50740. */
  50741. fileInfo: BasisFileInfo;
  50742. /**
  50743. * Format to use when loading the file
  50744. */
  50745. format: number;
  50746. }
  50747. /**
  50748. * Configuration options for the Basis transcoder
  50749. */
  50750. export class BasisTranscodeConfiguration {
  50751. /**
  50752. * Supported compression formats used to determine the supported output format of the transcoder
  50753. */
  50754. supportedCompressionFormats?: {
  50755. /**
  50756. * etc1 compression format
  50757. */
  50758. etc1?: boolean;
  50759. /**
  50760. * s3tc compression format
  50761. */
  50762. s3tc?: boolean;
  50763. /**
  50764. * pvrtc compression format
  50765. */
  50766. pvrtc?: boolean;
  50767. /**
  50768. * etc2 compression format
  50769. */
  50770. etc2?: boolean;
  50771. };
  50772. /**
  50773. * If mipmap levels should be loaded for transcoded images (Default: true)
  50774. */
  50775. loadMipmapLevels?: boolean;
  50776. /**
  50777. * Index of a single image to load (Default: all images)
  50778. */
  50779. loadSingleImage?: number;
  50780. }
  50781. /**
  50782. * Used to load .Basis files
  50783. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50784. */
  50785. export class BasisTools {
  50786. private static _IgnoreSupportedFormats;
  50787. /**
  50788. * URL to use when loading the basis transcoder
  50789. */
  50790. static JSModuleURL: string;
  50791. /**
  50792. * URL to use when loading the wasm module for the transcoder
  50793. */
  50794. static WasmModuleURL: string;
  50795. /**
  50796. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50797. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50798. * @returns internal format corresponding to the Basis format
  50799. */
  50800. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50801. private static _WorkerPromise;
  50802. private static _Worker;
  50803. private static _actionId;
  50804. private static _CreateWorkerAsync;
  50805. /**
  50806. * Transcodes a loaded image file to compressed pixel data
  50807. * @param imageData image data to transcode
  50808. * @param config configuration options for the transcoding
  50809. * @returns a promise resulting in the transcoded image
  50810. */
  50811. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50812. /**
  50813. * Loads a texture from the transcode result
  50814. * @param texture texture load to
  50815. * @param transcodeResult the result of transcoding the basis file to load from
  50816. */
  50817. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50818. }
  50819. }
  50820. declare module BABYLON {
  50821. /**
  50822. * Loader for .basis file format
  50823. */
  50824. export class _BasisTextureLoader implements IInternalTextureLoader {
  50825. /**
  50826. * Defines whether the loader supports cascade loading the different faces.
  50827. */
  50828. readonly supportCascades: boolean;
  50829. /**
  50830. * This returns if the loader support the current file information.
  50831. * @param extension defines the file extension of the file being loaded
  50832. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50833. * @param fallback defines the fallback internal texture if any
  50834. * @param isBase64 defines whether the texture is encoded as a base64
  50835. * @param isBuffer defines whether the texture data are stored as a buffer
  50836. * @returns true if the loader can load the specified file
  50837. */
  50838. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50839. /**
  50840. * Transform the url before loading if required.
  50841. * @param rootUrl the url of the texture
  50842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50843. * @returns the transformed texture
  50844. */
  50845. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50846. /**
  50847. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50848. * @param rootUrl the url of the texture
  50849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50850. * @returns the fallback texture
  50851. */
  50852. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50853. /**
  50854. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50855. * @param data contains the texture data
  50856. * @param texture defines the BabylonJS internal texture
  50857. * @param createPolynomials will be true if polynomials have been requested
  50858. * @param onLoad defines the callback to trigger once the texture is ready
  50859. * @param onError defines the callback to trigger in case of error
  50860. */
  50861. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50862. /**
  50863. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50864. * @param data contains the texture data
  50865. * @param texture defines the BabylonJS internal texture
  50866. * @param callback defines the method to call once ready to upload
  50867. */
  50868. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50869. }
  50870. }
  50871. declare module BABYLON {
  50872. /**
  50873. * 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.
  50874. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50876. */
  50877. export class CustomProceduralTexture extends ProceduralTexture {
  50878. private _animate;
  50879. private _time;
  50880. private _config;
  50881. private _texturePath;
  50882. /**
  50883. * Instantiates a new Custom Procedural Texture.
  50884. * 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.
  50885. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50886. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50887. * @param name Define the name of the texture
  50888. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50889. * @param size Define the size of the texture to create
  50890. * @param scene Define the scene the texture belongs to
  50891. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50892. * @param generateMipMaps Define if the texture should creates mip maps or not
  50893. */
  50894. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50895. private _loadJson;
  50896. /**
  50897. * Is the texture ready to be used ? (rendered at least once)
  50898. * @returns true if ready, otherwise, false.
  50899. */
  50900. isReady(): boolean;
  50901. /**
  50902. * Render the texture to its associated render target.
  50903. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50904. */
  50905. render(useCameraPostProcess?: boolean): void;
  50906. /**
  50907. * Update the list of dependant textures samplers in the shader.
  50908. */
  50909. updateTextures(): void;
  50910. /**
  50911. * Update the uniform values of the procedural texture in the shader.
  50912. */
  50913. updateShaderUniforms(): void;
  50914. /**
  50915. * Define if the texture animates or not.
  50916. */
  50917. animate: boolean;
  50918. }
  50919. }
  50920. declare module BABYLON {
  50921. /** @hidden */
  50922. export var noisePixelShader: {
  50923. name: string;
  50924. shader: string;
  50925. };
  50926. }
  50927. declare module BABYLON {
  50928. /**
  50929. * Class used to generate noise procedural textures
  50930. */
  50931. export class NoiseProceduralTexture extends ProceduralTexture {
  50932. private _time;
  50933. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50934. brightness: number;
  50935. /** Defines the number of octaves to process */
  50936. octaves: number;
  50937. /** Defines the level of persistence (0.8 by default) */
  50938. persistence: number;
  50939. /** Gets or sets animation speed factor (default is 1) */
  50940. animationSpeedFactor: number;
  50941. /**
  50942. * Creates a new NoiseProceduralTexture
  50943. * @param name defines the name fo the texture
  50944. * @param size defines the size of the texture (default is 256)
  50945. * @param scene defines the hosting scene
  50946. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50947. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50948. */
  50949. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50950. private _updateShaderUniforms;
  50951. protected _getDefines(): string;
  50952. /** Generate the current state of the procedural texture */
  50953. render(useCameraPostProcess?: boolean): void;
  50954. /**
  50955. * Serializes this noise procedural texture
  50956. * @returns a serialized noise procedural texture object
  50957. */
  50958. serialize(): any;
  50959. /**
  50960. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50961. * @param parsedTexture defines parsed texture data
  50962. * @param scene defines the current scene
  50963. * @param rootUrl defines the root URL containing noise procedural texture information
  50964. * @returns a parsed NoiseProceduralTexture
  50965. */
  50966. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50967. }
  50968. }
  50969. declare module BABYLON {
  50970. /**
  50971. * Raw cube texture where the raw buffers are passed in
  50972. */
  50973. export class RawCubeTexture extends CubeTexture {
  50974. /**
  50975. * Creates a cube texture where the raw buffers are passed in.
  50976. * @param scene defines the scene the texture is attached to
  50977. * @param data defines the array of data to use to create each face
  50978. * @param size defines the size of the textures
  50979. * @param format defines the format of the data
  50980. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50981. * @param generateMipMaps defines if the engine should generate the mip levels
  50982. * @param invertY defines if data must be stored with Y axis inverted
  50983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50984. * @param compression defines the compression used (null by default)
  50985. */
  50986. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50987. /**
  50988. * Updates the raw cube texture.
  50989. * @param data defines the data to store
  50990. * @param format defines the data format
  50991. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50992. * @param invertY defines if data must be stored with Y axis inverted
  50993. * @param compression defines the compression used (null by default)
  50994. * @param level defines which level of the texture to update
  50995. */
  50996. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50997. /**
  50998. * Updates a raw cube texture with RGBD encoded data.
  50999. * @param data defines the array of data [mipmap][face] to use to create each face
  51000. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51003. * @returns a promsie that resolves when the operation is complete
  51004. */
  51005. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51006. /**
  51007. * Clones the raw cube texture.
  51008. * @return a new cube texture
  51009. */
  51010. clone(): CubeTexture;
  51011. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51012. }
  51013. }
  51014. declare module BABYLON {
  51015. /**
  51016. * Class used to store 3D textures containing user data
  51017. */
  51018. export class RawTexture3D extends Texture {
  51019. /** Gets or sets the texture format to use */
  51020. format: number;
  51021. private _engine;
  51022. /**
  51023. * Create a new RawTexture3D
  51024. * @param data defines the data of the texture
  51025. * @param width defines the width of the texture
  51026. * @param height defines the height of the texture
  51027. * @param depth defines the depth of the texture
  51028. * @param format defines the texture format to use
  51029. * @param scene defines the hosting scene
  51030. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51031. * @param invertY defines if texture must be stored with Y axis inverted
  51032. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51033. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51034. */
  51035. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51036. /** Gets or sets the texture format to use */
  51037. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51038. /**
  51039. * Update the texture with new data
  51040. * @param data defines the data to store in the texture
  51041. */
  51042. update(data: ArrayBufferView): void;
  51043. }
  51044. }
  51045. declare module BABYLON {
  51046. /**
  51047. * Creates a refraction texture used by refraction channel of the standard material.
  51048. * It is like a mirror but to see through a material.
  51049. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51050. */
  51051. export class RefractionTexture extends RenderTargetTexture {
  51052. /**
  51053. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51054. * 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.
  51055. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51056. */
  51057. refractionPlane: Plane;
  51058. /**
  51059. * Define how deep under the surface we should see.
  51060. */
  51061. depth: number;
  51062. /**
  51063. * Creates a refraction texture used by refraction channel of the standard material.
  51064. * It is like a mirror but to see through a material.
  51065. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51066. * @param name Define the texture name
  51067. * @param size Define the size of the underlying texture
  51068. * @param scene Define the scene the refraction belongs to
  51069. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51070. */
  51071. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51072. /**
  51073. * Clone the refraction texture.
  51074. * @returns the cloned texture
  51075. */
  51076. clone(): RefractionTexture;
  51077. /**
  51078. * Serialize the texture to a JSON representation you could use in Parse later on
  51079. * @returns the serialized JSON representation
  51080. */
  51081. serialize(): any;
  51082. }
  51083. }
  51084. declare module BABYLON {
  51085. /**
  51086. * Defines the options related to the creation of an HtmlElementTexture
  51087. */
  51088. export interface IHtmlElementTextureOptions {
  51089. /**
  51090. * Defines wether mip maps should be created or not.
  51091. */
  51092. generateMipMaps?: boolean;
  51093. /**
  51094. * Defines the sampling mode of the texture.
  51095. */
  51096. samplingMode?: number;
  51097. /**
  51098. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51099. */
  51100. engine: Nullable<Engine>;
  51101. /**
  51102. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51103. */
  51104. scene: Nullable<Scene>;
  51105. }
  51106. /**
  51107. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51108. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51109. * is automatically managed.
  51110. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51111. * in your application.
  51112. *
  51113. * As the update is not automatic, you need to call them manually.
  51114. */
  51115. export class HtmlElementTexture extends BaseTexture {
  51116. /**
  51117. * The texture URL.
  51118. */
  51119. element: HTMLVideoElement | HTMLCanvasElement;
  51120. private static readonly DefaultOptions;
  51121. private _textureMatrix;
  51122. private _engine;
  51123. private _isVideo;
  51124. private _generateMipMaps;
  51125. private _samplingMode;
  51126. /**
  51127. * Instantiates a HtmlElementTexture from the following parameters.
  51128. *
  51129. * @param name Defines the name of the texture
  51130. * @param element Defines the video or canvas the texture is filled with
  51131. * @param options Defines the other none mandatory texture creation options
  51132. */
  51133. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51134. private _createInternalTexture;
  51135. /**
  51136. * Returns the texture matrix used in most of the material.
  51137. */
  51138. getTextureMatrix(): Matrix;
  51139. /**
  51140. * Updates the content of the texture.
  51141. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51142. */
  51143. update(invertY?: Nullable<boolean>): void;
  51144. }
  51145. }
  51146. declare module BABYLON {
  51147. /**
  51148. * Enum used to define the target of a block
  51149. */
  51150. export enum NodeMaterialBlockTargets {
  51151. /** Vertex shader */
  51152. Vertex = 1,
  51153. /** Fragment shader */
  51154. Fragment = 2,
  51155. /** Neutral */
  51156. Neutral = 4,
  51157. /** Vertex and Fragment */
  51158. VertexAndFragment = 3
  51159. }
  51160. }
  51161. declare module BABYLON {
  51162. /**
  51163. * Defines the kind of connection point for node based material
  51164. */
  51165. export enum NodeMaterialBlockConnectionPointTypes {
  51166. /** Float */
  51167. Float = 1,
  51168. /** Int */
  51169. Int = 2,
  51170. /** Vector2 */
  51171. Vector2 = 4,
  51172. /** Vector3 */
  51173. Vector3 = 8,
  51174. /** Vector4 */
  51175. Vector4 = 16,
  51176. /** Color3 */
  51177. Color3 = 32,
  51178. /** Color4 */
  51179. Color4 = 64,
  51180. /** Matrix */
  51181. Matrix = 128,
  51182. /** Detect type based on connection */
  51183. AutoDetect = 1024,
  51184. /** Output type that will be defined by input type */
  51185. BasedOnInput = 2048
  51186. }
  51187. }
  51188. declare module BABYLON {
  51189. /**
  51190. * Root class for all node material optimizers
  51191. */
  51192. export class NodeMaterialOptimizer {
  51193. /**
  51194. * Function used to optimize a NodeMaterial graph
  51195. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51196. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51197. */
  51198. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51199. }
  51200. }
  51201. declare module BABYLON {
  51202. /**
  51203. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51204. */
  51205. export class TransformBlock extends NodeMaterialBlock {
  51206. /**
  51207. * Defines the value to use to complement W value to transform it to a Vector4
  51208. */
  51209. complementW: number;
  51210. /**
  51211. * Defines the value to use to complement z value to transform it to a Vector4
  51212. */
  51213. complementZ: number;
  51214. /**
  51215. * Creates a new TransformBlock
  51216. * @param name defines the block name
  51217. */
  51218. constructor(name: string);
  51219. /**
  51220. * Gets the current class name
  51221. * @returns the class name
  51222. */
  51223. getClassName(): string;
  51224. /**
  51225. * Gets the vector input
  51226. */
  51227. readonly vector: NodeMaterialConnectionPoint;
  51228. /**
  51229. * Gets the output component
  51230. */
  51231. readonly output: NodeMaterialConnectionPoint;
  51232. /**
  51233. * Gets the matrix transform input
  51234. */
  51235. readonly transform: NodeMaterialConnectionPoint;
  51236. protected _buildBlock(state: NodeMaterialBuildState): this;
  51237. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51238. protected _dumpPropertiesCode(): string;
  51239. }
  51240. }
  51241. declare module BABYLON {
  51242. /**
  51243. * Block used to output the vertex position
  51244. */
  51245. export class VertexOutputBlock extends NodeMaterialBlock {
  51246. /**
  51247. * Creates a new VertexOutputBlock
  51248. * @param name defines the block name
  51249. */
  51250. constructor(name: string);
  51251. /**
  51252. * Gets the current class name
  51253. * @returns the class name
  51254. */
  51255. getClassName(): string;
  51256. /**
  51257. * Gets the vector input component
  51258. */
  51259. readonly vector: NodeMaterialConnectionPoint;
  51260. protected _buildBlock(state: NodeMaterialBuildState): this;
  51261. }
  51262. }
  51263. declare module BABYLON {
  51264. /**
  51265. * Block used to output the final color
  51266. */
  51267. export class FragmentOutputBlock extends NodeMaterialBlock {
  51268. /**
  51269. * Create a new FragmentOutputBlock
  51270. * @param name defines the block name
  51271. */
  51272. constructor(name: string);
  51273. /**
  51274. * Gets the current class name
  51275. * @returns the class name
  51276. */
  51277. getClassName(): string;
  51278. /**
  51279. * Gets the rgba input component
  51280. */
  51281. readonly rgba: NodeMaterialConnectionPoint;
  51282. /**
  51283. * Gets the rgb input component
  51284. */
  51285. readonly rgb: NodeMaterialConnectionPoint;
  51286. /**
  51287. * Gets the a input component
  51288. */
  51289. readonly a: NodeMaterialConnectionPoint;
  51290. protected _buildBlock(state: NodeMaterialBuildState): this;
  51291. }
  51292. }
  51293. declare module BABYLON {
  51294. /**
  51295. * Enum used to define system values e.g. values automatically provided by the system
  51296. */
  51297. export enum NodeMaterialSystemValues {
  51298. /** World */
  51299. World = 1,
  51300. /** View */
  51301. View = 2,
  51302. /** Projection */
  51303. Projection = 3,
  51304. /** ViewProjection */
  51305. ViewProjection = 4,
  51306. /** WorldView */
  51307. WorldView = 5,
  51308. /** WorldViewProjection */
  51309. WorldViewProjection = 6,
  51310. /** CameraPosition */
  51311. CameraPosition = 7,
  51312. /** Fog Color */
  51313. FogColor = 8
  51314. }
  51315. }
  51316. declare module BABYLON {
  51317. /**
  51318. * Block used to read a reflection texture from a sampler
  51319. */
  51320. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51321. private _define3DName;
  51322. private _defineCubicName;
  51323. private _defineExplicitName;
  51324. private _defineProjectionName;
  51325. private _defineLocalCubicName;
  51326. private _defineSphericalName;
  51327. private _definePlanarName;
  51328. private _defineEquirectangularName;
  51329. private _defineMirroredEquirectangularFixedName;
  51330. private _defineEquirectangularFixedName;
  51331. private _defineSkyboxName;
  51332. private _cubeSamplerName;
  51333. private _2DSamplerName;
  51334. private _positionUVWName;
  51335. private _directionWName;
  51336. private _reflectionCoordsName;
  51337. private _reflection2DCoordsName;
  51338. private _reflectionColorName;
  51339. private _reflectionMatrixName;
  51340. /**
  51341. * Gets or sets the texture associated with the node
  51342. */
  51343. texture: Nullable<BaseTexture>;
  51344. /**
  51345. * Create a new TextureBlock
  51346. * @param name defines the block name
  51347. */
  51348. constructor(name: string);
  51349. /**
  51350. * Gets the current class name
  51351. * @returns the class name
  51352. */
  51353. getClassName(): string;
  51354. /**
  51355. * Gets the world position input component
  51356. */
  51357. readonly position: NodeMaterialConnectionPoint;
  51358. /**
  51359. * Gets the world position input component
  51360. */
  51361. readonly worldPosition: NodeMaterialConnectionPoint;
  51362. /**
  51363. * Gets the world normal input component
  51364. */
  51365. readonly worldNormal: NodeMaterialConnectionPoint;
  51366. /**
  51367. * Gets the world input component
  51368. */
  51369. readonly world: NodeMaterialConnectionPoint;
  51370. /**
  51371. * Gets the camera (or eye) position component
  51372. */
  51373. readonly cameraPosition: NodeMaterialConnectionPoint;
  51374. /**
  51375. * Gets the view input component
  51376. */
  51377. readonly view: NodeMaterialConnectionPoint;
  51378. /**
  51379. * Gets the rgb output component
  51380. */
  51381. readonly rgb: NodeMaterialConnectionPoint;
  51382. /**
  51383. * Gets the r output component
  51384. */
  51385. readonly r: NodeMaterialConnectionPoint;
  51386. /**
  51387. * Gets the g output component
  51388. */
  51389. readonly g: NodeMaterialConnectionPoint;
  51390. /**
  51391. * Gets the b output component
  51392. */
  51393. readonly b: NodeMaterialConnectionPoint;
  51394. autoConfigure(material: NodeMaterial): void;
  51395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51396. isReady(): boolean;
  51397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51398. private _injectVertexCode;
  51399. private _writeOutput;
  51400. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51401. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51402. }
  51403. }
  51404. declare module BABYLON {
  51405. /**
  51406. * Interface used to configure the node material editor
  51407. */
  51408. export interface INodeMaterialEditorOptions {
  51409. /** Define the URl to load node editor script */
  51410. editorURL?: string;
  51411. }
  51412. /** @hidden */
  51413. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51414. /** BONES */
  51415. NUM_BONE_INFLUENCERS: number;
  51416. BonesPerMesh: number;
  51417. BONETEXTURE: boolean;
  51418. /** MORPH TARGETS */
  51419. MORPHTARGETS: boolean;
  51420. MORPHTARGETS_NORMAL: boolean;
  51421. MORPHTARGETS_TANGENT: boolean;
  51422. MORPHTARGETS_UV: boolean;
  51423. NUM_MORPH_INFLUENCERS: number;
  51424. /** IMAGE PROCESSING */
  51425. IMAGEPROCESSING: boolean;
  51426. VIGNETTE: boolean;
  51427. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51428. VIGNETTEBLENDMODEOPAQUE: boolean;
  51429. TONEMAPPING: boolean;
  51430. TONEMAPPING_ACES: boolean;
  51431. CONTRAST: boolean;
  51432. EXPOSURE: boolean;
  51433. COLORCURVES: boolean;
  51434. COLORGRADING: boolean;
  51435. COLORGRADING3D: boolean;
  51436. SAMPLER3DGREENDEPTH: boolean;
  51437. SAMPLER3DBGRMAP: boolean;
  51438. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51439. constructor();
  51440. setValue(name: string, value: boolean): void;
  51441. }
  51442. /**
  51443. * Class used to configure NodeMaterial
  51444. */
  51445. export interface INodeMaterialOptions {
  51446. /**
  51447. * Defines if blocks should emit comments
  51448. */
  51449. emitComments: boolean;
  51450. }
  51451. /**
  51452. * Class used to create a node based material built by assembling shader blocks
  51453. */
  51454. export class NodeMaterial extends PushMaterial {
  51455. private static _BuildIdGenerator;
  51456. private _options;
  51457. private _vertexCompilationState;
  51458. private _fragmentCompilationState;
  51459. private _sharedData;
  51460. private _buildId;
  51461. private _buildWasSuccessful;
  51462. private _cachedWorldViewMatrix;
  51463. private _cachedWorldViewProjectionMatrix;
  51464. private _optimizers;
  51465. private _animationFrame;
  51466. /** Define the URl to load node editor script */
  51467. static EditorURL: string;
  51468. private BJSNODEMATERIALEDITOR;
  51469. /** Get the inspector from bundle or global */
  51470. private _getGlobalNodeMaterialEditor;
  51471. /**
  51472. * 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)
  51473. */
  51474. ignoreAlpha: boolean;
  51475. /**
  51476. * Defines the maximum number of lights that can be used in the material
  51477. */
  51478. maxSimultaneousLights: number;
  51479. /**
  51480. * Observable raised when the material is built
  51481. */
  51482. onBuildObservable: Observable<NodeMaterial>;
  51483. /**
  51484. * Gets or sets the root nodes of the material vertex shader
  51485. */ private _vertexOutputNodes: NodeMaterialBlock[];
  51486. /**
  51487. * Gets or sets the root nodes of the material fragment (pixel) shader
  51488. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  51489. /** Gets or sets options to control the node material overall behavior */
  51490. options: INodeMaterialOptions;
  51491. /**
  51492. * Default configuration related to image processing available in the standard Material.
  51493. */
  51494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51495. /**
  51496. * Gets the image processing configuration used either in this material.
  51497. */
  51498. /**
  51499. * Sets the Default image processing configuration used either in the this material.
  51500. *
  51501. * If sets to null, the scene one is in use.
  51502. */
  51503. imageProcessingConfiguration: ImageProcessingConfiguration;
  51504. /**
  51505. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51506. */
  51507. attachedBlocks: NodeMaterialBlock[];
  51508. /**
  51509. * Create a new node based material
  51510. * @param name defines the material name
  51511. * @param scene defines the hosting scene
  51512. * @param options defines creation option
  51513. */
  51514. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51515. /**
  51516. * Gets the current class name of the material e.g. "NodeMaterial"
  51517. * @returns the class name
  51518. */
  51519. getClassName(): string;
  51520. /**
  51521. * Keep track of the image processing observer to allow dispose and replace.
  51522. */
  51523. private _imageProcessingObserver;
  51524. /**
  51525. * Attaches a new image processing configuration to the Standard Material.
  51526. * @param configuration
  51527. */
  51528. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51529. /**
  51530. * Get a block by its name
  51531. * @param name defines the name of the block to retrieve
  51532. * @returns the required block or null if not found
  51533. */
  51534. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  51535. /**
  51536. * Get a block by its name
  51537. * @param predicate defines the predicate used to find the good candidate
  51538. * @returns the required block or null if not found
  51539. */
  51540. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  51541. /**
  51542. * Get an input block by its name
  51543. * @param predicate defines the predicate used to find the good candidate
  51544. * @returns the required input block or null if not found
  51545. */
  51546. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  51547. /**
  51548. * Gets the list of input blocks attached to this material
  51549. * @returns an array of InputBlocks
  51550. */
  51551. getInputBlocks(): InputBlock[];
  51552. /**
  51553. * Adds a new optimizer to the list of optimizers
  51554. * @param optimizer defines the optimizers to add
  51555. * @returns the current material
  51556. */
  51557. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51558. /**
  51559. * Remove an optimizer from the list of optimizers
  51560. * @param optimizer defines the optimizers to remove
  51561. * @returns the current material
  51562. */
  51563. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51564. /**
  51565. * Add a new block to the list of output nodes
  51566. * @param node defines the node to add
  51567. * @returns the current material
  51568. */
  51569. addOutputNode(node: NodeMaterialBlock): this;
  51570. /**
  51571. * Remove a block from the list of root nodes
  51572. * @param node defines the node to remove
  51573. * @returns the current material
  51574. */
  51575. removeOutputNode(node: NodeMaterialBlock): this;
  51576. private _addVertexOutputNode;
  51577. private _removeVertexOutputNode;
  51578. private _addFragmentOutputNode;
  51579. private _removeFragmentOutputNode;
  51580. /**
  51581. * Specifies if the material will require alpha blending
  51582. * @returns a boolean specifying if alpha blending is needed
  51583. */
  51584. needAlphaBlending(): boolean;
  51585. /**
  51586. * Specifies if this material should be rendered in alpha test mode
  51587. * @returns a boolean specifying if an alpha test is needed.
  51588. */
  51589. needAlphaTesting(): boolean;
  51590. private _initializeBlock;
  51591. private _resetDualBlocks;
  51592. /**
  51593. * Build the material and generates the inner effect
  51594. * @param verbose defines if the build should log activity
  51595. */
  51596. build(verbose?: boolean): void;
  51597. /**
  51598. * Runs an otpimization phase to try to improve the shader code
  51599. */
  51600. optimize(): void;
  51601. private _prepareDefinesForAttributes;
  51602. /**
  51603. * Get if the submesh is ready to be used and all its information available.
  51604. * Child classes can use it to update shaders
  51605. * @param mesh defines the mesh to check
  51606. * @param subMesh defines which submesh to check
  51607. * @param useInstances specifies that instances should be used
  51608. * @returns a boolean indicating that the submesh is ready or not
  51609. */
  51610. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51611. /**
  51612. * Get a string representing the shaders built by the current node graph
  51613. */
  51614. readonly compiledShaders: string;
  51615. /**
  51616. * Binds the world matrix to the material
  51617. * @param world defines the world transformation matrix
  51618. */
  51619. bindOnlyWorldMatrix(world: Matrix): void;
  51620. /**
  51621. * Binds the submesh to this material by preparing the effect and shader to draw
  51622. * @param world defines the world transformation matrix
  51623. * @param mesh defines the mesh containing the submesh
  51624. * @param subMesh defines the submesh to bind the material to
  51625. */
  51626. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51627. /**
  51628. * Gets the active textures from the material
  51629. * @returns an array of textures
  51630. */
  51631. getActiveTextures(): BaseTexture[];
  51632. /**
  51633. * Gets the list of texture blocks
  51634. * @returns an array of texture blocks
  51635. */
  51636. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  51637. /**
  51638. * Specifies if the material uses a texture
  51639. * @param texture defines the texture to check against the material
  51640. * @returns a boolean specifying if the material uses the texture
  51641. */
  51642. hasTexture(texture: BaseTexture): boolean;
  51643. /**
  51644. * Disposes the material
  51645. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51646. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51647. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51648. */
  51649. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51650. /** Creates the node editor window. */
  51651. private _createNodeEditor;
  51652. /**
  51653. * Launch the node material editor
  51654. * @param config Define the configuration of the editor
  51655. * @return a promise fulfilled when the node editor is visible
  51656. */
  51657. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51658. /**
  51659. * Clear the current material
  51660. */
  51661. clear(): void;
  51662. /**
  51663. * Clear the current material and set it to a default state
  51664. */
  51665. setToDefault(): void;
  51666. /**
  51667. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  51668. * @param url defines the url to load from
  51669. * @returns a promise that will fullfil when the material is fully loaded
  51670. */
  51671. loadAsync(url: string): Promise<unknown>;
  51672. private _gatherBlocks;
  51673. /**
  51674. * Generate a string containing the code declaration required to create an equivalent of this material
  51675. * @returns a string
  51676. */
  51677. generateCode(): string;
  51678. /**
  51679. * Serializes this material in a JSON representation
  51680. * @returns the serialized material object
  51681. */
  51682. serialize(): any;
  51683. private _restoreConnections;
  51684. /**
  51685. * Clear the current graph and load a new one from a serialization object
  51686. * @param source defines the JSON representation of the material
  51687. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51688. */
  51689. loadFromSerialization(source: any, rootUrl?: string): void;
  51690. /**
  51691. * Creates a node material from parsed material data
  51692. * @param source defines the JSON representation of the material
  51693. * @param scene defines the hosting scene
  51694. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51695. * @returns a new node material
  51696. */
  51697. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51698. /**
  51699. * Creates a new node material set to default basic configuration
  51700. * @param name defines the name of the material
  51701. * @param scene defines the hosting scene
  51702. * @returns a new NodeMaterial
  51703. */
  51704. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  51705. }
  51706. }
  51707. declare module BABYLON {
  51708. /**
  51709. * Block used to read a texture from a sampler
  51710. */
  51711. export class TextureBlock extends NodeMaterialBlock {
  51712. private _defineName;
  51713. private _samplerName;
  51714. private _transformedUVName;
  51715. private _textureTransformName;
  51716. private _textureInfoName;
  51717. private _mainUVName;
  51718. private _mainUVDefineName;
  51719. /**
  51720. * Gets or sets the texture associated with the node
  51721. */
  51722. texture: Nullable<BaseTexture>;
  51723. /**
  51724. * Create a new TextureBlock
  51725. * @param name defines the block name
  51726. */
  51727. constructor(name: string);
  51728. /**
  51729. * Gets the current class name
  51730. * @returns the class name
  51731. */
  51732. getClassName(): string;
  51733. /**
  51734. * Gets the uv input component
  51735. */
  51736. readonly uv: NodeMaterialConnectionPoint;
  51737. /**
  51738. * Gets the rgba output component
  51739. */
  51740. readonly rgba: NodeMaterialConnectionPoint;
  51741. /**
  51742. * Gets the rgb output component
  51743. */
  51744. readonly rgb: NodeMaterialConnectionPoint;
  51745. /**
  51746. * Gets the r output component
  51747. */
  51748. readonly r: NodeMaterialConnectionPoint;
  51749. /**
  51750. * Gets the g output component
  51751. */
  51752. readonly g: NodeMaterialConnectionPoint;
  51753. /**
  51754. * Gets the b output component
  51755. */
  51756. readonly b: NodeMaterialConnectionPoint;
  51757. /**
  51758. * Gets the a output component
  51759. */
  51760. readonly a: NodeMaterialConnectionPoint;
  51761. readonly target: NodeMaterialBlockTargets;
  51762. autoConfigure(material: NodeMaterial): void;
  51763. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51765. isReady(): boolean;
  51766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51767. private readonly _isMixed;
  51768. private _injectVertexCode;
  51769. private _writeOutput;
  51770. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51771. protected _dumpPropertiesCode(): string;
  51772. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51773. }
  51774. }
  51775. declare module BABYLON {
  51776. /**
  51777. * Class used to store shared data between 2 NodeMaterialBuildState
  51778. */
  51779. export class NodeMaterialBuildStateSharedData {
  51780. /**
  51781. * Gets the list of emitted varyings
  51782. */
  51783. temps: string[];
  51784. /**
  51785. * Gets the list of emitted varyings
  51786. */
  51787. varyings: string[];
  51788. /**
  51789. * Gets the varying declaration string
  51790. */
  51791. varyingDeclaration: string;
  51792. /**
  51793. * Input blocks
  51794. */
  51795. inputBlocks: InputBlock[];
  51796. /**
  51797. * Input blocks
  51798. */
  51799. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  51800. /**
  51801. * Bindable blocks (Blocks that need to set data to the effect)
  51802. */
  51803. bindableBlocks: NodeMaterialBlock[];
  51804. /**
  51805. * List of blocks that can provide a compilation fallback
  51806. */
  51807. blocksWithFallbacks: NodeMaterialBlock[];
  51808. /**
  51809. * List of blocks that can provide a define update
  51810. */
  51811. blocksWithDefines: NodeMaterialBlock[];
  51812. /**
  51813. * List of blocks that can provide a repeatable content
  51814. */
  51815. repeatableContentBlocks: NodeMaterialBlock[];
  51816. /**
  51817. * List of blocks that can provide a dynamic list of uniforms
  51818. */
  51819. dynamicUniformBlocks: NodeMaterialBlock[];
  51820. /**
  51821. * List of blocks that can block the isReady function for the material
  51822. */
  51823. blockingBlocks: NodeMaterialBlock[];
  51824. /**
  51825. * Gets the list of animated inputs
  51826. */
  51827. animatedInputs: InputBlock[];
  51828. /**
  51829. * Build Id used to avoid multiple recompilations
  51830. */
  51831. buildId: number;
  51832. /** List of emitted variables */
  51833. variableNames: {
  51834. [key: string]: number;
  51835. };
  51836. /** List of emitted defines */
  51837. defineNames: {
  51838. [key: string]: number;
  51839. };
  51840. /** Should emit comments? */
  51841. emitComments: boolean;
  51842. /** Emit build activity */
  51843. verbose: boolean;
  51844. /**
  51845. * Gets the compilation hints emitted at compilation time
  51846. */
  51847. hints: {
  51848. needWorldViewMatrix: boolean;
  51849. needWorldViewProjectionMatrix: boolean;
  51850. needAlphaBlending: boolean;
  51851. needAlphaTesting: boolean;
  51852. };
  51853. /**
  51854. * List of compilation checks
  51855. */
  51856. checks: {
  51857. emitVertex: boolean;
  51858. emitFragment: boolean;
  51859. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51860. };
  51861. /** Creates a new shared data */
  51862. constructor();
  51863. /**
  51864. * Emits console errors and exceptions if there is a failing check
  51865. */
  51866. emitErrors(): void;
  51867. }
  51868. }
  51869. declare module BABYLON {
  51870. /**
  51871. * Class used to store node based material build state
  51872. */
  51873. export class NodeMaterialBuildState {
  51874. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51875. supportUniformBuffers: boolean;
  51876. /**
  51877. * Gets the list of emitted attributes
  51878. */
  51879. attributes: string[];
  51880. /**
  51881. * Gets the list of emitted uniforms
  51882. */
  51883. uniforms: string[];
  51884. /**
  51885. * Gets the list of emitted uniform buffers
  51886. */
  51887. uniformBuffers: string[];
  51888. /**
  51889. * Gets the list of emitted samplers
  51890. */
  51891. samplers: string[];
  51892. /**
  51893. * Gets the list of emitted functions
  51894. */
  51895. functions: {
  51896. [key: string]: string;
  51897. };
  51898. /**
  51899. * Gets the target of the compilation state
  51900. */
  51901. target: NodeMaterialBlockTargets;
  51902. /**
  51903. * Gets the list of emitted counters
  51904. */
  51905. counters: {
  51906. [key: string]: number;
  51907. };
  51908. /**
  51909. * Shared data between multiple NodeMaterialBuildState instances
  51910. */
  51911. sharedData: NodeMaterialBuildStateSharedData;
  51912. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  51913. /** @hidden */ private _attributeDeclaration: string;
  51914. /** @hidden */ private _uniformDeclaration: string;
  51915. /** @hidden */ private _samplerDeclaration: string;
  51916. /** @hidden */ private _varyingTransfer: string;
  51917. private _repeatableContentAnchorIndex;
  51918. /** @hidden */ private _builtCompilationString: string;
  51919. /**
  51920. * Gets the emitted compilation strings
  51921. */
  51922. compilationString: string;
  51923. /**
  51924. * Finalize the compilation strings
  51925. * @param state defines the current compilation state
  51926. */
  51927. finalize(state: NodeMaterialBuildState): void;
  51928. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  51929. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  51930. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  51931. /** @hidden */ private _excludeVariableName(name: string): void;
  51932. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51933. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  51934. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51935. replaceStrings?: {
  51936. search: RegExp;
  51937. replace: string;
  51938. }[];
  51939. repeatKey?: string;
  51940. }): string;
  51941. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51942. repeatKey?: string;
  51943. removeAttributes?: boolean;
  51944. removeUniforms?: boolean;
  51945. removeVaryings?: boolean;
  51946. removeIfDef?: boolean;
  51947. replaceStrings?: {
  51948. search: RegExp;
  51949. replace: string;
  51950. }[];
  51951. }, storeKey?: string): void;
  51952. /** @hidden */ private _registerTempVariable(name: string): boolean;
  51953. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  51954. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51955. }
  51956. }
  51957. declare module BABYLON {
  51958. /**
  51959. * Defines a block that can be used inside a node based material
  51960. */
  51961. export class NodeMaterialBlock {
  51962. private _buildId;
  51963. private _buildTarget;
  51964. private _target;
  51965. private _isFinalMerger;
  51966. private _isInput;
  51967. /** @hidden */ private _codeVariableName: string;
  51968. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  51969. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  51970. /** @hidden */ private _preparationId: number;
  51971. /**
  51972. * Gets or sets the name of the block
  51973. */
  51974. name: string;
  51975. /**
  51976. * Gets or sets the unique id of the node
  51977. */
  51978. uniqueId: number;
  51979. /**
  51980. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51981. */
  51982. readonly isFinalMerger: boolean;
  51983. /**
  51984. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51985. */
  51986. readonly isInput: boolean;
  51987. /**
  51988. * Gets or sets the build Id
  51989. */
  51990. buildId: number;
  51991. /**
  51992. * Gets or sets the target of the block
  51993. */
  51994. target: NodeMaterialBlockTargets;
  51995. /**
  51996. * Gets the list of input points
  51997. */
  51998. readonly inputs: NodeMaterialConnectionPoint[];
  51999. /** Gets the list of output points */
  52000. readonly outputs: NodeMaterialConnectionPoint[];
  52001. /**
  52002. * Find an input by its name
  52003. * @param name defines the name of the input to look for
  52004. * @returns the input or null if not found
  52005. */
  52006. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52007. /**
  52008. * Find an output by its name
  52009. * @param name defines the name of the outputto look for
  52010. * @returns the output or null if not found
  52011. */
  52012. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52013. /**
  52014. * Creates a new NodeMaterialBlock
  52015. * @param name defines the block name
  52016. * @param target defines the target of that block (Vertex by default)
  52017. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52018. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52019. */
  52020. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52021. /**
  52022. * Initialize the block and prepare the context for build
  52023. * @param state defines the state that will be used for the build
  52024. */
  52025. initialize(state: NodeMaterialBuildState): void;
  52026. /**
  52027. * Bind data to effect. Will only be called for blocks with isBindable === true
  52028. * @param effect defines the effect to bind data to
  52029. * @param nodeMaterial defines the hosting NodeMaterial
  52030. * @param mesh defines the mesh that will be rendered
  52031. */
  52032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52033. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52034. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52035. protected _writeFloat(value: number): string;
  52036. /**
  52037. * Gets the current class name e.g. "NodeMaterialBlock"
  52038. * @returns the class name
  52039. */
  52040. getClassName(): string;
  52041. /**
  52042. * Register a new input. Must be called inside a block constructor
  52043. * @param name defines the connection point name
  52044. * @param type defines the connection point type
  52045. * @param isOptional defines a boolean indicating that this input can be omitted
  52046. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52047. * @returns the current block
  52048. */
  52049. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52050. /**
  52051. * Register a new output. Must be called inside a block constructor
  52052. * @param name defines the connection point name
  52053. * @param type defines the connection point type
  52054. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52055. * @returns the current block
  52056. */
  52057. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52058. /**
  52059. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52060. * @param forOutput defines an optional connection point to check compatibility with
  52061. * @returns the first available input or null
  52062. */
  52063. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52064. /**
  52065. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52066. * @param forBlock defines an optional block to check compatibility with
  52067. * @returns the first available input or null
  52068. */
  52069. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52070. /**
  52071. * Gets the sibling of the given output
  52072. * @param current defines the current output
  52073. * @returns the next output in the list or null
  52074. */
  52075. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52076. /**
  52077. * Connect current block with another block
  52078. * @param other defines the block to connect with
  52079. * @param options define the various options to help pick the right connections
  52080. * @returns the current block
  52081. */
  52082. connectTo(other: NodeMaterialBlock, options?: {
  52083. input?: string;
  52084. output?: string;
  52085. outputSwizzle?: string;
  52086. }): this | undefined;
  52087. protected _buildBlock(state: NodeMaterialBuildState): void;
  52088. /**
  52089. * Add uniforms, samplers and uniform buffers at compilation time
  52090. * @param state defines the state to update
  52091. * @param nodeMaterial defines the node material requesting the update
  52092. * @param defines defines the material defines to update
  52093. */
  52094. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52095. /**
  52096. * Add potential fallbacks if shader compilation fails
  52097. * @param mesh defines the mesh to be rendered
  52098. * @param fallbacks defines the current prioritized list of fallbacks
  52099. */
  52100. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52101. /**
  52102. * Update defines for shader compilation
  52103. * @param mesh defines the mesh to be rendered
  52104. * @param nodeMaterial defines the node material requesting the update
  52105. * @param defines defines the material defines to update
  52106. * @param useInstances specifies that instances should be used
  52107. */
  52108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52109. /**
  52110. * Initialize defines for shader compilation
  52111. * @param mesh defines the mesh to be rendered
  52112. * @param nodeMaterial defines the node material requesting the update
  52113. * @param defines defines the material defines to be prepared
  52114. * @param useInstances specifies that instances should be used
  52115. */
  52116. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52117. /**
  52118. * Lets the block try to connect some inputs automatically
  52119. * @param material defines the hosting NodeMaterial
  52120. */
  52121. autoConfigure(material: NodeMaterial): void;
  52122. /**
  52123. * Function called when a block is declared as repeatable content generator
  52124. * @param vertexShaderState defines the current compilation state for the vertex shader
  52125. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52126. * @param mesh defines the mesh to be rendered
  52127. * @param defines defines the material defines to update
  52128. */
  52129. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52130. /**
  52131. * Checks if the block is ready
  52132. * @param mesh defines the mesh to be rendered
  52133. * @param nodeMaterial defines the node material requesting the update
  52134. * @param defines defines the material defines to update
  52135. * @param useInstances specifies that instances should be used
  52136. * @returns true if the block is ready
  52137. */
  52138. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52139. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52140. private _processBuild;
  52141. /**
  52142. * Compile the current node and generate the shader code
  52143. * @param state defines the current compilation state (uniforms, samplers, current string)
  52144. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52145. * @returns true if already built
  52146. */
  52147. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52148. protected _inputRename(name: string): string;
  52149. protected _outputRename(name: string): string;
  52150. protected _dumpPropertiesCode(): string;
  52151. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52152. /**
  52153. * Clone the current block to a new identical block
  52154. * @param scene defines the hosting scene
  52155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52156. * @returns a copy of the current block
  52157. */
  52158. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52159. /**
  52160. * Serializes this block in a JSON representation
  52161. * @returns the serialized block object
  52162. */
  52163. serialize(): any;
  52164. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52165. }
  52166. }
  52167. declare module BABYLON {
  52168. /**
  52169. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52170. */
  52171. export enum NodeMaterialBlockConnectionPointMode {
  52172. /** Value is an uniform */
  52173. Uniform = 0,
  52174. /** Value is a mesh attribute */
  52175. Attribute = 1,
  52176. /** Value is a varying between vertex and fragment shaders */
  52177. Varying = 2,
  52178. /** Mode is undefined */
  52179. Undefined = 3
  52180. }
  52181. }
  52182. declare module BABYLON {
  52183. /**
  52184. * Enum defining the type of animations supported by InputBlock
  52185. */
  52186. export enum AnimatedInputBlockTypes {
  52187. /** No animation */
  52188. None = 0,
  52189. /** Time based animation. Will only work for floats */
  52190. Time = 1
  52191. }
  52192. }
  52193. declare module BABYLON {
  52194. /**
  52195. * Block used to expose an input value
  52196. */
  52197. export class InputBlock extends NodeMaterialBlock {
  52198. private _mode;
  52199. private _associatedVariableName;
  52200. private _storedValue;
  52201. private _valueCallback;
  52202. private _type;
  52203. private _animationType;
  52204. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52205. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52206. visibleInInspector: boolean;
  52207. /**
  52208. * Gets or sets the connection point type (default is float)
  52209. */
  52210. readonly type: NodeMaterialBlockConnectionPointTypes;
  52211. /**
  52212. * Creates a new InputBlock
  52213. * @param name defines the block name
  52214. * @param target defines the target of that block (Vertex by default)
  52215. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52216. */
  52217. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52218. /**
  52219. * Gets the output component
  52220. */
  52221. readonly output: NodeMaterialConnectionPoint;
  52222. /**
  52223. * Set the source of this connection point to a vertex attribute
  52224. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52225. * @returns the current connection point
  52226. */
  52227. setAsAttribute(attributeName?: string): InputBlock;
  52228. /**
  52229. * Set the source of this connection point to a system value
  52230. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52231. * @returns the current connection point
  52232. */
  52233. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52234. /**
  52235. * Gets or sets the value of that point.
  52236. * Please note that this value will be ignored if valueCallback is defined
  52237. */
  52238. value: any;
  52239. /**
  52240. * Gets or sets a callback used to get the value of that point.
  52241. * Please note that setting this value will force the connection point to ignore the value property
  52242. */
  52243. valueCallback: () => any;
  52244. /**
  52245. * Gets or sets the associated variable name in the shader
  52246. */
  52247. associatedVariableName: string;
  52248. /** Gets or sets the type of animation applied to the input */
  52249. animationType: AnimatedInputBlockTypes;
  52250. /**
  52251. * Gets a boolean indicating that this connection point not defined yet
  52252. */
  52253. readonly isUndefined: boolean;
  52254. /**
  52255. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52256. * In this case the connection point name must be the name of the uniform to use.
  52257. * Can only be set on inputs
  52258. */
  52259. isUniform: boolean;
  52260. /**
  52261. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52262. * In this case the connection point name must be the name of the attribute to use
  52263. * Can only be set on inputs
  52264. */
  52265. isAttribute: boolean;
  52266. /**
  52267. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52268. * Can only be set on exit points
  52269. */
  52270. isVarying: boolean;
  52271. /**
  52272. * Gets a boolean indicating that the current connection point is a system value
  52273. */
  52274. readonly isSystemValue: boolean;
  52275. /**
  52276. * Gets or sets the current well known value or null if not defined as a system value
  52277. */
  52278. systemValue: Nullable<NodeMaterialSystemValues>;
  52279. /**
  52280. * Gets the current class name
  52281. * @returns the class name
  52282. */
  52283. getClassName(): string;
  52284. /**
  52285. * Animate the input if animationType !== None
  52286. * @param scene defines the rendering scene
  52287. */
  52288. animate(scene: Scene): void;
  52289. private _emitDefine;
  52290. /**
  52291. * Set the input block to its default value (based on its type)
  52292. */
  52293. setDefaultValue(): void;
  52294. protected _dumpPropertiesCode(): string;
  52295. private _emit;
  52296. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52297. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52298. protected _buildBlock(state: NodeMaterialBuildState): void;
  52299. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52300. }
  52301. }
  52302. declare module BABYLON {
  52303. /**
  52304. * Defines a connection point for a block
  52305. */
  52306. export class NodeMaterialConnectionPoint {
  52307. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52308. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52309. private _endpoints;
  52310. private _associatedVariableName;
  52311. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52312. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52313. private _type;
  52314. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52315. /**
  52316. * Gets or sets the additional types supported byt this connection point
  52317. */
  52318. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52319. /**
  52320. * Gets or sets the associated variable name in the shader
  52321. */
  52322. associatedVariableName: string;
  52323. /**
  52324. * Gets or sets the connection point type (default is float)
  52325. */
  52326. type: NodeMaterialBlockConnectionPointTypes;
  52327. /**
  52328. * Gets or sets the connection point name
  52329. */
  52330. name: string;
  52331. /**
  52332. * Gets or sets a boolean indicating that this connection point can be omitted
  52333. */
  52334. isOptional: boolean;
  52335. /**
  52336. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52337. */
  52338. define: string;
  52339. /** Gets or sets the target of that connection point */
  52340. target: NodeMaterialBlockTargets;
  52341. /**
  52342. * Gets a boolean indicating that the current point is connected
  52343. */
  52344. readonly isConnected: boolean;
  52345. /**
  52346. * Gets a boolean indicating that the current point is connected to an input block
  52347. */
  52348. readonly isConnectedToInputBlock: boolean;
  52349. /**
  52350. * Gets a the connected input block (if any)
  52351. */
  52352. readonly connectInputBlock: Nullable<InputBlock>;
  52353. /** Get the other side of the connection (if any) */
  52354. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52355. /** Get the block that owns this connection point */
  52356. readonly ownerBlock: NodeMaterialBlock;
  52357. /** Get the block connected on the other side of this connection (if any) */
  52358. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52359. /** Get the block connected on the endpoints of this connection (if any) */
  52360. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52361. /** Gets the list of connected endpoints */
  52362. readonly endpoints: NodeMaterialConnectionPoint[];
  52363. /** Gets a boolean indicating if that output point is connected to at least one input */
  52364. readonly hasEndpoints: boolean;
  52365. /**
  52366. * Creates a new connection point
  52367. * @param name defines the connection point name
  52368. * @param ownerBlock defines the block hosting this connection point
  52369. */
  52370. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52371. /**
  52372. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52373. * @returns the class name
  52374. */
  52375. getClassName(): string;
  52376. /**
  52377. * Gets an boolean indicating if the current point can be connected to another point
  52378. * @param connectionPoint defines the other connection point
  52379. * @returns true if the connection is possible
  52380. */
  52381. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52382. /**
  52383. * Connect this point to another connection point
  52384. * @param connectionPoint defines the other connection point
  52385. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52386. * @returns the current connection point
  52387. */
  52388. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52389. /**
  52390. * Disconnect this point from one of his endpoint
  52391. * @param endpoint defines the other connection point
  52392. * @returns the current connection point
  52393. */
  52394. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52395. /**
  52396. * Serializes this point in a JSON representation
  52397. * @returns the serialized point object
  52398. */
  52399. serialize(): any;
  52400. }
  52401. }
  52402. declare module BABYLON {
  52403. /**
  52404. * Block used to add support for vertex skinning (bones)
  52405. */
  52406. export class BonesBlock extends NodeMaterialBlock {
  52407. /**
  52408. * Creates a new BonesBlock
  52409. * @param name defines the block name
  52410. */
  52411. constructor(name: string);
  52412. /**
  52413. * Initialize the block and prepare the context for build
  52414. * @param state defines the state that will be used for the build
  52415. */
  52416. initialize(state: NodeMaterialBuildState): void;
  52417. /**
  52418. * Gets the current class name
  52419. * @returns the class name
  52420. */
  52421. getClassName(): string;
  52422. /**
  52423. * Gets the matrix indices input component
  52424. */
  52425. readonly matricesIndices: NodeMaterialConnectionPoint;
  52426. /**
  52427. * Gets the matrix weights input component
  52428. */
  52429. readonly matricesWeights: NodeMaterialConnectionPoint;
  52430. /**
  52431. * Gets the extra matrix indices input component
  52432. */
  52433. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52434. /**
  52435. * Gets the extra matrix weights input component
  52436. */
  52437. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52438. /**
  52439. * Gets the world input component
  52440. */
  52441. readonly world: NodeMaterialConnectionPoint;
  52442. /**
  52443. * Gets the output component
  52444. */
  52445. readonly output: NodeMaterialConnectionPoint;
  52446. autoConfigure(material: NodeMaterial): void;
  52447. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52449. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52450. protected _buildBlock(state: NodeMaterialBuildState): this;
  52451. }
  52452. }
  52453. declare module BABYLON {
  52454. /**
  52455. * Block used to add support for instances
  52456. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52457. */
  52458. export class InstancesBlock extends NodeMaterialBlock {
  52459. /**
  52460. * Creates a new InstancesBlock
  52461. * @param name defines the block name
  52462. */
  52463. constructor(name: string);
  52464. /**
  52465. * Gets the current class name
  52466. * @returns the class name
  52467. */
  52468. getClassName(): string;
  52469. /**
  52470. * Gets the first world row input component
  52471. */
  52472. readonly world0: NodeMaterialConnectionPoint;
  52473. /**
  52474. * Gets the second world row input component
  52475. */
  52476. readonly world1: NodeMaterialConnectionPoint;
  52477. /**
  52478. * Gets the third world row input component
  52479. */
  52480. readonly world2: NodeMaterialConnectionPoint;
  52481. /**
  52482. * Gets the forth world row input component
  52483. */
  52484. readonly world3: NodeMaterialConnectionPoint;
  52485. /**
  52486. * Gets the world input component
  52487. */
  52488. readonly world: NodeMaterialConnectionPoint;
  52489. /**
  52490. * Gets the output component
  52491. */
  52492. readonly output: NodeMaterialConnectionPoint;
  52493. autoConfigure(material: NodeMaterial): void;
  52494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52495. protected _buildBlock(state: NodeMaterialBuildState): this;
  52496. }
  52497. }
  52498. declare module BABYLON {
  52499. /**
  52500. * Block used to add morph targets support to vertex shader
  52501. */
  52502. export class MorphTargetsBlock extends NodeMaterialBlock {
  52503. private _repeatableContentAnchor;
  52504. private _repeatebleContentGenerated;
  52505. /**
  52506. * Create a new MorphTargetsBlock
  52507. * @param name defines the block name
  52508. */
  52509. constructor(name: string);
  52510. /**
  52511. * Gets the current class name
  52512. * @returns the class name
  52513. */
  52514. getClassName(): string;
  52515. /**
  52516. * Gets the position input component
  52517. */
  52518. readonly position: NodeMaterialConnectionPoint;
  52519. /**
  52520. * Gets the normal input component
  52521. */
  52522. readonly normal: NodeMaterialConnectionPoint;
  52523. /**
  52524. * Gets the tangent input component
  52525. */
  52526. readonly tangent: NodeMaterialConnectionPoint;
  52527. /**
  52528. * Gets the tangent input component
  52529. */
  52530. readonly uv: NodeMaterialConnectionPoint;
  52531. /**
  52532. * Gets the position output component
  52533. */
  52534. readonly positionOutput: NodeMaterialConnectionPoint;
  52535. /**
  52536. * Gets the normal output component
  52537. */
  52538. readonly normalOutput: NodeMaterialConnectionPoint;
  52539. /**
  52540. * Gets the tangent output component
  52541. */
  52542. readonly tangentOutput: NodeMaterialConnectionPoint;
  52543. /**
  52544. * Gets the tangent output component
  52545. */
  52546. readonly uvOutput: NodeMaterialConnectionPoint;
  52547. initialize(state: NodeMaterialBuildState): void;
  52548. autoConfigure(material: NodeMaterial): void;
  52549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52551. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52552. protected _buildBlock(state: NodeMaterialBuildState): this;
  52553. }
  52554. }
  52555. declare module BABYLON {
  52556. /**
  52557. * Block used to get data information from a light
  52558. */
  52559. export class LightInformationBlock extends NodeMaterialBlock {
  52560. private _lightDataDefineName;
  52561. private _lightColorDefineName;
  52562. /**
  52563. * Gets or sets the light associated with this block
  52564. */
  52565. light: Nullable<Light>;
  52566. /**
  52567. * Creates a new LightInformationBlock
  52568. * @param name defines the block name
  52569. */
  52570. constructor(name: string);
  52571. /**
  52572. * Gets the current class name
  52573. * @returns the class name
  52574. */
  52575. getClassName(): string;
  52576. /**
  52577. * Gets the world position input component
  52578. */
  52579. readonly worldPosition: NodeMaterialConnectionPoint;
  52580. /**
  52581. * Gets the direction output component
  52582. */
  52583. readonly direction: NodeMaterialConnectionPoint;
  52584. /**
  52585. * Gets the direction output component
  52586. */
  52587. readonly color: NodeMaterialConnectionPoint;
  52588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52589. protected _buildBlock(state: NodeMaterialBuildState): this;
  52590. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /**
  52595. * Block used to add an alpha test in the fragment shader
  52596. */
  52597. export class AlphaTestBlock extends NodeMaterialBlock {
  52598. /**
  52599. * Gets or sets the alpha value where alpha testing happens
  52600. */
  52601. alphaCutOff: number;
  52602. /**
  52603. * Create a new AlphaTestBlock
  52604. * @param name defines the block name
  52605. */
  52606. constructor(name: string);
  52607. /**
  52608. * Gets the current class name
  52609. * @returns the class name
  52610. */
  52611. getClassName(): string;
  52612. /**
  52613. * Gets the color input component
  52614. */
  52615. readonly color: NodeMaterialConnectionPoint;
  52616. /**
  52617. * Gets the alpha input component
  52618. */
  52619. readonly alpha: NodeMaterialConnectionPoint;
  52620. protected _buildBlock(state: NodeMaterialBuildState): this;
  52621. protected _dumpPropertiesCode(): string;
  52622. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. /**
  52627. * Block used to add image processing support to fragment shader
  52628. */
  52629. export class ImageProcessingBlock extends NodeMaterialBlock {
  52630. /**
  52631. * Create a new ImageProcessingBlock
  52632. * @param name defines the block name
  52633. */
  52634. constructor(name: string);
  52635. /**
  52636. * Gets the current class name
  52637. * @returns the class name
  52638. */
  52639. getClassName(): string;
  52640. /**
  52641. * Gets the color input component
  52642. */
  52643. readonly color: NodeMaterialConnectionPoint;
  52644. /**
  52645. * Gets the output component
  52646. */
  52647. readonly output: NodeMaterialConnectionPoint;
  52648. /**
  52649. * Initialize the block and prepare the context for build
  52650. * @param state defines the state that will be used for the build
  52651. */
  52652. initialize(state: NodeMaterialBuildState): void;
  52653. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52656. protected _buildBlock(state: NodeMaterialBuildState): this;
  52657. }
  52658. }
  52659. declare module BABYLON {
  52660. /**
  52661. * Block used to add support for scene fog
  52662. */
  52663. export class FogBlock extends NodeMaterialBlock {
  52664. private _fogDistanceName;
  52665. private _fogParameters;
  52666. /**
  52667. * Create a new FogBlock
  52668. * @param name defines the block name
  52669. */
  52670. constructor(name: string);
  52671. /**
  52672. * Gets the current class name
  52673. * @returns the class name
  52674. */
  52675. getClassName(): string;
  52676. /**
  52677. * Gets the world position input component
  52678. */
  52679. readonly worldPosition: NodeMaterialConnectionPoint;
  52680. /**
  52681. * Gets the view input component
  52682. */
  52683. readonly view: NodeMaterialConnectionPoint;
  52684. /**
  52685. * Gets the color input component
  52686. */
  52687. readonly input: NodeMaterialConnectionPoint;
  52688. /**
  52689. * Gets the fog color input component
  52690. */
  52691. readonly fogColor: NodeMaterialConnectionPoint;
  52692. /**
  52693. * Gets the output component
  52694. */
  52695. readonly output: NodeMaterialConnectionPoint;
  52696. autoConfigure(material: NodeMaterial): void;
  52697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52699. protected _buildBlock(state: NodeMaterialBuildState): this;
  52700. }
  52701. }
  52702. declare module BABYLON {
  52703. /**
  52704. * Block used to add light in the fragment shader
  52705. */
  52706. export class LightBlock extends NodeMaterialBlock {
  52707. private _lightId;
  52708. /**
  52709. * Gets or sets the light associated with this block
  52710. */
  52711. light: Nullable<Light>;
  52712. /**
  52713. * Create a new LightBlock
  52714. * @param name defines the block name
  52715. */
  52716. constructor(name: string);
  52717. /**
  52718. * Gets the current class name
  52719. * @returns the class name
  52720. */
  52721. getClassName(): string;
  52722. /**
  52723. * Gets the world position input component
  52724. */
  52725. readonly worldPosition: NodeMaterialConnectionPoint;
  52726. /**
  52727. * Gets the world normal input component
  52728. */
  52729. readonly worldNormal: NodeMaterialConnectionPoint;
  52730. /**
  52731. * Gets the camera (or eye) position component
  52732. */
  52733. readonly cameraPosition: NodeMaterialConnectionPoint;
  52734. /**
  52735. * Gets the diffuse output component
  52736. */
  52737. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52738. /**
  52739. * Gets the specular output component
  52740. */
  52741. readonly specularOutput: NodeMaterialConnectionPoint;
  52742. autoConfigure(material: NodeMaterial): void;
  52743. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52744. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52746. private _injectVertexCode;
  52747. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52748. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52749. }
  52750. }
  52751. declare module BABYLON {
  52752. /**
  52753. * Block used to multiply 2 values
  52754. */
  52755. export class MultiplyBlock extends NodeMaterialBlock {
  52756. /**
  52757. * Creates a new MultiplyBlock
  52758. * @param name defines the block name
  52759. */
  52760. constructor(name: string);
  52761. /**
  52762. * Gets the current class name
  52763. * @returns the class name
  52764. */
  52765. getClassName(): string;
  52766. /**
  52767. * Gets the left operand input component
  52768. */
  52769. readonly left: NodeMaterialConnectionPoint;
  52770. /**
  52771. * Gets the right operand input component
  52772. */
  52773. readonly right: NodeMaterialConnectionPoint;
  52774. /**
  52775. * Gets the output component
  52776. */
  52777. readonly output: NodeMaterialConnectionPoint;
  52778. protected _buildBlock(state: NodeMaterialBuildState): this;
  52779. }
  52780. }
  52781. declare module BABYLON {
  52782. /**
  52783. * Block used to add 2 vectors
  52784. */
  52785. export class AddBlock extends NodeMaterialBlock {
  52786. /**
  52787. * Creates a new AddBlock
  52788. * @param name defines the block name
  52789. */
  52790. constructor(name: string);
  52791. /**
  52792. * Gets the current class name
  52793. * @returns the class name
  52794. */
  52795. getClassName(): string;
  52796. /**
  52797. * Gets the left operand input component
  52798. */
  52799. readonly left: NodeMaterialConnectionPoint;
  52800. /**
  52801. * Gets the right operand input component
  52802. */
  52803. readonly right: NodeMaterialConnectionPoint;
  52804. /**
  52805. * Gets the output component
  52806. */
  52807. readonly output: NodeMaterialConnectionPoint;
  52808. protected _buildBlock(state: NodeMaterialBuildState): this;
  52809. }
  52810. }
  52811. declare module BABYLON {
  52812. /**
  52813. * Block used to scale a vector by a float
  52814. */
  52815. export class ScaleBlock extends NodeMaterialBlock {
  52816. /**
  52817. * Creates a new ScaleBlock
  52818. * @param name defines the block name
  52819. */
  52820. constructor(name: string);
  52821. /**
  52822. * Gets the current class name
  52823. * @returns the class name
  52824. */
  52825. getClassName(): string;
  52826. /**
  52827. * Gets the input component
  52828. */
  52829. readonly input: NodeMaterialConnectionPoint;
  52830. /**
  52831. * Gets the factor input component
  52832. */
  52833. readonly factor: NodeMaterialConnectionPoint;
  52834. /**
  52835. * Gets the output component
  52836. */
  52837. readonly output: NodeMaterialConnectionPoint;
  52838. protected _buildBlock(state: NodeMaterialBuildState): this;
  52839. }
  52840. }
  52841. declare module BABYLON {
  52842. /**
  52843. * Block used to clamp a float
  52844. */
  52845. export class ClampBlock extends NodeMaterialBlock {
  52846. /** Gets or sets the minimum range */
  52847. minimum: number;
  52848. /** Gets or sets the maximum range */
  52849. maximum: number;
  52850. /**
  52851. * Creates a new ClampBlock
  52852. * @param name defines the block name
  52853. */
  52854. constructor(name: string);
  52855. /**
  52856. * Gets the current class name
  52857. * @returns the class name
  52858. */
  52859. getClassName(): string;
  52860. /**
  52861. * Gets the value input component
  52862. */
  52863. readonly value: NodeMaterialConnectionPoint;
  52864. /**
  52865. * Gets the output component
  52866. */
  52867. readonly output: NodeMaterialConnectionPoint;
  52868. protected _buildBlock(state: NodeMaterialBuildState): this;
  52869. protected _dumpPropertiesCode(): string;
  52870. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52871. }
  52872. }
  52873. declare module BABYLON {
  52874. /**
  52875. * Block used to apply a cross product between 2 vectors
  52876. */
  52877. export class CrossBlock extends NodeMaterialBlock {
  52878. /**
  52879. * Creates a new CrossBlock
  52880. * @param name defines the block name
  52881. */
  52882. constructor(name: string);
  52883. /**
  52884. * Gets the current class name
  52885. * @returns the class name
  52886. */
  52887. getClassName(): string;
  52888. /**
  52889. * Gets the left operand input component
  52890. */
  52891. readonly left: NodeMaterialConnectionPoint;
  52892. /**
  52893. * Gets the right operand input component
  52894. */
  52895. readonly right: NodeMaterialConnectionPoint;
  52896. /**
  52897. * Gets the output component
  52898. */
  52899. readonly output: NodeMaterialConnectionPoint;
  52900. protected _buildBlock(state: NodeMaterialBuildState): this;
  52901. }
  52902. }
  52903. declare module BABYLON {
  52904. /**
  52905. * Block used to apply a dot product between 2 vectors
  52906. */
  52907. export class DotBlock extends NodeMaterialBlock {
  52908. /**
  52909. * Creates a new DotBlock
  52910. * @param name defines the block name
  52911. */
  52912. constructor(name: string);
  52913. /**
  52914. * Gets the current class name
  52915. * @returns the class name
  52916. */
  52917. getClassName(): string;
  52918. /**
  52919. * Gets the left operand input component
  52920. */
  52921. readonly left: NodeMaterialConnectionPoint;
  52922. /**
  52923. * Gets the right operand input component
  52924. */
  52925. readonly right: NodeMaterialConnectionPoint;
  52926. /**
  52927. * Gets the output component
  52928. */
  52929. readonly output: NodeMaterialConnectionPoint;
  52930. protected _buildBlock(state: NodeMaterialBuildState): this;
  52931. }
  52932. }
  52933. declare module BABYLON {
  52934. /**
  52935. * Block used to remap a float from a range to a new one
  52936. */
  52937. export class RemapBlock extends NodeMaterialBlock {
  52938. /**
  52939. * Gets or sets the source range
  52940. */
  52941. sourceRange: Vector2;
  52942. /**
  52943. * Gets or sets the target range
  52944. */
  52945. targetRange: Vector2;
  52946. /**
  52947. * Creates a new RemapBlock
  52948. * @param name defines the block name
  52949. */
  52950. constructor(name: string);
  52951. /**
  52952. * Gets the current class name
  52953. * @returns the class name
  52954. */
  52955. getClassName(): string;
  52956. /**
  52957. * Gets the input component
  52958. */
  52959. readonly input: NodeMaterialConnectionPoint;
  52960. /**
  52961. * Gets the output component
  52962. */
  52963. readonly output: NodeMaterialConnectionPoint;
  52964. protected _buildBlock(state: NodeMaterialBuildState): this;
  52965. protected _dumpPropertiesCode(): string;
  52966. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52967. }
  52968. }
  52969. declare module BABYLON {
  52970. /**
  52971. * Block used to normalize a vector
  52972. */
  52973. export class NormalizeBlock extends NodeMaterialBlock {
  52974. /**
  52975. * Creates a new NormalizeBlock
  52976. * @param name defines the block name
  52977. */
  52978. constructor(name: string);
  52979. /**
  52980. * Gets the current class name
  52981. * @returns the class name
  52982. */
  52983. getClassName(): string;
  52984. /**
  52985. * Gets the input component
  52986. */
  52987. readonly input: NodeMaterialConnectionPoint;
  52988. /**
  52989. * Gets the output component
  52990. */
  52991. readonly output: NodeMaterialConnectionPoint;
  52992. protected _buildBlock(state: NodeMaterialBuildState): this;
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /**
  52997. * Operations supported by the Trigonometry block
  52998. */
  52999. export enum TrigonometryBlockOperations {
  53000. /** Cos */
  53001. Cos = 0,
  53002. /** Sin */
  53003. Sin = 1,
  53004. /** Abs */
  53005. Abs = 2,
  53006. /** Exp */
  53007. Exp = 3,
  53008. /** Exp2 */
  53009. Exp2 = 4,
  53010. /** Round */
  53011. Round = 5,
  53012. /** Floor */
  53013. Floor = 6,
  53014. /** Ceiling */
  53015. Ceiling = 7
  53016. }
  53017. /**
  53018. * Block used to apply trigonometry operation to floats
  53019. */
  53020. export class TrigonometryBlock extends NodeMaterialBlock {
  53021. /**
  53022. * Gets or sets the operation applied by the block
  53023. */
  53024. operation: TrigonometryBlockOperations;
  53025. /**
  53026. * Creates a new TrigonometryBlock
  53027. * @param name defines the block name
  53028. */
  53029. constructor(name: string);
  53030. /**
  53031. * Gets the current class name
  53032. * @returns the class name
  53033. */
  53034. getClassName(): string;
  53035. /**
  53036. * Gets the input component
  53037. */
  53038. readonly input: NodeMaterialConnectionPoint;
  53039. /**
  53040. * Gets the output component
  53041. */
  53042. readonly output: NodeMaterialConnectionPoint;
  53043. protected _buildBlock(state: NodeMaterialBuildState): this;
  53044. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53045. }
  53046. }
  53047. declare module BABYLON {
  53048. /**
  53049. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53050. */
  53051. export class ColorMergerBlock extends NodeMaterialBlock {
  53052. /**
  53053. * Create a new ColorMergerBlock
  53054. * @param name defines the block name
  53055. */
  53056. constructor(name: string);
  53057. /**
  53058. * Gets the current class name
  53059. * @returns the class name
  53060. */
  53061. getClassName(): string;
  53062. /**
  53063. * Gets the r component (input)
  53064. */
  53065. readonly r: NodeMaterialConnectionPoint;
  53066. /**
  53067. * Gets the g component (input)
  53068. */
  53069. readonly g: NodeMaterialConnectionPoint;
  53070. /**
  53071. * Gets the b component (input)
  53072. */
  53073. readonly b: NodeMaterialConnectionPoint;
  53074. /**
  53075. * Gets the a component (input)
  53076. */
  53077. readonly a: NodeMaterialConnectionPoint;
  53078. /**
  53079. * Gets the rgba component (output)
  53080. */
  53081. readonly rgba: NodeMaterialConnectionPoint;
  53082. /**
  53083. * Gets the rgb component (output)
  53084. */
  53085. readonly rgb: NodeMaterialConnectionPoint;
  53086. protected _buildBlock(state: NodeMaterialBuildState): this;
  53087. }
  53088. }
  53089. declare module BABYLON {
  53090. /**
  53091. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53092. */
  53093. export class VectorMergerBlock extends NodeMaterialBlock {
  53094. /**
  53095. * Create a new VectorMergerBlock
  53096. * @param name defines the block name
  53097. */
  53098. constructor(name: string);
  53099. /**
  53100. * Gets the current class name
  53101. * @returns the class name
  53102. */
  53103. getClassName(): string;
  53104. /**
  53105. * Gets the x component (input)
  53106. */
  53107. readonly x: NodeMaterialConnectionPoint;
  53108. /**
  53109. * Gets the y component (input)
  53110. */
  53111. readonly y: NodeMaterialConnectionPoint;
  53112. /**
  53113. * Gets the z component (input)
  53114. */
  53115. readonly z: NodeMaterialConnectionPoint;
  53116. /**
  53117. * Gets the w component (input)
  53118. */
  53119. readonly w: NodeMaterialConnectionPoint;
  53120. /**
  53121. * Gets the xyzw component (output)
  53122. */
  53123. readonly xyzw: NodeMaterialConnectionPoint;
  53124. /**
  53125. * Gets the xyz component (output)
  53126. */
  53127. readonly xyz: NodeMaterialConnectionPoint;
  53128. /**
  53129. * Gets the xy component (output)
  53130. */
  53131. readonly xy: NodeMaterialConnectionPoint;
  53132. protected _buildBlock(state: NodeMaterialBuildState): this;
  53133. }
  53134. }
  53135. declare module BABYLON {
  53136. /**
  53137. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53138. */
  53139. export class ColorSplitterBlock extends NodeMaterialBlock {
  53140. /**
  53141. * Create a new ColorSplitterBlock
  53142. * @param name defines the block name
  53143. */
  53144. constructor(name: string);
  53145. /**
  53146. * Gets the current class name
  53147. * @returns the class name
  53148. */
  53149. getClassName(): string;
  53150. /**
  53151. * Gets the rgba component (input)
  53152. */
  53153. readonly rgba: NodeMaterialConnectionPoint;
  53154. /**
  53155. * Gets the rgb component (input)
  53156. */
  53157. readonly rgbIn: NodeMaterialConnectionPoint;
  53158. /**
  53159. * Gets the rgb component (output)
  53160. */
  53161. readonly rgbOut: NodeMaterialConnectionPoint;
  53162. /**
  53163. * Gets the r component (output)
  53164. */
  53165. readonly r: NodeMaterialConnectionPoint;
  53166. /**
  53167. * Gets the g component (output)
  53168. */
  53169. readonly g: NodeMaterialConnectionPoint;
  53170. /**
  53171. * Gets the b component (output)
  53172. */
  53173. readonly b: NodeMaterialConnectionPoint;
  53174. /**
  53175. * Gets the a component (output)
  53176. */
  53177. readonly a: NodeMaterialConnectionPoint;
  53178. protected _inputRename(name: string): string;
  53179. protected _outputRename(name: string): string;
  53180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53181. }
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53186. */
  53187. export class VectorSplitterBlock extends NodeMaterialBlock {
  53188. /**
  53189. * Create a new VectorSplitterBlock
  53190. * @param name defines the block name
  53191. */
  53192. constructor(name: string);
  53193. /**
  53194. * Gets the current class name
  53195. * @returns the class name
  53196. */
  53197. getClassName(): string;
  53198. /**
  53199. * Gets the xyzw component (input)
  53200. */
  53201. readonly xyzw: NodeMaterialConnectionPoint;
  53202. /**
  53203. * Gets the xyz component (input)
  53204. */
  53205. readonly xyzIn: NodeMaterialConnectionPoint;
  53206. /**
  53207. * Gets the xy component (input)
  53208. */
  53209. readonly xyIn: NodeMaterialConnectionPoint;
  53210. /**
  53211. * Gets the xyz component (output)
  53212. */
  53213. readonly xyzOut: NodeMaterialConnectionPoint;
  53214. /**
  53215. * Gets the xy component (output)
  53216. */
  53217. readonly xyOut: NodeMaterialConnectionPoint;
  53218. /**
  53219. * Gets the x component (output)
  53220. */
  53221. readonly x: NodeMaterialConnectionPoint;
  53222. /**
  53223. * Gets the y component (output)
  53224. */
  53225. readonly y: NodeMaterialConnectionPoint;
  53226. /**
  53227. * Gets the z component (output)
  53228. */
  53229. readonly z: NodeMaterialConnectionPoint;
  53230. /**
  53231. * Gets the w component (output)
  53232. */
  53233. readonly w: NodeMaterialConnectionPoint;
  53234. protected _inputRename(name: string): string;
  53235. protected _outputRename(name: string): string;
  53236. protected _buildBlock(state: NodeMaterialBuildState): this;
  53237. }
  53238. }
  53239. declare module BABYLON {
  53240. /**
  53241. * Block used to lerp 2 values
  53242. */
  53243. export class LerpBlock extends NodeMaterialBlock {
  53244. /**
  53245. * Creates a new LerpBlock
  53246. * @param name defines the block name
  53247. */
  53248. constructor(name: string);
  53249. /**
  53250. * Gets the current class name
  53251. * @returns the class name
  53252. */
  53253. getClassName(): string;
  53254. /**
  53255. * Gets the left operand input component
  53256. */
  53257. readonly left: NodeMaterialConnectionPoint;
  53258. /**
  53259. * Gets the right operand input component
  53260. */
  53261. readonly right: NodeMaterialConnectionPoint;
  53262. /**
  53263. * Gets the gradient operand input component
  53264. */
  53265. readonly gradient: NodeMaterialConnectionPoint;
  53266. /**
  53267. * Gets the output component
  53268. */
  53269. readonly output: NodeMaterialConnectionPoint;
  53270. protected _buildBlock(state: NodeMaterialBuildState): this;
  53271. }
  53272. }
  53273. declare module BABYLON {
  53274. /**
  53275. * Block used to divide 2 vectors
  53276. */
  53277. export class DivideBlock extends NodeMaterialBlock {
  53278. /**
  53279. * Creates a new DivideBlock
  53280. * @param name defines the block name
  53281. */
  53282. constructor(name: string);
  53283. /**
  53284. * Gets the current class name
  53285. * @returns the class name
  53286. */
  53287. getClassName(): string;
  53288. /**
  53289. * Gets the left operand input component
  53290. */
  53291. readonly left: NodeMaterialConnectionPoint;
  53292. /**
  53293. * Gets the right operand input component
  53294. */
  53295. readonly right: NodeMaterialConnectionPoint;
  53296. /**
  53297. * Gets the output component
  53298. */
  53299. readonly output: NodeMaterialConnectionPoint;
  53300. protected _buildBlock(state: NodeMaterialBuildState): this;
  53301. }
  53302. }
  53303. declare module BABYLON {
  53304. /**
  53305. * Block used to subtract 2 vectors
  53306. */
  53307. export class SubtractBlock extends NodeMaterialBlock {
  53308. /**
  53309. * Creates a new SubtractBlock
  53310. * @param name defines the block name
  53311. */
  53312. constructor(name: string);
  53313. /**
  53314. * Gets the current class name
  53315. * @returns the class name
  53316. */
  53317. getClassName(): string;
  53318. /**
  53319. * Gets the left operand input component
  53320. */
  53321. readonly left: NodeMaterialConnectionPoint;
  53322. /**
  53323. * Gets the right operand input component
  53324. */
  53325. readonly right: NodeMaterialConnectionPoint;
  53326. /**
  53327. * Gets the output component
  53328. */
  53329. readonly output: NodeMaterialConnectionPoint;
  53330. protected _buildBlock(state: NodeMaterialBuildState): this;
  53331. }
  53332. }
  53333. declare module BABYLON {
  53334. /**
  53335. * Block used to step a value
  53336. */
  53337. export class StepBlock extends NodeMaterialBlock {
  53338. /**
  53339. * Creates a new AddBlock
  53340. * @param name defines the block name
  53341. */
  53342. constructor(name: string);
  53343. /**
  53344. * Gets the current class name
  53345. * @returns the class name
  53346. */
  53347. getClassName(): string;
  53348. /**
  53349. * Gets the value operand input component
  53350. */
  53351. readonly value: NodeMaterialConnectionPoint;
  53352. /**
  53353. * Gets the edge operand input component
  53354. */
  53355. readonly edge: NodeMaterialConnectionPoint;
  53356. /**
  53357. * Gets the output component
  53358. */
  53359. readonly output: NodeMaterialConnectionPoint;
  53360. protected _buildBlock(state: NodeMaterialBuildState): this;
  53361. }
  53362. }
  53363. declare module BABYLON {
  53364. /**
  53365. * Block used to get the opposite of a value
  53366. */
  53367. export class OppositeBlock extends NodeMaterialBlock {
  53368. /**
  53369. * Creates a new OppositeBlock
  53370. * @param name defines the block name
  53371. */
  53372. constructor(name: string);
  53373. /**
  53374. * Gets the current class name
  53375. * @returns the class name
  53376. */
  53377. getClassName(): string;
  53378. /**
  53379. * Gets the input component
  53380. */
  53381. readonly input: NodeMaterialConnectionPoint;
  53382. /**
  53383. * Gets the output component
  53384. */
  53385. readonly output: NodeMaterialConnectionPoint;
  53386. protected _buildBlock(state: NodeMaterialBuildState): this;
  53387. }
  53388. }
  53389. declare module BABYLON {
  53390. /**
  53391. * Block used to get the view direction
  53392. */
  53393. export class ViewDirectionBlock extends NodeMaterialBlock {
  53394. /**
  53395. * Creates a new ViewDirectionBlock
  53396. * @param name defines the block name
  53397. */
  53398. constructor(name: string);
  53399. /**
  53400. * Gets the current class name
  53401. * @returns the class name
  53402. */
  53403. getClassName(): string;
  53404. /**
  53405. * Gets the world position component
  53406. */
  53407. readonly worldPosition: NodeMaterialConnectionPoint;
  53408. /**
  53409. * Gets the camera position component
  53410. */
  53411. readonly cameraPosition: NodeMaterialConnectionPoint;
  53412. /**
  53413. * Gets the output component
  53414. */
  53415. readonly output: NodeMaterialConnectionPoint;
  53416. autoConfigure(material: NodeMaterial): void;
  53417. protected _buildBlock(state: NodeMaterialBuildState): this;
  53418. }
  53419. }
  53420. declare module BABYLON {
  53421. /**
  53422. * Block used to compute fresnel value
  53423. */
  53424. export class FresnelBlock extends NodeMaterialBlock {
  53425. /**
  53426. * Create a new FresnelBlock
  53427. * @param name defines the block name
  53428. */
  53429. constructor(name: string);
  53430. /**
  53431. * Gets the current class name
  53432. * @returns the class name
  53433. */
  53434. getClassName(): string;
  53435. /**
  53436. * Gets the world normal input component
  53437. */
  53438. readonly worldNormal: NodeMaterialConnectionPoint;
  53439. /**
  53440. * Gets the view direction input component
  53441. */
  53442. readonly viewDirection: NodeMaterialConnectionPoint;
  53443. /**
  53444. * Gets the bias input component
  53445. */
  53446. readonly bias: NodeMaterialConnectionPoint;
  53447. /**
  53448. * Gets the camera (or eye) position component
  53449. */
  53450. readonly power: NodeMaterialConnectionPoint;
  53451. /**
  53452. * Gets the fresnel output component
  53453. */
  53454. readonly fresnel: NodeMaterialConnectionPoint;
  53455. autoConfigure(material: NodeMaterial): void;
  53456. protected _buildBlock(state: NodeMaterialBuildState): this;
  53457. }
  53458. }
  53459. declare module BABYLON {
  53460. /**
  53461. * Block used to get the max of 2 values
  53462. */
  53463. export class MaxBlock extends NodeMaterialBlock {
  53464. /**
  53465. * Creates a new MaxBlock
  53466. * @param name defines the block name
  53467. */
  53468. constructor(name: string);
  53469. /**
  53470. * Gets the current class name
  53471. * @returns the class name
  53472. */
  53473. getClassName(): string;
  53474. /**
  53475. * Gets the left operand input component
  53476. */
  53477. readonly left: NodeMaterialConnectionPoint;
  53478. /**
  53479. * Gets the right operand input component
  53480. */
  53481. readonly right: NodeMaterialConnectionPoint;
  53482. /**
  53483. * Gets the output component
  53484. */
  53485. readonly output: NodeMaterialConnectionPoint;
  53486. protected _buildBlock(state: NodeMaterialBuildState): this;
  53487. }
  53488. }
  53489. declare module BABYLON {
  53490. /**
  53491. * Block used to get the min of 2 values
  53492. */
  53493. export class MinBlock extends NodeMaterialBlock {
  53494. /**
  53495. * Creates a new MinBlock
  53496. * @param name defines the block name
  53497. */
  53498. constructor(name: string);
  53499. /**
  53500. * Gets the current class name
  53501. * @returns the class name
  53502. */
  53503. getClassName(): string;
  53504. /**
  53505. * Gets the left operand input component
  53506. */
  53507. readonly left: NodeMaterialConnectionPoint;
  53508. /**
  53509. * Gets the right operand input component
  53510. */
  53511. readonly right: NodeMaterialConnectionPoint;
  53512. /**
  53513. * Gets the output component
  53514. */
  53515. readonly output: NodeMaterialConnectionPoint;
  53516. protected _buildBlock(state: NodeMaterialBuildState): this;
  53517. }
  53518. }
  53519. declare module BABYLON {
  53520. /**
  53521. * Effect Render Options
  53522. */
  53523. export interface IEffectRendererOptions {
  53524. /**
  53525. * Defines the vertices positions.
  53526. */
  53527. positions?: number[];
  53528. /**
  53529. * Defines the indices.
  53530. */
  53531. indices?: number[];
  53532. }
  53533. /**
  53534. * Helper class to render one or more effects
  53535. */
  53536. export class EffectRenderer {
  53537. private engine;
  53538. private static _DefaultOptions;
  53539. private _vertexBuffers;
  53540. private _indexBuffer;
  53541. private _ringBufferIndex;
  53542. private _ringScreenBuffer;
  53543. private _fullscreenViewport;
  53544. private _getNextFrameBuffer;
  53545. /**
  53546. * Creates an effect renderer
  53547. * @param engine the engine to use for rendering
  53548. * @param options defines the options of the effect renderer
  53549. */
  53550. constructor(engine: Engine, options?: IEffectRendererOptions);
  53551. /**
  53552. * Sets the current viewport in normalized coordinates 0-1
  53553. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53554. */
  53555. setViewport(viewport?: Viewport): void;
  53556. /**
  53557. * Binds the embedded attributes buffer to the effect.
  53558. * @param effect Defines the effect to bind the attributes for
  53559. */
  53560. bindBuffers(effect: Effect): void;
  53561. /**
  53562. * Sets the current effect wrapper to use during draw.
  53563. * The effect needs to be ready before calling this api.
  53564. * This also sets the default full screen position attribute.
  53565. * @param effectWrapper Defines the effect to draw with
  53566. */
  53567. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53568. /**
  53569. * Draws a full screen quad.
  53570. */
  53571. draw(): void;
  53572. /**
  53573. * renders one or more effects to a specified texture
  53574. * @param effectWrappers list of effects to renderer
  53575. * @param outputTexture texture to draw to, if null it will render to the screen
  53576. */
  53577. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53578. /**
  53579. * Disposes of the effect renderer
  53580. */
  53581. dispose(): void;
  53582. }
  53583. /**
  53584. * Options to create an EffectWrapper
  53585. */
  53586. interface EffectWrapperCreationOptions {
  53587. /**
  53588. * Engine to use to create the effect
  53589. */
  53590. engine: Engine;
  53591. /**
  53592. * Fragment shader for the effect
  53593. */
  53594. fragmentShader: string;
  53595. /**
  53596. * Vertex shader for the effect
  53597. */
  53598. vertexShader?: string;
  53599. /**
  53600. * Attributes to use in the shader
  53601. */
  53602. attributeNames?: Array<string>;
  53603. /**
  53604. * Uniforms to use in the shader
  53605. */
  53606. uniformNames?: Array<string>;
  53607. /**
  53608. * Texture sampler names to use in the shader
  53609. */
  53610. samplerNames?: Array<string>;
  53611. /**
  53612. * The friendly name of the effect displayed in Spector.
  53613. */
  53614. name?: string;
  53615. }
  53616. /**
  53617. * Wraps an effect to be used for rendering
  53618. */
  53619. export class EffectWrapper {
  53620. /**
  53621. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53622. */
  53623. onApplyObservable: Observable<{}>;
  53624. /**
  53625. * The underlying effect
  53626. */
  53627. effect: Effect;
  53628. /**
  53629. * Creates an effect to be renderer
  53630. * @param creationOptions options to create the effect
  53631. */
  53632. constructor(creationOptions: EffectWrapperCreationOptions);
  53633. /**
  53634. * Disposes of the effect wrapper
  53635. */
  53636. dispose(): void;
  53637. }
  53638. }
  53639. declare module BABYLON {
  53640. /**
  53641. * Helper class to push actions to a pool of workers.
  53642. */
  53643. export class WorkerPool implements IDisposable {
  53644. private _workerInfos;
  53645. private _pendingActions;
  53646. /**
  53647. * Constructor
  53648. * @param workers Array of workers to use for actions
  53649. */
  53650. constructor(workers: Array<Worker>);
  53651. /**
  53652. * Terminates all workers and clears any pending actions.
  53653. */
  53654. dispose(): void;
  53655. /**
  53656. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53657. * pended until a worker has completed its action.
  53658. * @param action The action to perform. Call onComplete when the action is complete.
  53659. */
  53660. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53661. private _execute;
  53662. }
  53663. }
  53664. declare module BABYLON {
  53665. /**
  53666. * Configuration for Draco compression
  53667. */
  53668. export interface IDracoCompressionConfiguration {
  53669. /**
  53670. * Configuration for the decoder.
  53671. */
  53672. decoder: {
  53673. /**
  53674. * The url to the WebAssembly module.
  53675. */
  53676. wasmUrl?: string;
  53677. /**
  53678. * The url to the WebAssembly binary.
  53679. */
  53680. wasmBinaryUrl?: string;
  53681. /**
  53682. * The url to the fallback JavaScript module.
  53683. */
  53684. fallbackUrl?: string;
  53685. };
  53686. }
  53687. /**
  53688. * Draco compression (https://google.github.io/draco/)
  53689. *
  53690. * This class wraps the Draco module.
  53691. *
  53692. * **Encoder**
  53693. *
  53694. * The encoder is not currently implemented.
  53695. *
  53696. * **Decoder**
  53697. *
  53698. * 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.
  53699. *
  53700. * To update the configuration, use the following code:
  53701. * ```javascript
  53702. * DracoCompression.Configuration = {
  53703. * decoder: {
  53704. * wasmUrl: "<url to the WebAssembly library>",
  53705. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53706. * fallbackUrl: "<url to the fallback JavaScript library>",
  53707. * }
  53708. * };
  53709. * ```
  53710. *
  53711. * 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.
  53712. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53713. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53714. *
  53715. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53716. * ```javascript
  53717. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53718. * ```
  53719. *
  53720. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53721. */
  53722. export class DracoCompression implements IDisposable {
  53723. private _workerPoolPromise?;
  53724. private _decoderModulePromise?;
  53725. /**
  53726. * The configuration. Defaults to the following urls:
  53727. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  53728. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  53729. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  53730. */
  53731. static Configuration: IDracoCompressionConfiguration;
  53732. /**
  53733. * Returns true if the decoder configuration is available.
  53734. */
  53735. static readonly DecoderAvailable: boolean;
  53736. /**
  53737. * Default number of workers to create when creating the draco compression object.
  53738. */
  53739. static DefaultNumWorkers: number;
  53740. private static GetDefaultNumWorkers;
  53741. private static _Default;
  53742. /**
  53743. * Default instance for the draco compression object.
  53744. */
  53745. static readonly Default: DracoCompression;
  53746. /**
  53747. * Constructor
  53748. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  53749. */
  53750. constructor(numWorkers?: number);
  53751. /**
  53752. * Stop all async operations and release resources.
  53753. */
  53754. dispose(): void;
  53755. /**
  53756. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  53757. * @returns a promise that resolves when ready
  53758. */
  53759. whenReadyAsync(): Promise<void>;
  53760. /**
  53761. * Decode Draco compressed mesh data to vertex data.
  53762. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  53763. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  53764. * @returns A promise that resolves with the decoded vertex data
  53765. */
  53766. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  53767. [kind: string]: number;
  53768. }): Promise<VertexData>;
  53769. }
  53770. }
  53771. declare module BABYLON {
  53772. /**
  53773. * Class for building Constructive Solid Geometry
  53774. */
  53775. export class CSG {
  53776. private polygons;
  53777. /**
  53778. * The world matrix
  53779. */
  53780. matrix: Matrix;
  53781. /**
  53782. * Stores the position
  53783. */
  53784. position: Vector3;
  53785. /**
  53786. * Stores the rotation
  53787. */
  53788. rotation: Vector3;
  53789. /**
  53790. * Stores the rotation quaternion
  53791. */
  53792. rotationQuaternion: Nullable<Quaternion>;
  53793. /**
  53794. * Stores the scaling vector
  53795. */
  53796. scaling: Vector3;
  53797. /**
  53798. * Convert the Mesh to CSG
  53799. * @param mesh The Mesh to convert to CSG
  53800. * @returns A new CSG from the Mesh
  53801. */
  53802. static FromMesh(mesh: Mesh): CSG;
  53803. /**
  53804. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53805. * @param polygons Polygons used to construct a CSG solid
  53806. */
  53807. private static FromPolygons;
  53808. /**
  53809. * Clones, or makes a deep copy, of the CSG
  53810. * @returns A new CSG
  53811. */
  53812. clone(): CSG;
  53813. /**
  53814. * Unions this CSG with another CSG
  53815. * @param csg The CSG to union against this CSG
  53816. * @returns The unioned CSG
  53817. */
  53818. union(csg: CSG): CSG;
  53819. /**
  53820. * Unions this CSG with another CSG in place
  53821. * @param csg The CSG to union against this CSG
  53822. */
  53823. unionInPlace(csg: CSG): void;
  53824. /**
  53825. * Subtracts this CSG with another CSG
  53826. * @param csg The CSG to subtract against this CSG
  53827. * @returns A new CSG
  53828. */
  53829. subtract(csg: CSG): CSG;
  53830. /**
  53831. * Subtracts this CSG with another CSG in place
  53832. * @param csg The CSG to subtact against this CSG
  53833. */
  53834. subtractInPlace(csg: CSG): void;
  53835. /**
  53836. * Intersect this CSG with another CSG
  53837. * @param csg The CSG to intersect against this CSG
  53838. * @returns A new CSG
  53839. */
  53840. intersect(csg: CSG): CSG;
  53841. /**
  53842. * Intersects this CSG with another CSG in place
  53843. * @param csg The CSG to intersect against this CSG
  53844. */
  53845. intersectInPlace(csg: CSG): void;
  53846. /**
  53847. * Return a new CSG solid with solid and empty space switched. This solid is
  53848. * not modified.
  53849. * @returns A new CSG solid with solid and empty space switched
  53850. */
  53851. inverse(): CSG;
  53852. /**
  53853. * Inverses the CSG in place
  53854. */
  53855. inverseInPlace(): void;
  53856. /**
  53857. * This is used to keep meshes transformations so they can be restored
  53858. * when we build back a Babylon Mesh
  53859. * NB : All CSG operations are performed in world coordinates
  53860. * @param csg The CSG to copy the transform attributes from
  53861. * @returns This CSG
  53862. */
  53863. copyTransformAttributes(csg: CSG): CSG;
  53864. /**
  53865. * Build Raw mesh from CSG
  53866. * Coordinates here are in world space
  53867. * @param name The name of the mesh geometry
  53868. * @param scene The Scene
  53869. * @param keepSubMeshes Specifies if the submeshes should be kept
  53870. * @returns A new Mesh
  53871. */
  53872. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  53873. /**
  53874. * Build Mesh from CSG taking material and transforms into account
  53875. * @param name The name of the Mesh
  53876. * @param material The material of the Mesh
  53877. * @param scene The Scene
  53878. * @param keepSubMeshes Specifies if submeshes should be kept
  53879. * @returns The new Mesh
  53880. */
  53881. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  53882. }
  53883. }
  53884. declare module BABYLON {
  53885. /**
  53886. * Class used to create a trail following a mesh
  53887. */
  53888. export class TrailMesh extends Mesh {
  53889. private _generator;
  53890. private _autoStart;
  53891. private _running;
  53892. private _diameter;
  53893. private _length;
  53894. private _sectionPolygonPointsCount;
  53895. private _sectionVectors;
  53896. private _sectionNormalVectors;
  53897. private _beforeRenderObserver;
  53898. /**
  53899. * @constructor
  53900. * @param name The value used by scene.getMeshByName() to do a lookup.
  53901. * @param generator The mesh to generate a trail.
  53902. * @param scene The scene to add this mesh to.
  53903. * @param diameter Diameter of trailing mesh. Default is 1.
  53904. * @param length Length of trailing mesh. Default is 60.
  53905. * @param autoStart Automatically start trailing mesh. Default true.
  53906. */
  53907. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53908. /**
  53909. * "TrailMesh"
  53910. * @returns "TrailMesh"
  53911. */
  53912. getClassName(): string;
  53913. private _createMesh;
  53914. /**
  53915. * Start trailing mesh.
  53916. */
  53917. start(): void;
  53918. /**
  53919. * Stop trailing mesh.
  53920. */
  53921. stop(): void;
  53922. /**
  53923. * Update trailing mesh geometry.
  53924. */
  53925. update(): void;
  53926. /**
  53927. * Returns a new TrailMesh object.
  53928. * @param name is a string, the name given to the new mesh
  53929. * @param newGenerator use new generator object for cloned trail mesh
  53930. * @returns a new mesh
  53931. */
  53932. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53933. /**
  53934. * Serializes this trail mesh
  53935. * @param serializationObject object to write serialization to
  53936. */
  53937. serialize(serializationObject: any): void;
  53938. /**
  53939. * Parses a serialized trail mesh
  53940. * @param parsedMesh the serialized mesh
  53941. * @param scene the scene to create the trail mesh in
  53942. * @returns the created trail mesh
  53943. */
  53944. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53945. }
  53946. }
  53947. declare module BABYLON {
  53948. /**
  53949. * Class containing static functions to help procedurally build meshes
  53950. */
  53951. export class TiledBoxBuilder {
  53952. /**
  53953. * Creates a box mesh
  53954. * 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)
  53955. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53957. * * 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
  53958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53959. * @param name defines the name of the mesh
  53960. * @param options defines the options used to create the mesh
  53961. * @param scene defines the hosting scene
  53962. * @returns the box mesh
  53963. */
  53964. static CreateTiledBox(name: string, options: {
  53965. pattern?: number;
  53966. width?: number;
  53967. height?: number;
  53968. depth?: number;
  53969. tileSize?: number;
  53970. tileWidth?: number;
  53971. tileHeight?: number;
  53972. alignHorizontal?: number;
  53973. alignVertical?: number;
  53974. faceUV?: Vector4[];
  53975. faceColors?: Color4[];
  53976. sideOrientation?: number;
  53977. updatable?: boolean;
  53978. }, scene?: Nullable<Scene>): Mesh;
  53979. }
  53980. }
  53981. declare module BABYLON {
  53982. /**
  53983. * Class containing static functions to help procedurally build meshes
  53984. */
  53985. export class TorusKnotBuilder {
  53986. /**
  53987. * Creates a torus knot mesh
  53988. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53989. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53990. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53991. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53993. * * 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
  53994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53995. * @param name defines the name of the mesh
  53996. * @param options defines the options used to create the mesh
  53997. * @param scene defines the hosting scene
  53998. * @returns the torus knot mesh
  53999. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54000. */
  54001. static CreateTorusKnot(name: string, options: {
  54002. radius?: number;
  54003. tube?: number;
  54004. radialSegments?: number;
  54005. tubularSegments?: number;
  54006. p?: number;
  54007. q?: number;
  54008. updatable?: boolean;
  54009. sideOrientation?: number;
  54010. frontUVs?: Vector4;
  54011. backUVs?: Vector4;
  54012. }, scene: any): Mesh;
  54013. }
  54014. }
  54015. declare module BABYLON {
  54016. /**
  54017. * Polygon
  54018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54019. */
  54020. export class Polygon {
  54021. /**
  54022. * Creates a rectangle
  54023. * @param xmin bottom X coord
  54024. * @param ymin bottom Y coord
  54025. * @param xmax top X coord
  54026. * @param ymax top Y coord
  54027. * @returns points that make the resulting rectation
  54028. */
  54029. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54030. /**
  54031. * Creates a circle
  54032. * @param radius radius of circle
  54033. * @param cx scale in x
  54034. * @param cy scale in y
  54035. * @param numberOfSides number of sides that make up the circle
  54036. * @returns points that make the resulting circle
  54037. */
  54038. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54039. /**
  54040. * Creates a polygon from input string
  54041. * @param input Input polygon data
  54042. * @returns the parsed points
  54043. */
  54044. static Parse(input: string): Vector2[];
  54045. /**
  54046. * Starts building a polygon from x and y coordinates
  54047. * @param x x coordinate
  54048. * @param y y coordinate
  54049. * @returns the started path2
  54050. */
  54051. static StartingAt(x: number, y: number): Path2;
  54052. }
  54053. /**
  54054. * Builds a polygon
  54055. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54056. */
  54057. export class PolygonMeshBuilder {
  54058. private _points;
  54059. private _outlinepoints;
  54060. private _holes;
  54061. private _name;
  54062. private _scene;
  54063. private _epoints;
  54064. private _eholes;
  54065. private _addToepoint;
  54066. /**
  54067. * Babylon reference to the earcut plugin.
  54068. */
  54069. bjsEarcut: any;
  54070. /**
  54071. * Creates a PolygonMeshBuilder
  54072. * @param name name of the builder
  54073. * @param contours Path of the polygon
  54074. * @param scene scene to add to when creating the mesh
  54075. * @param earcutInjection can be used to inject your own earcut reference
  54076. */
  54077. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54078. /**
  54079. * Adds a whole within the polygon
  54080. * @param hole Array of points defining the hole
  54081. * @returns this
  54082. */
  54083. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54084. /**
  54085. * Creates the polygon
  54086. * @param updatable If the mesh should be updatable
  54087. * @param depth The depth of the mesh created
  54088. * @returns the created mesh
  54089. */
  54090. build(updatable?: boolean, depth?: number): Mesh;
  54091. /**
  54092. * Creates the polygon
  54093. * @param depth The depth of the mesh created
  54094. * @returns the created VertexData
  54095. */
  54096. buildVertexData(depth?: number): VertexData;
  54097. /**
  54098. * Adds a side to the polygon
  54099. * @param positions points that make the polygon
  54100. * @param normals normals of the polygon
  54101. * @param uvs uvs of the polygon
  54102. * @param indices indices of the polygon
  54103. * @param bounds bounds of the polygon
  54104. * @param points points of the polygon
  54105. * @param depth depth of the polygon
  54106. * @param flip flip of the polygon
  54107. */
  54108. private addSide;
  54109. }
  54110. }
  54111. declare module BABYLON {
  54112. /**
  54113. * Class containing static functions to help procedurally build meshes
  54114. */
  54115. export class PolygonBuilder {
  54116. /**
  54117. * Creates a polygon mesh
  54118. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54119. * * 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
  54120. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54122. * * 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)
  54123. * * Remember you can only change the shape positions, not their number when updating a polygon
  54124. * @param name defines the name of the mesh
  54125. * @param options defines the options used to create the mesh
  54126. * @param scene defines the hosting scene
  54127. * @param earcutInjection can be used to inject your own earcut reference
  54128. * @returns the polygon mesh
  54129. */
  54130. static CreatePolygon(name: string, options: {
  54131. shape: Vector3[];
  54132. holes?: Vector3[][];
  54133. depth?: number;
  54134. faceUV?: Vector4[];
  54135. faceColors?: Color4[];
  54136. updatable?: boolean;
  54137. sideOrientation?: number;
  54138. frontUVs?: Vector4;
  54139. backUVs?: Vector4;
  54140. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54141. /**
  54142. * Creates an extruded polygon mesh, with depth in the Y direction.
  54143. * * 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)
  54144. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54145. * @param name defines the name of the mesh
  54146. * @param options defines the options used to create the mesh
  54147. * @param scene defines the hosting scene
  54148. * @param earcutInjection can be used to inject your own earcut reference
  54149. * @returns the polygon mesh
  54150. */
  54151. static ExtrudePolygon(name: string, options: {
  54152. shape: Vector3[];
  54153. holes?: Vector3[][];
  54154. depth?: number;
  54155. faceUV?: Vector4[];
  54156. faceColors?: Color4[];
  54157. updatable?: boolean;
  54158. sideOrientation?: number;
  54159. frontUVs?: Vector4;
  54160. backUVs?: Vector4;
  54161. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54162. }
  54163. }
  54164. declare module BABYLON {
  54165. /**
  54166. * Class containing static functions to help procedurally build meshes
  54167. */
  54168. export class LatheBuilder {
  54169. /**
  54170. * Creates lathe mesh.
  54171. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54172. * * 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
  54173. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54174. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54175. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54176. * * 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
  54177. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54178. * * 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
  54179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54180. * * 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
  54181. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54183. * @param name defines the name of the mesh
  54184. * @param options defines the options used to create the mesh
  54185. * @param scene defines the hosting scene
  54186. * @returns the lathe mesh
  54187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54188. */
  54189. static CreateLathe(name: string, options: {
  54190. shape: Vector3[];
  54191. radius?: number;
  54192. tessellation?: number;
  54193. clip?: number;
  54194. arc?: number;
  54195. closed?: boolean;
  54196. updatable?: boolean;
  54197. sideOrientation?: number;
  54198. frontUVs?: Vector4;
  54199. backUVs?: Vector4;
  54200. cap?: number;
  54201. invertUV?: boolean;
  54202. }, scene?: Nullable<Scene>): Mesh;
  54203. }
  54204. }
  54205. declare module BABYLON {
  54206. /**
  54207. * Class containing static functions to help procedurally build meshes
  54208. */
  54209. export class TiledPlaneBuilder {
  54210. /**
  54211. * Creates a tiled plane mesh
  54212. * * The parameter `pattern` will, depending on value, do nothing or
  54213. * * * flip (reflect about central vertical) alternate tiles across and up
  54214. * * * flip every tile on alternate rows
  54215. * * * rotate (180 degs) alternate tiles across and up
  54216. * * * rotate every tile on alternate rows
  54217. * * * flip and rotate alternate tiles across and up
  54218. * * * flip and rotate every tile on alternate rows
  54219. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54220. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54221. * * 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
  54222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54223. * * 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)
  54224. * * 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)
  54225. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54226. * @param name defines the name of the mesh
  54227. * @param options defines the options used to create the mesh
  54228. * @param scene defines the hosting scene
  54229. * @returns the box mesh
  54230. */
  54231. static CreateTiledPlane(name: string, options: {
  54232. pattern?: number;
  54233. tileSize?: number;
  54234. tileWidth?: number;
  54235. tileHeight?: number;
  54236. size?: number;
  54237. width?: number;
  54238. height?: number;
  54239. alignHorizontal?: number;
  54240. alignVertical?: number;
  54241. sideOrientation?: number;
  54242. frontUVs?: Vector4;
  54243. backUVs?: Vector4;
  54244. updatable?: boolean;
  54245. }, scene?: Nullable<Scene>): Mesh;
  54246. }
  54247. }
  54248. declare module BABYLON {
  54249. /**
  54250. * Class containing static functions to help procedurally build meshes
  54251. */
  54252. export class TubeBuilder {
  54253. /**
  54254. * Creates a tube mesh.
  54255. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54256. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54257. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54258. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54259. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54260. * * 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)
  54261. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54262. * * 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
  54263. * * 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
  54264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54265. * * 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
  54266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54268. * @param name defines the name of the mesh
  54269. * @param options defines the options used to create the mesh
  54270. * @param scene defines the hosting scene
  54271. * @returns the tube mesh
  54272. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54273. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54274. */
  54275. static CreateTube(name: string, options: {
  54276. path: Vector3[];
  54277. radius?: number;
  54278. tessellation?: number;
  54279. radiusFunction?: {
  54280. (i: number, distance: number): number;
  54281. };
  54282. cap?: number;
  54283. arc?: number;
  54284. updatable?: boolean;
  54285. sideOrientation?: number;
  54286. frontUVs?: Vector4;
  54287. backUVs?: Vector4;
  54288. instance?: Mesh;
  54289. invertUV?: boolean;
  54290. }, scene?: Nullable<Scene>): Mesh;
  54291. }
  54292. }
  54293. declare module BABYLON {
  54294. /**
  54295. * Class containing static functions to help procedurally build meshes
  54296. */
  54297. export class IcoSphereBuilder {
  54298. /**
  54299. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54300. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54301. * * 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`)
  54302. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54303. * * 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
  54304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54305. * * 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
  54306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54307. * @param name defines the name of the mesh
  54308. * @param options defines the options used to create the mesh
  54309. * @param scene defines the hosting scene
  54310. * @returns the icosahedron mesh
  54311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54312. */
  54313. static CreateIcoSphere(name: string, options: {
  54314. radius?: number;
  54315. radiusX?: number;
  54316. radiusY?: number;
  54317. radiusZ?: number;
  54318. flat?: boolean;
  54319. subdivisions?: number;
  54320. sideOrientation?: number;
  54321. frontUVs?: Vector4;
  54322. backUVs?: Vector4;
  54323. updatable?: boolean;
  54324. }, scene?: Nullable<Scene>): Mesh;
  54325. }
  54326. }
  54327. declare module BABYLON {
  54328. /**
  54329. * Class containing static functions to help procedurally build meshes
  54330. */
  54331. export class DecalBuilder {
  54332. /**
  54333. * Creates a decal mesh.
  54334. * 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
  54335. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54336. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54337. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54338. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54339. * @param name defines the name of the mesh
  54340. * @param sourceMesh defines the mesh where the decal must be applied
  54341. * @param options defines the options used to create the mesh
  54342. * @param scene defines the hosting scene
  54343. * @returns the decal mesh
  54344. * @see https://doc.babylonjs.com/how_to/decals
  54345. */
  54346. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54347. position?: Vector3;
  54348. normal?: Vector3;
  54349. size?: Vector3;
  54350. angle?: number;
  54351. }): Mesh;
  54352. }
  54353. }
  54354. declare module BABYLON {
  54355. /**
  54356. * Class containing static functions to help procedurally build meshes
  54357. */
  54358. export class MeshBuilder {
  54359. /**
  54360. * Creates a box mesh
  54361. * * The parameter `size` sets the size (float) of each box side (default 1)
  54362. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54363. * * 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)
  54364. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54366. * * 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
  54367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54368. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54369. * @param name defines the name of the mesh
  54370. * @param options defines the options used to create the mesh
  54371. * @param scene defines the hosting scene
  54372. * @returns the box mesh
  54373. */
  54374. static CreateBox(name: string, options: {
  54375. size?: number;
  54376. width?: number;
  54377. height?: number;
  54378. depth?: number;
  54379. faceUV?: Vector4[];
  54380. faceColors?: Color4[];
  54381. sideOrientation?: number;
  54382. frontUVs?: Vector4;
  54383. backUVs?: Vector4;
  54384. updatable?: boolean;
  54385. }, scene?: Nullable<Scene>): Mesh;
  54386. /**
  54387. * Creates a tiled box mesh
  54388. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54390. * @param name defines the name of the mesh
  54391. * @param options defines the options used to create the mesh
  54392. * @param scene defines the hosting scene
  54393. * @returns the tiled box mesh
  54394. */
  54395. static CreateTiledBox(name: string, options: {
  54396. pattern?: number;
  54397. size?: number;
  54398. width?: number;
  54399. height?: number;
  54400. depth: number;
  54401. tileSize?: number;
  54402. tileWidth?: number;
  54403. tileHeight?: number;
  54404. faceUV?: Vector4[];
  54405. faceColors?: Color4[];
  54406. alignHorizontal?: number;
  54407. alignVertical?: number;
  54408. sideOrientation?: number;
  54409. updatable?: boolean;
  54410. }, scene?: Nullable<Scene>): Mesh;
  54411. /**
  54412. * Creates a sphere mesh
  54413. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54414. * * 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`)
  54415. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54416. * * 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
  54417. * * 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)
  54418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54419. * * 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
  54420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54421. * @param name defines the name of the mesh
  54422. * @param options defines the options used to create the mesh
  54423. * @param scene defines the hosting scene
  54424. * @returns the sphere mesh
  54425. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54426. */
  54427. static CreateSphere(name: string, options: {
  54428. segments?: number;
  54429. diameter?: number;
  54430. diameterX?: number;
  54431. diameterY?: number;
  54432. diameterZ?: number;
  54433. arc?: number;
  54434. slice?: number;
  54435. sideOrientation?: number;
  54436. frontUVs?: Vector4;
  54437. backUVs?: Vector4;
  54438. updatable?: boolean;
  54439. }, scene?: Nullable<Scene>): Mesh;
  54440. /**
  54441. * Creates a plane polygonal mesh. By default, this is a disc
  54442. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54443. * * 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
  54444. * * 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
  54445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54446. * * 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
  54447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54448. * @param name defines the name of the mesh
  54449. * @param options defines the options used to create the mesh
  54450. * @param scene defines the hosting scene
  54451. * @returns the plane polygonal mesh
  54452. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54453. */
  54454. static CreateDisc(name: string, options: {
  54455. radius?: number;
  54456. tessellation?: number;
  54457. arc?: number;
  54458. updatable?: boolean;
  54459. sideOrientation?: number;
  54460. frontUVs?: Vector4;
  54461. backUVs?: Vector4;
  54462. }, scene?: Nullable<Scene>): Mesh;
  54463. /**
  54464. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54465. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54466. * * 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`)
  54467. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54468. * * 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
  54469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54470. * * 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
  54471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54472. * @param name defines the name of the mesh
  54473. * @param options defines the options used to create the mesh
  54474. * @param scene defines the hosting scene
  54475. * @returns the icosahedron mesh
  54476. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54477. */
  54478. static CreateIcoSphere(name: string, options: {
  54479. radius?: number;
  54480. radiusX?: number;
  54481. radiusY?: number;
  54482. radiusZ?: number;
  54483. flat?: boolean;
  54484. subdivisions?: number;
  54485. sideOrientation?: number;
  54486. frontUVs?: Vector4;
  54487. backUVs?: Vector4;
  54488. updatable?: boolean;
  54489. }, scene?: Nullable<Scene>): Mesh;
  54490. /**
  54491. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54492. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54493. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54494. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54495. * * 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
  54496. * * 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
  54497. * * 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
  54498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54499. * * 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
  54500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54501. * * 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
  54502. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54503. * * 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
  54504. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54506. * @param name defines the name of the mesh
  54507. * @param options defines the options used to create the mesh
  54508. * @param scene defines the hosting scene
  54509. * @returns the ribbon mesh
  54510. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54512. */
  54513. static CreateRibbon(name: string, options: {
  54514. pathArray: Vector3[][];
  54515. closeArray?: boolean;
  54516. closePath?: boolean;
  54517. offset?: number;
  54518. updatable?: boolean;
  54519. sideOrientation?: number;
  54520. frontUVs?: Vector4;
  54521. backUVs?: Vector4;
  54522. instance?: Mesh;
  54523. invertUV?: boolean;
  54524. uvs?: Vector2[];
  54525. colors?: Color4[];
  54526. }, scene?: Nullable<Scene>): Mesh;
  54527. /**
  54528. * Creates a cylinder or a cone mesh
  54529. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54530. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54531. * * 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.
  54532. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54533. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54534. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54535. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54536. * * 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).
  54537. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54538. * * 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).
  54539. * * 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
  54540. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54541. * * 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
  54542. * * 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.
  54543. * * If `enclose` is false, a ring surface is one element.
  54544. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54545. * * 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
  54546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54547. * * 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
  54548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54549. * @param name defines the name of the mesh
  54550. * @param options defines the options used to create the mesh
  54551. * @param scene defines the hosting scene
  54552. * @returns the cylinder mesh
  54553. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54554. */
  54555. static CreateCylinder(name: string, options: {
  54556. height?: number;
  54557. diameterTop?: number;
  54558. diameterBottom?: number;
  54559. diameter?: number;
  54560. tessellation?: number;
  54561. subdivisions?: number;
  54562. arc?: number;
  54563. faceColors?: Color4[];
  54564. faceUV?: Vector4[];
  54565. updatable?: boolean;
  54566. hasRings?: boolean;
  54567. enclose?: boolean;
  54568. cap?: number;
  54569. sideOrientation?: number;
  54570. frontUVs?: Vector4;
  54571. backUVs?: Vector4;
  54572. }, scene?: Nullable<Scene>): Mesh;
  54573. /**
  54574. * Creates a torus mesh
  54575. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54576. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54577. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54579. * * 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
  54580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54581. * @param name defines the name of the mesh
  54582. * @param options defines the options used to create the mesh
  54583. * @param scene defines the hosting scene
  54584. * @returns the torus mesh
  54585. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54586. */
  54587. static CreateTorus(name: string, options: {
  54588. diameter?: number;
  54589. thickness?: number;
  54590. tessellation?: number;
  54591. updatable?: boolean;
  54592. sideOrientation?: number;
  54593. frontUVs?: Vector4;
  54594. backUVs?: Vector4;
  54595. }, scene?: Nullable<Scene>): Mesh;
  54596. /**
  54597. * Creates a torus knot mesh
  54598. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54599. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54600. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54601. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54603. * * 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
  54604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54605. * @param name defines the name of the mesh
  54606. * @param options defines the options used to create the mesh
  54607. * @param scene defines the hosting scene
  54608. * @returns the torus knot mesh
  54609. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54610. */
  54611. static CreateTorusKnot(name: string, options: {
  54612. radius?: number;
  54613. tube?: number;
  54614. radialSegments?: number;
  54615. tubularSegments?: number;
  54616. p?: number;
  54617. q?: number;
  54618. updatable?: boolean;
  54619. sideOrientation?: number;
  54620. frontUVs?: Vector4;
  54621. backUVs?: Vector4;
  54622. }, scene?: Nullable<Scene>): Mesh;
  54623. /**
  54624. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54625. * * 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
  54626. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54627. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54628. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54629. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54630. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54631. * * 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
  54632. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54635. * @param name defines the name of the new line system
  54636. * @param options defines the options used to create the line system
  54637. * @param scene defines the hosting scene
  54638. * @returns a new line system mesh
  54639. */
  54640. static CreateLineSystem(name: string, options: {
  54641. lines: Vector3[][];
  54642. updatable?: boolean;
  54643. instance?: Nullable<LinesMesh>;
  54644. colors?: Nullable<Color4[][]>;
  54645. useVertexAlpha?: boolean;
  54646. }, scene: Nullable<Scene>): LinesMesh;
  54647. /**
  54648. * Creates a line mesh
  54649. * 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
  54650. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54651. * * The parameter `points` is an array successive Vector3
  54652. * * 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
  54653. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54654. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54655. * * When updating an instance, remember that only point positions can change, not the number of points
  54656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54657. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54658. * @param name defines the name of the new line system
  54659. * @param options defines the options used to create the line system
  54660. * @param scene defines the hosting scene
  54661. * @returns a new line mesh
  54662. */
  54663. static CreateLines(name: string, options: {
  54664. points: Vector3[];
  54665. updatable?: boolean;
  54666. instance?: Nullable<LinesMesh>;
  54667. colors?: Color4[];
  54668. useVertexAlpha?: boolean;
  54669. }, scene?: Nullable<Scene>): LinesMesh;
  54670. /**
  54671. * Creates a dashed line mesh
  54672. * * 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
  54673. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54674. * * The parameter `points` is an array successive Vector3
  54675. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54676. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54677. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54678. * * 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
  54679. * * When updating an instance, remember that only point positions can change, not the number of points
  54680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54681. * @param name defines the name of the mesh
  54682. * @param options defines the options used to create the mesh
  54683. * @param scene defines the hosting scene
  54684. * @returns the dashed line mesh
  54685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54686. */
  54687. static CreateDashedLines(name: string, options: {
  54688. points: Vector3[];
  54689. dashSize?: number;
  54690. gapSize?: number;
  54691. dashNb?: number;
  54692. updatable?: boolean;
  54693. instance?: LinesMesh;
  54694. }, scene?: Nullable<Scene>): LinesMesh;
  54695. /**
  54696. * 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.
  54697. * * 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.
  54698. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54699. * * 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.
  54700. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54701. * * 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
  54702. * * 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
  54703. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54705. * * 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
  54706. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54708. * @param name defines the name of the mesh
  54709. * @param options defines the options used to create the mesh
  54710. * @param scene defines the hosting scene
  54711. * @returns the extruded shape mesh
  54712. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54714. */
  54715. static ExtrudeShape(name: string, options: {
  54716. shape: Vector3[];
  54717. path: Vector3[];
  54718. scale?: number;
  54719. rotation?: number;
  54720. cap?: number;
  54721. updatable?: boolean;
  54722. sideOrientation?: number;
  54723. frontUVs?: Vector4;
  54724. backUVs?: Vector4;
  54725. instance?: Mesh;
  54726. invertUV?: boolean;
  54727. }, scene?: Nullable<Scene>): Mesh;
  54728. /**
  54729. * Creates an custom extruded shape mesh.
  54730. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54731. * * 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.
  54732. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54733. * * 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
  54734. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54735. * * 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
  54736. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54737. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54738. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54739. * * 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
  54740. * * 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
  54741. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54743. * * 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
  54744. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54746. * @param name defines the name of the mesh
  54747. * @param options defines the options used to create the mesh
  54748. * @param scene defines the hosting scene
  54749. * @returns the custom extruded shape mesh
  54750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54751. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54752. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54753. */
  54754. static ExtrudeShapeCustom(name: string, options: {
  54755. shape: Vector3[];
  54756. path: Vector3[];
  54757. scaleFunction?: any;
  54758. rotationFunction?: any;
  54759. ribbonCloseArray?: boolean;
  54760. ribbonClosePath?: boolean;
  54761. cap?: number;
  54762. updatable?: boolean;
  54763. sideOrientation?: number;
  54764. frontUVs?: Vector4;
  54765. backUVs?: Vector4;
  54766. instance?: Mesh;
  54767. invertUV?: boolean;
  54768. }, scene?: Nullable<Scene>): Mesh;
  54769. /**
  54770. * Creates lathe mesh.
  54771. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54772. * * 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
  54773. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54774. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54775. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54776. * * 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
  54777. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54778. * * 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
  54779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54780. * * 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
  54781. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 lathe mesh
  54787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54788. */
  54789. static CreateLathe(name: string, options: {
  54790. shape: Vector3[];
  54791. radius?: number;
  54792. tessellation?: number;
  54793. clip?: number;
  54794. arc?: number;
  54795. closed?: boolean;
  54796. updatable?: boolean;
  54797. sideOrientation?: number;
  54798. frontUVs?: Vector4;
  54799. backUVs?: Vector4;
  54800. cap?: number;
  54801. invertUV?: boolean;
  54802. }, scene?: Nullable<Scene>): Mesh;
  54803. /**
  54804. * Creates a tiled plane mesh
  54805. * * You can set a limited pattern arrangement with the tiles
  54806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54807. * * 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
  54808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54809. * @param name defines the name of the mesh
  54810. * @param options defines the options used to create the mesh
  54811. * @param scene defines the hosting scene
  54812. * @returns the plane mesh
  54813. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54814. */
  54815. static CreateTiledPlane(name: string, options: {
  54816. pattern?: number;
  54817. tileSize?: number;
  54818. tileWidth?: number;
  54819. tileHeight?: number;
  54820. size?: number;
  54821. width?: number;
  54822. height?: number;
  54823. alignHorizontal?: number;
  54824. alignVertical?: number;
  54825. sideOrientation?: number;
  54826. frontUVs?: Vector4;
  54827. backUVs?: Vector4;
  54828. updatable?: boolean;
  54829. }, scene?: Nullable<Scene>): Mesh;
  54830. /**
  54831. * Creates a plane mesh
  54832. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54833. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54834. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54836. * * 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
  54837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54838. * @param name defines the name of the mesh
  54839. * @param options defines the options used to create the mesh
  54840. * @param scene defines the hosting scene
  54841. * @returns the plane mesh
  54842. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54843. */
  54844. static CreatePlane(name: string, options: {
  54845. size?: number;
  54846. width?: number;
  54847. height?: number;
  54848. sideOrientation?: number;
  54849. frontUVs?: Vector4;
  54850. backUVs?: Vector4;
  54851. updatable?: boolean;
  54852. sourcePlane?: Plane;
  54853. }, scene?: Nullable<Scene>): Mesh;
  54854. /**
  54855. * Creates a ground mesh
  54856. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54857. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54859. * @param name defines the name of the mesh
  54860. * @param options defines the options used to create the mesh
  54861. * @param scene defines the hosting scene
  54862. * @returns the ground mesh
  54863. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54864. */
  54865. static CreateGround(name: string, options: {
  54866. width?: number;
  54867. height?: number;
  54868. subdivisions?: number;
  54869. subdivisionsX?: number;
  54870. subdivisionsY?: number;
  54871. updatable?: boolean;
  54872. }, scene?: Nullable<Scene>): Mesh;
  54873. /**
  54874. * Creates a tiled ground mesh
  54875. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54876. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54877. * * 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
  54878. * * 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
  54879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54880. * @param name defines the name of the mesh
  54881. * @param options defines the options used to create the mesh
  54882. * @param scene defines the hosting scene
  54883. * @returns the tiled ground mesh
  54884. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54885. */
  54886. static CreateTiledGround(name: string, options: {
  54887. xmin: number;
  54888. zmin: number;
  54889. xmax: number;
  54890. zmax: number;
  54891. subdivisions?: {
  54892. w: number;
  54893. h: number;
  54894. };
  54895. precision?: {
  54896. w: number;
  54897. h: number;
  54898. };
  54899. updatable?: boolean;
  54900. }, scene?: Nullable<Scene>): Mesh;
  54901. /**
  54902. * Creates a ground mesh from a height map
  54903. * * The parameter `url` sets the URL of the height map image resource.
  54904. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54905. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54906. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54907. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54908. * * 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.
  54909. * * 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).
  54910. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54912. * @param name defines the name of the mesh
  54913. * @param url defines the url to the height map
  54914. * @param options defines the options used to create the mesh
  54915. * @param scene defines the hosting scene
  54916. * @returns the ground mesh
  54917. * @see https://doc.babylonjs.com/babylon101/height_map
  54918. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54919. */
  54920. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54921. width?: number;
  54922. height?: number;
  54923. subdivisions?: number;
  54924. minHeight?: number;
  54925. maxHeight?: number;
  54926. colorFilter?: Color3;
  54927. alphaFilter?: number;
  54928. updatable?: boolean;
  54929. onReady?: (mesh: GroundMesh) => void;
  54930. }, scene?: Nullable<Scene>): GroundMesh;
  54931. /**
  54932. * Creates a polygon mesh
  54933. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54934. * * 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
  54935. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54937. * * 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)
  54938. * * Remember you can only change the shape positions, not their number when updating a polygon
  54939. * @param name defines the name of the mesh
  54940. * @param options defines the options used to create the mesh
  54941. * @param scene defines the hosting scene
  54942. * @param earcutInjection can be used to inject your own earcut reference
  54943. * @returns the polygon mesh
  54944. */
  54945. static CreatePolygon(name: string, options: {
  54946. shape: Vector3[];
  54947. holes?: Vector3[][];
  54948. depth?: number;
  54949. faceUV?: Vector4[];
  54950. faceColors?: Color4[];
  54951. updatable?: boolean;
  54952. sideOrientation?: number;
  54953. frontUVs?: Vector4;
  54954. backUVs?: Vector4;
  54955. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54956. /**
  54957. * Creates an extruded polygon mesh, with depth in the Y direction.
  54958. * * 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)
  54959. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54960. * @param name defines the name of the mesh
  54961. * @param options defines the options used to create the mesh
  54962. * @param scene defines the hosting scene
  54963. * @param earcutInjection can be used to inject your own earcut reference
  54964. * @returns the polygon mesh
  54965. */
  54966. static ExtrudePolygon(name: string, options: {
  54967. shape: Vector3[];
  54968. holes?: Vector3[][];
  54969. depth?: number;
  54970. faceUV?: Vector4[];
  54971. faceColors?: Color4[];
  54972. updatable?: boolean;
  54973. sideOrientation?: number;
  54974. frontUVs?: Vector4;
  54975. backUVs?: Vector4;
  54976. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54977. /**
  54978. * Creates a tube mesh.
  54979. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54980. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54981. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54982. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54983. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54984. * * 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)
  54985. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54986. * * 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
  54987. * * 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
  54988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54989. * * 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
  54990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54992. * @param name defines the name of the mesh
  54993. * @param options defines the options used to create the mesh
  54994. * @param scene defines the hosting scene
  54995. * @returns the tube mesh
  54996. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54997. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54998. */
  54999. static CreateTube(name: string, options: {
  55000. path: Vector3[];
  55001. radius?: number;
  55002. tessellation?: number;
  55003. radiusFunction?: {
  55004. (i: number, distance: number): number;
  55005. };
  55006. cap?: number;
  55007. arc?: number;
  55008. updatable?: boolean;
  55009. sideOrientation?: number;
  55010. frontUVs?: Vector4;
  55011. backUVs?: Vector4;
  55012. instance?: Mesh;
  55013. invertUV?: boolean;
  55014. }, scene?: Nullable<Scene>): Mesh;
  55015. /**
  55016. * Creates a polyhedron mesh
  55017. * * 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
  55018. * * The parameter `size` (positive float, default 1) sets the polygon size
  55019. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55020. * * 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`
  55021. * * 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
  55022. * * 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)`)
  55023. * * 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
  55024. * * 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
  55025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55026. * * 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
  55027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55028. * @param name defines the name of the mesh
  55029. * @param options defines the options used to create the mesh
  55030. * @param scene defines the hosting scene
  55031. * @returns the polyhedron mesh
  55032. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55033. */
  55034. static CreatePolyhedron(name: string, options: {
  55035. type?: number;
  55036. size?: number;
  55037. sizeX?: number;
  55038. sizeY?: number;
  55039. sizeZ?: number;
  55040. custom?: any;
  55041. faceUV?: Vector4[];
  55042. faceColors?: Color4[];
  55043. flat?: boolean;
  55044. updatable?: boolean;
  55045. sideOrientation?: number;
  55046. frontUVs?: Vector4;
  55047. backUVs?: Vector4;
  55048. }, scene?: Nullable<Scene>): Mesh;
  55049. /**
  55050. * Creates a decal mesh.
  55051. * 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
  55052. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55053. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55054. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55055. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55056. * @param name defines the name of the mesh
  55057. * @param sourceMesh defines the mesh where the decal must be applied
  55058. * @param options defines the options used to create the mesh
  55059. * @param scene defines the hosting scene
  55060. * @returns the decal mesh
  55061. * @see https://doc.babylonjs.com/how_to/decals
  55062. */
  55063. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55064. position?: Vector3;
  55065. normal?: Vector3;
  55066. size?: Vector3;
  55067. angle?: number;
  55068. }): Mesh;
  55069. }
  55070. }
  55071. declare module BABYLON {
  55072. /**
  55073. * A simplifier interface for future simplification implementations
  55074. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55075. */
  55076. export interface ISimplifier {
  55077. /**
  55078. * Simplification of a given mesh according to the given settings.
  55079. * Since this requires computation, it is assumed that the function runs async.
  55080. * @param settings The settings of the simplification, including quality and distance
  55081. * @param successCallback A callback that will be called after the mesh was simplified.
  55082. * @param errorCallback in case of an error, this callback will be called. optional.
  55083. */
  55084. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55085. }
  55086. /**
  55087. * Expected simplification settings.
  55088. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55089. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55090. */
  55091. export interface ISimplificationSettings {
  55092. /**
  55093. * Gets or sets the expected quality
  55094. */
  55095. quality: number;
  55096. /**
  55097. * Gets or sets the distance when this optimized version should be used
  55098. */
  55099. distance: number;
  55100. /**
  55101. * Gets an already optimized mesh
  55102. */
  55103. optimizeMesh?: boolean;
  55104. }
  55105. /**
  55106. * Class used to specify simplification options
  55107. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55108. */
  55109. export class SimplificationSettings implements ISimplificationSettings {
  55110. /** expected quality */
  55111. quality: number;
  55112. /** distance when this optimized version should be used */
  55113. distance: number;
  55114. /** already optimized mesh */
  55115. optimizeMesh?: boolean | undefined;
  55116. /**
  55117. * Creates a SimplificationSettings
  55118. * @param quality expected quality
  55119. * @param distance distance when this optimized version should be used
  55120. * @param optimizeMesh already optimized mesh
  55121. */
  55122. constructor(
  55123. /** expected quality */
  55124. quality: number,
  55125. /** distance when this optimized version should be used */
  55126. distance: number,
  55127. /** already optimized mesh */
  55128. optimizeMesh?: boolean | undefined);
  55129. }
  55130. /**
  55131. * Interface used to define a simplification task
  55132. */
  55133. export interface ISimplificationTask {
  55134. /**
  55135. * Array of settings
  55136. */
  55137. settings: Array<ISimplificationSettings>;
  55138. /**
  55139. * Simplification type
  55140. */
  55141. simplificationType: SimplificationType;
  55142. /**
  55143. * Mesh to simplify
  55144. */
  55145. mesh: Mesh;
  55146. /**
  55147. * Callback called on success
  55148. */
  55149. successCallback?: () => void;
  55150. /**
  55151. * Defines if parallel processing can be used
  55152. */
  55153. parallelProcessing: boolean;
  55154. }
  55155. /**
  55156. * Queue used to order the simplification tasks
  55157. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55158. */
  55159. export class SimplificationQueue {
  55160. private _simplificationArray;
  55161. /**
  55162. * Gets a boolean indicating that the process is still running
  55163. */
  55164. running: boolean;
  55165. /**
  55166. * Creates a new queue
  55167. */
  55168. constructor();
  55169. /**
  55170. * Adds a new simplification task
  55171. * @param task defines a task to add
  55172. */
  55173. addTask(task: ISimplificationTask): void;
  55174. /**
  55175. * Execute next task
  55176. */
  55177. executeNext(): void;
  55178. /**
  55179. * Execute a simplification task
  55180. * @param task defines the task to run
  55181. */
  55182. runSimplification(task: ISimplificationTask): void;
  55183. private getSimplifier;
  55184. }
  55185. /**
  55186. * The implemented types of simplification
  55187. * At the moment only Quadratic Error Decimation is implemented
  55188. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55189. */
  55190. export enum SimplificationType {
  55191. /** Quadratic error decimation */
  55192. QUADRATIC = 0
  55193. }
  55194. }
  55195. declare module BABYLON {
  55196. interface Scene {
  55197. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  55198. /**
  55199. * Gets or sets the simplification queue attached to the scene
  55200. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55201. */
  55202. simplificationQueue: SimplificationQueue;
  55203. }
  55204. interface Mesh {
  55205. /**
  55206. * Simplify the mesh according to the given array of settings.
  55207. * Function will return immediately and will simplify async
  55208. * @param settings a collection of simplification settings
  55209. * @param parallelProcessing should all levels calculate parallel or one after the other
  55210. * @param simplificationType the type of simplification to run
  55211. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55212. * @returns the current mesh
  55213. */
  55214. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55215. }
  55216. /**
  55217. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55218. * created in a scene
  55219. */
  55220. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55221. /**
  55222. * The component name helpfull to identify the component in the list of scene components.
  55223. */
  55224. readonly name: string;
  55225. /**
  55226. * The scene the component belongs to.
  55227. */
  55228. scene: Scene;
  55229. /**
  55230. * Creates a new instance of the component for the given scene
  55231. * @param scene Defines the scene to register the component in
  55232. */
  55233. constructor(scene: Scene);
  55234. /**
  55235. * Registers the component in a given scene
  55236. */
  55237. register(): void;
  55238. /**
  55239. * Rebuilds the elements related to this component in case of
  55240. * context lost for instance.
  55241. */
  55242. rebuild(): void;
  55243. /**
  55244. * Disposes the component and the associated ressources
  55245. */
  55246. dispose(): void;
  55247. private _beforeCameraUpdate;
  55248. }
  55249. }
  55250. declare module BABYLON {
  55251. /**
  55252. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55253. */
  55254. export interface INavigationEnginePlugin {
  55255. /**
  55256. * plugin name
  55257. */
  55258. name: string;
  55259. /**
  55260. * Creates a navigation mesh
  55261. * @param meshes array of all the geometry used to compute the navigatio mesh
  55262. * @param parameters bunch of parameters used to filter geometry
  55263. */
  55264. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55265. /**
  55266. * Create a navigation mesh debug mesh
  55267. * @param scene is where the mesh will be added
  55268. * @returns debug display mesh
  55269. */
  55270. createDebugNavMesh(scene: Scene): Mesh;
  55271. /**
  55272. * Get a navigation mesh constrained position, closest to the parameter position
  55273. * @param position world position
  55274. * @returns the closest point to position constrained by the navigation mesh
  55275. */
  55276. getClosestPoint(position: Vector3): Vector3;
  55277. /**
  55278. * Get a navigation mesh constrained position, within a particular radius
  55279. * @param position world position
  55280. * @param maxRadius the maximum distance to the constrained world position
  55281. * @returns the closest point to position constrained by the navigation mesh
  55282. */
  55283. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55284. /**
  55285. * Compute the final position from a segment made of destination-position
  55286. * @param position world position
  55287. * @param destination world position
  55288. * @returns the resulting point along the navmesh
  55289. */
  55290. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55291. /**
  55292. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55293. * @param start world position
  55294. * @param end world position
  55295. * @returns array containing world position composing the path
  55296. */
  55297. computePath(start: Vector3, end: Vector3): Vector3[];
  55298. /**
  55299. * If this plugin is supported
  55300. * @returns true if plugin is supported
  55301. */
  55302. isSupported(): boolean;
  55303. /**
  55304. * Create a new Crowd so you can add agents
  55305. * @param maxAgents the maximum agent count in the crowd
  55306. * @param maxAgentRadius the maximum radius an agent can have
  55307. * @param scene to attach the crowd to
  55308. * @returns the crowd you can add agents to
  55309. */
  55310. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55311. /**
  55312. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55313. * The queries will try to find a solution within those bounds
  55314. * default is (1,1,1)
  55315. * @param extent x,y,z value that define the extent around the queries point of reference
  55316. */
  55317. setDefaultQueryExtent(extent: Vector3): void;
  55318. /**
  55319. * Get the Bounding box extent specified by setDefaultQueryExtent
  55320. * @returns the box extent values
  55321. */
  55322. getDefaultQueryExtent(): Vector3;
  55323. /**
  55324. * Release all resources
  55325. */
  55326. dispose(): void;
  55327. }
  55328. /**
  55329. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55330. */
  55331. export interface ICrowd {
  55332. /**
  55333. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55334. * You can attach anything to that node. The node position is updated in the scene update tick.
  55335. * @param pos world position that will be constrained by the navigation mesh
  55336. * @param parameters agent parameters
  55337. * @param transform hooked to the agent that will be update by the scene
  55338. * @returns agent index
  55339. */
  55340. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55341. /**
  55342. * Returns the agent position in world space
  55343. * @param index agent index returned by addAgent
  55344. * @returns world space position
  55345. */
  55346. getAgentPosition(index: number): Vector3;
  55347. /**
  55348. * Gets the agent velocity in world space
  55349. * @param index agent index returned by addAgent
  55350. * @returns world space velocity
  55351. */
  55352. getAgentVelocity(index: number): Vector3;
  55353. /**
  55354. * remove a particular agent previously created
  55355. * @param index agent index returned by addAgent
  55356. */
  55357. removeAgent(index: number): void;
  55358. /**
  55359. * get the list of all agents attached to this crowd
  55360. * @returns list of agent indices
  55361. */
  55362. getAgents(): number[];
  55363. /**
  55364. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55365. * @param deltaTime in seconds
  55366. */
  55367. update(deltaTime: number): void;
  55368. /**
  55369. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55370. * @param index agent index returned by addAgent
  55371. * @param destination targeted world position
  55372. */
  55373. agentGoto(index: number, destination: Vector3): void;
  55374. /**
  55375. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55376. * The queries will try to find a solution within those bounds
  55377. * default is (1,1,1)
  55378. * @param extent x,y,z value that define the extent around the queries point of reference
  55379. */
  55380. setDefaultQueryExtent(extent: Vector3): void;
  55381. /**
  55382. * Get the Bounding box extent specified by setDefaultQueryExtent
  55383. * @returns the box extent values
  55384. */
  55385. getDefaultQueryExtent(): Vector3;
  55386. /**
  55387. * Release all resources
  55388. */
  55389. dispose(): void;
  55390. }
  55391. /**
  55392. * Configures an agent
  55393. */
  55394. export interface IAgentParameters {
  55395. /**
  55396. * Agent radius. [Limit: >= 0]
  55397. */
  55398. radius: number;
  55399. /**
  55400. * Agent height. [Limit: > 0]
  55401. */
  55402. height: number;
  55403. /**
  55404. * Maximum allowed acceleration. [Limit: >= 0]
  55405. */
  55406. maxAcceleration: number;
  55407. /**
  55408. * Maximum allowed speed. [Limit: >= 0]
  55409. */
  55410. maxSpeed: number;
  55411. /**
  55412. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55413. */
  55414. collisionQueryRange: number;
  55415. /**
  55416. * The path visibility optimization range. [Limit: > 0]
  55417. */
  55418. pathOptimizationRange: number;
  55419. /**
  55420. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55421. */
  55422. separationWeight: number;
  55423. }
  55424. /**
  55425. * Configures the navigation mesh creation
  55426. */
  55427. export interface INavMeshParameters {
  55428. /**
  55429. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55430. */
  55431. cs: number;
  55432. /**
  55433. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55434. */
  55435. ch: number;
  55436. /**
  55437. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55438. */
  55439. walkableSlopeAngle: number;
  55440. /**
  55441. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55442. * be considered walkable. [Limit: >= 3] [Units: vx]
  55443. */
  55444. walkableHeight: number;
  55445. /**
  55446. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55447. */
  55448. walkableClimb: number;
  55449. /**
  55450. * The distance to erode/shrink the walkable area of the heightfield away from
  55451. * obstructions. [Limit: >=0] [Units: vx]
  55452. */
  55453. walkableRadius: number;
  55454. /**
  55455. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55456. */
  55457. maxEdgeLen: number;
  55458. /**
  55459. * The maximum distance a simplfied contour's border edges should deviate
  55460. * the original raw contour. [Limit: >=0] [Units: vx]
  55461. */
  55462. maxSimplificationError: number;
  55463. /**
  55464. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55465. */
  55466. minRegionArea: number;
  55467. /**
  55468. * Any regions with a span count smaller than this value will, if possible,
  55469. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55470. */
  55471. mergeRegionArea: number;
  55472. /**
  55473. * The maximum number of vertices allowed for polygons generated during the
  55474. * contour to polygon conversion process. [Limit: >= 3]
  55475. */
  55476. maxVertsPerPoly: number;
  55477. /**
  55478. * Sets the sampling distance to use when generating the detail mesh.
  55479. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55480. */
  55481. detailSampleDist: number;
  55482. /**
  55483. * The maximum distance the detail mesh surface should deviate from heightfield
  55484. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55485. */
  55486. detailSampleMaxError: number;
  55487. }
  55488. }
  55489. declare module BABYLON {
  55490. /**
  55491. * RecastJS navigation plugin
  55492. */
  55493. export class RecastJSPlugin implements INavigationEnginePlugin {
  55494. /**
  55495. * Reference to the Recast library
  55496. */
  55497. bjsRECAST: any;
  55498. /**
  55499. * plugin name
  55500. */
  55501. name: string;
  55502. /**
  55503. * the first navmesh created. We might extend this to support multiple navmeshes
  55504. */
  55505. navMesh: any;
  55506. /**
  55507. * Initializes the recastJS plugin
  55508. * @param recastInjection can be used to inject your own recast reference
  55509. */
  55510. constructor(recastInjection?: any);
  55511. /**
  55512. * Creates a navigation mesh
  55513. * @param meshes array of all the geometry used to compute the navigatio mesh
  55514. * @param parameters bunch of parameters used to filter geometry
  55515. */
  55516. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55517. /**
  55518. * Create a navigation mesh debug mesh
  55519. * @param scene is where the mesh will be added
  55520. * @returns debug display mesh
  55521. */
  55522. createDebugNavMesh(scene: Scene): Mesh;
  55523. /**
  55524. * Get a navigation mesh constrained position, closest to the parameter position
  55525. * @param position world position
  55526. * @returns the closest point to position constrained by the navigation mesh
  55527. */
  55528. getClosestPoint(position: Vector3): Vector3;
  55529. /**
  55530. * Get a navigation mesh constrained position, within a particular radius
  55531. * @param position world position
  55532. * @param maxRadius the maximum distance to the constrained world position
  55533. * @returns the closest point to position constrained by the navigation mesh
  55534. */
  55535. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55536. /**
  55537. * Compute the final position from a segment made of destination-position
  55538. * @param position world position
  55539. * @param destination world position
  55540. * @returns the resulting point along the navmesh
  55541. */
  55542. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55543. /**
  55544. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55545. * @param start world position
  55546. * @param end world position
  55547. * @returns array containing world position composing the path
  55548. */
  55549. computePath(start: Vector3, end: Vector3): Vector3[];
  55550. /**
  55551. * Create a new Crowd so you can add agents
  55552. * @param maxAgents the maximum agent count in the crowd
  55553. * @param maxAgentRadius the maximum radius an agent can have
  55554. * @param scene to attach the crowd to
  55555. * @returns the crowd you can add agents to
  55556. */
  55557. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55558. /**
  55559. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55560. * The queries will try to find a solution within those bounds
  55561. * default is (1,1,1)
  55562. * @param extent x,y,z value that define the extent around the queries point of reference
  55563. */
  55564. setDefaultQueryExtent(extent: Vector3): void;
  55565. /**
  55566. * Get the Bounding box extent specified by setDefaultQueryExtent
  55567. * @returns the box extent values
  55568. */
  55569. getDefaultQueryExtent(): Vector3;
  55570. /**
  55571. * Disposes
  55572. */
  55573. dispose(): void;
  55574. /**
  55575. * If this plugin is supported
  55576. * @returns true if plugin is supported
  55577. */
  55578. isSupported(): boolean;
  55579. }
  55580. /**
  55581. * Recast detour crowd implementation
  55582. */
  55583. export class RecastJSCrowd implements ICrowd {
  55584. /**
  55585. * Recast/detour plugin
  55586. */
  55587. bjsRECASTPlugin: RecastJSPlugin;
  55588. /**
  55589. * Link to the detour crowd
  55590. */
  55591. recastCrowd: any;
  55592. /**
  55593. * One transform per agent
  55594. */
  55595. transforms: TransformNode[];
  55596. /**
  55597. * All agents created
  55598. */
  55599. agents: number[];
  55600. /**
  55601. * Link to the scene is kept to unregister the crowd from the scene
  55602. */
  55603. private _scene;
  55604. /**
  55605. * Observer for crowd updates
  55606. */
  55607. private _onBeforeAnimationsObserver;
  55608. /**
  55609. * Constructor
  55610. * @param plugin recastJS plugin
  55611. * @param maxAgents the maximum agent count in the crowd
  55612. * @param maxAgentRadius the maximum radius an agent can have
  55613. * @param scene to attach the crowd to
  55614. * @returns the crowd you can add agents to
  55615. */
  55616. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55617. /**
  55618. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55619. * You can attach anything to that node. The node position is updated in the scene update tick.
  55620. * @param pos world position that will be constrained by the navigation mesh
  55621. * @param parameters agent parameters
  55622. * @param transform hooked to the agent that will be update by the scene
  55623. * @returns agent index
  55624. */
  55625. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55626. /**
  55627. * Returns the agent position in world space
  55628. * @param index agent index returned by addAgent
  55629. * @returns world space position
  55630. */
  55631. getAgentPosition(index: number): Vector3;
  55632. /**
  55633. * Returns the agent velocity in world space
  55634. * @param index agent index returned by addAgent
  55635. * @returns world space velocity
  55636. */
  55637. getAgentVelocity(index: number): Vector3;
  55638. /**
  55639. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55640. * @param index agent index returned by addAgent
  55641. * @param destination targeted world position
  55642. */
  55643. agentGoto(index: number, destination: Vector3): void;
  55644. /**
  55645. * remove a particular agent previously created
  55646. * @param index agent index returned by addAgent
  55647. */
  55648. removeAgent(index: number): void;
  55649. /**
  55650. * get the list of all agents attached to this crowd
  55651. * @returns list of agent indices
  55652. */
  55653. getAgents(): number[];
  55654. /**
  55655. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55656. * @param deltaTime in seconds
  55657. */
  55658. update(deltaTime: number): void;
  55659. /**
  55660. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  55661. * The queries will try to find a solution within those bounds
  55662. * default is (1,1,1)
  55663. * @param extent x,y,z value that define the extent around the queries point of reference
  55664. */
  55665. setDefaultQueryExtent(extent: Vector3): void;
  55666. /**
  55667. * Get the Bounding box extent specified by setDefaultQueryExtent
  55668. * @returns the box extent values
  55669. */
  55670. getDefaultQueryExtent(): Vector3;
  55671. /**
  55672. * Release all resources
  55673. */
  55674. dispose(): void;
  55675. }
  55676. }
  55677. declare module BABYLON {
  55678. /**
  55679. * Class used to enable access to IndexedDB
  55680. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55681. */
  55682. export class Database implements IOfflineProvider {
  55683. private _callbackManifestChecked;
  55684. private _currentSceneUrl;
  55685. private _db;
  55686. private _enableSceneOffline;
  55687. private _enableTexturesOffline;
  55688. private _manifestVersionFound;
  55689. private _mustUpdateRessources;
  55690. private _hasReachedQuota;
  55691. private _isSupported;
  55692. private _idbFactory;
  55693. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55694. private static IsUASupportingBlobStorage;
  55695. /**
  55696. * Gets a boolean indicating if Database storate is enabled (off by default)
  55697. */
  55698. static IDBStorageEnabled: boolean;
  55699. /**
  55700. * Gets a boolean indicating if scene must be saved in the database
  55701. */
  55702. readonly enableSceneOffline: boolean;
  55703. /**
  55704. * Gets a boolean indicating if textures must be saved in the database
  55705. */
  55706. readonly enableTexturesOffline: boolean;
  55707. /**
  55708. * Creates a new Database
  55709. * @param urlToScene defines the url to load the scene
  55710. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55711. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55712. */
  55713. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55714. private static _ParseURL;
  55715. private static _ReturnFullUrlLocation;
  55716. private _checkManifestFile;
  55717. /**
  55718. * Open the database and make it available
  55719. * @param successCallback defines the callback to call on success
  55720. * @param errorCallback defines the callback to call on error
  55721. */
  55722. open(successCallback: () => void, errorCallback: () => void): void;
  55723. /**
  55724. * Loads an image from the database
  55725. * @param url defines the url to load from
  55726. * @param image defines the target DOM image
  55727. */
  55728. loadImage(url: string, image: HTMLImageElement): void;
  55729. private _loadImageFromDBAsync;
  55730. private _saveImageIntoDBAsync;
  55731. private _checkVersionFromDB;
  55732. private _loadVersionFromDBAsync;
  55733. private _saveVersionIntoDBAsync;
  55734. /**
  55735. * Loads a file from database
  55736. * @param url defines the URL to load from
  55737. * @param sceneLoaded defines a callback to call on success
  55738. * @param progressCallBack defines a callback to call when progress changed
  55739. * @param errorCallback defines a callback to call on error
  55740. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55741. */
  55742. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55743. private _loadFileAsync;
  55744. private _saveFileAsync;
  55745. /**
  55746. * Validates if xhr data is correct
  55747. * @param xhr defines the request to validate
  55748. * @param dataType defines the expected data type
  55749. * @returns true if data is correct
  55750. */
  55751. private static _ValidateXHRData;
  55752. }
  55753. }
  55754. declare module BABYLON {
  55755. /** @hidden */
  55756. export var gpuUpdateParticlesPixelShader: {
  55757. name: string;
  55758. shader: string;
  55759. };
  55760. }
  55761. declare module BABYLON {
  55762. /** @hidden */
  55763. export var gpuUpdateParticlesVertexShader: {
  55764. name: string;
  55765. shader: string;
  55766. };
  55767. }
  55768. declare module BABYLON {
  55769. /** @hidden */
  55770. export var clipPlaneFragmentDeclaration2: {
  55771. name: string;
  55772. shader: string;
  55773. };
  55774. }
  55775. declare module BABYLON {
  55776. /** @hidden */
  55777. export var gpuRenderParticlesPixelShader: {
  55778. name: string;
  55779. shader: string;
  55780. };
  55781. }
  55782. declare module BABYLON {
  55783. /** @hidden */
  55784. export var clipPlaneVertexDeclaration2: {
  55785. name: string;
  55786. shader: string;
  55787. };
  55788. }
  55789. declare module BABYLON {
  55790. /** @hidden */
  55791. export var gpuRenderParticlesVertexShader: {
  55792. name: string;
  55793. shader: string;
  55794. };
  55795. }
  55796. declare module BABYLON {
  55797. /**
  55798. * This represents a GPU particle system in Babylon
  55799. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55800. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55801. */
  55802. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55803. /**
  55804. * The layer mask we are rendering the particles through.
  55805. */
  55806. layerMask: number;
  55807. private _capacity;
  55808. private _activeCount;
  55809. private _currentActiveCount;
  55810. private _accumulatedCount;
  55811. private _renderEffect;
  55812. private _updateEffect;
  55813. private _buffer0;
  55814. private _buffer1;
  55815. private _spriteBuffer;
  55816. private _updateVAO;
  55817. private _renderVAO;
  55818. private _targetIndex;
  55819. private _sourceBuffer;
  55820. private _targetBuffer;
  55821. private _engine;
  55822. private _currentRenderId;
  55823. private _started;
  55824. private _stopped;
  55825. private _timeDelta;
  55826. private _randomTexture;
  55827. private _randomTexture2;
  55828. private _attributesStrideSize;
  55829. private _updateEffectOptions;
  55830. private _randomTextureSize;
  55831. private _actualFrame;
  55832. private readonly _rawTextureWidth;
  55833. /**
  55834. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55835. */
  55836. static readonly IsSupported: boolean;
  55837. /**
  55838. * An event triggered when the system is disposed.
  55839. */
  55840. onDisposeObservable: Observable<GPUParticleSystem>;
  55841. /**
  55842. * Gets the maximum number of particles active at the same time.
  55843. * @returns The max number of active particles.
  55844. */
  55845. getCapacity(): number;
  55846. /**
  55847. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55848. * to override the particles.
  55849. */
  55850. forceDepthWrite: boolean;
  55851. /**
  55852. * Gets or set the number of active particles
  55853. */
  55854. activeParticleCount: number;
  55855. private _preWarmDone;
  55856. /**
  55857. * Is this system ready to be used/rendered
  55858. * @return true if the system is ready
  55859. */
  55860. isReady(): boolean;
  55861. /**
  55862. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55863. * @returns True if it has been started, otherwise false.
  55864. */
  55865. isStarted(): boolean;
  55866. /**
  55867. * Starts the particle system and begins to emit
  55868. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55869. */
  55870. start(delay?: number): void;
  55871. /**
  55872. * Stops the particle system.
  55873. */
  55874. stop(): void;
  55875. /**
  55876. * Remove all active particles
  55877. */
  55878. reset(): void;
  55879. /**
  55880. * Returns the string "GPUParticleSystem"
  55881. * @returns a string containing the class name
  55882. */
  55883. getClassName(): string;
  55884. private _colorGradientsTexture;
  55885. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55886. /**
  55887. * Adds a new color gradient
  55888. * @param gradient defines the gradient to use (between 0 and 1)
  55889. * @param color1 defines the color to affect to the specified gradient
  55890. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55891. * @returns the current particle system
  55892. */
  55893. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55894. /**
  55895. * Remove a specific color gradient
  55896. * @param gradient defines the gradient to remove
  55897. * @returns the current particle system
  55898. */
  55899. removeColorGradient(gradient: number): GPUParticleSystem;
  55900. private _angularSpeedGradientsTexture;
  55901. private _sizeGradientsTexture;
  55902. private _velocityGradientsTexture;
  55903. private _limitVelocityGradientsTexture;
  55904. private _dragGradientsTexture;
  55905. private _addFactorGradient;
  55906. /**
  55907. * Adds a new size gradient
  55908. * @param gradient defines the gradient to use (between 0 and 1)
  55909. * @param factor defines the size factor to affect to the specified gradient
  55910. * @returns the current particle system
  55911. */
  55912. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55913. /**
  55914. * Remove a specific size gradient
  55915. * @param gradient defines the gradient to remove
  55916. * @returns the current particle system
  55917. */
  55918. removeSizeGradient(gradient: number): GPUParticleSystem;
  55919. /**
  55920. * Adds a new angular speed gradient
  55921. * @param gradient defines the gradient to use (between 0 and 1)
  55922. * @param factor defines the angular speed to affect to the specified gradient
  55923. * @returns the current particle system
  55924. */
  55925. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55926. /**
  55927. * Remove a specific angular speed gradient
  55928. * @param gradient defines the gradient to remove
  55929. * @returns the current particle system
  55930. */
  55931. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55932. /**
  55933. * Adds a new velocity gradient
  55934. * @param gradient defines the gradient to use (between 0 and 1)
  55935. * @param factor defines the velocity to affect to the specified gradient
  55936. * @returns the current particle system
  55937. */
  55938. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55939. /**
  55940. * Remove a specific velocity gradient
  55941. * @param gradient defines the gradient to remove
  55942. * @returns the current particle system
  55943. */
  55944. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55945. /**
  55946. * Adds a new limit velocity gradient
  55947. * @param gradient defines the gradient to use (between 0 and 1)
  55948. * @param factor defines the limit velocity value to affect to the specified gradient
  55949. * @returns the current particle system
  55950. */
  55951. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55952. /**
  55953. * Remove a specific limit velocity gradient
  55954. * @param gradient defines the gradient to remove
  55955. * @returns the current particle system
  55956. */
  55957. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55958. /**
  55959. * Adds a new drag gradient
  55960. * @param gradient defines the gradient to use (between 0 and 1)
  55961. * @param factor defines the drag value to affect to the specified gradient
  55962. * @returns the current particle system
  55963. */
  55964. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55965. /**
  55966. * Remove a specific drag gradient
  55967. * @param gradient defines the gradient to remove
  55968. * @returns the current particle system
  55969. */
  55970. removeDragGradient(gradient: number): GPUParticleSystem;
  55971. /**
  55972. * Not supported by GPUParticleSystem
  55973. * @param gradient defines the gradient to use (between 0 and 1)
  55974. * @param factor defines the emit rate value to affect to the specified gradient
  55975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55976. * @returns the current particle system
  55977. */
  55978. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55979. /**
  55980. * Not supported by GPUParticleSystem
  55981. * @param gradient defines the gradient to remove
  55982. * @returns the current particle system
  55983. */
  55984. removeEmitRateGradient(gradient: number): IParticleSystem;
  55985. /**
  55986. * Not supported by GPUParticleSystem
  55987. * @param gradient defines the gradient to use (between 0 and 1)
  55988. * @param factor defines the start size value to affect to the specified gradient
  55989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55990. * @returns the current particle system
  55991. */
  55992. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55993. /**
  55994. * Not supported by GPUParticleSystem
  55995. * @param gradient defines the gradient to remove
  55996. * @returns the current particle system
  55997. */
  55998. removeStartSizeGradient(gradient: number): IParticleSystem;
  55999. /**
  56000. * Not supported by GPUParticleSystem
  56001. * @param gradient defines the gradient to use (between 0 and 1)
  56002. * @param min defines the color remap minimal range
  56003. * @param max defines the color remap maximal range
  56004. * @returns the current particle system
  56005. */
  56006. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56007. /**
  56008. * Not supported by GPUParticleSystem
  56009. * @param gradient defines the gradient to remove
  56010. * @returns the current particle system
  56011. */
  56012. removeColorRemapGradient(): IParticleSystem;
  56013. /**
  56014. * Not supported by GPUParticleSystem
  56015. * @param gradient defines the gradient to use (between 0 and 1)
  56016. * @param min defines the alpha remap minimal range
  56017. * @param max defines the alpha remap maximal range
  56018. * @returns the current particle system
  56019. */
  56020. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56021. /**
  56022. * Not supported by GPUParticleSystem
  56023. * @param gradient defines the gradient to remove
  56024. * @returns the current particle system
  56025. */
  56026. removeAlphaRemapGradient(): IParticleSystem;
  56027. /**
  56028. * Not supported by GPUParticleSystem
  56029. * @param gradient defines the gradient to use (between 0 and 1)
  56030. * @param color defines the color to affect to the specified gradient
  56031. * @returns the current particle system
  56032. */
  56033. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56034. /**
  56035. * Not supported by GPUParticleSystem
  56036. * @param gradient defines the gradient to remove
  56037. * @returns the current particle system
  56038. */
  56039. removeRampGradient(): IParticleSystem;
  56040. /**
  56041. * Not supported by GPUParticleSystem
  56042. * @returns the list of ramp gradients
  56043. */
  56044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56045. /**
  56046. * Not supported by GPUParticleSystem
  56047. * Gets or sets a boolean indicating that ramp gradients must be used
  56048. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56049. */
  56050. useRampGradients: boolean;
  56051. /**
  56052. * Not supported by GPUParticleSystem
  56053. * @param gradient defines the gradient to use (between 0 and 1)
  56054. * @param factor defines the life time factor to affect to the specified gradient
  56055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56056. * @returns the current particle system
  56057. */
  56058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56059. /**
  56060. * Not supported by GPUParticleSystem
  56061. * @param gradient defines the gradient to remove
  56062. * @returns the current particle system
  56063. */
  56064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56065. /**
  56066. * Instantiates a GPU particle system.
  56067. * 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.
  56068. * @param name The name of the particle system
  56069. * @param options The options used to create the system
  56070. * @param scene The scene the particle system belongs to
  56071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56072. */
  56073. constructor(name: string, options: Partial<{
  56074. capacity: number;
  56075. randomTextureSize: number;
  56076. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56077. protected _reset(): void;
  56078. private _createUpdateVAO;
  56079. private _createRenderVAO;
  56080. private _initialize;
  56081. /** @hidden */ private _recreateUpdateEffect(): void;
  56082. /** @hidden */ private _recreateRenderEffect(): void;
  56083. /**
  56084. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56085. * @param preWarm defines if we are in the pre-warmimg phase
  56086. */
  56087. animate(preWarm?: boolean): void;
  56088. private _createFactorGradientTexture;
  56089. private _createSizeGradientTexture;
  56090. private _createAngularSpeedGradientTexture;
  56091. private _createVelocityGradientTexture;
  56092. private _createLimitVelocityGradientTexture;
  56093. private _createDragGradientTexture;
  56094. private _createColorGradientTexture;
  56095. /**
  56096. * Renders the particle system in its current state
  56097. * @param preWarm defines if the system should only update the particles but not render them
  56098. * @returns the current number of particles
  56099. */
  56100. render(preWarm?: boolean): number;
  56101. /**
  56102. * Rebuilds the particle system
  56103. */
  56104. rebuild(): void;
  56105. private _releaseBuffers;
  56106. private _releaseVAOs;
  56107. /**
  56108. * Disposes the particle system and free the associated resources
  56109. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56110. */
  56111. dispose(disposeTexture?: boolean): void;
  56112. /**
  56113. * Clones the particle system.
  56114. * @param name The name of the cloned object
  56115. * @param newEmitter The new emitter to use
  56116. * @returns the cloned particle system
  56117. */
  56118. clone(name: string, newEmitter: any): GPUParticleSystem;
  56119. /**
  56120. * Serializes the particle system to a JSON object.
  56121. * @returns the JSON object
  56122. */
  56123. serialize(): any;
  56124. /**
  56125. * Parses a JSON object to create a GPU particle system.
  56126. * @param parsedParticleSystem The JSON object to parse
  56127. * @param scene The scene to create the particle system in
  56128. * @param rootUrl The root url to use to load external dependencies like texture
  56129. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56130. * @returns the parsed GPU particle system
  56131. */
  56132. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56133. }
  56134. }
  56135. declare module BABYLON {
  56136. /**
  56137. * Represents a set of particle systems working together to create a specific effect
  56138. */
  56139. export class ParticleSystemSet implements IDisposable {
  56140. private _emitterCreationOptions;
  56141. private _emitterNode;
  56142. /**
  56143. * Gets the particle system list
  56144. */
  56145. systems: IParticleSystem[];
  56146. /**
  56147. * Gets the emitter node used with this set
  56148. */
  56149. readonly emitterNode: Nullable<TransformNode>;
  56150. /**
  56151. * Creates a new emitter mesh as a sphere
  56152. * @param options defines the options used to create the sphere
  56153. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56154. * @param scene defines the hosting scene
  56155. */
  56156. setEmitterAsSphere(options: {
  56157. diameter: number;
  56158. segments: number;
  56159. color: Color3;
  56160. }, renderingGroupId: number, scene: Scene): void;
  56161. /**
  56162. * Starts all particle systems of the set
  56163. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56164. */
  56165. start(emitter?: AbstractMesh): void;
  56166. /**
  56167. * Release all associated resources
  56168. */
  56169. dispose(): void;
  56170. /**
  56171. * Serialize the set into a JSON compatible object
  56172. * @returns a JSON compatible representation of the set
  56173. */
  56174. serialize(): any;
  56175. /**
  56176. * Parse a new ParticleSystemSet from a serialized source
  56177. * @param data defines a JSON compatible representation of the set
  56178. * @param scene defines the hosting scene
  56179. * @param gpu defines if we want GPU particles or CPU particles
  56180. * @returns a new ParticleSystemSet
  56181. */
  56182. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56183. }
  56184. }
  56185. declare module BABYLON {
  56186. /**
  56187. * This class is made for on one-liner static method to help creating particle system set.
  56188. */
  56189. export class ParticleHelper {
  56190. /**
  56191. * Gets or sets base Assets URL
  56192. */
  56193. static BaseAssetsUrl: string;
  56194. /**
  56195. * Create a default particle system that you can tweak
  56196. * @param emitter defines the emitter to use
  56197. * @param capacity defines the system capacity (default is 500 particles)
  56198. * @param scene defines the hosting scene
  56199. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56200. * @returns the new Particle system
  56201. */
  56202. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56203. /**
  56204. * This is the main static method (one-liner) of this helper to create different particle systems
  56205. * @param type This string represents the type to the particle system to create
  56206. * @param scene The scene where the particle system should live
  56207. * @param gpu If the system will use gpu
  56208. * @returns the ParticleSystemSet created
  56209. */
  56210. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56211. /**
  56212. * Static function used to export a particle system to a ParticleSystemSet variable.
  56213. * Please note that the emitter shape is not exported
  56214. * @param systems defines the particle systems to export
  56215. * @returns the created particle system set
  56216. */
  56217. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56218. }
  56219. }
  56220. declare module BABYLON {
  56221. interface Engine {
  56222. /**
  56223. * Create an effect to use with particle systems.
  56224. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56225. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56226. * @param uniformsNames defines a list of attribute names
  56227. * @param samplers defines an array of string used to represent textures
  56228. * @param defines defines the string containing the defines to use to compile the shaders
  56229. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56230. * @param onCompiled defines a function to call when the effect creation is successful
  56231. * @param onError defines a function to call when the effect creation has failed
  56232. * @returns the new Effect
  56233. */
  56234. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56235. }
  56236. interface Mesh {
  56237. /**
  56238. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56239. * @returns an array of IParticleSystem
  56240. */
  56241. getEmittedParticleSystems(): IParticleSystem[];
  56242. /**
  56243. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56244. * @returns an array of IParticleSystem
  56245. */
  56246. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56247. }
  56248. /**
  56249. * @hidden
  56250. */
  56251. export var _IDoNeedToBeInTheBuild: number;
  56252. }
  56253. declare module BABYLON {
  56254. interface Scene {
  56255. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  56256. /**
  56257. * Gets the current physics engine
  56258. * @returns a IPhysicsEngine or null if none attached
  56259. */
  56260. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56261. /**
  56262. * Enables physics to the current scene
  56263. * @param gravity defines the scene's gravity for the physics engine
  56264. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56265. * @return a boolean indicating if the physics engine was initialized
  56266. */
  56267. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56268. /**
  56269. * Disables and disposes the physics engine associated with the scene
  56270. */
  56271. disablePhysicsEngine(): void;
  56272. /**
  56273. * Gets a boolean indicating if there is an active physics engine
  56274. * @returns a boolean indicating if there is an active physics engine
  56275. */
  56276. isPhysicsEnabled(): boolean;
  56277. /**
  56278. * Deletes a physics compound impostor
  56279. * @param compound defines the compound to delete
  56280. */
  56281. deleteCompoundImpostor(compound: any): void;
  56282. /**
  56283. * An event triggered when physic simulation is about to be run
  56284. */
  56285. onBeforePhysicsObservable: Observable<Scene>;
  56286. /**
  56287. * An event triggered when physic simulation has been done
  56288. */
  56289. onAfterPhysicsObservable: Observable<Scene>;
  56290. }
  56291. interface AbstractMesh {
  56292. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  56293. /**
  56294. * Gets or sets impostor used for physic simulation
  56295. * @see http://doc.babylonjs.com/features/physics_engine
  56296. */
  56297. physicsImpostor: Nullable<PhysicsImpostor>;
  56298. /**
  56299. * Gets the current physics impostor
  56300. * @see http://doc.babylonjs.com/features/physics_engine
  56301. * @returns a physics impostor or null
  56302. */
  56303. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56304. /** Apply a physic impulse to the mesh
  56305. * @param force defines the force to apply
  56306. * @param contactPoint defines where to apply the force
  56307. * @returns the current mesh
  56308. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56309. */
  56310. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56311. /**
  56312. * Creates a physic joint between two meshes
  56313. * @param otherMesh defines the other mesh to use
  56314. * @param pivot1 defines the pivot to use on this mesh
  56315. * @param pivot2 defines the pivot to use on the other mesh
  56316. * @param options defines additional options (can be plugin dependent)
  56317. * @returns the current mesh
  56318. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56319. */
  56320. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56321. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  56322. }
  56323. /**
  56324. * Defines the physics engine scene component responsible to manage a physics engine
  56325. */
  56326. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56327. /**
  56328. * The component name helpful to identify the component in the list of scene components.
  56329. */
  56330. readonly name: string;
  56331. /**
  56332. * The scene the component belongs to.
  56333. */
  56334. scene: Scene;
  56335. /**
  56336. * Creates a new instance of the component for the given scene
  56337. * @param scene Defines the scene to register the component in
  56338. */
  56339. constructor(scene: Scene);
  56340. /**
  56341. * Registers the component in a given scene
  56342. */
  56343. register(): void;
  56344. /**
  56345. * Rebuilds the elements related to this component in case of
  56346. * context lost for instance.
  56347. */
  56348. rebuild(): void;
  56349. /**
  56350. * Disposes the component and the associated ressources
  56351. */
  56352. dispose(): void;
  56353. }
  56354. }
  56355. declare module BABYLON {
  56356. /**
  56357. * A helper for physics simulations
  56358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56359. */
  56360. export class PhysicsHelper {
  56361. private _scene;
  56362. private _physicsEngine;
  56363. /**
  56364. * Initializes the Physics helper
  56365. * @param scene Babylon.js scene
  56366. */
  56367. constructor(scene: Scene);
  56368. /**
  56369. * Applies a radial explosion impulse
  56370. * @param origin the origin of the explosion
  56371. * @param radiusOrEventOptions the radius or the options of radial explosion
  56372. * @param strength the explosion strength
  56373. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56374. * @returns A physics radial explosion event, or null
  56375. */
  56376. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56377. /**
  56378. * Applies a radial explosion force
  56379. * @param origin the origin of the explosion
  56380. * @param radiusOrEventOptions the radius or the options of radial explosion
  56381. * @param strength the explosion strength
  56382. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56383. * @returns A physics radial explosion event, or null
  56384. */
  56385. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56386. /**
  56387. * Creates a gravitational field
  56388. * @param origin the origin of the explosion
  56389. * @param radiusOrEventOptions the radius or the options of radial explosion
  56390. * @param strength the explosion strength
  56391. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56392. * @returns A physics gravitational field event, or null
  56393. */
  56394. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56395. /**
  56396. * Creates a physics updraft event
  56397. * @param origin the origin of the updraft
  56398. * @param radiusOrEventOptions the radius or the options of the updraft
  56399. * @param strength the strength of the updraft
  56400. * @param height the height of the updraft
  56401. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56402. * @returns A physics updraft event, or null
  56403. */
  56404. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56405. /**
  56406. * Creates a physics vortex event
  56407. * @param origin the of the vortex
  56408. * @param radiusOrEventOptions the radius or the options of the vortex
  56409. * @param strength the strength of the vortex
  56410. * @param height the height of the vortex
  56411. * @returns a Physics vortex event, or null
  56412. * A physics vortex event or null
  56413. */
  56414. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56415. }
  56416. /**
  56417. * Represents a physics radial explosion event
  56418. */
  56419. class PhysicsRadialExplosionEvent {
  56420. private _scene;
  56421. private _options;
  56422. private _sphere;
  56423. private _dataFetched;
  56424. /**
  56425. * Initializes a radial explosioin event
  56426. * @param _scene BabylonJS scene
  56427. * @param _options The options for the vortex event
  56428. */
  56429. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56430. /**
  56431. * Returns the data related to the radial explosion event (sphere).
  56432. * @returns The radial explosion event data
  56433. */
  56434. getData(): PhysicsRadialExplosionEventData;
  56435. /**
  56436. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56437. * @param impostor A physics imposter
  56438. * @param origin the origin of the explosion
  56439. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56440. */
  56441. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56442. /**
  56443. * Triggers affecterd impostors callbacks
  56444. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56445. */
  56446. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56447. /**
  56448. * Disposes the sphere.
  56449. * @param force Specifies if the sphere should be disposed by force
  56450. */
  56451. dispose(force?: boolean): void;
  56452. /*** Helpers ***/
  56453. private _prepareSphere;
  56454. private _intersectsWithSphere;
  56455. }
  56456. /**
  56457. * Represents a gravitational field event
  56458. */
  56459. class PhysicsGravitationalFieldEvent {
  56460. private _physicsHelper;
  56461. private _scene;
  56462. private _origin;
  56463. private _options;
  56464. private _tickCallback;
  56465. private _sphere;
  56466. private _dataFetched;
  56467. /**
  56468. * Initializes the physics gravitational field event
  56469. * @param _physicsHelper A physics helper
  56470. * @param _scene BabylonJS scene
  56471. * @param _origin The origin position of the gravitational field event
  56472. * @param _options The options for the vortex event
  56473. */
  56474. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56475. /**
  56476. * Returns the data related to the gravitational field event (sphere).
  56477. * @returns A gravitational field event
  56478. */
  56479. getData(): PhysicsGravitationalFieldEventData;
  56480. /**
  56481. * Enables the gravitational field.
  56482. */
  56483. enable(): void;
  56484. /**
  56485. * Disables the gravitational field.
  56486. */
  56487. disable(): void;
  56488. /**
  56489. * Disposes the sphere.
  56490. * @param force The force to dispose from the gravitational field event
  56491. */
  56492. dispose(force?: boolean): void;
  56493. private _tick;
  56494. }
  56495. /**
  56496. * Represents a physics updraft event
  56497. */
  56498. class PhysicsUpdraftEvent {
  56499. private _scene;
  56500. private _origin;
  56501. private _options;
  56502. private _physicsEngine;
  56503. private _originTop;
  56504. private _originDirection;
  56505. private _tickCallback;
  56506. private _cylinder;
  56507. private _cylinderPosition;
  56508. private _dataFetched;
  56509. /**
  56510. * Initializes the physics updraft event
  56511. * @param _scene BabylonJS scene
  56512. * @param _origin The origin position of the updraft
  56513. * @param _options The options for the updraft event
  56514. */
  56515. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56516. /**
  56517. * Returns the data related to the updraft event (cylinder).
  56518. * @returns A physics updraft event
  56519. */
  56520. getData(): PhysicsUpdraftEventData;
  56521. /**
  56522. * Enables the updraft.
  56523. */
  56524. enable(): void;
  56525. /**
  56526. * Disables the updraft.
  56527. */
  56528. disable(): void;
  56529. /**
  56530. * Disposes the cylinder.
  56531. * @param force Specifies if the updraft should be disposed by force
  56532. */
  56533. dispose(force?: boolean): void;
  56534. private getImpostorHitData;
  56535. private _tick;
  56536. /*** Helpers ***/
  56537. private _prepareCylinder;
  56538. private _intersectsWithCylinder;
  56539. }
  56540. /**
  56541. * Represents a physics vortex event
  56542. */
  56543. class PhysicsVortexEvent {
  56544. private _scene;
  56545. private _origin;
  56546. private _options;
  56547. private _physicsEngine;
  56548. private _originTop;
  56549. private _tickCallback;
  56550. private _cylinder;
  56551. private _cylinderPosition;
  56552. private _dataFetched;
  56553. /**
  56554. * Initializes the physics vortex event
  56555. * @param _scene The BabylonJS scene
  56556. * @param _origin The origin position of the vortex
  56557. * @param _options The options for the vortex event
  56558. */
  56559. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56560. /**
  56561. * Returns the data related to the vortex event (cylinder).
  56562. * @returns The physics vortex event data
  56563. */
  56564. getData(): PhysicsVortexEventData;
  56565. /**
  56566. * Enables the vortex.
  56567. */
  56568. enable(): void;
  56569. /**
  56570. * Disables the cortex.
  56571. */
  56572. disable(): void;
  56573. /**
  56574. * Disposes the sphere.
  56575. * @param force
  56576. */
  56577. dispose(force?: boolean): void;
  56578. private getImpostorHitData;
  56579. private _tick;
  56580. /*** Helpers ***/
  56581. private _prepareCylinder;
  56582. private _intersectsWithCylinder;
  56583. }
  56584. /**
  56585. * Options fot the radial explosion event
  56586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56587. */
  56588. export class PhysicsRadialExplosionEventOptions {
  56589. /**
  56590. * The radius of the sphere for the radial explosion.
  56591. */
  56592. radius: number;
  56593. /**
  56594. * The strenth of the explosion.
  56595. */
  56596. strength: number;
  56597. /**
  56598. * The strenght of the force in correspondence to the distance of the affected object
  56599. */
  56600. falloff: PhysicsRadialImpulseFalloff;
  56601. /**
  56602. * Sphere options for the radial explosion.
  56603. */
  56604. sphere: {
  56605. segments: number;
  56606. diameter: number;
  56607. };
  56608. /**
  56609. * Sphere options for the radial explosion.
  56610. */
  56611. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56612. }
  56613. /**
  56614. * Options fot the updraft event
  56615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56616. */
  56617. export class PhysicsUpdraftEventOptions {
  56618. /**
  56619. * The radius of the cylinder for the vortex
  56620. */
  56621. radius: number;
  56622. /**
  56623. * The strenth of the updraft.
  56624. */
  56625. strength: number;
  56626. /**
  56627. * The height of the cylinder for the updraft.
  56628. */
  56629. height: number;
  56630. /**
  56631. * The mode for the the updraft.
  56632. */
  56633. updraftMode: PhysicsUpdraftMode;
  56634. }
  56635. /**
  56636. * Options fot the vortex event
  56637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56638. */
  56639. export class PhysicsVortexEventOptions {
  56640. /**
  56641. * The radius of the cylinder for the vortex
  56642. */
  56643. radius: number;
  56644. /**
  56645. * The strenth of the vortex.
  56646. */
  56647. strength: number;
  56648. /**
  56649. * The height of the cylinder for the vortex.
  56650. */
  56651. height: number;
  56652. /**
  56653. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56654. */
  56655. centripetalForceThreshold: number;
  56656. /**
  56657. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56658. */
  56659. centripetalForceMultiplier: number;
  56660. /**
  56661. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56662. */
  56663. centrifugalForceMultiplier: number;
  56664. /**
  56665. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56666. */
  56667. updraftForceMultiplier: number;
  56668. }
  56669. /**
  56670. * The strenght of the force in correspondence to the distance of the affected object
  56671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56672. */
  56673. export enum PhysicsRadialImpulseFalloff {
  56674. /** Defines that impulse is constant in strength across it's whole radius */
  56675. Constant = 0,
  56676. /** Defines that impulse gets weaker if it's further from the origin */
  56677. Linear = 1
  56678. }
  56679. /**
  56680. * The strength of the force in correspondence to the distance of the affected object
  56681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56682. */
  56683. export enum PhysicsUpdraftMode {
  56684. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56685. Center = 0,
  56686. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56687. Perpendicular = 1
  56688. }
  56689. /**
  56690. * Interface for a physics hit data
  56691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56692. */
  56693. export interface PhysicsHitData {
  56694. /**
  56695. * The force applied at the contact point
  56696. */
  56697. force: Vector3;
  56698. /**
  56699. * The contact point
  56700. */
  56701. contactPoint: Vector3;
  56702. /**
  56703. * The distance from the origin to the contact point
  56704. */
  56705. distanceFromOrigin: number;
  56706. }
  56707. /**
  56708. * Interface for radial explosion event data
  56709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56710. */
  56711. export interface PhysicsRadialExplosionEventData {
  56712. /**
  56713. * A sphere used for the radial explosion event
  56714. */
  56715. sphere: Mesh;
  56716. }
  56717. /**
  56718. * Interface for gravitational field event data
  56719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56720. */
  56721. export interface PhysicsGravitationalFieldEventData {
  56722. /**
  56723. * A sphere mesh used for the gravitational field event
  56724. */
  56725. sphere: Mesh;
  56726. }
  56727. /**
  56728. * Interface for updraft event data
  56729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56730. */
  56731. export interface PhysicsUpdraftEventData {
  56732. /**
  56733. * A cylinder used for the updraft event
  56734. */
  56735. cylinder: Mesh;
  56736. }
  56737. /**
  56738. * Interface for vortex event data
  56739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56740. */
  56741. export interface PhysicsVortexEventData {
  56742. /**
  56743. * A cylinder used for the vortex event
  56744. */
  56745. cylinder: Mesh;
  56746. }
  56747. /**
  56748. * Interface for an affected physics impostor
  56749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56750. */
  56751. export interface PhysicsAffectedImpostorWithData {
  56752. /**
  56753. * The impostor affected by the effect
  56754. */
  56755. impostor: PhysicsImpostor;
  56756. /**
  56757. * The data about the hit/horce from the explosion
  56758. */
  56759. hitData: PhysicsHitData;
  56760. }
  56761. }
  56762. declare module BABYLON {
  56763. /** @hidden */
  56764. export var blackAndWhitePixelShader: {
  56765. name: string;
  56766. shader: string;
  56767. };
  56768. }
  56769. declare module BABYLON {
  56770. /**
  56771. * Post process used to render in black and white
  56772. */
  56773. export class BlackAndWhitePostProcess extends PostProcess {
  56774. /**
  56775. * Linear about to convert he result to black and white (default: 1)
  56776. */
  56777. degree: number;
  56778. /**
  56779. * Creates a black and white post process
  56780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56781. * @param name The name of the effect.
  56782. * @param options The required width/height ratio to downsize to before computing the render pass.
  56783. * @param camera The camera to apply the render pass to.
  56784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56785. * @param engine The engine which the post process will be applied. (default: current engine)
  56786. * @param reusable If the post process can be reused on the same frame. (default: false)
  56787. */
  56788. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56789. }
  56790. }
  56791. declare module BABYLON {
  56792. /**
  56793. * This represents a set of one or more post processes in Babylon.
  56794. * A post process can be used to apply a shader to a texture after it is rendered.
  56795. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56796. */
  56797. export class PostProcessRenderEffect {
  56798. private _postProcesses;
  56799. private _getPostProcesses;
  56800. private _singleInstance;
  56801. private _cameras;
  56802. private _indicesForCamera;
  56803. /**
  56804. * Name of the effect
  56805. * @hidden
  56806. */ private _name: string;
  56807. /**
  56808. * Instantiates a post process render effect.
  56809. * A post process can be used to apply a shader to a texture after it is rendered.
  56810. * @param engine The engine the effect is tied to
  56811. * @param name The name of the effect
  56812. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56813. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56814. */
  56815. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56816. /**
  56817. * Checks if all the post processes in the effect are supported.
  56818. */
  56819. readonly isSupported: boolean;
  56820. /**
  56821. * Updates the current state of the effect
  56822. * @hidden
  56823. */ private _update(): void;
  56824. /**
  56825. * Attaches the effect on cameras
  56826. * @param cameras The camera to attach to.
  56827. * @hidden
  56828. */ private _attachCameras(cameras: Camera): void;
  56829. /**
  56830. * Attaches the effect on cameras
  56831. * @param cameras The camera to attach to.
  56832. * @hidden
  56833. */ private _attachCameras(cameras: Camera[]): void;
  56834. /**
  56835. * Detaches the effect on cameras
  56836. * @param cameras The camera to detatch from.
  56837. * @hidden
  56838. */ private _detachCameras(cameras: Camera): void;
  56839. /**
  56840. * Detatches the effect on cameras
  56841. * @param cameras The camera to detatch from.
  56842. * @hidden
  56843. */ private _detachCameras(cameras: Camera[]): void;
  56844. /**
  56845. * Enables the effect on given cameras
  56846. * @param cameras The camera to enable.
  56847. * @hidden
  56848. */ private _enable(cameras: Camera): void;
  56849. /**
  56850. * Enables the effect on given cameras
  56851. * @param cameras The camera to enable.
  56852. * @hidden
  56853. */ private _enable(cameras: Nullable<Camera[]>): void;
  56854. /**
  56855. * Disables the effect on the given cameras
  56856. * @param cameras The camera to disable.
  56857. * @hidden
  56858. */ private _disable(cameras: Camera): void;
  56859. /**
  56860. * Disables the effect on the given cameras
  56861. * @param cameras The camera to disable.
  56862. * @hidden
  56863. */ private _disable(cameras: Nullable<Camera[]>): void;
  56864. /**
  56865. * Gets a list of the post processes contained in the effect.
  56866. * @param camera The camera to get the post processes on.
  56867. * @returns The list of the post processes in the effect.
  56868. */
  56869. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56870. }
  56871. }
  56872. declare module BABYLON {
  56873. /** @hidden */
  56874. export var extractHighlightsPixelShader: {
  56875. name: string;
  56876. shader: string;
  56877. };
  56878. }
  56879. declare module BABYLON {
  56880. /**
  56881. * 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.
  56882. */
  56883. export class ExtractHighlightsPostProcess extends PostProcess {
  56884. /**
  56885. * The luminance threshold, pixels below this value will be set to black.
  56886. */
  56887. threshold: number;
  56888. /** @hidden */ private _exposure: number;
  56889. /**
  56890. * Post process which has the input texture to be used when performing highlight extraction
  56891. * @hidden
  56892. */ private _inputPostProcess: Nullable<PostProcess>;
  56893. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56894. }
  56895. }
  56896. declare module BABYLON {
  56897. /** @hidden */
  56898. export var bloomMergePixelShader: {
  56899. name: string;
  56900. shader: string;
  56901. };
  56902. }
  56903. declare module BABYLON {
  56904. /**
  56905. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56906. */
  56907. export class BloomMergePostProcess extends PostProcess {
  56908. /** Weight of the bloom to be added to the original input. */
  56909. weight: number;
  56910. /**
  56911. * Creates a new instance of @see BloomMergePostProcess
  56912. * @param name The name of the effect.
  56913. * @param originalFromInput Post process which's input will be used for the merge.
  56914. * @param blurred Blurred highlights post process which's output will be used.
  56915. * @param weight Weight of the bloom to be added to the original input.
  56916. * @param options The required width/height ratio to downsize to before computing the render pass.
  56917. * @param camera The camera to apply the render pass to.
  56918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56919. * @param engine The engine which the post process will be applied. (default: current engine)
  56920. * @param reusable If the post process can be reused on the same frame. (default: false)
  56921. * @param textureType Type of textures used when performing the post process. (default: 0)
  56922. * @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)
  56923. */
  56924. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56925. /** Weight of the bloom to be added to the original input. */
  56926. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56927. }
  56928. }
  56929. declare module BABYLON {
  56930. /**
  56931. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56932. */
  56933. export class BloomEffect extends PostProcessRenderEffect {
  56934. private bloomScale;
  56935. /**
  56936. * @hidden Internal
  56937. */ private _effects: Array<PostProcess>;
  56938. /**
  56939. * @hidden Internal
  56940. */ private _downscale: ExtractHighlightsPostProcess;
  56941. private _blurX;
  56942. private _blurY;
  56943. private _merge;
  56944. /**
  56945. * The luminance threshold to find bright areas of the image to bloom.
  56946. */
  56947. threshold: number;
  56948. /**
  56949. * The strength of the bloom.
  56950. */
  56951. weight: number;
  56952. /**
  56953. * Specifies the size of the bloom blur kernel, relative to the final output size
  56954. */
  56955. kernel: number;
  56956. /**
  56957. * Creates a new instance of @see BloomEffect
  56958. * @param scene The scene the effect belongs to.
  56959. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56960. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56961. * @param bloomWeight The the strength of bloom.
  56962. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56963. * @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)
  56964. */
  56965. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56966. /**
  56967. * Disposes each of the internal effects for a given camera.
  56968. * @param camera The camera to dispose the effect on.
  56969. */
  56970. disposeEffects(camera: Camera): void;
  56971. /**
  56972. * @hidden Internal
  56973. */ private _updateEffects(): void;
  56974. /**
  56975. * Internal
  56976. * @returns if all the contained post processes are ready.
  56977. * @hidden
  56978. */ private _isReady(): boolean;
  56979. }
  56980. }
  56981. declare module BABYLON {
  56982. /** @hidden */
  56983. export var chromaticAberrationPixelShader: {
  56984. name: string;
  56985. shader: string;
  56986. };
  56987. }
  56988. declare module BABYLON {
  56989. /**
  56990. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56991. */
  56992. export class ChromaticAberrationPostProcess extends PostProcess {
  56993. /**
  56994. * The amount of seperation of rgb channels (default: 30)
  56995. */
  56996. aberrationAmount: number;
  56997. /**
  56998. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56999. */
  57000. radialIntensity: number;
  57001. /**
  57002. * 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))
  57003. */
  57004. direction: Vector2;
  57005. /**
  57006. * 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))
  57007. */
  57008. centerPosition: Vector2;
  57009. /**
  57010. * Creates a new instance ChromaticAberrationPostProcess
  57011. * @param name The name of the effect.
  57012. * @param screenWidth The width of the screen to apply the effect on.
  57013. * @param screenHeight The height of the screen to apply the effect on.
  57014. * @param options The required width/height ratio to downsize to before computing the render pass.
  57015. * @param camera The camera to apply the render pass to.
  57016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57017. * @param engine The engine which the post process will be applied. (default: current engine)
  57018. * @param reusable If the post process can be reused on the same frame. (default: false)
  57019. * @param textureType Type of textures used when performing the post process. (default: 0)
  57020. * @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)
  57021. */
  57022. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57023. }
  57024. }
  57025. declare module BABYLON {
  57026. /** @hidden */
  57027. export var circleOfConfusionPixelShader: {
  57028. name: string;
  57029. shader: string;
  57030. };
  57031. }
  57032. declare module BABYLON {
  57033. /**
  57034. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57035. */
  57036. export class CircleOfConfusionPostProcess extends PostProcess {
  57037. /**
  57038. * 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.
  57039. */
  57040. lensSize: number;
  57041. /**
  57042. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57043. */
  57044. fStop: number;
  57045. /**
  57046. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57047. */
  57048. focusDistance: number;
  57049. /**
  57050. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57051. */
  57052. focalLength: number;
  57053. private _depthTexture;
  57054. /**
  57055. * Creates a new instance CircleOfConfusionPostProcess
  57056. * @param name The name of the effect.
  57057. * @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.
  57058. * @param options The required width/height ratio to downsize to before computing the render pass.
  57059. * @param camera The camera to apply the render pass to.
  57060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57061. * @param engine The engine which the post process will be applied. (default: current engine)
  57062. * @param reusable If the post process can be reused on the same frame. (default: false)
  57063. * @param textureType Type of textures used when performing the post process. (default: 0)
  57064. * @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)
  57065. */
  57066. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57067. /**
  57068. * 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.
  57069. */
  57070. depthTexture: RenderTargetTexture;
  57071. }
  57072. }
  57073. declare module BABYLON {
  57074. /** @hidden */
  57075. export var colorCorrectionPixelShader: {
  57076. name: string;
  57077. shader: string;
  57078. };
  57079. }
  57080. declare module BABYLON {
  57081. /**
  57082. *
  57083. * This post-process allows the modification of rendered colors by using
  57084. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57085. *
  57086. * The object needs to be provided an url to a texture containing the color
  57087. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57088. * Use an image editing software to tweak the LUT to match your needs.
  57089. *
  57090. * For an example of a color LUT, see here:
  57091. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57092. * For explanations on color grading, see here:
  57093. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57094. *
  57095. */
  57096. export class ColorCorrectionPostProcess extends PostProcess {
  57097. private _colorTableTexture;
  57098. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57099. }
  57100. }
  57101. declare module BABYLON {
  57102. /** @hidden */
  57103. export var convolutionPixelShader: {
  57104. name: string;
  57105. shader: string;
  57106. };
  57107. }
  57108. declare module BABYLON {
  57109. /**
  57110. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57111. * input texture to perform effects such as edge detection or sharpening
  57112. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57113. */
  57114. export class ConvolutionPostProcess extends PostProcess {
  57115. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57116. kernel: number[];
  57117. /**
  57118. * Creates a new instance ConvolutionPostProcess
  57119. * @param name The name of the effect.
  57120. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57121. * @param options The required width/height ratio to downsize to before computing the render pass.
  57122. * @param camera The camera to apply the render pass to.
  57123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57124. * @param engine The engine which the post process will be applied. (default: current engine)
  57125. * @param reusable If the post process can be reused on the same frame. (default: false)
  57126. * @param textureType Type of textures used when performing the post process. (default: 0)
  57127. */
  57128. constructor(name: string,
  57129. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57130. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57131. /**
  57132. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57133. */
  57134. static EdgeDetect0Kernel: number[];
  57135. /**
  57136. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57137. */
  57138. static EdgeDetect1Kernel: number[];
  57139. /**
  57140. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57141. */
  57142. static EdgeDetect2Kernel: number[];
  57143. /**
  57144. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57145. */
  57146. static SharpenKernel: number[];
  57147. /**
  57148. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57149. */
  57150. static EmbossKernel: number[];
  57151. /**
  57152. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57153. */
  57154. static GaussianKernel: number[];
  57155. }
  57156. }
  57157. declare module BABYLON {
  57158. /**
  57159. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57160. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57161. * based on samples that have a large difference in distance than the center pixel.
  57162. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57163. */
  57164. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57165. direction: Vector2;
  57166. /**
  57167. * Creates a new instance CircleOfConfusionPostProcess
  57168. * @param name The name of the effect.
  57169. * @param scene The scene the effect belongs to.
  57170. * @param direction The direction the blur should be applied.
  57171. * @param kernel The size of the kernel used to blur.
  57172. * @param options The required width/height ratio to downsize to before computing the render pass.
  57173. * @param camera The camera to apply the render pass to.
  57174. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57175. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57177. * @param engine The engine which the post process will be applied. (default: current engine)
  57178. * @param reusable If the post process can be reused on the same frame. (default: false)
  57179. * @param textureType Type of textures used when performing the post process. (default: 0)
  57180. * @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)
  57181. */
  57182. 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);
  57183. }
  57184. }
  57185. declare module BABYLON {
  57186. /** @hidden */
  57187. export var depthOfFieldMergePixelShader: {
  57188. name: string;
  57189. shader: string;
  57190. };
  57191. }
  57192. declare module BABYLON {
  57193. /**
  57194. * Options to be set when merging outputs from the default pipeline.
  57195. */
  57196. export class DepthOfFieldMergePostProcessOptions {
  57197. /**
  57198. * The original image to merge on top of
  57199. */
  57200. originalFromInput: PostProcess;
  57201. /**
  57202. * Parameters to perform the merge of the depth of field effect
  57203. */
  57204. depthOfField?: {
  57205. circleOfConfusion: PostProcess;
  57206. blurSteps: Array<PostProcess>;
  57207. };
  57208. /**
  57209. * Parameters to perform the merge of bloom effect
  57210. */
  57211. bloom?: {
  57212. blurred: PostProcess;
  57213. weight: number;
  57214. };
  57215. }
  57216. /**
  57217. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57218. */
  57219. export class DepthOfFieldMergePostProcess extends PostProcess {
  57220. private blurSteps;
  57221. /**
  57222. * Creates a new instance of DepthOfFieldMergePostProcess
  57223. * @param name The name of the effect.
  57224. * @param originalFromInput Post process which's input will be used for the merge.
  57225. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57226. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57227. * @param options The required width/height ratio to downsize to before computing the render pass.
  57228. * @param camera The camera to apply the render pass to.
  57229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57230. * @param engine The engine which the post process will be applied. (default: current engine)
  57231. * @param reusable If the post process can be reused on the same frame. (default: false)
  57232. * @param textureType Type of textures used when performing the post process. (default: 0)
  57233. * @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)
  57234. */
  57235. 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);
  57236. /**
  57237. * Updates the effect with the current post process compile time values and recompiles the shader.
  57238. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57239. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57240. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57241. * @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
  57242. * @param onCompiled Called when the shader has been compiled.
  57243. * @param onError Called if there is an error when compiling a shader.
  57244. */
  57245. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57246. }
  57247. }
  57248. declare module BABYLON {
  57249. /**
  57250. * Specifies the level of max blur that should be applied when using the depth of field effect
  57251. */
  57252. export enum DepthOfFieldEffectBlurLevel {
  57253. /**
  57254. * Subtle blur
  57255. */
  57256. Low = 0,
  57257. /**
  57258. * Medium blur
  57259. */
  57260. Medium = 1,
  57261. /**
  57262. * Large blur
  57263. */
  57264. High = 2
  57265. }
  57266. /**
  57267. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57268. */
  57269. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57270. private _circleOfConfusion;
  57271. /**
  57272. * @hidden Internal, blurs from high to low
  57273. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57274. private _depthOfFieldBlurY;
  57275. private _dofMerge;
  57276. /**
  57277. * @hidden Internal post processes in depth of field effect
  57278. */ private _effects: Array<PostProcess>;
  57279. /**
  57280. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57281. */
  57282. focalLength: number;
  57283. /**
  57284. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57285. */
  57286. fStop: number;
  57287. /**
  57288. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57289. */
  57290. focusDistance: number;
  57291. /**
  57292. * 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.
  57293. */
  57294. lensSize: number;
  57295. /**
  57296. * Creates a new instance DepthOfFieldEffect
  57297. * @param scene The scene the effect belongs to.
  57298. * @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.
  57299. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57300. * @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)
  57301. */
  57302. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57303. /**
  57304. * Get the current class name of the current effet
  57305. * @returns "DepthOfFieldEffect"
  57306. */
  57307. getClassName(): string;
  57308. /**
  57309. * 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.
  57310. */
  57311. depthTexture: RenderTargetTexture;
  57312. /**
  57313. * Disposes each of the internal effects for a given camera.
  57314. * @param camera The camera to dispose the effect on.
  57315. */
  57316. disposeEffects(camera: Camera): void;
  57317. /**
  57318. * @hidden Internal
  57319. */ private _updateEffects(): void;
  57320. /**
  57321. * Internal
  57322. * @returns if all the contained post processes are ready.
  57323. * @hidden
  57324. */ private _isReady(): boolean;
  57325. }
  57326. }
  57327. declare module BABYLON {
  57328. /** @hidden */
  57329. export var displayPassPixelShader: {
  57330. name: string;
  57331. shader: string;
  57332. };
  57333. }
  57334. declare module BABYLON {
  57335. /**
  57336. * DisplayPassPostProcess which produces an output the same as it's input
  57337. */
  57338. export class DisplayPassPostProcess extends PostProcess {
  57339. /**
  57340. * Creates the DisplayPassPostProcess
  57341. * @param name The name of the effect.
  57342. * @param options The required width/height ratio to downsize to before computing the render pass.
  57343. * @param camera The camera to apply the render pass to.
  57344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57345. * @param engine The engine which the post process will be applied. (default: current engine)
  57346. * @param reusable If the post process can be reused on the same frame. (default: false)
  57347. */
  57348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57349. }
  57350. }
  57351. declare module BABYLON {
  57352. /** @hidden */
  57353. export var filterPixelShader: {
  57354. name: string;
  57355. shader: string;
  57356. };
  57357. }
  57358. declare module BABYLON {
  57359. /**
  57360. * Applies a kernel filter to the image
  57361. */
  57362. export class FilterPostProcess extends PostProcess {
  57363. /** The matrix to be applied to the image */
  57364. kernelMatrix: Matrix;
  57365. /**
  57366. *
  57367. * @param name The name of the effect.
  57368. * @param kernelMatrix The matrix to be applied to the image
  57369. * @param options The required width/height ratio to downsize to before computing the render pass.
  57370. * @param camera The camera to apply the render pass to.
  57371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57372. * @param engine The engine which the post process will be applied. (default: current engine)
  57373. * @param reusable If the post process can be reused on the same frame. (default: false)
  57374. */
  57375. constructor(name: string,
  57376. /** The matrix to be applied to the image */
  57377. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57378. }
  57379. }
  57380. declare module BABYLON {
  57381. /** @hidden */
  57382. export var fxaaPixelShader: {
  57383. name: string;
  57384. shader: string;
  57385. };
  57386. }
  57387. declare module BABYLON {
  57388. /** @hidden */
  57389. export var fxaaVertexShader: {
  57390. name: string;
  57391. shader: string;
  57392. };
  57393. }
  57394. declare module BABYLON {
  57395. /**
  57396. * Fxaa post process
  57397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57398. */
  57399. export class FxaaPostProcess extends PostProcess {
  57400. /** @hidden */
  57401. texelWidth: number;
  57402. /** @hidden */
  57403. texelHeight: number;
  57404. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57405. private _getDefines;
  57406. }
  57407. }
  57408. declare module BABYLON {
  57409. /** @hidden */
  57410. export var grainPixelShader: {
  57411. name: string;
  57412. shader: string;
  57413. };
  57414. }
  57415. declare module BABYLON {
  57416. /**
  57417. * The GrainPostProcess adds noise to the image at mid luminance levels
  57418. */
  57419. export class GrainPostProcess extends PostProcess {
  57420. /**
  57421. * The intensity of the grain added (default: 30)
  57422. */
  57423. intensity: number;
  57424. /**
  57425. * If the grain should be randomized on every frame
  57426. */
  57427. animated: boolean;
  57428. /**
  57429. * Creates a new instance of @see GrainPostProcess
  57430. * @param name The name of the effect.
  57431. * @param options The required width/height ratio to downsize to before computing the render pass.
  57432. * @param camera The camera to apply the render pass to.
  57433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57434. * @param engine The engine which the post process will be applied. (default: current engine)
  57435. * @param reusable If the post process can be reused on the same frame. (default: false)
  57436. * @param textureType Type of textures used when performing the post process. (default: 0)
  57437. * @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)
  57438. */
  57439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57440. }
  57441. }
  57442. declare module BABYLON {
  57443. /** @hidden */
  57444. export var highlightsPixelShader: {
  57445. name: string;
  57446. shader: string;
  57447. };
  57448. }
  57449. declare module BABYLON {
  57450. /**
  57451. * Extracts highlights from the image
  57452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57453. */
  57454. export class HighlightsPostProcess extends PostProcess {
  57455. /**
  57456. * Extracts highlights from the image
  57457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57458. * @param name The name of the effect.
  57459. * @param options The required width/height ratio to downsize to before computing the render pass.
  57460. * @param camera The camera to apply the render pass to.
  57461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57462. * @param engine The engine which the post process will be applied. (default: current engine)
  57463. * @param reusable If the post process can be reused on the same frame. (default: false)
  57464. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57465. */
  57466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57467. }
  57468. }
  57469. declare module BABYLON {
  57470. /** @hidden */
  57471. export var mrtFragmentDeclaration: {
  57472. name: string;
  57473. shader: string;
  57474. };
  57475. }
  57476. declare module BABYLON {
  57477. /** @hidden */
  57478. export var geometryPixelShader: {
  57479. name: string;
  57480. shader: string;
  57481. };
  57482. }
  57483. declare module BABYLON {
  57484. /** @hidden */
  57485. export var geometryVertexShader: {
  57486. name: string;
  57487. shader: string;
  57488. };
  57489. }
  57490. declare module BABYLON {
  57491. /** @hidden */
  57492. interface ISavedTransformationMatrix {
  57493. world: Matrix;
  57494. viewProjection: Matrix;
  57495. }
  57496. /**
  57497. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57498. */
  57499. export class GeometryBufferRenderer {
  57500. /**
  57501. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57502. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57503. */
  57504. static readonly POSITION_TEXTURE_TYPE: number;
  57505. /**
  57506. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57507. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57508. */
  57509. static readonly VELOCITY_TEXTURE_TYPE: number;
  57510. /**
  57511. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57512. * in order to compute objects velocities when enableVelocity is set to "true"
  57513. * @hidden
  57514. */ private _previousTransformationMatrices: {
  57515. [index: number]: ISavedTransformationMatrix;
  57516. };
  57517. /**
  57518. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57519. * in order to compute objects velocities when enableVelocity is set to "true"
  57520. * @hidden
  57521. */ private _previousBonesTransformationMatrices: {
  57522. [index: number]: Float32Array;
  57523. };
  57524. /**
  57525. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57526. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57527. */
  57528. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57529. private _scene;
  57530. private _multiRenderTarget;
  57531. private _ratio;
  57532. private _enablePosition;
  57533. private _enableVelocity;
  57534. private _positionIndex;
  57535. private _velocityIndex;
  57536. protected _effect: Effect;
  57537. protected _cachedDefines: string;
  57538. /**
  57539. * Set the render list (meshes to be rendered) used in the G buffer.
  57540. */
  57541. renderList: Mesh[];
  57542. /**
  57543. * Gets wether or not G buffer are supported by the running hardware.
  57544. * This requires draw buffer supports
  57545. */
  57546. readonly isSupported: boolean;
  57547. /**
  57548. * Returns the index of the given texture type in the G-Buffer textures array
  57549. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57550. * @returns the index of the given texture type in the G-Buffer textures array
  57551. */
  57552. getTextureIndex(textureType: number): number;
  57553. /**
  57554. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57555. */
  57556. /**
  57557. * Sets whether or not objects positions are enabled for the G buffer.
  57558. */
  57559. enablePosition: boolean;
  57560. /**
  57561. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57562. */
  57563. /**
  57564. * Sets wether or not objects velocities are enabled for the G buffer.
  57565. */
  57566. enableVelocity: boolean;
  57567. /**
  57568. * Gets the scene associated with the buffer.
  57569. */
  57570. readonly scene: Scene;
  57571. /**
  57572. * Gets the ratio used by the buffer during its creation.
  57573. * How big is the buffer related to the main canvas.
  57574. */
  57575. readonly ratio: number;
  57576. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  57577. /**
  57578. * Creates a new G Buffer for the scene
  57579. * @param scene The scene the buffer belongs to
  57580. * @param ratio How big is the buffer related to the main canvas.
  57581. */
  57582. constructor(scene: Scene, ratio?: number);
  57583. /**
  57584. * Checks wether everything is ready to render a submesh to the G buffer.
  57585. * @param subMesh the submesh to check readiness for
  57586. * @param useInstances is the mesh drawn using instance or not
  57587. * @returns true if ready otherwise false
  57588. */
  57589. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57590. /**
  57591. * Gets the current underlying G Buffer.
  57592. * @returns the buffer
  57593. */
  57594. getGBuffer(): MultiRenderTarget;
  57595. /**
  57596. * Gets the number of samples used to render the buffer (anti aliasing).
  57597. */
  57598. /**
  57599. * Sets the number of samples used to render the buffer (anti aliasing).
  57600. */
  57601. samples: number;
  57602. /**
  57603. * Disposes the renderer and frees up associated resources.
  57604. */
  57605. dispose(): void;
  57606. protected _createRenderTargets(): void;
  57607. private _copyBonesTransformationMatrices;
  57608. }
  57609. }
  57610. declare module BABYLON {
  57611. interface Scene {
  57612. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57613. /**
  57614. * Gets or Sets the current geometry buffer associated to the scene.
  57615. */
  57616. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57617. /**
  57618. * Enables a GeometryBufferRender and associates it with the scene
  57619. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57620. * @returns the GeometryBufferRenderer
  57621. */
  57622. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57623. /**
  57624. * Disables the GeometryBufferRender associated with the scene
  57625. */
  57626. disableGeometryBufferRenderer(): void;
  57627. }
  57628. /**
  57629. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57630. * in several rendering techniques.
  57631. */
  57632. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57633. /**
  57634. * The component name helpful to identify the component in the list of scene components.
  57635. */
  57636. readonly name: string;
  57637. /**
  57638. * The scene the component belongs to.
  57639. */
  57640. scene: Scene;
  57641. /**
  57642. * Creates a new instance of the component for the given scene
  57643. * @param scene Defines the scene to register the component in
  57644. */
  57645. constructor(scene: Scene);
  57646. /**
  57647. * Registers the component in a given scene
  57648. */
  57649. register(): void;
  57650. /**
  57651. * Rebuilds the elements related to this component in case of
  57652. * context lost for instance.
  57653. */
  57654. rebuild(): void;
  57655. /**
  57656. * Disposes the component and the associated ressources
  57657. */
  57658. dispose(): void;
  57659. private _gatherRenderTargets;
  57660. }
  57661. }
  57662. declare module BABYLON {
  57663. /** @hidden */
  57664. export var motionBlurPixelShader: {
  57665. name: string;
  57666. shader: string;
  57667. };
  57668. }
  57669. declare module BABYLON {
  57670. /**
  57671. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57672. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57673. * As an example, all you have to do is to create the post-process:
  57674. * var mb = new BABYLON.MotionBlurPostProcess(
  57675. * 'mb', // The name of the effect.
  57676. * scene, // The scene containing the objects to blur according to their velocity.
  57677. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57678. * camera // The camera to apply the render pass to.
  57679. * );
  57680. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57681. */
  57682. export class MotionBlurPostProcess extends PostProcess {
  57683. /**
  57684. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57685. */
  57686. motionStrength: number;
  57687. /**
  57688. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57689. */
  57690. /**
  57691. * Sets the number of iterations to be used for motion blur quality
  57692. */
  57693. motionBlurSamples: number;
  57694. private _motionBlurSamples;
  57695. private _geometryBufferRenderer;
  57696. /**
  57697. * Creates a new instance MotionBlurPostProcess
  57698. * @param name The name of the effect.
  57699. * @param scene The scene containing the objects to blur according to their velocity.
  57700. * @param options The required width/height ratio to downsize to before computing the render pass.
  57701. * @param camera The camera to apply the render pass to.
  57702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57703. * @param engine The engine which the post process will be applied. (default: current engine)
  57704. * @param reusable If the post process can be reused on the same frame. (default: false)
  57705. * @param textureType Type of textures used when performing the post process. (default: 0)
  57706. * @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)
  57707. */
  57708. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57709. /**
  57710. * Excludes the given skinned mesh from computing bones velocities.
  57711. * 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.
  57712. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57713. */
  57714. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57715. /**
  57716. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57717. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57718. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57719. */
  57720. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57721. /**
  57722. * Disposes the post process.
  57723. * @param camera The camera to dispose the post process on.
  57724. */
  57725. dispose(camera?: Camera): void;
  57726. }
  57727. }
  57728. declare module BABYLON {
  57729. /** @hidden */
  57730. export var refractionPixelShader: {
  57731. name: string;
  57732. shader: string;
  57733. };
  57734. }
  57735. declare module BABYLON {
  57736. /**
  57737. * Post process which applies a refractin texture
  57738. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57739. */
  57740. export class RefractionPostProcess extends PostProcess {
  57741. /** the base color of the refraction (used to taint the rendering) */
  57742. color: Color3;
  57743. /** simulated refraction depth */
  57744. depth: number;
  57745. /** the coefficient of the base color (0 to remove base color tainting) */
  57746. colorLevel: number;
  57747. private _refTexture;
  57748. private _ownRefractionTexture;
  57749. /**
  57750. * Gets or sets the refraction texture
  57751. * Please note that you are responsible for disposing the texture if you set it manually
  57752. */
  57753. refractionTexture: Texture;
  57754. /**
  57755. * Initializes the RefractionPostProcess
  57756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57757. * @param name The name of the effect.
  57758. * @param refractionTextureUrl Url of the refraction texture to use
  57759. * @param color the base color of the refraction (used to taint the rendering)
  57760. * @param depth simulated refraction depth
  57761. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57762. * @param camera The camera to apply the render pass to.
  57763. * @param options The required width/height ratio to downsize to before computing the render pass.
  57764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57765. * @param engine The engine which the post process will be applied. (default: current engine)
  57766. * @param reusable If the post process can be reused on the same frame. (default: false)
  57767. */
  57768. constructor(name: string, refractionTextureUrl: string,
  57769. /** the base color of the refraction (used to taint the rendering) */
  57770. color: Color3,
  57771. /** simulated refraction depth */
  57772. depth: number,
  57773. /** the coefficient of the base color (0 to remove base color tainting) */
  57774. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57775. /**
  57776. * Disposes of the post process
  57777. * @param camera Camera to dispose post process on
  57778. */
  57779. dispose(camera: Camera): void;
  57780. }
  57781. }
  57782. declare module BABYLON {
  57783. /** @hidden */
  57784. export var sharpenPixelShader: {
  57785. name: string;
  57786. shader: string;
  57787. };
  57788. }
  57789. declare module BABYLON {
  57790. /**
  57791. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57792. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57793. */
  57794. export class SharpenPostProcess extends PostProcess {
  57795. /**
  57796. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  57797. */
  57798. colorAmount: number;
  57799. /**
  57800. * How much sharpness should be applied (default: 0.3)
  57801. */
  57802. edgeAmount: number;
  57803. /**
  57804. * Creates a new instance ConvolutionPostProcess
  57805. * @param name The name of the effect.
  57806. * @param options The required width/height ratio to downsize to before computing the render pass.
  57807. * @param camera The camera to apply the render pass to.
  57808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57809. * @param engine The engine which the post process will be applied. (default: current engine)
  57810. * @param reusable If the post process can be reused on the same frame. (default: false)
  57811. * @param textureType Type of textures used when performing the post process. (default: 0)
  57812. * @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)
  57813. */
  57814. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57815. }
  57816. }
  57817. declare module BABYLON {
  57818. /**
  57819. * PostProcessRenderPipeline
  57820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57821. */
  57822. export class PostProcessRenderPipeline {
  57823. private engine;
  57824. private _renderEffects;
  57825. private _renderEffectsForIsolatedPass;
  57826. /**
  57827. * List of inspectable custom properties (used by the Inspector)
  57828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57829. */
  57830. inspectableCustomProperties: IInspectable[];
  57831. /**
  57832. * @hidden
  57833. */
  57834. protected _cameras: Camera[];
  57835. /** @hidden */ private _name: string;
  57836. /**
  57837. * Gets pipeline name
  57838. */
  57839. readonly name: string;
  57840. /**
  57841. * Initializes a PostProcessRenderPipeline
  57842. * @param engine engine to add the pipeline to
  57843. * @param name name of the pipeline
  57844. */
  57845. constructor(engine: Engine, name: string);
  57846. /**
  57847. * Gets the class name
  57848. * @returns "PostProcessRenderPipeline"
  57849. */
  57850. getClassName(): string;
  57851. /**
  57852. * If all the render effects in the pipeline are supported
  57853. */
  57854. readonly isSupported: boolean;
  57855. /**
  57856. * Adds an effect to the pipeline
  57857. * @param renderEffect the effect to add
  57858. */
  57859. addEffect(renderEffect: PostProcessRenderEffect): void;
  57860. /** @hidden */ private _rebuild(): void;
  57861. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  57862. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57863. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57864. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57865. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  57866. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  57867. /** @hidden */ private _detachCameras(cameras: Camera): void;
  57868. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  57869. /** @hidden */ private _update(): void;
  57870. /** @hidden */ private _reset(): void;
  57871. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57872. /**
  57873. * Disposes of the pipeline
  57874. */
  57875. dispose(): void;
  57876. }
  57877. }
  57878. declare module BABYLON {
  57879. /**
  57880. * PostProcessRenderPipelineManager class
  57881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57882. */
  57883. export class PostProcessRenderPipelineManager {
  57884. private _renderPipelines;
  57885. /**
  57886. * Initializes a PostProcessRenderPipelineManager
  57887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57888. */
  57889. constructor();
  57890. /**
  57891. * Gets the list of supported render pipelines
  57892. */
  57893. readonly supportedPipelines: PostProcessRenderPipeline[];
  57894. /**
  57895. * Adds a pipeline to the manager
  57896. * @param renderPipeline The pipeline to add
  57897. */
  57898. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57899. /**
  57900. * Attaches a camera to the pipeline
  57901. * @param renderPipelineName The name of the pipeline to attach to
  57902. * @param cameras the camera to attach
  57903. * @param unique if the camera can be attached multiple times to the pipeline
  57904. */
  57905. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57906. /**
  57907. * Detaches a camera from the pipeline
  57908. * @param renderPipelineName The name of the pipeline to detach from
  57909. * @param cameras the camera to detach
  57910. */
  57911. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57912. /**
  57913. * Enables an effect by name on a pipeline
  57914. * @param renderPipelineName the name of the pipeline to enable the effect in
  57915. * @param renderEffectName the name of the effect to enable
  57916. * @param cameras the cameras that the effect should be enabled on
  57917. */
  57918. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57919. /**
  57920. * Disables an effect by name on a pipeline
  57921. * @param renderPipelineName the name of the pipeline to disable the effect in
  57922. * @param renderEffectName the name of the effect to disable
  57923. * @param cameras the cameras that the effect should be disabled on
  57924. */
  57925. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57926. /**
  57927. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57928. */
  57929. update(): void;
  57930. /** @hidden */ private _rebuild(): void;
  57931. /**
  57932. * Disposes of the manager and pipelines
  57933. */
  57934. dispose(): void;
  57935. }
  57936. }
  57937. declare module BABYLON {
  57938. interface Scene {
  57939. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57940. /**
  57941. * Gets the postprocess render pipeline manager
  57942. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57943. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57944. */
  57945. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57946. }
  57947. /**
  57948. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57949. */
  57950. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57951. /**
  57952. * The component name helpfull to identify the component in the list of scene components.
  57953. */
  57954. readonly name: string;
  57955. /**
  57956. * The scene the component belongs to.
  57957. */
  57958. scene: Scene;
  57959. /**
  57960. * Creates a new instance of the component for the given scene
  57961. * @param scene Defines the scene to register the component in
  57962. */
  57963. constructor(scene: Scene);
  57964. /**
  57965. * Registers the component in a given scene
  57966. */
  57967. register(): void;
  57968. /**
  57969. * Rebuilds the elements related to this component in case of
  57970. * context lost for instance.
  57971. */
  57972. rebuild(): void;
  57973. /**
  57974. * Disposes the component and the associated ressources
  57975. */
  57976. dispose(): void;
  57977. private _gatherRenderTargets;
  57978. }
  57979. }
  57980. declare module BABYLON {
  57981. /**
  57982. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57983. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57984. */
  57985. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57986. private _scene;
  57987. private _camerasToBeAttached;
  57988. /**
  57989. * ID of the sharpen post process,
  57990. */
  57991. private readonly SharpenPostProcessId;
  57992. /**
  57993. * @ignore
  57994. * ID of the image processing post process;
  57995. */
  57996. readonly ImageProcessingPostProcessId: string;
  57997. /**
  57998. * @ignore
  57999. * ID of the Fast Approximate Anti-Aliasing post process;
  58000. */
  58001. readonly FxaaPostProcessId: string;
  58002. /**
  58003. * ID of the chromatic aberration post process,
  58004. */
  58005. private readonly ChromaticAberrationPostProcessId;
  58006. /**
  58007. * ID of the grain post process
  58008. */
  58009. private readonly GrainPostProcessId;
  58010. /**
  58011. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58012. */
  58013. sharpen: SharpenPostProcess;
  58014. private _sharpenEffect;
  58015. private bloom;
  58016. /**
  58017. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58018. */
  58019. depthOfField: DepthOfFieldEffect;
  58020. /**
  58021. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58022. */
  58023. fxaa: FxaaPostProcess;
  58024. /**
  58025. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58026. */
  58027. imageProcessing: ImageProcessingPostProcess;
  58028. /**
  58029. * Chromatic aberration post process which will shift rgb colors in the image
  58030. */
  58031. chromaticAberration: ChromaticAberrationPostProcess;
  58032. private _chromaticAberrationEffect;
  58033. /**
  58034. * Grain post process which add noise to the image
  58035. */
  58036. grain: GrainPostProcess;
  58037. private _grainEffect;
  58038. /**
  58039. * Glow post process which adds a glow to emissive areas of the image
  58040. */
  58041. private _glowLayer;
  58042. /**
  58043. * Animations which can be used to tweak settings over a period of time
  58044. */
  58045. animations: Animation[];
  58046. private _imageProcessingConfigurationObserver;
  58047. private _sharpenEnabled;
  58048. private _bloomEnabled;
  58049. private _depthOfFieldEnabled;
  58050. private _depthOfFieldBlurLevel;
  58051. private _fxaaEnabled;
  58052. private _imageProcessingEnabled;
  58053. private _defaultPipelineTextureType;
  58054. private _bloomScale;
  58055. private _chromaticAberrationEnabled;
  58056. private _grainEnabled;
  58057. private _buildAllowed;
  58058. /**
  58059. * Gets active scene
  58060. */
  58061. readonly scene: Scene;
  58062. /**
  58063. * Enable or disable the sharpen process from the pipeline
  58064. */
  58065. sharpenEnabled: boolean;
  58066. private _resizeObserver;
  58067. private _hardwareScaleLevel;
  58068. private _bloomKernel;
  58069. /**
  58070. * Specifies the size of the bloom blur kernel, relative to the final output size
  58071. */
  58072. bloomKernel: number;
  58073. /**
  58074. * Specifies the weight of the bloom in the final rendering
  58075. */
  58076. private _bloomWeight;
  58077. /**
  58078. * Specifies the luma threshold for the area that will be blurred by the bloom
  58079. */
  58080. private _bloomThreshold;
  58081. private _hdr;
  58082. /**
  58083. * The strength of the bloom.
  58084. */
  58085. bloomWeight: number;
  58086. /**
  58087. * The strength of the bloom.
  58088. */
  58089. bloomThreshold: number;
  58090. /**
  58091. * The scale of the bloom, lower value will provide better performance.
  58092. */
  58093. bloomScale: number;
  58094. /**
  58095. * Enable or disable the bloom from the pipeline
  58096. */
  58097. bloomEnabled: boolean;
  58098. private _rebuildBloom;
  58099. /**
  58100. * If the depth of field is enabled.
  58101. */
  58102. depthOfFieldEnabled: boolean;
  58103. /**
  58104. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58105. */
  58106. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58107. /**
  58108. * If the anti aliasing is enabled.
  58109. */
  58110. fxaaEnabled: boolean;
  58111. private _samples;
  58112. /**
  58113. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58114. */
  58115. samples: number;
  58116. /**
  58117. * If image processing is enabled.
  58118. */
  58119. imageProcessingEnabled: boolean;
  58120. /**
  58121. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58122. */
  58123. glowLayerEnabled: boolean;
  58124. /**
  58125. * Gets the glow layer (or null if not defined)
  58126. */
  58127. readonly glowLayer: Nullable<GlowLayer>;
  58128. /**
  58129. * Enable or disable the chromaticAberration process from the pipeline
  58130. */
  58131. chromaticAberrationEnabled: boolean;
  58132. /**
  58133. * Enable or disable the grain process from the pipeline
  58134. */
  58135. grainEnabled: boolean;
  58136. /**
  58137. * @constructor
  58138. * @param name - The rendering pipeline name (default: "")
  58139. * @param hdr - If high dynamic range textures should be used (default: true)
  58140. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58141. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58142. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58143. */
  58144. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58145. /**
  58146. * Get the class name
  58147. * @returns "DefaultRenderingPipeline"
  58148. */
  58149. getClassName(): string;
  58150. /**
  58151. * Force the compilation of the entire pipeline.
  58152. */
  58153. prepare(): void;
  58154. private _hasCleared;
  58155. private _prevPostProcess;
  58156. private _prevPrevPostProcess;
  58157. private _setAutoClearAndTextureSharing;
  58158. private _depthOfFieldSceneObserver;
  58159. private _buildPipeline;
  58160. private _disposePostProcesses;
  58161. /**
  58162. * Adds a camera to the pipeline
  58163. * @param camera the camera to be added
  58164. */
  58165. addCamera(camera: Camera): void;
  58166. /**
  58167. * Removes a camera from the pipeline
  58168. * @param camera the camera to remove
  58169. */
  58170. removeCamera(camera: Camera): void;
  58171. /**
  58172. * Dispose of the pipeline and stop all post processes
  58173. */
  58174. dispose(): void;
  58175. /**
  58176. * Serialize the rendering pipeline (Used when exporting)
  58177. * @returns the serialized object
  58178. */
  58179. serialize(): any;
  58180. /**
  58181. * Parse the serialized pipeline
  58182. * @param source Source pipeline.
  58183. * @param scene The scene to load the pipeline to.
  58184. * @param rootUrl The URL of the serialized pipeline.
  58185. * @returns An instantiated pipeline from the serialized object.
  58186. */
  58187. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58188. }
  58189. }
  58190. declare module BABYLON {
  58191. /** @hidden */
  58192. export var lensHighlightsPixelShader: {
  58193. name: string;
  58194. shader: string;
  58195. };
  58196. }
  58197. declare module BABYLON {
  58198. /** @hidden */
  58199. export var depthOfFieldPixelShader: {
  58200. name: string;
  58201. shader: string;
  58202. };
  58203. }
  58204. declare module BABYLON {
  58205. /**
  58206. * BABYLON.JS Chromatic Aberration GLSL Shader
  58207. * Author: Olivier Guyot
  58208. * Separates very slightly R, G and B colors on the edges of the screen
  58209. * Inspired by Francois Tarlier & Martins Upitis
  58210. */
  58211. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58212. /**
  58213. * @ignore
  58214. * The chromatic aberration PostProcess id in the pipeline
  58215. */
  58216. LensChromaticAberrationEffect: string;
  58217. /**
  58218. * @ignore
  58219. * The highlights enhancing PostProcess id in the pipeline
  58220. */
  58221. HighlightsEnhancingEffect: string;
  58222. /**
  58223. * @ignore
  58224. * The depth-of-field PostProcess id in the pipeline
  58225. */
  58226. LensDepthOfFieldEffect: string;
  58227. private _scene;
  58228. private _depthTexture;
  58229. private _grainTexture;
  58230. private _chromaticAberrationPostProcess;
  58231. private _highlightsPostProcess;
  58232. private _depthOfFieldPostProcess;
  58233. private _edgeBlur;
  58234. private _grainAmount;
  58235. private _chromaticAberration;
  58236. private _distortion;
  58237. private _highlightsGain;
  58238. private _highlightsThreshold;
  58239. private _dofDistance;
  58240. private _dofAperture;
  58241. private _dofDarken;
  58242. private _dofPentagon;
  58243. private _blurNoise;
  58244. /**
  58245. * @constructor
  58246. *
  58247. * Effect parameters are as follow:
  58248. * {
  58249. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58250. * edge_blur: number; // from 0 to x (1 for realism)
  58251. * distortion: number; // from 0 to x (1 for realism)
  58252. * grain_amount: number; // from 0 to 1
  58253. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58254. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58255. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58256. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58257. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58258. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58259. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58260. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58261. * }
  58262. * Note: if an effect parameter is unset, effect is disabled
  58263. *
  58264. * @param name The rendering pipeline name
  58265. * @param parameters - An object containing all parameters (see above)
  58266. * @param scene The scene linked to this pipeline
  58267. * @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)
  58268. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58269. */
  58270. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58271. /**
  58272. * Get the class name
  58273. * @returns "LensRenderingPipeline"
  58274. */
  58275. getClassName(): string;
  58276. /**
  58277. * Gets associated scene
  58278. */
  58279. readonly scene: Scene;
  58280. /**
  58281. * Gets or sets the edge blur
  58282. */
  58283. edgeBlur: number;
  58284. /**
  58285. * Gets or sets the grain amount
  58286. */
  58287. grainAmount: number;
  58288. /**
  58289. * Gets or sets the chromatic aberration amount
  58290. */
  58291. chromaticAberration: number;
  58292. /**
  58293. * Gets or sets the depth of field aperture
  58294. */
  58295. dofAperture: number;
  58296. /**
  58297. * Gets or sets the edge distortion
  58298. */
  58299. edgeDistortion: number;
  58300. /**
  58301. * Gets or sets the depth of field distortion
  58302. */
  58303. dofDistortion: number;
  58304. /**
  58305. * Gets or sets the darken out of focus amount
  58306. */
  58307. darkenOutOfFocus: number;
  58308. /**
  58309. * Gets or sets a boolean indicating if blur noise is enabled
  58310. */
  58311. blurNoise: boolean;
  58312. /**
  58313. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58314. */
  58315. pentagonBokeh: boolean;
  58316. /**
  58317. * Gets or sets the highlight grain amount
  58318. */
  58319. highlightsGain: number;
  58320. /**
  58321. * Gets or sets the highlight threshold
  58322. */
  58323. highlightsThreshold: number;
  58324. /**
  58325. * Sets the amount of blur at the edges
  58326. * @param amount blur amount
  58327. */
  58328. setEdgeBlur(amount: number): void;
  58329. /**
  58330. * Sets edge blur to 0
  58331. */
  58332. disableEdgeBlur(): void;
  58333. /**
  58334. * Sets the amout of grain
  58335. * @param amount Amount of grain
  58336. */
  58337. setGrainAmount(amount: number): void;
  58338. /**
  58339. * Set grain amount to 0
  58340. */
  58341. disableGrain(): void;
  58342. /**
  58343. * Sets the chromatic aberration amount
  58344. * @param amount amount of chromatic aberration
  58345. */
  58346. setChromaticAberration(amount: number): void;
  58347. /**
  58348. * Sets chromatic aberration amount to 0
  58349. */
  58350. disableChromaticAberration(): void;
  58351. /**
  58352. * Sets the EdgeDistortion amount
  58353. * @param amount amount of EdgeDistortion
  58354. */
  58355. setEdgeDistortion(amount: number): void;
  58356. /**
  58357. * Sets edge distortion to 0
  58358. */
  58359. disableEdgeDistortion(): void;
  58360. /**
  58361. * Sets the FocusDistance amount
  58362. * @param amount amount of FocusDistance
  58363. */
  58364. setFocusDistance(amount: number): void;
  58365. /**
  58366. * Disables depth of field
  58367. */
  58368. disableDepthOfField(): void;
  58369. /**
  58370. * Sets the Aperture amount
  58371. * @param amount amount of Aperture
  58372. */
  58373. setAperture(amount: number): void;
  58374. /**
  58375. * Sets the DarkenOutOfFocus amount
  58376. * @param amount amount of DarkenOutOfFocus
  58377. */
  58378. setDarkenOutOfFocus(amount: number): void;
  58379. private _pentagonBokehIsEnabled;
  58380. /**
  58381. * Creates a pentagon bokeh effect
  58382. */
  58383. enablePentagonBokeh(): void;
  58384. /**
  58385. * Disables the pentagon bokeh effect
  58386. */
  58387. disablePentagonBokeh(): void;
  58388. /**
  58389. * Enables noise blur
  58390. */
  58391. enableNoiseBlur(): void;
  58392. /**
  58393. * Disables noise blur
  58394. */
  58395. disableNoiseBlur(): void;
  58396. /**
  58397. * Sets the HighlightsGain amount
  58398. * @param amount amount of HighlightsGain
  58399. */
  58400. setHighlightsGain(amount: number): void;
  58401. /**
  58402. * Sets the HighlightsThreshold amount
  58403. * @param amount amount of HighlightsThreshold
  58404. */
  58405. setHighlightsThreshold(amount: number): void;
  58406. /**
  58407. * Disables highlights
  58408. */
  58409. disableHighlights(): void;
  58410. /**
  58411. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58412. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58413. */
  58414. dispose(disableDepthRender?: boolean): void;
  58415. private _createChromaticAberrationPostProcess;
  58416. private _createHighlightsPostProcess;
  58417. private _createDepthOfFieldPostProcess;
  58418. private _createGrainTexture;
  58419. }
  58420. }
  58421. declare module BABYLON {
  58422. /** @hidden */
  58423. export var ssao2PixelShader: {
  58424. name: string;
  58425. shader: string;
  58426. };
  58427. }
  58428. declare module BABYLON {
  58429. /** @hidden */
  58430. export var ssaoCombinePixelShader: {
  58431. name: string;
  58432. shader: string;
  58433. };
  58434. }
  58435. declare module BABYLON {
  58436. /**
  58437. * Render pipeline to produce ssao effect
  58438. */
  58439. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58440. /**
  58441. * @ignore
  58442. * The PassPostProcess id in the pipeline that contains the original scene color
  58443. */
  58444. SSAOOriginalSceneColorEffect: string;
  58445. /**
  58446. * @ignore
  58447. * The SSAO PostProcess id in the pipeline
  58448. */
  58449. SSAORenderEffect: string;
  58450. /**
  58451. * @ignore
  58452. * The horizontal blur PostProcess id in the pipeline
  58453. */
  58454. SSAOBlurHRenderEffect: string;
  58455. /**
  58456. * @ignore
  58457. * The vertical blur PostProcess id in the pipeline
  58458. */
  58459. SSAOBlurVRenderEffect: string;
  58460. /**
  58461. * @ignore
  58462. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58463. */
  58464. SSAOCombineRenderEffect: string;
  58465. /**
  58466. * The output strength of the SSAO post-process. Default value is 1.0.
  58467. */
  58468. totalStrength: number;
  58469. /**
  58470. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58471. */
  58472. maxZ: number;
  58473. /**
  58474. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58475. */
  58476. minZAspect: number;
  58477. private _samples;
  58478. /**
  58479. * Number of samples used for the SSAO calculations. Default value is 8
  58480. */
  58481. samples: number;
  58482. private _textureSamples;
  58483. /**
  58484. * Number of samples to use for antialiasing
  58485. */
  58486. textureSamples: number;
  58487. /**
  58488. * Ratio object used for SSAO ratio and blur ratio
  58489. */
  58490. private _ratio;
  58491. /**
  58492. * Dynamically generated sphere sampler.
  58493. */
  58494. private _sampleSphere;
  58495. /**
  58496. * Blur filter offsets
  58497. */
  58498. private _samplerOffsets;
  58499. private _expensiveBlur;
  58500. /**
  58501. * If bilateral blur should be used
  58502. */
  58503. expensiveBlur: boolean;
  58504. /**
  58505. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58506. */
  58507. radius: number;
  58508. /**
  58509. * The base color of the SSAO post-process
  58510. * The final result is "base + ssao" between [0, 1]
  58511. */
  58512. base: number;
  58513. /**
  58514. * Support test.
  58515. */
  58516. static readonly IsSupported: boolean;
  58517. private _scene;
  58518. private _depthTexture;
  58519. private _normalTexture;
  58520. private _randomTexture;
  58521. private _originalColorPostProcess;
  58522. private _ssaoPostProcess;
  58523. private _blurHPostProcess;
  58524. private _blurVPostProcess;
  58525. private _ssaoCombinePostProcess;
  58526. private _firstUpdate;
  58527. /**
  58528. * Gets active scene
  58529. */
  58530. readonly scene: Scene;
  58531. /**
  58532. * @constructor
  58533. * @param name The rendering pipeline name
  58534. * @param scene The scene linked to this pipeline
  58535. * @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 }
  58536. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58537. */
  58538. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58539. /**
  58540. * Get the class name
  58541. * @returns "SSAO2RenderingPipeline"
  58542. */
  58543. getClassName(): string;
  58544. /**
  58545. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58546. */
  58547. dispose(disableGeometryBufferRenderer?: boolean): void;
  58548. private _createBlurPostProcess;
  58549. /** @hidden */ private _rebuild(): void;
  58550. private _bits;
  58551. private _radicalInverse_VdC;
  58552. private _hammersley;
  58553. private _hemisphereSample_uniform;
  58554. private _generateHemisphere;
  58555. private _createSSAOPostProcess;
  58556. private _createSSAOCombinePostProcess;
  58557. private _createRandomTexture;
  58558. /**
  58559. * Serialize the rendering pipeline (Used when exporting)
  58560. * @returns the serialized object
  58561. */
  58562. serialize(): any;
  58563. /**
  58564. * Parse the serialized pipeline
  58565. * @param source Source pipeline.
  58566. * @param scene The scene to load the pipeline to.
  58567. * @param rootUrl The URL of the serialized pipeline.
  58568. * @returns An instantiated pipeline from the serialized object.
  58569. */
  58570. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58571. }
  58572. }
  58573. declare module BABYLON {
  58574. /** @hidden */
  58575. export var ssaoPixelShader: {
  58576. name: string;
  58577. shader: string;
  58578. };
  58579. }
  58580. declare module BABYLON {
  58581. /**
  58582. * Render pipeline to produce ssao effect
  58583. */
  58584. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58585. /**
  58586. * @ignore
  58587. * The PassPostProcess id in the pipeline that contains the original scene color
  58588. */
  58589. SSAOOriginalSceneColorEffect: string;
  58590. /**
  58591. * @ignore
  58592. * The SSAO PostProcess id in the pipeline
  58593. */
  58594. SSAORenderEffect: string;
  58595. /**
  58596. * @ignore
  58597. * The horizontal blur PostProcess id in the pipeline
  58598. */
  58599. SSAOBlurHRenderEffect: string;
  58600. /**
  58601. * @ignore
  58602. * The vertical blur PostProcess id in the pipeline
  58603. */
  58604. SSAOBlurVRenderEffect: string;
  58605. /**
  58606. * @ignore
  58607. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58608. */
  58609. SSAOCombineRenderEffect: string;
  58610. /**
  58611. * The output strength of the SSAO post-process. Default value is 1.0.
  58612. */
  58613. totalStrength: number;
  58614. /**
  58615. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58616. */
  58617. radius: number;
  58618. /**
  58619. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58620. * Must not be equal to fallOff and superior to fallOff.
  58621. * Default value is 0.0075
  58622. */
  58623. area: number;
  58624. /**
  58625. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58626. * Must not be equal to area and inferior to area.
  58627. * Default value is 0.000001
  58628. */
  58629. fallOff: number;
  58630. /**
  58631. * The base color of the SSAO post-process
  58632. * The final result is "base + ssao" between [0, 1]
  58633. */
  58634. base: number;
  58635. private _scene;
  58636. private _depthTexture;
  58637. private _randomTexture;
  58638. private _originalColorPostProcess;
  58639. private _ssaoPostProcess;
  58640. private _blurHPostProcess;
  58641. private _blurVPostProcess;
  58642. private _ssaoCombinePostProcess;
  58643. private _firstUpdate;
  58644. /**
  58645. * Gets active scene
  58646. */
  58647. readonly scene: Scene;
  58648. /**
  58649. * @constructor
  58650. * @param name - The rendering pipeline name
  58651. * @param scene - The scene linked to this pipeline
  58652. * @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 }
  58653. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58654. */
  58655. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58656. /**
  58657. * Get the class name
  58658. * @returns "SSAORenderingPipeline"
  58659. */
  58660. getClassName(): string;
  58661. /**
  58662. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58663. */
  58664. dispose(disableDepthRender?: boolean): void;
  58665. private _createBlurPostProcess;
  58666. /** @hidden */ private _rebuild(): void;
  58667. private _createSSAOPostProcess;
  58668. private _createSSAOCombinePostProcess;
  58669. private _createRandomTexture;
  58670. }
  58671. }
  58672. declare module BABYLON {
  58673. /** @hidden */
  58674. export var standardPixelShader: {
  58675. name: string;
  58676. shader: string;
  58677. };
  58678. }
  58679. declare module BABYLON {
  58680. /**
  58681. * Standard rendering pipeline
  58682. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58683. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58684. */
  58685. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58686. /**
  58687. * Public members
  58688. */
  58689. /**
  58690. * Post-process which contains the original scene color before the pipeline applies all the effects
  58691. */
  58692. originalPostProcess: Nullable<PostProcess>;
  58693. /**
  58694. * Post-process used to down scale an image x4
  58695. */
  58696. downSampleX4PostProcess: Nullable<PostProcess>;
  58697. /**
  58698. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58699. */
  58700. brightPassPostProcess: Nullable<PostProcess>;
  58701. /**
  58702. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58703. */
  58704. blurHPostProcesses: PostProcess[];
  58705. /**
  58706. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58707. */
  58708. blurVPostProcesses: PostProcess[];
  58709. /**
  58710. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58711. */
  58712. textureAdderPostProcess: Nullable<PostProcess>;
  58713. /**
  58714. * Post-process used to create volumetric lighting effect
  58715. */
  58716. volumetricLightPostProcess: Nullable<PostProcess>;
  58717. /**
  58718. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58719. */
  58720. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  58721. /**
  58722. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  58723. */
  58724. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  58725. /**
  58726. * Post-process used to merge the volumetric light effect and the real scene color
  58727. */
  58728. volumetricLightMergePostProces: Nullable<PostProcess>;
  58729. /**
  58730. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  58731. */
  58732. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  58733. /**
  58734. * Base post-process used to calculate the average luminance of the final image for HDR
  58735. */
  58736. luminancePostProcess: Nullable<PostProcess>;
  58737. /**
  58738. * Post-processes used to create down sample post-processes in order to get
  58739. * the average luminance of the final image for HDR
  58740. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  58741. */
  58742. luminanceDownSamplePostProcesses: PostProcess[];
  58743. /**
  58744. * Post-process used to create a HDR effect (light adaptation)
  58745. */
  58746. hdrPostProcess: Nullable<PostProcess>;
  58747. /**
  58748. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  58749. */
  58750. textureAdderFinalPostProcess: Nullable<PostProcess>;
  58751. /**
  58752. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  58753. */
  58754. lensFlareFinalPostProcess: Nullable<PostProcess>;
  58755. /**
  58756. * Post-process used to merge the final HDR post-process and the real scene color
  58757. */
  58758. hdrFinalPostProcess: Nullable<PostProcess>;
  58759. /**
  58760. * Post-process used to create a lens flare effect
  58761. */
  58762. lensFlarePostProcess: Nullable<PostProcess>;
  58763. /**
  58764. * Post-process that merges the result of the lens flare post-process and the real scene color
  58765. */
  58766. lensFlareComposePostProcess: Nullable<PostProcess>;
  58767. /**
  58768. * Post-process used to create a motion blur effect
  58769. */
  58770. motionBlurPostProcess: Nullable<PostProcess>;
  58771. /**
  58772. * Post-process used to create a depth of field effect
  58773. */
  58774. depthOfFieldPostProcess: Nullable<PostProcess>;
  58775. /**
  58776. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58777. */
  58778. fxaaPostProcess: Nullable<FxaaPostProcess>;
  58779. /**
  58780. * Represents the brightness threshold in order to configure the illuminated surfaces
  58781. */
  58782. brightThreshold: number;
  58783. /**
  58784. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  58785. */
  58786. blurWidth: number;
  58787. /**
  58788. * Sets if the blur for highlighted surfaces must be only horizontal
  58789. */
  58790. horizontalBlur: boolean;
  58791. /**
  58792. * Gets the overall exposure used by the pipeline
  58793. */
  58794. /**
  58795. * Sets the overall exposure used by the pipeline
  58796. */
  58797. exposure: number;
  58798. /**
  58799. * Texture used typically to simulate "dirty" on camera lens
  58800. */
  58801. lensTexture: Nullable<Texture>;
  58802. /**
  58803. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  58804. */
  58805. volumetricLightCoefficient: number;
  58806. /**
  58807. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  58808. */
  58809. volumetricLightPower: number;
  58810. /**
  58811. * Used the set the blur intensity to smooth the volumetric lights
  58812. */
  58813. volumetricLightBlurScale: number;
  58814. /**
  58815. * Light (spot or directional) used to generate the volumetric lights rays
  58816. * The source light must have a shadow generate so the pipeline can get its
  58817. * depth map
  58818. */
  58819. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58820. /**
  58821. * For eye adaptation, represents the minimum luminance the eye can see
  58822. */
  58823. hdrMinimumLuminance: number;
  58824. /**
  58825. * For eye adaptation, represents the decrease luminance speed
  58826. */
  58827. hdrDecreaseRate: number;
  58828. /**
  58829. * For eye adaptation, represents the increase luminance speed
  58830. */
  58831. hdrIncreaseRate: number;
  58832. /**
  58833. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58834. */
  58835. /**
  58836. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58837. */
  58838. hdrAutoExposure: boolean;
  58839. /**
  58840. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58841. */
  58842. lensColorTexture: Nullable<Texture>;
  58843. /**
  58844. * The overall strengh for the lens flare effect
  58845. */
  58846. lensFlareStrength: number;
  58847. /**
  58848. * Dispersion coefficient for lens flare ghosts
  58849. */
  58850. lensFlareGhostDispersal: number;
  58851. /**
  58852. * Main lens flare halo width
  58853. */
  58854. lensFlareHaloWidth: number;
  58855. /**
  58856. * Based on the lens distortion effect, defines how much the lens flare result
  58857. * is distorted
  58858. */
  58859. lensFlareDistortionStrength: number;
  58860. /**
  58861. * Configures the blur intensity used for for lens flare (halo)
  58862. */
  58863. lensFlareBlurWidth: number;
  58864. /**
  58865. * Lens star texture must be used to simulate rays on the flares and is available
  58866. * in the documentation
  58867. */
  58868. lensStarTexture: Nullable<Texture>;
  58869. /**
  58870. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58871. * flare effect by taking account of the dirt texture
  58872. */
  58873. lensFlareDirtTexture: Nullable<Texture>;
  58874. /**
  58875. * Represents the focal length for the depth of field effect
  58876. */
  58877. depthOfFieldDistance: number;
  58878. /**
  58879. * Represents the blur intensity for the blurred part of the depth of field effect
  58880. */
  58881. depthOfFieldBlurWidth: number;
  58882. /**
  58883. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58884. */
  58885. /**
  58886. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58887. */
  58888. motionStrength: number;
  58889. /**
  58890. * Gets wether or not the motion blur post-process is object based or screen based.
  58891. */
  58892. /**
  58893. * Sets wether or not the motion blur post-process should be object based or screen based
  58894. */
  58895. objectBasedMotionBlur: boolean;
  58896. /**
  58897. * List of animations for the pipeline (IAnimatable implementation)
  58898. */
  58899. animations: Animation[];
  58900. /**
  58901. * Private members
  58902. */
  58903. private _scene;
  58904. private _currentDepthOfFieldSource;
  58905. private _basePostProcess;
  58906. private _fixedExposure;
  58907. private _currentExposure;
  58908. private _hdrAutoExposure;
  58909. private _hdrCurrentLuminance;
  58910. private _motionStrength;
  58911. private _isObjectBasedMotionBlur;
  58912. private _floatTextureType;
  58913. private _camerasToBeAttached;
  58914. private _ratio;
  58915. private _bloomEnabled;
  58916. private _depthOfFieldEnabled;
  58917. private _vlsEnabled;
  58918. private _lensFlareEnabled;
  58919. private _hdrEnabled;
  58920. private _motionBlurEnabled;
  58921. private _fxaaEnabled;
  58922. private _motionBlurSamples;
  58923. private _volumetricLightStepsCount;
  58924. private _samples;
  58925. /**
  58926. * @ignore
  58927. * Specifies if the bloom pipeline is enabled
  58928. */
  58929. BloomEnabled: boolean;
  58930. /**
  58931. * @ignore
  58932. * Specifies if the depth of field pipeline is enabed
  58933. */
  58934. DepthOfFieldEnabled: boolean;
  58935. /**
  58936. * @ignore
  58937. * Specifies if the lens flare pipeline is enabed
  58938. */
  58939. LensFlareEnabled: boolean;
  58940. /**
  58941. * @ignore
  58942. * Specifies if the HDR pipeline is enabled
  58943. */
  58944. HDREnabled: boolean;
  58945. /**
  58946. * @ignore
  58947. * Specifies if the volumetric lights scattering effect is enabled
  58948. */
  58949. VLSEnabled: boolean;
  58950. /**
  58951. * @ignore
  58952. * Specifies if the motion blur effect is enabled
  58953. */
  58954. MotionBlurEnabled: boolean;
  58955. /**
  58956. * Specifies if anti-aliasing is enabled
  58957. */
  58958. fxaaEnabled: boolean;
  58959. /**
  58960. * Specifies the number of steps used to calculate the volumetric lights
  58961. * Typically in interval [50, 200]
  58962. */
  58963. volumetricLightStepsCount: number;
  58964. /**
  58965. * Specifies the number of samples used for the motion blur effect
  58966. * Typically in interval [16, 64]
  58967. */
  58968. motionBlurSamples: number;
  58969. /**
  58970. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58971. */
  58972. samples: number;
  58973. /**
  58974. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58975. * @constructor
  58976. * @param name The rendering pipeline name
  58977. * @param scene The scene linked to this pipeline
  58978. * @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)
  58979. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58980. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58981. */
  58982. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58983. private _buildPipeline;
  58984. private _createDownSampleX4PostProcess;
  58985. private _createBrightPassPostProcess;
  58986. private _createBlurPostProcesses;
  58987. private _createTextureAdderPostProcess;
  58988. private _createVolumetricLightPostProcess;
  58989. private _createLuminancePostProcesses;
  58990. private _createHdrPostProcess;
  58991. private _createLensFlarePostProcess;
  58992. private _createDepthOfFieldPostProcess;
  58993. private _createMotionBlurPostProcess;
  58994. private _getDepthTexture;
  58995. private _disposePostProcesses;
  58996. /**
  58997. * Dispose of the pipeline and stop all post processes
  58998. */
  58999. dispose(): void;
  59000. /**
  59001. * Serialize the rendering pipeline (Used when exporting)
  59002. * @returns the serialized object
  59003. */
  59004. serialize(): any;
  59005. /**
  59006. * Parse the serialized pipeline
  59007. * @param source Source pipeline.
  59008. * @param scene The scene to load the pipeline to.
  59009. * @param rootUrl The URL of the serialized pipeline.
  59010. * @returns An instantiated pipeline from the serialized object.
  59011. */
  59012. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59013. /**
  59014. * Luminance steps
  59015. */
  59016. static LuminanceSteps: number;
  59017. }
  59018. }
  59019. declare module BABYLON {
  59020. /** @hidden */
  59021. export var tonemapPixelShader: {
  59022. name: string;
  59023. shader: string;
  59024. };
  59025. }
  59026. declare module BABYLON {
  59027. /** Defines operator used for tonemapping */
  59028. export enum TonemappingOperator {
  59029. /** Hable */
  59030. Hable = 0,
  59031. /** Reinhard */
  59032. Reinhard = 1,
  59033. /** HejiDawson */
  59034. HejiDawson = 2,
  59035. /** Photographic */
  59036. Photographic = 3
  59037. }
  59038. /**
  59039. * Defines a post process to apply tone mapping
  59040. */
  59041. export class TonemapPostProcess extends PostProcess {
  59042. private _operator;
  59043. /** Defines the required exposure adjustement */
  59044. exposureAdjustment: number;
  59045. /**
  59046. * Creates a new TonemapPostProcess
  59047. * @param name defines the name of the postprocess
  59048. * @param _operator defines the operator to use
  59049. * @param exposureAdjustment defines the required exposure adjustement
  59050. * @param camera defines the camera to use (can be null)
  59051. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59052. * @param engine defines the hosting engine (can be ignore if camera is set)
  59053. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59054. */
  59055. constructor(name: string, _operator: TonemappingOperator,
  59056. /** Defines the required exposure adjustement */
  59057. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59058. }
  59059. }
  59060. declare module BABYLON {
  59061. /** @hidden */
  59062. export var depthVertexShader: {
  59063. name: string;
  59064. shader: string;
  59065. };
  59066. }
  59067. declare module BABYLON {
  59068. /** @hidden */
  59069. export var volumetricLightScatteringPixelShader: {
  59070. name: string;
  59071. shader: string;
  59072. };
  59073. }
  59074. declare module BABYLON {
  59075. /** @hidden */
  59076. export var volumetricLightScatteringPassVertexShader: {
  59077. name: string;
  59078. shader: string;
  59079. };
  59080. }
  59081. declare module BABYLON {
  59082. /** @hidden */
  59083. export var volumetricLightScatteringPassPixelShader: {
  59084. name: string;
  59085. shader: string;
  59086. };
  59087. }
  59088. declare module BABYLON {
  59089. /**
  59090. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59091. */
  59092. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59093. private _volumetricLightScatteringPass;
  59094. private _volumetricLightScatteringRTT;
  59095. private _viewPort;
  59096. private _screenCoordinates;
  59097. private _cachedDefines;
  59098. /**
  59099. * If not undefined, the mesh position is computed from the attached node position
  59100. */
  59101. attachedNode: {
  59102. position: Vector3;
  59103. };
  59104. /**
  59105. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59106. */
  59107. customMeshPosition: Vector3;
  59108. /**
  59109. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59110. */
  59111. useCustomMeshPosition: boolean;
  59112. /**
  59113. * If the post-process should inverse the light scattering direction
  59114. */
  59115. invert: boolean;
  59116. /**
  59117. * The internal mesh used by the post-process
  59118. */
  59119. mesh: Mesh;
  59120. /**
  59121. * @hidden
  59122. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59123. */
  59124. useDiffuseColor: boolean;
  59125. /**
  59126. * Array containing the excluded meshes not rendered in the internal pass
  59127. */
  59128. excludedMeshes: AbstractMesh[];
  59129. /**
  59130. * Controls the overall intensity of the post-process
  59131. */
  59132. exposure: number;
  59133. /**
  59134. * Dissipates each sample's contribution in range [0, 1]
  59135. */
  59136. decay: number;
  59137. /**
  59138. * Controls the overall intensity of each sample
  59139. */
  59140. weight: number;
  59141. /**
  59142. * Controls the density of each sample
  59143. */
  59144. density: number;
  59145. /**
  59146. * @constructor
  59147. * @param name The post-process name
  59148. * @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)
  59149. * @param camera The camera that the post-process will be attached to
  59150. * @param mesh The mesh used to create the light scattering
  59151. * @param samples The post-process quality, default 100
  59152. * @param samplingModeThe post-process filtering mode
  59153. * @param engine The babylon engine
  59154. * @param reusable If the post-process is reusable
  59155. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59156. */
  59157. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59158. /**
  59159. * Returns the string "VolumetricLightScatteringPostProcess"
  59160. * @returns "VolumetricLightScatteringPostProcess"
  59161. */
  59162. getClassName(): string;
  59163. private _isReady;
  59164. /**
  59165. * Sets the new light position for light scattering effect
  59166. * @param position The new custom light position
  59167. */
  59168. setCustomMeshPosition(position: Vector3): void;
  59169. /**
  59170. * Returns the light position for light scattering effect
  59171. * @return Vector3 The custom light position
  59172. */
  59173. getCustomMeshPosition(): Vector3;
  59174. /**
  59175. * Disposes the internal assets and detaches the post-process from the camera
  59176. */
  59177. dispose(camera: Camera): void;
  59178. /**
  59179. * Returns the render target texture used by the post-process
  59180. * @return the render target texture used by the post-process
  59181. */
  59182. getPass(): RenderTargetTexture;
  59183. private _meshExcluded;
  59184. private _createPass;
  59185. private _updateMeshScreenCoordinates;
  59186. /**
  59187. * Creates a default mesh for the Volumeric Light Scattering post-process
  59188. * @param name The mesh name
  59189. * @param scene The scene where to create the mesh
  59190. * @return the default mesh
  59191. */
  59192. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59193. }
  59194. }
  59195. declare module BABYLON {
  59196. interface Scene {
  59197. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  59198. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  59199. /**
  59200. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59201. */
  59202. forceShowBoundingBoxes: boolean;
  59203. /**
  59204. * Gets the bounding box renderer associated with the scene
  59205. * @returns a BoundingBoxRenderer
  59206. */
  59207. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59208. }
  59209. interface AbstractMesh {
  59210. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  59211. /**
  59212. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59213. */
  59214. showBoundingBox: boolean;
  59215. }
  59216. /**
  59217. * Component responsible of rendering the bounding box of the meshes in a scene.
  59218. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59219. */
  59220. export class BoundingBoxRenderer implements ISceneComponent {
  59221. /**
  59222. * The component name helpfull to identify the component in the list of scene components.
  59223. */
  59224. readonly name: string;
  59225. /**
  59226. * The scene the component belongs to.
  59227. */
  59228. scene: Scene;
  59229. /**
  59230. * Color of the bounding box lines placed in front of an object
  59231. */
  59232. frontColor: Color3;
  59233. /**
  59234. * Color of the bounding box lines placed behind an object
  59235. */
  59236. backColor: Color3;
  59237. /**
  59238. * Defines if the renderer should show the back lines or not
  59239. */
  59240. showBackLines: boolean;
  59241. /**
  59242. * @hidden
  59243. */
  59244. renderList: SmartArray<BoundingBox>;
  59245. private _colorShader;
  59246. private _vertexBuffers;
  59247. private _indexBuffer;
  59248. private _fillIndexBuffer;
  59249. private _fillIndexData;
  59250. /**
  59251. * Instantiates a new bounding box renderer in a scene.
  59252. * @param scene the scene the renderer renders in
  59253. */
  59254. constructor(scene: Scene);
  59255. /**
  59256. * Registers the component in a given scene
  59257. */
  59258. register(): void;
  59259. private _evaluateSubMesh;
  59260. private _activeMesh;
  59261. private _prepareRessources;
  59262. private _createIndexBuffer;
  59263. /**
  59264. * Rebuilds the elements related to this component in case of
  59265. * context lost for instance.
  59266. */
  59267. rebuild(): void;
  59268. /**
  59269. * @hidden
  59270. */
  59271. reset(): void;
  59272. /**
  59273. * Render the bounding boxes of a specific rendering group
  59274. * @param renderingGroupId defines the rendering group to render
  59275. */
  59276. render(renderingGroupId: number): void;
  59277. /**
  59278. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59279. * @param mesh Define the mesh to render the occlusion bounding box for
  59280. */
  59281. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59282. /**
  59283. * Dispose and release the resources attached to this renderer.
  59284. */
  59285. dispose(): void;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /** @hidden */
  59290. export var depthPixelShader: {
  59291. name: string;
  59292. shader: string;
  59293. };
  59294. }
  59295. declare module BABYLON {
  59296. /**
  59297. * This represents a depth renderer in Babylon.
  59298. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59299. */
  59300. export class DepthRenderer {
  59301. private _scene;
  59302. private _depthMap;
  59303. private _effect;
  59304. private readonly _storeNonLinearDepth;
  59305. private readonly _clearColor;
  59306. /** Get if the depth renderer is using packed depth or not */
  59307. readonly isPacked: boolean;
  59308. private _cachedDefines;
  59309. private _camera;
  59310. /**
  59311. * Specifiess that the depth renderer will only be used within
  59312. * the camera it is created for.
  59313. * This can help forcing its rendering during the camera processing.
  59314. */
  59315. useOnlyInActiveCamera: boolean;
  59316. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  59317. /**
  59318. * Instantiates a depth renderer
  59319. * @param scene The scene the renderer belongs to
  59320. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59321. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59322. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59323. */
  59324. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59325. /**
  59326. * Creates the depth rendering effect and checks if the effect is ready.
  59327. * @param subMesh The submesh to be used to render the depth map of
  59328. * @param useInstances If multiple world instances should be used
  59329. * @returns if the depth renderer is ready to render the depth map
  59330. */
  59331. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59332. /**
  59333. * Gets the texture which the depth map will be written to.
  59334. * @returns The depth map texture
  59335. */
  59336. getDepthMap(): RenderTargetTexture;
  59337. /**
  59338. * Disposes of the depth renderer.
  59339. */
  59340. dispose(): void;
  59341. }
  59342. }
  59343. declare module BABYLON {
  59344. interface Scene {
  59345. /** @hidden (Backing field) */ private _depthRenderer: {
  59346. [id: string]: DepthRenderer;
  59347. };
  59348. /**
  59349. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59350. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59351. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59352. * @returns the created depth renderer
  59353. */
  59354. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59355. /**
  59356. * Disables a depth renderer for a given camera
  59357. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59358. */
  59359. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59360. }
  59361. /**
  59362. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59363. * in several rendering techniques.
  59364. */
  59365. export class DepthRendererSceneComponent implements ISceneComponent {
  59366. /**
  59367. * The component name helpfull to identify the component in the list of scene components.
  59368. */
  59369. readonly name: string;
  59370. /**
  59371. * The scene the component belongs to.
  59372. */
  59373. scene: Scene;
  59374. /**
  59375. * Creates a new instance of the component for the given scene
  59376. * @param scene Defines the scene to register the component in
  59377. */
  59378. constructor(scene: Scene);
  59379. /**
  59380. * Registers the component in a given scene
  59381. */
  59382. register(): void;
  59383. /**
  59384. * Rebuilds the elements related to this component in case of
  59385. * context lost for instance.
  59386. */
  59387. rebuild(): void;
  59388. /**
  59389. * Disposes the component and the associated ressources
  59390. */
  59391. dispose(): void;
  59392. private _gatherRenderTargets;
  59393. private _gatherActiveCameraRenderTargets;
  59394. }
  59395. }
  59396. declare module BABYLON {
  59397. /** @hidden */
  59398. export var outlinePixelShader: {
  59399. name: string;
  59400. shader: string;
  59401. };
  59402. }
  59403. declare module BABYLON {
  59404. /** @hidden */
  59405. export var outlineVertexShader: {
  59406. name: string;
  59407. shader: string;
  59408. };
  59409. }
  59410. declare module BABYLON {
  59411. interface Scene {
  59412. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  59413. /**
  59414. * Gets the outline renderer associated with the scene
  59415. * @returns a OutlineRenderer
  59416. */
  59417. getOutlineRenderer(): OutlineRenderer;
  59418. }
  59419. interface AbstractMesh {
  59420. /** @hidden (Backing field) */ private _renderOutline: boolean;
  59421. /**
  59422. * Gets or sets a boolean indicating if the outline must be rendered as well
  59423. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59424. */
  59425. renderOutline: boolean;
  59426. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  59427. /**
  59428. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59429. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59430. */
  59431. renderOverlay: boolean;
  59432. }
  59433. /**
  59434. * This class is responsible to draw bothe outline/overlay of meshes.
  59435. * It should not be used directly but through the available method on mesh.
  59436. */
  59437. export class OutlineRenderer implements ISceneComponent {
  59438. /**
  59439. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59440. */
  59441. private static _StencilReference;
  59442. /**
  59443. * The name of the component. Each component must have a unique name.
  59444. */
  59445. name: string;
  59446. /**
  59447. * The scene the component belongs to.
  59448. */
  59449. scene: Scene;
  59450. /**
  59451. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59452. */
  59453. zOffset: number;
  59454. private _engine;
  59455. private _effect;
  59456. private _cachedDefines;
  59457. private _savedDepthWrite;
  59458. /**
  59459. * Instantiates a new outline renderer. (There could be only one per scene).
  59460. * @param scene Defines the scene it belongs to
  59461. */
  59462. constructor(scene: Scene);
  59463. /**
  59464. * Register the component to one instance of a scene.
  59465. */
  59466. register(): void;
  59467. /**
  59468. * Rebuilds the elements related to this component in case of
  59469. * context lost for instance.
  59470. */
  59471. rebuild(): void;
  59472. /**
  59473. * Disposes the component and the associated ressources.
  59474. */
  59475. dispose(): void;
  59476. /**
  59477. * Renders the outline in the canvas.
  59478. * @param subMesh Defines the sumesh to render
  59479. * @param batch Defines the batch of meshes in case of instances
  59480. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59481. */
  59482. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59483. /**
  59484. * Returns whether or not the outline renderer is ready for a given submesh.
  59485. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59486. * @param subMesh Defines the submesh to check readyness for
  59487. * @param useInstances Defines wheter wee are trying to render instances or not
  59488. * @returns true if ready otherwise false
  59489. */
  59490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59491. private _beforeRenderingMesh;
  59492. private _afterRenderingMesh;
  59493. }
  59494. }
  59495. declare module BABYLON {
  59496. /**
  59497. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59498. * @see http://doc.babylonjs.com/babylon101/sprites
  59499. */
  59500. export class SpritePackedManager extends SpriteManager {
  59501. /** defines the packed manager's name */
  59502. name: string;
  59503. /**
  59504. * Creates a new sprite manager from a packed sprite sheet
  59505. * @param name defines the manager's name
  59506. * @param imgUrl defines the sprite sheet url
  59507. * @param capacity defines the maximum allowed number of sprites
  59508. * @param scene defines the hosting scene
  59509. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59510. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59511. * @param samplingMode defines the smapling mode to use with spritesheet
  59512. * @param fromPacked set to true; do not alter
  59513. */
  59514. constructor(
  59515. /** defines the packed manager's name */
  59516. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * Defines the list of states available for a task inside a AssetsManager
  59522. */
  59523. export enum AssetTaskState {
  59524. /**
  59525. * Initialization
  59526. */
  59527. INIT = 0,
  59528. /**
  59529. * Running
  59530. */
  59531. RUNNING = 1,
  59532. /**
  59533. * Done
  59534. */
  59535. DONE = 2,
  59536. /**
  59537. * Error
  59538. */
  59539. ERROR = 3
  59540. }
  59541. /**
  59542. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59543. */
  59544. export abstract class AbstractAssetTask {
  59545. /**
  59546. * Task name
  59547. */ name: string;
  59548. /**
  59549. * Callback called when the task is successful
  59550. */
  59551. onSuccess: (task: any) => void;
  59552. /**
  59553. * Callback called when the task is not successful
  59554. */
  59555. onError: (task: any, message?: string, exception?: any) => void;
  59556. /**
  59557. * Creates a new AssetsManager
  59558. * @param name defines the name of the task
  59559. */
  59560. constructor(
  59561. /**
  59562. * Task name
  59563. */ name: string);
  59564. private _isCompleted;
  59565. private _taskState;
  59566. private _errorObject;
  59567. /**
  59568. * Get if the task is completed
  59569. */
  59570. readonly isCompleted: boolean;
  59571. /**
  59572. * Gets the current state of the task
  59573. */
  59574. readonly taskState: AssetTaskState;
  59575. /**
  59576. * Gets the current error object (if task is in error)
  59577. */
  59578. readonly errorObject: {
  59579. message?: string;
  59580. exception?: any;
  59581. };
  59582. /**
  59583. * Internal only
  59584. * @hidden
  59585. */ private _setErrorObject(message?: string, exception?: any): void;
  59586. /**
  59587. * Execute the current task
  59588. * @param scene defines the scene where you want your assets to be loaded
  59589. * @param onSuccess is a callback called when the task is successfully executed
  59590. * @param onError is a callback called if an error occurs
  59591. */
  59592. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59593. /**
  59594. * Execute the current task
  59595. * @param scene defines the scene where you want your assets to be loaded
  59596. * @param onSuccess is a callback called when the task is successfully executed
  59597. * @param onError is a callback called if an error occurs
  59598. */
  59599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59600. /**
  59601. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59602. * This can be used with failed tasks that have the reason for failure fixed.
  59603. */
  59604. reset(): void;
  59605. private onErrorCallback;
  59606. private onDoneCallback;
  59607. }
  59608. /**
  59609. * Define the interface used by progress events raised during assets loading
  59610. */
  59611. export interface IAssetsProgressEvent {
  59612. /**
  59613. * Defines the number of remaining tasks to process
  59614. */
  59615. remainingCount: number;
  59616. /**
  59617. * Defines the total number of tasks
  59618. */
  59619. totalCount: number;
  59620. /**
  59621. * Defines the task that was just processed
  59622. */
  59623. task: AbstractAssetTask;
  59624. }
  59625. /**
  59626. * Class used to share progress information about assets loading
  59627. */
  59628. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59629. /**
  59630. * Defines the number of remaining tasks to process
  59631. */
  59632. remainingCount: number;
  59633. /**
  59634. * Defines the total number of tasks
  59635. */
  59636. totalCount: number;
  59637. /**
  59638. * Defines the task that was just processed
  59639. */
  59640. task: AbstractAssetTask;
  59641. /**
  59642. * Creates a AssetsProgressEvent
  59643. * @param remainingCount defines the number of remaining tasks to process
  59644. * @param totalCount defines the total number of tasks
  59645. * @param task defines the task that was just processed
  59646. */
  59647. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  59648. }
  59649. /**
  59650. * Define a task used by AssetsManager to load meshes
  59651. */
  59652. export class MeshAssetTask extends AbstractAssetTask {
  59653. /**
  59654. * Defines the name of the task
  59655. */
  59656. name: string;
  59657. /**
  59658. * Defines the list of mesh's names you want to load
  59659. */
  59660. meshesNames: any;
  59661. /**
  59662. * Defines the root url to use as a base to load your meshes and associated resources
  59663. */
  59664. rootUrl: string;
  59665. /**
  59666. * Defines the filename of the scene to load from
  59667. */
  59668. sceneFilename: string;
  59669. /**
  59670. * Gets the list of loaded meshes
  59671. */
  59672. loadedMeshes: Array<AbstractMesh>;
  59673. /**
  59674. * Gets the list of loaded particle systems
  59675. */
  59676. loadedParticleSystems: Array<IParticleSystem>;
  59677. /**
  59678. * Gets the list of loaded skeletons
  59679. */
  59680. loadedSkeletons: Array<Skeleton>;
  59681. /**
  59682. * Gets the list of loaded animation groups
  59683. */
  59684. loadedAnimationGroups: Array<AnimationGroup>;
  59685. /**
  59686. * Callback called when the task is successful
  59687. */
  59688. onSuccess: (task: MeshAssetTask) => void;
  59689. /**
  59690. * Callback called when the task is successful
  59691. */
  59692. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  59693. /**
  59694. * Creates a new MeshAssetTask
  59695. * @param name defines the name of the task
  59696. * @param meshesNames defines the list of mesh's names you want to load
  59697. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  59698. * @param sceneFilename defines the filename of the scene to load from
  59699. */
  59700. constructor(
  59701. /**
  59702. * Defines the name of the task
  59703. */
  59704. name: string,
  59705. /**
  59706. * Defines the list of mesh's names you want to load
  59707. */
  59708. meshesNames: any,
  59709. /**
  59710. * Defines the root url to use as a base to load your meshes and associated resources
  59711. */
  59712. rootUrl: string,
  59713. /**
  59714. * Defines the filename of the scene to load from
  59715. */
  59716. sceneFilename: string);
  59717. /**
  59718. * Execute the current task
  59719. * @param scene defines the scene where you want your assets to be loaded
  59720. * @param onSuccess is a callback called when the task is successfully executed
  59721. * @param onError is a callback called if an error occurs
  59722. */
  59723. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59724. }
  59725. /**
  59726. * Define a task used by AssetsManager to load text content
  59727. */
  59728. export class TextFileAssetTask extends AbstractAssetTask {
  59729. /**
  59730. * Defines the name of the task
  59731. */
  59732. name: string;
  59733. /**
  59734. * Defines the location of the file to load
  59735. */
  59736. url: string;
  59737. /**
  59738. * Gets the loaded text string
  59739. */
  59740. text: string;
  59741. /**
  59742. * Callback called when the task is successful
  59743. */
  59744. onSuccess: (task: TextFileAssetTask) => void;
  59745. /**
  59746. * Callback called when the task is successful
  59747. */
  59748. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  59749. /**
  59750. * Creates a new TextFileAssetTask object
  59751. * @param name defines the name of the task
  59752. * @param url defines the location of the file to load
  59753. */
  59754. constructor(
  59755. /**
  59756. * Defines the name of the task
  59757. */
  59758. name: string,
  59759. /**
  59760. * Defines the location of the file to load
  59761. */
  59762. url: string);
  59763. /**
  59764. * Execute the current task
  59765. * @param scene defines the scene where you want your assets to be loaded
  59766. * @param onSuccess is a callback called when the task is successfully executed
  59767. * @param onError is a callback called if an error occurs
  59768. */
  59769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59770. }
  59771. /**
  59772. * Define a task used by AssetsManager to load binary data
  59773. */
  59774. export class BinaryFileAssetTask extends AbstractAssetTask {
  59775. /**
  59776. * Defines the name of the task
  59777. */
  59778. name: string;
  59779. /**
  59780. * Defines the location of the file to load
  59781. */
  59782. url: string;
  59783. /**
  59784. * Gets the lodaded data (as an array buffer)
  59785. */
  59786. data: ArrayBuffer;
  59787. /**
  59788. * Callback called when the task is successful
  59789. */
  59790. onSuccess: (task: BinaryFileAssetTask) => void;
  59791. /**
  59792. * Callback called when the task is successful
  59793. */
  59794. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  59795. /**
  59796. * Creates a new BinaryFileAssetTask object
  59797. * @param name defines the name of the new task
  59798. * @param url defines the location of the file to load
  59799. */
  59800. constructor(
  59801. /**
  59802. * Defines the name of the task
  59803. */
  59804. name: string,
  59805. /**
  59806. * Defines the location of the file to load
  59807. */
  59808. url: string);
  59809. /**
  59810. * Execute the current task
  59811. * @param scene defines the scene where you want your assets to be loaded
  59812. * @param onSuccess is a callback called when the task is successfully executed
  59813. * @param onError is a callback called if an error occurs
  59814. */
  59815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59816. }
  59817. /**
  59818. * Define a task used by AssetsManager to load images
  59819. */
  59820. export class ImageAssetTask extends AbstractAssetTask {
  59821. /**
  59822. * Defines the name of the task
  59823. */
  59824. name: string;
  59825. /**
  59826. * Defines the location of the image to load
  59827. */
  59828. url: string;
  59829. /**
  59830. * Gets the loaded images
  59831. */
  59832. image: HTMLImageElement;
  59833. /**
  59834. * Callback called when the task is successful
  59835. */
  59836. onSuccess: (task: ImageAssetTask) => void;
  59837. /**
  59838. * Callback called when the task is successful
  59839. */
  59840. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59841. /**
  59842. * Creates a new ImageAssetTask
  59843. * @param name defines the name of the task
  59844. * @param url defines the location of the image to load
  59845. */
  59846. constructor(
  59847. /**
  59848. * Defines the name of the task
  59849. */
  59850. name: string,
  59851. /**
  59852. * Defines the location of the image to load
  59853. */
  59854. url: string);
  59855. /**
  59856. * Execute the current task
  59857. * @param scene defines the scene where you want your assets to be loaded
  59858. * @param onSuccess is a callback called when the task is successfully executed
  59859. * @param onError is a callback called if an error occurs
  59860. */
  59861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59862. }
  59863. /**
  59864. * Defines the interface used by texture loading tasks
  59865. */
  59866. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59867. /**
  59868. * Gets the loaded texture
  59869. */
  59870. texture: TEX;
  59871. }
  59872. /**
  59873. * Define a task used by AssetsManager to load 2D textures
  59874. */
  59875. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59876. /**
  59877. * Defines the name of the task
  59878. */
  59879. name: string;
  59880. /**
  59881. * Defines the location of the file to load
  59882. */
  59883. url: string;
  59884. /**
  59885. * Defines if mipmap should not be generated (default is false)
  59886. */
  59887. noMipmap?: boolean | undefined;
  59888. /**
  59889. * Defines if texture must be inverted on Y axis (default is false)
  59890. */
  59891. invertY?: boolean | undefined;
  59892. /**
  59893. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59894. */
  59895. samplingMode: number;
  59896. /**
  59897. * Gets the loaded texture
  59898. */
  59899. texture: Texture;
  59900. /**
  59901. * Callback called when the task is successful
  59902. */
  59903. onSuccess: (task: TextureAssetTask) => void;
  59904. /**
  59905. * Callback called when the task is successful
  59906. */
  59907. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59908. /**
  59909. * Creates a new TextureAssetTask object
  59910. * @param name defines the name of the task
  59911. * @param url defines the location of the file to load
  59912. * @param noMipmap defines if mipmap should not be generated (default is false)
  59913. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59914. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59915. */
  59916. constructor(
  59917. /**
  59918. * Defines the name of the task
  59919. */
  59920. name: string,
  59921. /**
  59922. * Defines the location of the file to load
  59923. */
  59924. url: string,
  59925. /**
  59926. * Defines if mipmap should not be generated (default is false)
  59927. */
  59928. noMipmap?: boolean | undefined,
  59929. /**
  59930. * Defines if texture must be inverted on Y axis (default is false)
  59931. */
  59932. invertY?: boolean | undefined,
  59933. /**
  59934. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59935. */
  59936. samplingMode?: number);
  59937. /**
  59938. * Execute the current task
  59939. * @param scene defines the scene where you want your assets to be loaded
  59940. * @param onSuccess is a callback called when the task is successfully executed
  59941. * @param onError is a callback called if an error occurs
  59942. */
  59943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59944. }
  59945. /**
  59946. * Define a task used by AssetsManager to load cube textures
  59947. */
  59948. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59949. /**
  59950. * Defines the name of the task
  59951. */
  59952. name: string;
  59953. /**
  59954. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59955. */
  59956. url: string;
  59957. /**
  59958. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59959. */
  59960. extensions?: string[] | undefined;
  59961. /**
  59962. * Defines if mipmaps should not be generated (default is false)
  59963. */
  59964. noMipmap?: boolean | undefined;
  59965. /**
  59966. * Defines the explicit list of files (undefined by default)
  59967. */
  59968. files?: string[] | undefined;
  59969. /**
  59970. * Gets the loaded texture
  59971. */
  59972. texture: CubeTexture;
  59973. /**
  59974. * Callback called when the task is successful
  59975. */
  59976. onSuccess: (task: CubeTextureAssetTask) => void;
  59977. /**
  59978. * Callback called when the task is successful
  59979. */
  59980. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59981. /**
  59982. * Creates a new CubeTextureAssetTask
  59983. * @param name defines the name of the task
  59984. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59985. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59986. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59987. * @param files defines the explicit list of files (undefined by default)
  59988. */
  59989. constructor(
  59990. /**
  59991. * Defines the name of the task
  59992. */
  59993. name: string,
  59994. /**
  59995. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59996. */
  59997. url: string,
  59998. /**
  59999. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60000. */
  60001. extensions?: string[] | undefined,
  60002. /**
  60003. * Defines if mipmaps should not be generated (default is false)
  60004. */
  60005. noMipmap?: boolean | undefined,
  60006. /**
  60007. * Defines the explicit list of files (undefined by default)
  60008. */
  60009. files?: string[] | undefined);
  60010. /**
  60011. * Execute the current task
  60012. * @param scene defines the scene where you want your assets to be loaded
  60013. * @param onSuccess is a callback called when the task is successfully executed
  60014. * @param onError is a callback called if an error occurs
  60015. */
  60016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60017. }
  60018. /**
  60019. * Define a task used by AssetsManager to load HDR cube textures
  60020. */
  60021. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60022. /**
  60023. * Defines the name of the task
  60024. */
  60025. name: string;
  60026. /**
  60027. * Defines the location of the file to load
  60028. */
  60029. url: string;
  60030. /**
  60031. * Defines the desired size (the more it increases the longer the generation will be)
  60032. */
  60033. size: number;
  60034. /**
  60035. * Defines if mipmaps should not be generated (default is false)
  60036. */
  60037. noMipmap: boolean;
  60038. /**
  60039. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60040. */
  60041. generateHarmonics: boolean;
  60042. /**
  60043. * 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)
  60044. */
  60045. gammaSpace: boolean;
  60046. /**
  60047. * Internal Use Only
  60048. */
  60049. reserved: boolean;
  60050. /**
  60051. * Gets the loaded texture
  60052. */
  60053. texture: HDRCubeTexture;
  60054. /**
  60055. * Callback called when the task is successful
  60056. */
  60057. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60058. /**
  60059. * Callback called when the task is successful
  60060. */
  60061. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60062. /**
  60063. * Creates a new HDRCubeTextureAssetTask object
  60064. * @param name defines the name of the task
  60065. * @param url defines the location of the file to load
  60066. * @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.
  60067. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60068. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60069. * @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)
  60070. * @param reserved Internal use only
  60071. */
  60072. constructor(
  60073. /**
  60074. * Defines the name of the task
  60075. */
  60076. name: string,
  60077. /**
  60078. * Defines the location of the file to load
  60079. */
  60080. url: string,
  60081. /**
  60082. * Defines the desired size (the more it increases the longer the generation will be)
  60083. */
  60084. size: number,
  60085. /**
  60086. * Defines if mipmaps should not be generated (default is false)
  60087. */
  60088. noMipmap?: boolean,
  60089. /**
  60090. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60091. */
  60092. generateHarmonics?: boolean,
  60093. /**
  60094. * 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)
  60095. */
  60096. gammaSpace?: boolean,
  60097. /**
  60098. * Internal Use Only
  60099. */
  60100. reserved?: boolean);
  60101. /**
  60102. * Execute the current task
  60103. * @param scene defines the scene where you want your assets to be loaded
  60104. * @param onSuccess is a callback called when the task is successfully executed
  60105. * @param onError is a callback called if an error occurs
  60106. */
  60107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60108. }
  60109. /**
  60110. * Define a task used by AssetsManager to load Equirectangular cube textures
  60111. */
  60112. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60113. /**
  60114. * Defines the name of the task
  60115. */
  60116. name: string;
  60117. /**
  60118. * Defines the location of the file to load
  60119. */
  60120. url: string;
  60121. /**
  60122. * Defines the desired size (the more it increases the longer the generation will be)
  60123. */
  60124. size: number;
  60125. /**
  60126. * Defines if mipmaps should not be generated (default is false)
  60127. */
  60128. noMipmap: boolean;
  60129. /**
  60130. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60131. * but the standard material would require them in Gamma space) (default is true)
  60132. */
  60133. gammaSpace: boolean;
  60134. /**
  60135. * Gets the loaded texture
  60136. */
  60137. texture: EquiRectangularCubeTexture;
  60138. /**
  60139. * Callback called when the task is successful
  60140. */
  60141. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60142. /**
  60143. * Callback called when the task is successful
  60144. */
  60145. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60146. /**
  60147. * Creates a new EquiRectangularCubeTextureAssetTask object
  60148. * @param name defines the name of the task
  60149. * @param url defines the location of the file to load
  60150. * @param size defines the desired size (the more it increases the longer the generation will be)
  60151. * If the size is omitted this implies you are using a preprocessed cubemap.
  60152. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60153. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60154. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60155. * (default is true)
  60156. */
  60157. constructor(
  60158. /**
  60159. * Defines the name of the task
  60160. */
  60161. name: string,
  60162. /**
  60163. * Defines the location of the file to load
  60164. */
  60165. url: string,
  60166. /**
  60167. * Defines the desired size (the more it increases the longer the generation will be)
  60168. */
  60169. size: number,
  60170. /**
  60171. * Defines if mipmaps should not be generated (default is false)
  60172. */
  60173. noMipmap?: boolean,
  60174. /**
  60175. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60176. * but the standard material would require them in Gamma space) (default is true)
  60177. */
  60178. gammaSpace?: boolean);
  60179. /**
  60180. * Execute the current task
  60181. * @param scene defines the scene where you want your assets to be loaded
  60182. * @param onSuccess is a callback called when the task is successfully executed
  60183. * @param onError is a callback called if an error occurs
  60184. */
  60185. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60186. }
  60187. /**
  60188. * This class can be used to easily import assets into a scene
  60189. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60190. */
  60191. export class AssetsManager {
  60192. private _scene;
  60193. private _isLoading;
  60194. protected _tasks: AbstractAssetTask[];
  60195. protected _waitingTasksCount: number;
  60196. protected _totalTasksCount: number;
  60197. /**
  60198. * Callback called when all tasks are processed
  60199. */
  60200. onFinish: (tasks: AbstractAssetTask[]) => void;
  60201. /**
  60202. * Callback called when a task is successful
  60203. */
  60204. onTaskSuccess: (task: AbstractAssetTask) => void;
  60205. /**
  60206. * Callback called when a task had an error
  60207. */
  60208. onTaskError: (task: AbstractAssetTask) => void;
  60209. /**
  60210. * Callback called when a task is done (whatever the result is)
  60211. */
  60212. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60213. /**
  60214. * Observable called when all tasks are processed
  60215. */
  60216. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60217. /**
  60218. * Observable called when a task had an error
  60219. */
  60220. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60221. /**
  60222. * Observable called when all tasks were executed
  60223. */
  60224. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60225. /**
  60226. * Observable called when a task is done (whatever the result is)
  60227. */
  60228. onProgressObservable: Observable<IAssetsProgressEvent>;
  60229. /**
  60230. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60232. */
  60233. useDefaultLoadingScreen: boolean;
  60234. /**
  60235. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60236. * when all assets have been downloaded.
  60237. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60238. */
  60239. autoHideLoadingUI: boolean;
  60240. /**
  60241. * Creates a new AssetsManager
  60242. * @param scene defines the scene to work on
  60243. */
  60244. constructor(scene: Scene);
  60245. /**
  60246. * Add a MeshAssetTask to the list of active tasks
  60247. * @param taskName defines the name of the new task
  60248. * @param meshesNames defines the name of meshes to load
  60249. * @param rootUrl defines the root url to use to locate files
  60250. * @param sceneFilename defines the filename of the scene file
  60251. * @returns a new MeshAssetTask object
  60252. */
  60253. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60254. /**
  60255. * Add a TextFileAssetTask to the list of active tasks
  60256. * @param taskName defines the name of the new task
  60257. * @param url defines the url of the file to load
  60258. * @returns a new TextFileAssetTask object
  60259. */
  60260. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60261. /**
  60262. * Add a BinaryFileAssetTask to the list of active tasks
  60263. * @param taskName defines the name of the new task
  60264. * @param url defines the url of the file to load
  60265. * @returns a new BinaryFileAssetTask object
  60266. */
  60267. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60268. /**
  60269. * Add a ImageAssetTask to the list of active tasks
  60270. * @param taskName defines the name of the new task
  60271. * @param url defines the url of the file to load
  60272. * @returns a new ImageAssetTask object
  60273. */
  60274. addImageTask(taskName: string, url: string): ImageAssetTask;
  60275. /**
  60276. * Add a TextureAssetTask to the list of active tasks
  60277. * @param taskName defines the name of the new task
  60278. * @param url defines the url of the file to load
  60279. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60280. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60281. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60282. * @returns a new TextureAssetTask object
  60283. */
  60284. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60285. /**
  60286. * Add a CubeTextureAssetTask to the list of active tasks
  60287. * @param taskName defines the name of the new task
  60288. * @param url defines the url of the file to load
  60289. * @param extensions defines the extension to use to load the cube map (can be null)
  60290. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60291. * @param files defines the list of files to load (can be null)
  60292. * @returns a new CubeTextureAssetTask object
  60293. */
  60294. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60295. /**
  60296. *
  60297. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60298. * @param taskName defines the name of the new task
  60299. * @param url defines the url of the file to load
  60300. * @param size defines the size you want for the cubemap (can be null)
  60301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60302. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60303. * @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)
  60304. * @param reserved Internal use only
  60305. * @returns a new HDRCubeTextureAssetTask object
  60306. */
  60307. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60308. /**
  60309. *
  60310. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60311. * @param taskName defines the name of the new task
  60312. * @param url defines the url of the file to load
  60313. * @param size defines the size you want for the cubemap (can be null)
  60314. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60315. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60316. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60317. * @returns a new EquiRectangularCubeTextureAssetTask object
  60318. */
  60319. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60320. /**
  60321. * Remove a task from the assets manager.
  60322. * @param task the task to remove
  60323. */
  60324. removeTask(task: AbstractAssetTask): void;
  60325. private _decreaseWaitingTasksCount;
  60326. private _runTask;
  60327. /**
  60328. * Reset the AssetsManager and remove all tasks
  60329. * @return the current instance of the AssetsManager
  60330. */
  60331. reset(): AssetsManager;
  60332. /**
  60333. * Start the loading process
  60334. * @return the current instance of the AssetsManager
  60335. */
  60336. load(): AssetsManager;
  60337. /**
  60338. * Start the loading process as an async operation
  60339. * @return a promise returning the list of failed tasks
  60340. */
  60341. loadAsync(): Promise<void>;
  60342. }
  60343. }
  60344. declare module BABYLON {
  60345. /**
  60346. * Wrapper class for promise with external resolve and reject.
  60347. */
  60348. export class Deferred<T> {
  60349. /**
  60350. * The promise associated with this deferred object.
  60351. */
  60352. readonly promise: Promise<T>;
  60353. private _resolve;
  60354. private _reject;
  60355. /**
  60356. * The resolve method of the promise associated with this deferred object.
  60357. */
  60358. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60359. /**
  60360. * The reject method of the promise associated with this deferred object.
  60361. */
  60362. readonly reject: (reason?: any) => void;
  60363. /**
  60364. * Constructor for this deferred object.
  60365. */
  60366. constructor();
  60367. }
  60368. }
  60369. declare module BABYLON {
  60370. /**
  60371. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60372. */
  60373. export class MeshExploder {
  60374. private _centerMesh;
  60375. private _meshes;
  60376. private _meshesOrigins;
  60377. private _toCenterVectors;
  60378. private _scaledDirection;
  60379. private _newPosition;
  60380. private _centerPosition;
  60381. /**
  60382. * Explodes meshes from a center mesh.
  60383. * @param meshes The meshes to explode.
  60384. * @param centerMesh The mesh to be center of explosion.
  60385. */
  60386. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60387. private _setCenterMesh;
  60388. /**
  60389. * Get class name
  60390. * @returns "MeshExploder"
  60391. */
  60392. getClassName(): string;
  60393. /**
  60394. * "Exploded meshes"
  60395. * @returns Array of meshes with the centerMesh at index 0.
  60396. */
  60397. getMeshes(): Array<Mesh>;
  60398. /**
  60399. * Explodes meshes giving a specific direction
  60400. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60401. */
  60402. explode(direction?: number): void;
  60403. }
  60404. }
  60405. declare module BABYLON {
  60406. /**
  60407. * Class used to help managing file picking and drag'n'drop
  60408. */
  60409. export class FilesInput {
  60410. /**
  60411. * List of files ready to be loaded
  60412. */
  60413. static readonly FilesToLoad: {
  60414. [key: string]: File;
  60415. };
  60416. /**
  60417. * Callback called when a file is processed
  60418. */
  60419. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60420. private _engine;
  60421. private _currentScene;
  60422. private _sceneLoadedCallback;
  60423. private _progressCallback;
  60424. private _additionalRenderLoopLogicCallback;
  60425. private _textureLoadingCallback;
  60426. private _startingProcessingFilesCallback;
  60427. private _onReloadCallback;
  60428. private _errorCallback;
  60429. private _elementToMonitor;
  60430. private _sceneFileToLoad;
  60431. private _filesToLoad;
  60432. /**
  60433. * Creates a new FilesInput
  60434. * @param engine defines the rendering engine
  60435. * @param scene defines the hosting scene
  60436. * @param sceneLoadedCallback callback called when scene is loaded
  60437. * @param progressCallback callback called to track progress
  60438. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60439. * @param textureLoadingCallback callback called when a texture is loading
  60440. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60441. * @param onReloadCallback callback called when a reload is requested
  60442. * @param errorCallback callback call if an error occurs
  60443. */
  60444. 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);
  60445. private _dragEnterHandler;
  60446. private _dragOverHandler;
  60447. private _dropHandler;
  60448. /**
  60449. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60450. * @param elementToMonitor defines the DOM element to track
  60451. */
  60452. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60453. /**
  60454. * Release all associated resources
  60455. */
  60456. dispose(): void;
  60457. private renderFunction;
  60458. private drag;
  60459. private drop;
  60460. private _traverseFolder;
  60461. private _processFiles;
  60462. /**
  60463. * Load files from a drop event
  60464. * @param event defines the drop event to use as source
  60465. */
  60466. loadFiles(event: any): void;
  60467. private _processReload;
  60468. /**
  60469. * Reload the current scene from the loaded files
  60470. */
  60471. reload(): void;
  60472. }
  60473. }
  60474. declare module BABYLON {
  60475. /**
  60476. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60477. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60478. */
  60479. export class SceneOptimization {
  60480. /**
  60481. * Defines the priority of this optimization (0 by default which means first in the list)
  60482. */
  60483. priority: number;
  60484. /**
  60485. * Gets a string describing the action executed by the current optimization
  60486. * @returns description string
  60487. */
  60488. getDescription(): string;
  60489. /**
  60490. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60491. * @param scene defines the current scene where to apply this optimization
  60492. * @param optimizer defines the current optimizer
  60493. * @returns true if everything that can be done was applied
  60494. */
  60495. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60496. /**
  60497. * Creates the SceneOptimization object
  60498. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60499. * @param desc defines the description associated with the optimization
  60500. */
  60501. constructor(
  60502. /**
  60503. * Defines the priority of this optimization (0 by default which means first in the list)
  60504. */
  60505. priority?: number);
  60506. }
  60507. /**
  60508. * Defines an optimization used to reduce the size of render target textures
  60509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60510. */
  60511. export class TextureOptimization extends SceneOptimization {
  60512. /**
  60513. * Defines the priority of this optimization (0 by default which means first in the list)
  60514. */
  60515. priority: number;
  60516. /**
  60517. * 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
  60518. */
  60519. maximumSize: number;
  60520. /**
  60521. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60522. */
  60523. step: number;
  60524. /**
  60525. * Gets a string describing the action executed by the current optimization
  60526. * @returns description string
  60527. */
  60528. getDescription(): string;
  60529. /**
  60530. * Creates the TextureOptimization object
  60531. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60532. * @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
  60533. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60534. */
  60535. constructor(
  60536. /**
  60537. * Defines the priority of this optimization (0 by default which means first in the list)
  60538. */
  60539. priority?: number,
  60540. /**
  60541. * 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
  60542. */
  60543. maximumSize?: number,
  60544. /**
  60545. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60546. */
  60547. step?: number);
  60548. /**
  60549. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60550. * @param scene defines the current scene where to apply this optimization
  60551. * @param optimizer defines the current optimizer
  60552. * @returns true if everything that can be done was applied
  60553. */
  60554. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60555. }
  60556. /**
  60557. * Defines an optimization used to increase or decrease the rendering resolution
  60558. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60559. */
  60560. export class HardwareScalingOptimization extends SceneOptimization {
  60561. /**
  60562. * Defines the priority of this optimization (0 by default which means first in the list)
  60563. */
  60564. priority: number;
  60565. /**
  60566. * Defines the maximum scale to use (2 by default)
  60567. */
  60568. maximumScale: number;
  60569. /**
  60570. * Defines the step to use between two passes (0.5 by default)
  60571. */
  60572. step: number;
  60573. private _currentScale;
  60574. private _directionOffset;
  60575. /**
  60576. * Gets a string describing the action executed by the current optimization
  60577. * @return description string
  60578. */
  60579. getDescription(): string;
  60580. /**
  60581. * Creates the HardwareScalingOptimization object
  60582. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60583. * @param maximumScale defines the maximum scale to use (2 by default)
  60584. * @param step defines the step to use between two passes (0.5 by default)
  60585. */
  60586. constructor(
  60587. /**
  60588. * Defines the priority of this optimization (0 by default which means first in the list)
  60589. */
  60590. priority?: number,
  60591. /**
  60592. * Defines the maximum scale to use (2 by default)
  60593. */
  60594. maximumScale?: number,
  60595. /**
  60596. * Defines the step to use between two passes (0.5 by default)
  60597. */
  60598. step?: number);
  60599. /**
  60600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60601. * @param scene defines the current scene where to apply this optimization
  60602. * @param optimizer defines the current optimizer
  60603. * @returns true if everything that can be done was applied
  60604. */
  60605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60606. }
  60607. /**
  60608. * Defines an optimization used to remove shadows
  60609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60610. */
  60611. export class ShadowsOptimization extends SceneOptimization {
  60612. /**
  60613. * Gets a string describing the action executed by the current optimization
  60614. * @return description string
  60615. */
  60616. getDescription(): string;
  60617. /**
  60618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60619. * @param scene defines the current scene where to apply this optimization
  60620. * @param optimizer defines the current optimizer
  60621. * @returns true if everything that can be done was applied
  60622. */
  60623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60624. }
  60625. /**
  60626. * Defines an optimization used to turn post-processes off
  60627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60628. */
  60629. export class PostProcessesOptimization extends SceneOptimization {
  60630. /**
  60631. * Gets a string describing the action executed by the current optimization
  60632. * @return description string
  60633. */
  60634. getDescription(): string;
  60635. /**
  60636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60637. * @param scene defines the current scene where to apply this optimization
  60638. * @param optimizer defines the current optimizer
  60639. * @returns true if everything that can be done was applied
  60640. */
  60641. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60642. }
  60643. /**
  60644. * Defines an optimization used to turn lens flares off
  60645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60646. */
  60647. export class LensFlaresOptimization extends SceneOptimization {
  60648. /**
  60649. * Gets a string describing the action executed by the current optimization
  60650. * @return description string
  60651. */
  60652. getDescription(): string;
  60653. /**
  60654. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60655. * @param scene defines the current scene where to apply this optimization
  60656. * @param optimizer defines the current optimizer
  60657. * @returns true if everything that can be done was applied
  60658. */
  60659. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60660. }
  60661. /**
  60662. * Defines an optimization based on user defined callback.
  60663. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60664. */
  60665. export class CustomOptimization extends SceneOptimization {
  60666. /**
  60667. * Callback called to apply the custom optimization.
  60668. */
  60669. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  60670. /**
  60671. * Callback called to get custom description
  60672. */
  60673. onGetDescription: () => string;
  60674. /**
  60675. * Gets a string describing the action executed by the current optimization
  60676. * @returns description string
  60677. */
  60678. getDescription(): string;
  60679. /**
  60680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60681. * @param scene defines the current scene where to apply this optimization
  60682. * @param optimizer defines the current optimizer
  60683. * @returns true if everything that can be done was applied
  60684. */
  60685. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60686. }
  60687. /**
  60688. * Defines an optimization used to turn particles off
  60689. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60690. */
  60691. export class ParticlesOptimization extends SceneOptimization {
  60692. /**
  60693. * Gets a string describing the action executed by the current optimization
  60694. * @return description string
  60695. */
  60696. getDescription(): string;
  60697. /**
  60698. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60699. * @param scene defines the current scene where to apply this optimization
  60700. * @param optimizer defines the current optimizer
  60701. * @returns true if everything that can be done was applied
  60702. */
  60703. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60704. }
  60705. /**
  60706. * Defines an optimization used to turn render targets off
  60707. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60708. */
  60709. export class RenderTargetsOptimization extends SceneOptimization {
  60710. /**
  60711. * Gets a string describing the action executed by the current optimization
  60712. * @return description string
  60713. */
  60714. getDescription(): string;
  60715. /**
  60716. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60717. * @param scene defines the current scene where to apply this optimization
  60718. * @param optimizer defines the current optimizer
  60719. * @returns true if everything that can be done was applied
  60720. */
  60721. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60722. }
  60723. /**
  60724. * Defines an optimization used to merge meshes with compatible materials
  60725. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60726. */
  60727. export class MergeMeshesOptimization extends SceneOptimization {
  60728. private static _UpdateSelectionTree;
  60729. /**
  60730. * Gets or sets a boolean which defines if optimization octree has to be updated
  60731. */
  60732. /**
  60733. * Gets or sets a boolean which defines if optimization octree has to be updated
  60734. */
  60735. static UpdateSelectionTree: boolean;
  60736. /**
  60737. * Gets a string describing the action executed by the current optimization
  60738. * @return description string
  60739. */
  60740. getDescription(): string;
  60741. private _canBeMerged;
  60742. /**
  60743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60744. * @param scene defines the current scene where to apply this optimization
  60745. * @param optimizer defines the current optimizer
  60746. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  60747. * @returns true if everything that can be done was applied
  60748. */
  60749. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  60750. }
  60751. /**
  60752. * Defines a list of options used by SceneOptimizer
  60753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60754. */
  60755. export class SceneOptimizerOptions {
  60756. /**
  60757. * Defines the target frame rate to reach (60 by default)
  60758. */
  60759. targetFrameRate: number;
  60760. /**
  60761. * Defines the interval between two checkes (2000ms by default)
  60762. */
  60763. trackerDuration: number;
  60764. /**
  60765. * Gets the list of optimizations to apply
  60766. */
  60767. optimizations: SceneOptimization[];
  60768. /**
  60769. * Creates a new list of options used by SceneOptimizer
  60770. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  60771. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  60772. */
  60773. constructor(
  60774. /**
  60775. * Defines the target frame rate to reach (60 by default)
  60776. */
  60777. targetFrameRate?: number,
  60778. /**
  60779. * Defines the interval between two checkes (2000ms by default)
  60780. */
  60781. trackerDuration?: number);
  60782. /**
  60783. * Add a new optimization
  60784. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  60785. * @returns the current SceneOptimizerOptions
  60786. */
  60787. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  60788. /**
  60789. * Add a new custom optimization
  60790. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  60791. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  60792. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60793. * @returns the current SceneOptimizerOptions
  60794. */
  60795. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  60796. /**
  60797. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  60798. * @param targetFrameRate defines the target frame rate (60 by default)
  60799. * @returns a SceneOptimizerOptions object
  60800. */
  60801. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60802. /**
  60803. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  60804. * @param targetFrameRate defines the target frame rate (60 by default)
  60805. * @returns a SceneOptimizerOptions object
  60806. */
  60807. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60808. /**
  60809. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  60810. * @param targetFrameRate defines the target frame rate (60 by default)
  60811. * @returns a SceneOptimizerOptions object
  60812. */
  60813. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  60814. }
  60815. /**
  60816. * Class used to run optimizations in order to reach a target frame rate
  60817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60818. */
  60819. export class SceneOptimizer implements IDisposable {
  60820. private _isRunning;
  60821. private _options;
  60822. private _scene;
  60823. private _currentPriorityLevel;
  60824. private _targetFrameRate;
  60825. private _trackerDuration;
  60826. private _currentFrameRate;
  60827. private _sceneDisposeObserver;
  60828. private _improvementMode;
  60829. /**
  60830. * Defines an observable called when the optimizer reaches the target frame rate
  60831. */
  60832. onSuccessObservable: Observable<SceneOptimizer>;
  60833. /**
  60834. * Defines an observable called when the optimizer enables an optimization
  60835. */
  60836. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60837. /**
  60838. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60839. */
  60840. onFailureObservable: Observable<SceneOptimizer>;
  60841. /**
  60842. * Gets a boolean indicating if the optimizer is in improvement mode
  60843. */
  60844. readonly isInImprovementMode: boolean;
  60845. /**
  60846. * Gets the current priority level (0 at start)
  60847. */
  60848. readonly currentPriorityLevel: number;
  60849. /**
  60850. * Gets the current frame rate checked by the SceneOptimizer
  60851. */
  60852. readonly currentFrameRate: number;
  60853. /**
  60854. * Gets or sets the current target frame rate (60 by default)
  60855. */
  60856. /**
  60857. * Gets or sets the current target frame rate (60 by default)
  60858. */
  60859. targetFrameRate: number;
  60860. /**
  60861. * Gets or sets the current interval between two checks (every 2000ms by default)
  60862. */
  60863. /**
  60864. * Gets or sets the current interval between two checks (every 2000ms by default)
  60865. */
  60866. trackerDuration: number;
  60867. /**
  60868. * Gets the list of active optimizations
  60869. */
  60870. readonly optimizations: SceneOptimization[];
  60871. /**
  60872. * Creates a new SceneOptimizer
  60873. * @param scene defines the scene to work on
  60874. * @param options defines the options to use with the SceneOptimizer
  60875. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60876. * @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)
  60877. */
  60878. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60879. /**
  60880. * Stops the current optimizer
  60881. */
  60882. stop(): void;
  60883. /**
  60884. * Reset the optimizer to initial step (current priority level = 0)
  60885. */
  60886. reset(): void;
  60887. /**
  60888. * Start the optimizer. By default it will try to reach a specific framerate
  60889. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60890. */
  60891. start(): void;
  60892. private _checkCurrentState;
  60893. /**
  60894. * Release all resources
  60895. */
  60896. dispose(): void;
  60897. /**
  60898. * Helper function to create a SceneOptimizer with one single line of code
  60899. * @param scene defines the scene to work on
  60900. * @param options defines the options to use with the SceneOptimizer
  60901. * @param onSuccess defines a callback to call on success
  60902. * @param onFailure defines a callback to call on failure
  60903. * @returns the new SceneOptimizer object
  60904. */
  60905. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60906. }
  60907. }
  60908. declare module BABYLON {
  60909. /**
  60910. * Class used to serialize a scene into a string
  60911. */
  60912. export class SceneSerializer {
  60913. /**
  60914. * Clear cache used by a previous serialization
  60915. */
  60916. static ClearCache(): void;
  60917. /**
  60918. * Serialize a scene into a JSON compatible object
  60919. * @param scene defines the scene to serialize
  60920. * @returns a JSON compatible object
  60921. */
  60922. static Serialize(scene: Scene): any;
  60923. /**
  60924. * Serialize a mesh into a JSON compatible object
  60925. * @param toSerialize defines the mesh to serialize
  60926. * @param withParents defines if parents must be serialized as well
  60927. * @param withChildren defines if children must be serialized as well
  60928. * @returns a JSON compatible object
  60929. */
  60930. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60931. }
  60932. }
  60933. declare module BABYLON {
  60934. /**
  60935. * Class used to host texture specific utilities
  60936. */
  60937. export class TextureTools {
  60938. /**
  60939. * Uses the GPU to create a copy texture rescaled at a given size
  60940. * @param texture Texture to copy from
  60941. * @param width defines the desired width
  60942. * @param height defines the desired height
  60943. * @param useBilinearMode defines if bilinear mode has to be used
  60944. * @return the generated texture
  60945. */
  60946. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60947. }
  60948. }
  60949. declare module BABYLON {
  60950. /**
  60951. * This represents the different options available for the video capture.
  60952. */
  60953. export interface VideoRecorderOptions {
  60954. /** Defines the mime type of the video. */
  60955. mimeType: string;
  60956. /** Defines the FPS the video should be recorded at. */
  60957. fps: number;
  60958. /** Defines the chunk size for the recording data. */
  60959. recordChunckSize: number;
  60960. /** The audio tracks to attach to the recording. */
  60961. audioTracks?: MediaStreamTrack[];
  60962. }
  60963. /**
  60964. * This can help with recording videos from BabylonJS.
  60965. * This is based on the available WebRTC functionalities of the browser.
  60966. *
  60967. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60968. */
  60969. export class VideoRecorder {
  60970. private static readonly _defaultOptions;
  60971. /**
  60972. * Returns whether or not the VideoRecorder is available in your browser.
  60973. * @param engine Defines the Babylon Engine.
  60974. * @returns true if supported otherwise false.
  60975. */
  60976. static IsSupported(engine: Engine): boolean;
  60977. private readonly _options;
  60978. private _canvas;
  60979. private _mediaRecorder;
  60980. private _recordedChunks;
  60981. private _fileName;
  60982. private _resolve;
  60983. private _reject;
  60984. /**
  60985. * True when a recording is already in progress.
  60986. */
  60987. readonly isRecording: boolean;
  60988. /**
  60989. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60990. * @param engine Defines the BabylonJS Engine you wish to record.
  60991. * @param options Defines options that can be used to customize the capture.
  60992. */
  60993. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60994. /**
  60995. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60996. */
  60997. stopRecording(): void;
  60998. /**
  60999. * Starts recording the canvas for a max duration specified in parameters.
  61000. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61001. * If null no automatic download will start and you can rely on the promise to get the data back.
  61002. * @param maxDuration Defines the maximum recording time in seconds.
  61003. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61004. * @return A promise callback at the end of the recording with the video data in Blob.
  61005. */
  61006. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61007. /**
  61008. * Releases internal resources used during the recording.
  61009. */
  61010. dispose(): void;
  61011. private _handleDataAvailable;
  61012. private _handleError;
  61013. private _handleStop;
  61014. }
  61015. }
  61016. declare module BABYLON {
  61017. /**
  61018. * Class containing a set of static utilities functions for screenshots
  61019. */
  61020. export class ScreenshotTools {
  61021. /**
  61022. * Captures a screenshot of the current rendering
  61023. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61024. * @param engine defines the rendering engine
  61025. * @param camera defines the source camera
  61026. * @param size This parameter can be set to a single number or to an object with the
  61027. * following (optional) properties: precision, width, height. If a single number is passed,
  61028. * it will be used for both width and height. If an object is passed, the screenshot size
  61029. * will be derived from the parameters. The precision property is a multiplier allowing
  61030. * rendering at a higher or lower resolution
  61031. * @param successCallback defines the callback receives a single parameter which contains the
  61032. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61033. * src parameter of an <img> to display it
  61034. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61035. * Check your browser for supported MIME types
  61036. */
  61037. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61038. /**
  61039. * Captures a screenshot of the current rendering
  61040. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61041. * @param engine defines the rendering engine
  61042. * @param camera defines the source camera
  61043. * @param size This parameter can be set to a single number or to an object with the
  61044. * following (optional) properties: precision, width, height. If a single number is passed,
  61045. * it will be used for both width and height. If an object is passed, the screenshot size
  61046. * will be derived from the parameters. The precision property is a multiplier allowing
  61047. * rendering at a higher or lower resolution
  61048. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61049. * Check your browser for supported MIME types
  61050. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61051. * to the src parameter of an <img> to display it
  61052. */
  61053. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61054. /**
  61055. * Generates an image screenshot from the specified camera.
  61056. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61057. * @param engine The engine to use for rendering
  61058. * @param camera The camera to use for rendering
  61059. * @param size This parameter can be set to a single number or to an object with the
  61060. * following (optional) properties: precision, width, height. If a single number is passed,
  61061. * it will be used for both width and height. If an object is passed, the screenshot size
  61062. * will be derived from the parameters. The precision property is a multiplier allowing
  61063. * rendering at a higher or lower resolution
  61064. * @param successCallback The callback receives a single parameter which contains the
  61065. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61066. * src parameter of an <img> to display it
  61067. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61068. * Check your browser for supported MIME types
  61069. * @param samples Texture samples (default: 1)
  61070. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61071. * @param fileName A name for for the downloaded file.
  61072. */
  61073. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61074. /**
  61075. * Generates an image screenshot from the specified camera.
  61076. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61077. * @param engine The engine to use for rendering
  61078. * @param camera The camera to use for rendering
  61079. * @param size This parameter can be set to a single number or to an object with the
  61080. * following (optional) properties: precision, width, height. If a single number is passed,
  61081. * it will be used for both width and height. If an object is passed, the screenshot size
  61082. * will be derived from the parameters. The precision property is a multiplier allowing
  61083. * rendering at a higher or lower resolution
  61084. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61085. * Check your browser for supported MIME types
  61086. * @param samples Texture samples (default: 1)
  61087. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61088. * @param fileName A name for for the downloaded file.
  61089. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61090. * to the src parameter of an <img> to display it
  61091. */
  61092. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61093. /**
  61094. * Gets height and width for screenshot size
  61095. * @private
  61096. */
  61097. private static _getScreenshotSize;
  61098. }
  61099. }
  61100. declare module BABYLON {
  61101. /**
  61102. * A cursor which tracks a point on a path
  61103. */
  61104. export class PathCursor {
  61105. private path;
  61106. /**
  61107. * Stores path cursor callbacks for when an onchange event is triggered
  61108. */
  61109. private _onchange;
  61110. /**
  61111. * The value of the path cursor
  61112. */
  61113. value: number;
  61114. /**
  61115. * The animation array of the path cursor
  61116. */
  61117. animations: Animation[];
  61118. /**
  61119. * Initializes the path cursor
  61120. * @param path The path to track
  61121. */
  61122. constructor(path: Path2);
  61123. /**
  61124. * Gets the cursor point on the path
  61125. * @returns A point on the path cursor at the cursor location
  61126. */
  61127. getPoint(): Vector3;
  61128. /**
  61129. * Moves the cursor ahead by the step amount
  61130. * @param step The amount to move the cursor forward
  61131. * @returns This path cursor
  61132. */
  61133. moveAhead(step?: number): PathCursor;
  61134. /**
  61135. * Moves the cursor behind by the step amount
  61136. * @param step The amount to move the cursor back
  61137. * @returns This path cursor
  61138. */
  61139. moveBack(step?: number): PathCursor;
  61140. /**
  61141. * Moves the cursor by the step amount
  61142. * If the step amount is greater than one, an exception is thrown
  61143. * @param step The amount to move the cursor
  61144. * @returns This path cursor
  61145. */
  61146. move(step: number): PathCursor;
  61147. /**
  61148. * Ensures that the value is limited between zero and one
  61149. * @returns This path cursor
  61150. */
  61151. private ensureLimits;
  61152. /**
  61153. * Runs onchange callbacks on change (used by the animation engine)
  61154. * @returns This path cursor
  61155. */
  61156. private raiseOnChange;
  61157. /**
  61158. * Executes a function on change
  61159. * @param f A path cursor onchange callback
  61160. * @returns This path cursor
  61161. */
  61162. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61163. }
  61164. }
  61165. declare module BABYLON {
  61166. /** @hidden */
  61167. export var blurPixelShader: {
  61168. name: string;
  61169. shader: string;
  61170. };
  61171. }
  61172. declare module BABYLON {
  61173. /** @hidden */
  61174. export var pointCloudVertexDeclaration: {
  61175. name: string;
  61176. shader: string;
  61177. };
  61178. }
  61179. // Mixins
  61180. interface Window {
  61181. mozIndexedDB: IDBFactory;
  61182. webkitIndexedDB: IDBFactory;
  61183. msIndexedDB: IDBFactory;
  61184. webkitURL: typeof URL;
  61185. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61186. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61187. WebGLRenderingContext: WebGLRenderingContext;
  61188. MSGesture: MSGesture;
  61189. CANNON: any;
  61190. AudioContext: AudioContext;
  61191. webkitAudioContext: AudioContext;
  61192. PointerEvent: any;
  61193. Math: Math;
  61194. Uint8Array: Uint8ArrayConstructor;
  61195. Float32Array: Float32ArrayConstructor;
  61196. mozURL: typeof URL;
  61197. msURL: typeof URL;
  61198. VRFrameData: any; // WebVR, from specs 1.1
  61199. DracoDecoderModule: any;
  61200. setImmediate(handler: (...args: any[]) => void): number;
  61201. }
  61202. interface HTMLCanvasElement {
  61203. requestPointerLock(): void;
  61204. msRequestPointerLock?(): void;
  61205. mozRequestPointerLock?(): void;
  61206. webkitRequestPointerLock?(): void;
  61207. /** Track wether a record is in progress */
  61208. isRecording: boolean;
  61209. /** Capture Stream method defined by some browsers */
  61210. captureStream(fps?: number): MediaStream;
  61211. }
  61212. interface CanvasRenderingContext2D {
  61213. msImageSmoothingEnabled: boolean;
  61214. }
  61215. interface MouseEvent {
  61216. mozMovementX: number;
  61217. mozMovementY: number;
  61218. webkitMovementX: number;
  61219. webkitMovementY: number;
  61220. msMovementX: number;
  61221. msMovementY: number;
  61222. }
  61223. interface Navigator {
  61224. mozGetVRDevices: (any: any) => any;
  61225. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61226. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61227. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61228. webkitGetGamepads(): Gamepad[];
  61229. msGetGamepads(): Gamepad[];
  61230. webkitGamepads(): Gamepad[];
  61231. }
  61232. interface HTMLVideoElement {
  61233. mozSrcObject: any;
  61234. }
  61235. interface Math {
  61236. fround(x: number): number;
  61237. imul(a: number, b: number): number;
  61238. }
  61239. interface WebGLRenderingContext {
  61240. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61241. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61242. vertexAttribDivisor(index: number, divisor: number): void;
  61243. createVertexArray(): any;
  61244. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61245. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61246. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61247. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61248. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61249. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61250. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61251. // Queries
  61252. createQuery(): WebGLQuery;
  61253. deleteQuery(query: WebGLQuery): void;
  61254. beginQuery(target: number, query: WebGLQuery): void;
  61255. endQuery(target: number): void;
  61256. getQueryParameter(query: WebGLQuery, pname: number): any;
  61257. getQuery(target: number, pname: number): any;
  61258. MAX_SAMPLES: number;
  61259. RGBA8: number;
  61260. READ_FRAMEBUFFER: number;
  61261. DRAW_FRAMEBUFFER: number;
  61262. UNIFORM_BUFFER: number;
  61263. HALF_FLOAT_OES: number;
  61264. RGBA16F: number;
  61265. RGBA32F: number;
  61266. R32F: number;
  61267. RG32F: number;
  61268. RGB32F: number;
  61269. R16F: number;
  61270. RG16F: number;
  61271. RGB16F: number;
  61272. RED: number;
  61273. RG: number;
  61274. R8: number;
  61275. RG8: number;
  61276. UNSIGNED_INT_24_8: number;
  61277. DEPTH24_STENCIL8: number;
  61278. /* Multiple Render Targets */
  61279. drawBuffers(buffers: number[]): void;
  61280. readBuffer(src: number): void;
  61281. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61282. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61283. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61284. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61285. // Occlusion Query
  61286. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61287. ANY_SAMPLES_PASSED: number;
  61288. QUERY_RESULT_AVAILABLE: number;
  61289. QUERY_RESULT: number;
  61290. }
  61291. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61292. }
  61293. interface EXT_disjoint_timer_query {
  61294. QUERY_COUNTER_BITS_EXT: number;
  61295. TIME_ELAPSED_EXT: number;
  61296. TIMESTAMP_EXT: number;
  61297. GPU_DISJOINT_EXT: number;
  61298. QUERY_RESULT_EXT: number;
  61299. QUERY_RESULT_AVAILABLE_EXT: number;
  61300. queryCounterEXT(query: WebGLQuery, target: number): void;
  61301. createQueryEXT(): WebGLQuery;
  61302. beginQueryEXT(target: number, query: WebGLQuery): void;
  61303. endQueryEXT(target: number): void;
  61304. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61305. deleteQueryEXT(query: WebGLQuery): void;
  61306. }
  61307. interface WebGLUniformLocation { private _currentState: any;
  61308. }
  61309. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61310. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61311. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61312. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61313. interface WebGLRenderingContext {
  61314. readonly RASTERIZER_DISCARD: number;
  61315. readonly DEPTH_COMPONENT24: number;
  61316. readonly TEXTURE_3D: number;
  61317. readonly TEXTURE_2D_ARRAY: number;
  61318. readonly TEXTURE_COMPARE_FUNC: number;
  61319. readonly TEXTURE_COMPARE_MODE: number;
  61320. readonly COMPARE_REF_TO_TEXTURE: number;
  61321. readonly TEXTURE_WRAP_R: number;
  61322. readonly HALF_FLOAT: number;
  61323. readonly RGB8: number;
  61324. readonly RED_INTEGER: number;
  61325. readonly RG_INTEGER: number;
  61326. readonly RGB_INTEGER: number;
  61327. readonly RGBA_INTEGER: number;
  61328. readonly R8_SNORM: number;
  61329. readonly RG8_SNORM: number;
  61330. readonly RGB8_SNORM: number;
  61331. readonly RGBA8_SNORM: number;
  61332. readonly R8I: number;
  61333. readonly RG8I: number;
  61334. readonly RGB8I: number;
  61335. readonly RGBA8I: number;
  61336. readonly R8UI: number;
  61337. readonly RG8UI: number;
  61338. readonly RGB8UI: number;
  61339. readonly RGBA8UI: number;
  61340. readonly R16I: number;
  61341. readonly RG16I: number;
  61342. readonly RGB16I: number;
  61343. readonly RGBA16I: number;
  61344. readonly R16UI: number;
  61345. readonly RG16UI: number;
  61346. readonly RGB16UI: number;
  61347. readonly RGBA16UI: number;
  61348. readonly R32I: number;
  61349. readonly RG32I: number;
  61350. readonly RGB32I: number;
  61351. readonly RGBA32I: number;
  61352. readonly R32UI: number;
  61353. readonly RG32UI: number;
  61354. readonly RGB32UI: number;
  61355. readonly RGBA32UI: number;
  61356. readonly RGB10_A2UI: number;
  61357. readonly R11F_G11F_B10F: number;
  61358. readonly RGB9_E5: number;
  61359. readonly RGB10_A2: number;
  61360. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61361. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61362. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61363. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61364. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61365. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61366. 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;
  61367. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61368. readonly TRANSFORM_FEEDBACK: number;
  61369. readonly INTERLEAVED_ATTRIBS: number;
  61370. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61371. createTransformFeedback(): WebGLTransformFeedback;
  61372. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61373. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61374. beginTransformFeedback(primitiveMode: number): void;
  61375. endTransformFeedback(): void;
  61376. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61377. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61378. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61379. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61380. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61381. }
  61382. interface ImageBitmap {
  61383. readonly width: number;
  61384. readonly height: number;
  61385. close(): void;
  61386. }
  61387. interface WebGLQuery extends WebGLObject {
  61388. }
  61389. declare var WebGLQuery: {
  61390. prototype: WebGLQuery;
  61391. new(): WebGLQuery;
  61392. };
  61393. interface WebGLSampler extends WebGLObject {
  61394. }
  61395. declare var WebGLSampler: {
  61396. prototype: WebGLSampler;
  61397. new(): WebGLSampler;
  61398. };
  61399. interface WebGLSync extends WebGLObject {
  61400. }
  61401. declare var WebGLSync: {
  61402. prototype: WebGLSync;
  61403. new(): WebGLSync;
  61404. };
  61405. interface WebGLTransformFeedback extends WebGLObject {
  61406. }
  61407. declare var WebGLTransformFeedback: {
  61408. prototype: WebGLTransformFeedback;
  61409. new(): WebGLTransformFeedback;
  61410. };
  61411. interface WebGLVertexArrayObject extends WebGLObject {
  61412. }
  61413. declare var WebGLVertexArrayObject: {
  61414. prototype: WebGLVertexArrayObject;
  61415. new(): WebGLVertexArrayObject;
  61416. };
  61417. // Type definitions for WebVR API
  61418. // Project: https://w3c.github.io/webvr/
  61419. // Definitions by: six a <https://github.com/lostfictions>
  61420. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61421. interface VRDisplay extends EventTarget {
  61422. /**
  61423. * Dictionary of capabilities describing the VRDisplay.
  61424. */
  61425. readonly capabilities: VRDisplayCapabilities;
  61426. /**
  61427. * z-depth defining the far plane of the eye view frustum
  61428. * enables mapping of values in the render target depth
  61429. * attachment to scene coordinates. Initially set to 10000.0.
  61430. */
  61431. depthFar: number;
  61432. /**
  61433. * z-depth defining the near plane of the eye view frustum
  61434. * enables mapping of values in the render target depth
  61435. * attachment to scene coordinates. Initially set to 0.01.
  61436. */
  61437. depthNear: number;
  61438. /**
  61439. * An identifier for this distinct VRDisplay. Used as an
  61440. * association point in the Gamepad API.
  61441. */
  61442. readonly displayId: number;
  61443. /**
  61444. * A display name, a user-readable name identifying it.
  61445. */
  61446. readonly displayName: string;
  61447. readonly isConnected: boolean;
  61448. readonly isPresenting: boolean;
  61449. /**
  61450. * If this VRDisplay supports room-scale experiences, the optional
  61451. * stage attribute contains details on the room-scale parameters.
  61452. */
  61453. readonly stageParameters: VRStageParameters | null;
  61454. /**
  61455. * Passing the value returned by `requestAnimationFrame` to
  61456. * `cancelAnimationFrame` will unregister the callback.
  61457. * @param handle Define the hanle of the request to cancel
  61458. */
  61459. cancelAnimationFrame(handle: number): void;
  61460. /**
  61461. * Stops presenting to the VRDisplay.
  61462. * @returns a promise to know when it stopped
  61463. */
  61464. exitPresent(): Promise<void>;
  61465. /**
  61466. * Return the current VREyeParameters for the given eye.
  61467. * @param whichEye Define the eye we want the parameter for
  61468. * @returns the eye parameters
  61469. */
  61470. getEyeParameters(whichEye: string): VREyeParameters;
  61471. /**
  61472. * Populates the passed VRFrameData with the information required to render
  61473. * the current frame.
  61474. * @param frameData Define the data structure to populate
  61475. * @returns true if ok otherwise false
  61476. */
  61477. getFrameData(frameData: VRFrameData): boolean;
  61478. /**
  61479. * Get the layers currently being presented.
  61480. * @returns the list of VR layers
  61481. */
  61482. getLayers(): VRLayer[];
  61483. /**
  61484. * Return a VRPose containing the future predicted pose of the VRDisplay
  61485. * when the current frame will be presented. The value returned will not
  61486. * change until JavaScript has returned control to the browser.
  61487. *
  61488. * The VRPose will contain the position, orientation, velocity,
  61489. * and acceleration of each of these properties.
  61490. * @returns the pose object
  61491. */
  61492. getPose(): VRPose;
  61493. /**
  61494. * Return the current instantaneous pose of the VRDisplay, with no
  61495. * prediction applied.
  61496. * @returns the current instantaneous pose
  61497. */
  61498. getImmediatePose(): VRPose;
  61499. /**
  61500. * The callback passed to `requestAnimationFrame` will be called
  61501. * any time a new frame should be rendered. When the VRDisplay is
  61502. * presenting the callback will be called at the native refresh
  61503. * rate of the HMD. When not presenting this function acts
  61504. * identically to how window.requestAnimationFrame acts. Content should
  61505. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61506. * asynchronously from other displays and at differing refresh rates.
  61507. * @param callback Define the eaction to run next frame
  61508. * @returns the request handle it
  61509. */
  61510. requestAnimationFrame(callback: FrameRequestCallback): number;
  61511. /**
  61512. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61513. * Repeat calls while already presenting will update the VRLayers being displayed.
  61514. * @param layers Define the list of layer to present
  61515. * @returns a promise to know when the request has been fulfilled
  61516. */
  61517. requestPresent(layers: VRLayer[]): Promise<void>;
  61518. /**
  61519. * Reset the pose for this display, treating its current position and
  61520. * orientation as the "origin/zero" values. VRPose.position,
  61521. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61522. * updated when calling resetPose(). This should be called in only
  61523. * sitting-space experiences.
  61524. */
  61525. resetPose(): void;
  61526. /**
  61527. * The VRLayer provided to the VRDisplay will be captured and presented
  61528. * in the HMD. Calling this function has the same effect on the source
  61529. * canvas as any other operation that uses its source image, and canvases
  61530. * created without preserveDrawingBuffer set to true will be cleared.
  61531. * @param pose Define the pose to submit
  61532. */
  61533. submitFrame(pose?: VRPose): void;
  61534. }
  61535. declare var VRDisplay: {
  61536. prototype: VRDisplay;
  61537. new(): VRDisplay;
  61538. };
  61539. interface VRLayer {
  61540. leftBounds?: number[] | Float32Array | null;
  61541. rightBounds?: number[] | Float32Array | null;
  61542. source?: HTMLCanvasElement | null;
  61543. }
  61544. interface VRDisplayCapabilities {
  61545. readonly canPresent: boolean;
  61546. readonly hasExternalDisplay: boolean;
  61547. readonly hasOrientation: boolean;
  61548. readonly hasPosition: boolean;
  61549. readonly maxLayers: number;
  61550. }
  61551. interface VREyeParameters {
  61552. /** @deprecated */
  61553. readonly fieldOfView: VRFieldOfView;
  61554. readonly offset: Float32Array;
  61555. readonly renderHeight: number;
  61556. readonly renderWidth: number;
  61557. }
  61558. interface VRFieldOfView {
  61559. readonly downDegrees: number;
  61560. readonly leftDegrees: number;
  61561. readonly rightDegrees: number;
  61562. readonly upDegrees: number;
  61563. }
  61564. interface VRFrameData {
  61565. readonly leftProjectionMatrix: Float32Array;
  61566. readonly leftViewMatrix: Float32Array;
  61567. readonly pose: VRPose;
  61568. readonly rightProjectionMatrix: Float32Array;
  61569. readonly rightViewMatrix: Float32Array;
  61570. readonly timestamp: number;
  61571. }
  61572. interface VRPose {
  61573. readonly angularAcceleration: Float32Array | null;
  61574. readonly angularVelocity: Float32Array | null;
  61575. readonly linearAcceleration: Float32Array | null;
  61576. readonly linearVelocity: Float32Array | null;
  61577. readonly orientation: Float32Array | null;
  61578. readonly position: Float32Array | null;
  61579. readonly timestamp: number;
  61580. }
  61581. interface VRStageParameters {
  61582. sittingToStandingTransform?: Float32Array;
  61583. sizeX?: number;
  61584. sizeY?: number;
  61585. }
  61586. interface Navigator {
  61587. getVRDisplays(): Promise<VRDisplay[]>;
  61588. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61589. }
  61590. interface Window {
  61591. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61592. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61593. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61594. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61595. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61596. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61597. }
  61598. interface Gamepad {
  61599. readonly displayId: number;
  61600. }
  61601. type XRSessionMode =
  61602. | "inline"
  61603. | "immersive-vr"
  61604. | "immersive-ar";
  61605. type XRReferenceSpaceType =
  61606. | "viewer"
  61607. | "local"
  61608. | "local-floor"
  61609. | "bounded-floor"
  61610. | "unbounded";
  61611. type XREnvironmentBlendMode =
  61612. | "opaque"
  61613. | "additive"
  61614. | "alpha-blend";
  61615. type XRVisibilityState =
  61616. | "visible"
  61617. | "visible-blurred"
  61618. | "hidden";
  61619. type XRHandedness =
  61620. | "none"
  61621. | "left"
  61622. | "right";
  61623. type XRTargetRayMode =
  61624. | "gaze"
  61625. | "tracked-pointer"
  61626. | "screen";
  61627. type XREye =
  61628. | "none"
  61629. | "left"
  61630. | "right";
  61631. interface XRSpace extends EventTarget {
  61632. }
  61633. interface XRRenderState {
  61634. depthNear?: number;
  61635. depthFar?: number;
  61636. inlineVerticalFieldOfView?: number;
  61637. baseLayer?: XRWebGLLayer;
  61638. }
  61639. interface XRInputSource {
  61640. handedness: XRHandedness;
  61641. targetRayMode: XRTargetRayMode;
  61642. targetRaySpace: XRSpace;
  61643. gripSpace: XRSpace | undefined;
  61644. gamepad: Gamepad | undefined;
  61645. profiles: Array<string>;
  61646. }
  61647. interface XRSession {
  61648. addEventListener: Function;
  61649. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  61650. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  61651. requestAnimationFrame: Function;
  61652. end(): Promise<void>;
  61653. renderState: XRRenderState;
  61654. inputSources: Array<XRInputSource>;
  61655. }
  61656. interface XRReferenceSpace extends XRSpace {
  61657. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  61658. onreset: any;
  61659. }
  61660. interface XRFrame {
  61661. session: XRSession;
  61662. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  61663. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  61664. }
  61665. interface XRViewerPose extends XRPose {
  61666. views: Array<XRView>;
  61667. }
  61668. interface XRPose {
  61669. transform: XRRigidTransform;
  61670. emulatedPosition: boolean;
  61671. }
  61672. declare var XRWebGLLayer: {
  61673. prototype: XRWebGLLayer;
  61674. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  61675. };
  61676. interface XRWebGLLayer {
  61677. framebuffer: WebGLFramebuffer;
  61678. framebufferWidth: number;
  61679. framebufferHeight: number;
  61680. getViewport: Function;
  61681. }
  61682. interface XRRigidTransform {
  61683. position: DOMPointReadOnly;
  61684. orientation: DOMPointReadOnly;
  61685. matrix: Float32Array;
  61686. inverse: XRRigidTransform;
  61687. }
  61688. interface XRView {
  61689. eye: XREye;
  61690. projectionMatrix: Float32Array;
  61691. transform: XRRigidTransform;
  61692. }
  61693. interface XRInputSourceChangeEvent {
  61694. session: XRSession;
  61695. removed: Array<XRInputSource>;
  61696. added: Array<XRInputSource>;
  61697. }
  61698. declare module BABYLON.GUI {
  61699. /**
  61700. * Class used to specific a value and its associated unit
  61701. */
  61702. export class ValueAndUnit {
  61703. /** defines the unit to store */
  61704. unit: number;
  61705. /** defines a boolean indicating if the value can be negative */
  61706. negativeValueAllowed: boolean;
  61707. private _value;
  61708. private _originalUnit;
  61709. /**
  61710. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  61711. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61712. */
  61713. ignoreAdaptiveScaling: boolean;
  61714. /**
  61715. * Creates a new ValueAndUnit
  61716. * @param value defines the value to store
  61717. * @param unit defines the unit to store
  61718. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  61719. */
  61720. constructor(value: number,
  61721. /** defines the unit to store */
  61722. unit?: number,
  61723. /** defines a boolean indicating if the value can be negative */
  61724. negativeValueAllowed?: boolean);
  61725. /** Gets a boolean indicating if the value is a percentage */
  61726. readonly isPercentage: boolean;
  61727. /** Gets a boolean indicating if the value is store as pixel */
  61728. readonly isPixel: boolean;
  61729. /** Gets direct internal value */
  61730. readonly internalValue: number;
  61731. /**
  61732. * Gets value as pixel
  61733. * @param host defines the root host
  61734. * @param refValue defines the reference value for percentages
  61735. * @returns the value as pixel
  61736. */
  61737. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  61738. /**
  61739. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  61740. * @param value defines the value to store
  61741. * @param unit defines the unit to store
  61742. * @returns the current ValueAndUnit
  61743. */
  61744. updateInPlace(value: number, unit?: number): ValueAndUnit;
  61745. /**
  61746. * Gets the value accordingly to its unit
  61747. * @param host defines the root host
  61748. * @returns the value
  61749. */
  61750. getValue(host: AdvancedDynamicTexture): number;
  61751. /**
  61752. * Gets a string representation of the value
  61753. * @param host defines the root host
  61754. * @param decimals defines an optional number of decimals to display
  61755. * @returns a string
  61756. */
  61757. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  61758. /**
  61759. * Store a value parsed from a string
  61760. * @param source defines the source string
  61761. * @returns true if the value was successfully parsed
  61762. */
  61763. fromString(source: string | number): boolean;
  61764. private static _Regex;
  61765. private static _UNITMODE_PERCENTAGE;
  61766. private static _UNITMODE_PIXEL;
  61767. /** UNITMODE_PERCENTAGE */
  61768. static readonly UNITMODE_PERCENTAGE: number;
  61769. /** UNITMODE_PIXEL */
  61770. static readonly UNITMODE_PIXEL: number;
  61771. }
  61772. }
  61773. declare module BABYLON.GUI {
  61774. /**
  61775. * Define a style used by control to automatically setup properties based on a template.
  61776. * Only support font related properties so far
  61777. */
  61778. export class Style implements BABYLON.IDisposable {
  61779. private _fontFamily;
  61780. private _fontStyle;
  61781. private _fontWeight;
  61782. /** @hidden */ private _host: AdvancedDynamicTexture;
  61783. /** @hidden */ private _fontSize: ValueAndUnit;
  61784. /**
  61785. * BABYLON.Observable raised when the style values are changed
  61786. */
  61787. onChangedObservable: BABYLON.Observable<Style>;
  61788. /**
  61789. * Creates a new style object
  61790. * @param host defines the AdvancedDynamicTexture which hosts this style
  61791. */
  61792. constructor(host: AdvancedDynamicTexture);
  61793. /**
  61794. * Gets or sets the font size
  61795. */
  61796. fontSize: string | number;
  61797. /**
  61798. * Gets or sets the font family
  61799. */
  61800. fontFamily: string;
  61801. /**
  61802. * Gets or sets the font style
  61803. */
  61804. fontStyle: string;
  61805. /** Gets or sets font weight */
  61806. fontWeight: string;
  61807. /** Dispose all associated resources */
  61808. dispose(): void;
  61809. }
  61810. }
  61811. declare module BABYLON.GUI {
  61812. /**
  61813. * Class used to transport BABYLON.Vector2 information for pointer events
  61814. */
  61815. export class Vector2WithInfo extends BABYLON.Vector2 {
  61816. /** defines the current mouse button index */
  61817. buttonIndex: number;
  61818. /**
  61819. * Creates a new Vector2WithInfo
  61820. * @param source defines the vector2 data to transport
  61821. * @param buttonIndex defines the current mouse button index
  61822. */
  61823. constructor(source: BABYLON.Vector2,
  61824. /** defines the current mouse button index */
  61825. buttonIndex?: number);
  61826. }
  61827. /** Class used to provide 2D matrix features */
  61828. export class Matrix2D {
  61829. /** Gets the internal array of 6 floats used to store matrix data */
  61830. m: Float32Array;
  61831. /**
  61832. * Creates a new matrix
  61833. * @param m00 defines value for (0, 0)
  61834. * @param m01 defines value for (0, 1)
  61835. * @param m10 defines value for (1, 0)
  61836. * @param m11 defines value for (1, 1)
  61837. * @param m20 defines value for (2, 0)
  61838. * @param m21 defines value for (2, 1)
  61839. */
  61840. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61841. /**
  61842. * Fills the matrix from direct values
  61843. * @param m00 defines value for (0, 0)
  61844. * @param m01 defines value for (0, 1)
  61845. * @param m10 defines value for (1, 0)
  61846. * @param m11 defines value for (1, 1)
  61847. * @param m20 defines value for (2, 0)
  61848. * @param m21 defines value for (2, 1)
  61849. * @returns the current modified matrix
  61850. */
  61851. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61852. /**
  61853. * Gets matrix determinant
  61854. * @returns the determinant
  61855. */
  61856. determinant(): number;
  61857. /**
  61858. * Inverses the matrix and stores it in a target matrix
  61859. * @param result defines the target matrix
  61860. * @returns the current matrix
  61861. */
  61862. invertToRef(result: Matrix2D): Matrix2D;
  61863. /**
  61864. * Multiplies the current matrix with another one
  61865. * @param other defines the second operand
  61866. * @param result defines the target matrix
  61867. * @returns the current matrix
  61868. */
  61869. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61870. /**
  61871. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61872. * @param x defines the x coordinate to transform
  61873. * @param y defines the x coordinate to transform
  61874. * @param result defines the target vector2
  61875. * @returns the current matrix
  61876. */
  61877. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61878. /**
  61879. * Creates an identity matrix
  61880. * @returns a new matrix
  61881. */
  61882. static Identity(): Matrix2D;
  61883. /**
  61884. * Creates a translation matrix and stores it in a target matrix
  61885. * @param x defines the x coordinate of the translation
  61886. * @param y defines the y coordinate of the translation
  61887. * @param result defines the target matrix
  61888. */
  61889. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61890. /**
  61891. * Creates a scaling matrix and stores it in a target matrix
  61892. * @param x defines the x coordinate of the scaling
  61893. * @param y defines the y coordinate of the scaling
  61894. * @param result defines the target matrix
  61895. */
  61896. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61897. /**
  61898. * Creates a rotation matrix and stores it in a target matrix
  61899. * @param angle defines the rotation angle
  61900. * @param result defines the target matrix
  61901. */
  61902. static RotationToRef(angle: number, result: Matrix2D): void;
  61903. private static _TempPreTranslationMatrix;
  61904. private static _TempPostTranslationMatrix;
  61905. private static _TempRotationMatrix;
  61906. private static _TempScalingMatrix;
  61907. private static _TempCompose0;
  61908. private static _TempCompose1;
  61909. private static _TempCompose2;
  61910. /**
  61911. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61912. * @param tx defines the x coordinate of the translation
  61913. * @param ty defines the y coordinate of the translation
  61914. * @param angle defines the rotation angle
  61915. * @param scaleX defines the x coordinate of the scaling
  61916. * @param scaleY defines the y coordinate of the scaling
  61917. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61918. * @param result defines the target matrix
  61919. */
  61920. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61921. }
  61922. }
  61923. declare module BABYLON.GUI {
  61924. /**
  61925. * Class used to store 2D control sizes
  61926. */
  61927. export class Measure {
  61928. /** defines left coordinate */
  61929. left: number;
  61930. /** defines top coordinate */
  61931. top: number;
  61932. /** defines width dimension */
  61933. width: number;
  61934. /** defines height dimension */
  61935. height: number;
  61936. /**
  61937. * Creates a new measure
  61938. * @param left defines left coordinate
  61939. * @param top defines top coordinate
  61940. * @param width defines width dimension
  61941. * @param height defines height dimension
  61942. */
  61943. constructor(
  61944. /** defines left coordinate */
  61945. left: number,
  61946. /** defines top coordinate */
  61947. top: number,
  61948. /** defines width dimension */
  61949. width: number,
  61950. /** defines height dimension */
  61951. height: number);
  61952. /**
  61953. * Copy from another measure
  61954. * @param other defines the other measure to copy from
  61955. */
  61956. copyFrom(other: Measure): void;
  61957. /**
  61958. * Copy from a group of 4 floats
  61959. * @param left defines left coordinate
  61960. * @param top defines top coordinate
  61961. * @param width defines width dimension
  61962. * @param height defines height dimension
  61963. */
  61964. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61965. /**
  61966. * Computes the axis aligned bounding box measure for two given measures
  61967. * @param a Input measure
  61968. * @param b Input measure
  61969. * @param result the resulting bounding measure
  61970. */
  61971. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61972. /**
  61973. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61974. * @param transform the matrix to transform the measure before computing the AABB
  61975. * @param result the resulting AABB
  61976. */
  61977. transformToRef(transform: Matrix2D, result: Measure): void;
  61978. /**
  61979. * Check equality between this measure and another one
  61980. * @param other defines the other measures
  61981. * @returns true if both measures are equals
  61982. */
  61983. isEqualsTo(other: Measure): boolean;
  61984. /**
  61985. * Creates an empty measure
  61986. * @returns a new measure
  61987. */
  61988. static Empty(): Measure;
  61989. }
  61990. }
  61991. declare module BABYLON.GUI {
  61992. /**
  61993. * Interface used to define a control that can receive focus
  61994. */
  61995. export interface IFocusableControl {
  61996. /**
  61997. * Function called when the control receives the focus
  61998. */
  61999. onFocus(): void;
  62000. /**
  62001. * Function called when the control loses the focus
  62002. */
  62003. onBlur(): void;
  62004. /**
  62005. * Function called to let the control handle keyboard events
  62006. * @param evt defines the current keyboard event
  62007. */
  62008. processKeyboard(evt: KeyboardEvent): void;
  62009. /**
  62010. * Function called to get the list of controls that should not steal the focus from this control
  62011. * @returns an array of controls
  62012. */
  62013. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62014. }
  62015. /**
  62016. * Class used to create texture to support 2D GUI elements
  62017. * @see http://doc.babylonjs.com/how_to/gui
  62018. */
  62019. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62020. private _isDirty;
  62021. private _renderObserver;
  62022. private _resizeObserver;
  62023. private _preKeyboardObserver;
  62024. private _pointerMoveObserver;
  62025. private _pointerObserver;
  62026. private _canvasPointerOutObserver;
  62027. private _background;
  62028. /** @hidden */ private _rootContainer: Container;
  62029. /** @hidden */ private _lastPickedControl: Control;
  62030. /** @hidden */ private _lastControlOver: {
  62031. [pointerId: number]: Control;
  62032. };
  62033. /** @hidden */ private _lastControlDown: {
  62034. [pointerId: number]: Control;
  62035. };
  62036. /** @hidden */ private _capturingControl: {
  62037. [pointerId: number]: Control;
  62038. };
  62039. /** @hidden */ private _shouldBlockPointer: boolean;
  62040. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62041. /** @hidden */ private _linkedControls: Control[];
  62042. private _isFullscreen;
  62043. private _fullscreenViewport;
  62044. private _idealWidth;
  62045. private _idealHeight;
  62046. private _useSmallestIdeal;
  62047. private _renderAtIdealSize;
  62048. private _focusedControl;
  62049. private _blockNextFocusCheck;
  62050. private _renderScale;
  62051. private _rootCanvas;
  62052. private _cursorChanged;
  62053. /**
  62054. * Define type to string to ensure compatibility across browsers
  62055. * Safari doesn't support DataTransfer constructor
  62056. */
  62057. private _clipboardData;
  62058. /**
  62059. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62060. */
  62061. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62062. /**
  62063. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62064. */
  62065. onControlPickedObservable: BABYLON.Observable<Control>;
  62066. /**
  62067. * BABYLON.Observable event triggered before layout is evaluated
  62068. */
  62069. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62070. /**
  62071. * BABYLON.Observable event triggered after the layout was evaluated
  62072. */
  62073. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62074. /**
  62075. * BABYLON.Observable event triggered before the texture is rendered
  62076. */
  62077. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62078. /**
  62079. * BABYLON.Observable event triggered after the texture was rendered
  62080. */
  62081. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62082. /**
  62083. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62084. */
  62085. premulAlpha: boolean;
  62086. /**
  62087. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62088. * Useful when you want more antialiasing
  62089. */
  62090. renderScale: number;
  62091. /** Gets or sets the background color */
  62092. background: string;
  62093. /**
  62094. * Gets or sets the ideal width used to design controls.
  62095. * The GUI will then rescale everything accordingly
  62096. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62097. */
  62098. idealWidth: number;
  62099. /**
  62100. * Gets or sets the ideal height used to design controls.
  62101. * The GUI will then rescale everything accordingly
  62102. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62103. */
  62104. idealHeight: number;
  62105. /**
  62106. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62107. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62108. */
  62109. useSmallestIdeal: boolean;
  62110. /**
  62111. * Gets or sets a boolean indicating if adaptive scaling must be used
  62112. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62113. */
  62114. renderAtIdealSize: boolean;
  62115. /**
  62116. * Gets the underlying layer used to render the texture when in fullscreen mode
  62117. */
  62118. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62119. /**
  62120. * Gets the root container control
  62121. */
  62122. readonly rootContainer: Container;
  62123. /**
  62124. * Returns an array containing the root container.
  62125. * This is mostly used to let the Inspector introspects the ADT
  62126. * @returns an array containing the rootContainer
  62127. */
  62128. getChildren(): Array<Container>;
  62129. /**
  62130. * Will return all controls that are inside this texture
  62131. * @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
  62132. * @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
  62133. * @return all child controls
  62134. */
  62135. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62136. /**
  62137. * Gets or sets the current focused control
  62138. */
  62139. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62140. /**
  62141. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62142. */
  62143. isForeground: boolean;
  62144. /**
  62145. * Gets or set information about clipboardData
  62146. */
  62147. clipboardData: string;
  62148. /**
  62149. * Creates a new AdvancedDynamicTexture
  62150. * @param name defines the name of the texture
  62151. * @param width defines the width of the texture
  62152. * @param height defines the height of the texture
  62153. * @param scene defines the hosting scene
  62154. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62155. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62156. */
  62157. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62158. /**
  62159. * Get the current class name of the texture useful for serialization or dynamic coding.
  62160. * @returns "AdvancedDynamicTexture"
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Function used to execute a function on all controls
  62165. * @param func defines the function to execute
  62166. * @param container defines the container where controls belong. If null the root container will be used
  62167. */
  62168. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62169. private _useInvalidateRectOptimization;
  62170. /**
  62171. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62172. */
  62173. useInvalidateRectOptimization: boolean;
  62174. private _invalidatedRectangle;
  62175. /**
  62176. * Invalidates a rectangle area on the gui texture
  62177. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62178. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62179. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62180. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62181. */
  62182. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62183. /**
  62184. * Marks the texture as dirty forcing a complete update
  62185. */
  62186. markAsDirty(): void;
  62187. /**
  62188. * Helper function used to create a new style
  62189. * @returns a new style
  62190. * @see http://doc.babylonjs.com/how_to/gui#styles
  62191. */
  62192. createStyle(): Style;
  62193. /**
  62194. * Adds a new control to the root container
  62195. * @param control defines the control to add
  62196. * @returns the current texture
  62197. */
  62198. addControl(control: Control): AdvancedDynamicTexture;
  62199. /**
  62200. * Removes a control from the root container
  62201. * @param control defines the control to remove
  62202. * @returns the current texture
  62203. */
  62204. removeControl(control: Control): AdvancedDynamicTexture;
  62205. /**
  62206. * Release all resources
  62207. */
  62208. dispose(): void;
  62209. private _onResize;
  62210. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62211. /**
  62212. * Get screen coordinates for a vector3
  62213. * @param position defines the position to project
  62214. * @param worldMatrix defines the world matrix to use
  62215. * @returns the projected position
  62216. */
  62217. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62218. private _checkUpdate;
  62219. private _clearMeasure;
  62220. private _render;
  62221. /** @hidden */ private _changeCursor(cursor: string): void;
  62222. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  62223. private _doPicking;
  62224. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  62225. [pointerId: number]: Control;
  62226. }, control: Control): void;
  62227. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  62228. /** Attach to all scene events required to support pointer events */
  62229. attach(): void;
  62230. /** @hidden */
  62231. private onClipboardCopy;
  62232. /** @hidden */
  62233. private onClipboardCut;
  62234. /** @hidden */
  62235. private onClipboardPaste;
  62236. /**
  62237. * Register the clipboard Events onto the canvas
  62238. */
  62239. registerClipboardEvents(): void;
  62240. /**
  62241. * Unregister the clipboard Events from the canvas
  62242. */
  62243. unRegisterClipboardEvents(): void;
  62244. /**
  62245. * Connect the texture to a hosting mesh to enable interactions
  62246. * @param mesh defines the mesh to attach to
  62247. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62248. */
  62249. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62250. /**
  62251. * Move the focus to a specific control
  62252. * @param control defines the control which will receive the focus
  62253. */
  62254. moveFocusToControl(control: IFocusableControl): void;
  62255. private _manageFocus;
  62256. private _attachToOnPointerOut;
  62257. /**
  62258. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62259. * @param mesh defines the mesh which will receive the texture
  62260. * @param width defines the texture width (1024 by default)
  62261. * @param height defines the texture height (1024 by default)
  62262. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62263. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62264. * @returns a new AdvancedDynamicTexture
  62265. */
  62266. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62267. /**
  62268. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62269. * In this mode the texture will rely on a layer for its rendering.
  62270. * This allows it to be treated like any other layer.
  62271. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62272. * LayerMask is set through advancedTexture.layer.layerMask
  62273. * @param name defines name for the texture
  62274. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62275. * @param scene defines the hsoting scene
  62276. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62277. * @returns a new AdvancedDynamicTexture
  62278. */
  62279. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62280. }
  62281. }
  62282. declare module BABYLON.GUI {
  62283. /**
  62284. * Root class used for all 2D controls
  62285. * @see http://doc.babylonjs.com/how_to/gui#controls
  62286. */
  62287. export class Control {
  62288. /** defines the name of the control */
  62289. name?: string | undefined;
  62290. /**
  62291. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62292. */
  62293. static AllowAlphaInheritance: boolean;
  62294. private _alpha;
  62295. private _alphaSet;
  62296. private _zIndex;
  62297. /** @hidden */ private _host: AdvancedDynamicTexture;
  62298. /** Gets or sets the control parent */
  62299. parent: BABYLON.Nullable<Container>;
  62300. /** @hidden */ private _currentMeasure: Measure;
  62301. private _fontFamily;
  62302. private _fontStyle;
  62303. private _fontWeight;
  62304. private _fontSize;
  62305. private _font;
  62306. /** @hidden */ private _width: ValueAndUnit;
  62307. /** @hidden */ private _height: ValueAndUnit;
  62308. /** @hidden */
  62309. protected _fontOffset: {
  62310. ascent: number;
  62311. height: number;
  62312. descent: number;
  62313. };
  62314. private _color;
  62315. private _style;
  62316. private _styleObserver;
  62317. /** @hidden */
  62318. protected _horizontalAlignment: number;
  62319. /** @hidden */
  62320. protected _verticalAlignment: number;
  62321. /** @hidden */
  62322. protected _isDirty: boolean;
  62323. /** @hidden */
  62324. protected _wasDirty: boolean;
  62325. /** @hidden */ private _tempParentMeasure: Measure;
  62326. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62327. /** @hidden */
  62328. protected _cachedParentMeasure: Measure;
  62329. private _paddingLeft;
  62330. private _paddingRight;
  62331. private _paddingTop;
  62332. private _paddingBottom;
  62333. /** @hidden */ private _left: ValueAndUnit;
  62334. /** @hidden */ private _top: ValueAndUnit;
  62335. private _scaleX;
  62336. private _scaleY;
  62337. private _rotation;
  62338. private _transformCenterX;
  62339. private _transformCenterY;
  62340. /** @hidden */ private _transformMatrix: Matrix2D;
  62341. /** @hidden */
  62342. protected _invertTransformMatrix: Matrix2D;
  62343. /** @hidden */
  62344. protected _transformedPosition: BABYLON.Vector2;
  62345. private _isMatrixDirty;
  62346. private _cachedOffsetX;
  62347. private _cachedOffsetY;
  62348. private _isVisible;
  62349. private _isHighlighted;
  62350. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62351. private _fontSet;
  62352. private _dummyVector2;
  62353. private _downCount;
  62354. private _enterCount;
  62355. private _doNotRender;
  62356. private _downPointerIds;
  62357. protected _isEnabled: boolean;
  62358. protected _disabledColor: string;
  62359. /** @hidden */
  62360. protected _rebuildLayout: boolean;
  62361. /** @hidden */ private _isClipped: boolean;
  62362. /** @hidden */ private _tag: any;
  62363. /**
  62364. * 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
  62365. */
  62366. uniqueId: number;
  62367. /**
  62368. * Gets or sets an object used to store user defined information for the node
  62369. */
  62370. metadata: any;
  62371. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62372. isHitTestVisible: boolean;
  62373. /** Gets or sets a boolean indicating if the control can block pointer events */
  62374. isPointerBlocker: boolean;
  62375. /** Gets or sets a boolean indicating if the control can be focusable */
  62376. isFocusInvisible: boolean;
  62377. /**
  62378. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62379. * 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
  62380. */
  62381. clipChildren: boolean;
  62382. /**
  62383. * Gets or sets a boolean indicating that control content must be clipped
  62384. * 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
  62385. */
  62386. clipContent: boolean;
  62387. /**
  62388. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62389. */
  62390. useBitmapCache: boolean;
  62391. private _cacheData;
  62392. private _shadowOffsetX;
  62393. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62394. shadowOffsetX: number;
  62395. private _shadowOffsetY;
  62396. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62397. shadowOffsetY: number;
  62398. private _shadowBlur;
  62399. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62400. shadowBlur: number;
  62401. private _shadowColor;
  62402. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62403. shadowColor: string;
  62404. /** Gets or sets the cursor to use when the control is hovered */
  62405. hoverCursor: string;
  62406. /** @hidden */
  62407. protected _linkOffsetX: ValueAndUnit;
  62408. /** @hidden */
  62409. protected _linkOffsetY: ValueAndUnit;
  62410. /** Gets the control type name */
  62411. readonly typeName: string;
  62412. /**
  62413. * Get the current class name of the control.
  62414. * @returns current class name
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * An event triggered when the pointer move over the control.
  62419. */
  62420. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62421. /**
  62422. * An event triggered when the pointer move out of the control.
  62423. */
  62424. onPointerOutObservable: BABYLON.Observable<Control>;
  62425. /**
  62426. * An event triggered when the pointer taps the control
  62427. */
  62428. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62429. /**
  62430. * An event triggered when pointer up
  62431. */
  62432. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62433. /**
  62434. * An event triggered when a control is clicked on
  62435. */
  62436. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62437. /**
  62438. * An event triggered when pointer enters the control
  62439. */
  62440. onPointerEnterObservable: BABYLON.Observable<Control>;
  62441. /**
  62442. * An event triggered when the control is marked as dirty
  62443. */
  62444. onDirtyObservable: BABYLON.Observable<Control>;
  62445. /**
  62446. * An event triggered before drawing the control
  62447. */
  62448. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62449. /**
  62450. * An event triggered after the control was drawn
  62451. */
  62452. onAfterDrawObservable: BABYLON.Observable<Control>;
  62453. /**
  62454. * Get the hosting AdvancedDynamicTexture
  62455. */
  62456. readonly host: AdvancedDynamicTexture;
  62457. /** Gets or set information about font offsets (used to render and align text) */
  62458. fontOffset: {
  62459. ascent: number;
  62460. height: number;
  62461. descent: number;
  62462. };
  62463. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62464. alpha: number;
  62465. /**
  62466. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62467. */
  62468. isHighlighted: boolean;
  62469. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62470. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62471. */
  62472. scaleX: number;
  62473. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62474. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62475. */
  62476. scaleY: number;
  62477. /** Gets or sets the rotation angle (0 by default)
  62478. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62479. */
  62480. rotation: number;
  62481. /** Gets or sets the transformation center on Y axis (0 by default)
  62482. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62483. */
  62484. transformCenterY: number;
  62485. /** Gets or sets the transformation center on X axis (0 by default)
  62486. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62487. */
  62488. transformCenterX: number;
  62489. /**
  62490. * Gets or sets the horizontal alignment
  62491. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62492. */
  62493. horizontalAlignment: number;
  62494. /**
  62495. * Gets or sets the vertical alignment
  62496. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62497. */
  62498. verticalAlignment: number;
  62499. /**
  62500. * Gets or sets control width
  62501. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62502. */
  62503. width: string | number;
  62504. /**
  62505. * Gets or sets the control width in pixel
  62506. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62507. */
  62508. widthInPixels: number;
  62509. /**
  62510. * Gets or sets control height
  62511. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62512. */
  62513. height: string | number;
  62514. /**
  62515. * Gets or sets control height in pixel
  62516. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62517. */
  62518. heightInPixels: number;
  62519. /** Gets or set font family */
  62520. fontFamily: string;
  62521. /** Gets or sets font style */
  62522. fontStyle: string;
  62523. /** Gets or sets font weight */
  62524. fontWeight: string;
  62525. /**
  62526. * Gets or sets style
  62527. * @see http://doc.babylonjs.com/how_to/gui#styles
  62528. */
  62529. style: BABYLON.Nullable<Style>;
  62530. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  62531. /** Gets or sets font size in pixels */
  62532. fontSizeInPixels: number;
  62533. /** Gets or sets font size */
  62534. fontSize: string | number;
  62535. /** Gets or sets foreground color */
  62536. color: string;
  62537. /** Gets or sets z index which is used to reorder controls on the z axis */
  62538. zIndex: number;
  62539. /** Gets or sets a boolean indicating if the control can be rendered */
  62540. notRenderable: boolean;
  62541. /** Gets or sets a boolean indicating if the control is visible */
  62542. isVisible: boolean;
  62543. /** Gets a boolean indicating that the control needs to update its rendering */
  62544. readonly isDirty: boolean;
  62545. /**
  62546. * Gets the current linked mesh (or null if none)
  62547. */
  62548. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62549. /**
  62550. * Gets or sets a value indicating the padding to use on the left of the control
  62551. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62552. */
  62553. paddingLeft: string | number;
  62554. /**
  62555. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62556. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62557. */
  62558. paddingLeftInPixels: number;
  62559. /**
  62560. * Gets or sets a value indicating the padding to use on the right of the control
  62561. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62562. */
  62563. paddingRight: string | number;
  62564. /**
  62565. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62566. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62567. */
  62568. paddingRightInPixels: number;
  62569. /**
  62570. * Gets or sets a value indicating the padding to use on the top of the control
  62571. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62572. */
  62573. paddingTop: string | number;
  62574. /**
  62575. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62576. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62577. */
  62578. paddingTopInPixels: number;
  62579. /**
  62580. * Gets or sets a value indicating the padding to use on the bottom of the control
  62581. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62582. */
  62583. paddingBottom: string | number;
  62584. /**
  62585. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62586. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62587. */
  62588. paddingBottomInPixels: number;
  62589. /**
  62590. * Gets or sets a value indicating the left coordinate of the control
  62591. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62592. */
  62593. left: string | number;
  62594. /**
  62595. * Gets or sets a value indicating the left coordinate in pixels of the control
  62596. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62597. */
  62598. leftInPixels: number;
  62599. /**
  62600. * Gets or sets a value indicating the top coordinate of the control
  62601. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62602. */
  62603. top: string | number;
  62604. /**
  62605. * Gets or sets a value indicating the top coordinate in pixels of the control
  62606. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62607. */
  62608. topInPixels: number;
  62609. /**
  62610. * Gets or sets a value indicating the offset on X axis to the linked mesh
  62611. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62612. */
  62613. linkOffsetX: string | number;
  62614. /**
  62615. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  62616. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62617. */
  62618. linkOffsetXInPixels: number;
  62619. /**
  62620. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  62621. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62622. */
  62623. linkOffsetY: string | number;
  62624. /**
  62625. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  62626. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62627. */
  62628. linkOffsetYInPixels: number;
  62629. /** Gets the center coordinate on X axis */
  62630. readonly centerX: number;
  62631. /** Gets the center coordinate on Y axis */
  62632. readonly centerY: number;
  62633. /** Gets or sets if control is Enabled*/
  62634. isEnabled: boolean;
  62635. /** Gets or sets background color of control if it's disabled*/
  62636. disabledColor: string;
  62637. /**
  62638. * Creates a new control
  62639. * @param name defines the name of the control
  62640. */
  62641. constructor(
  62642. /** defines the name of the control */
  62643. name?: string | undefined);
  62644. /** @hidden */
  62645. protected _getTypeName(): string;
  62646. /**
  62647. * Gets the first ascendant in the hierarchy of the given type
  62648. * @param className defines the required type
  62649. * @returns the ascendant or null if not found
  62650. */
  62651. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  62652. /** @hidden */ private _resetFontCache(): void;
  62653. /**
  62654. * Determines if a container is an ascendant of the current control
  62655. * @param container defines the container to look for
  62656. * @returns true if the container is one of the ascendant of the control
  62657. */
  62658. isAscendant(container: Control): boolean;
  62659. /**
  62660. * Gets coordinates in local control space
  62661. * @param globalCoordinates defines the coordinates to transform
  62662. * @returns the new coordinates in local space
  62663. */
  62664. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62665. /**
  62666. * Gets coordinates in local control space
  62667. * @param globalCoordinates defines the coordinates to transform
  62668. * @param result defines the target vector2 where to store the result
  62669. * @returns the current control
  62670. */
  62671. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  62672. /**
  62673. * Gets coordinates in parent local control space
  62674. * @param globalCoordinates defines the coordinates to transform
  62675. * @returns the new coordinates in parent local space
  62676. */
  62677. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  62678. /**
  62679. * Move the current control to a vector3 position projected onto the screen.
  62680. * @param position defines the target position
  62681. * @param scene defines the hosting scene
  62682. */
  62683. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  62684. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62685. /**
  62686. * Will return all controls that have this control as ascendant
  62687. * @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
  62688. * @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
  62689. * @return all child controls
  62690. */
  62691. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62692. /**
  62693. * Link current control with a target mesh
  62694. * @param mesh defines the mesh to link with
  62695. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  62696. */
  62697. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  62698. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  62699. /** @hidden */ private _offsetLeft(offset: number): void;
  62700. /** @hidden */ private _offsetTop(offset: number): void;
  62701. /** @hidden */ private _markMatrixAsDirty(): void;
  62702. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  62703. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  62704. /** @hidden */
  62705. protected invalidateRect(): void;
  62706. /** @hidden */ private _markAsDirty(force?: boolean): void;
  62707. /** @hidden */ private _markAllAsDirty(): void;
  62708. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  62709. /** @hidden */
  62710. protected _transform(context?: CanvasRenderingContext2D): void;
  62711. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  62712. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62713. /** @hidden */
  62714. protected _applyStates(context: CanvasRenderingContext2D): void;
  62715. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62716. /** @hidden */
  62717. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62718. protected _evaluateClippingState(parentMeasure: Measure): void;
  62719. /** @hidden */ private _measure(): void;
  62720. /** @hidden */
  62721. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62722. /** @hidden */
  62723. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62724. /** @hidden */
  62725. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62726. /** @hidden */
  62727. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62728. private static _ClipMeasure;
  62729. private _tmpMeasureA;
  62730. private _clip;
  62731. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  62732. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  62733. /**
  62734. * Tests if a given coordinates belong to the current control
  62735. * @param x defines x coordinate to test
  62736. * @param y defines y coordinate to test
  62737. * @returns true if the coordinates are inside the control
  62738. */
  62739. contains(x: number, y: number): boolean;
  62740. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62741. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62742. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  62743. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  62744. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62745. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62746. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62747. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  62748. private _prepareFont;
  62749. /** Releases associated resources */
  62750. dispose(): void;
  62751. private static _HORIZONTAL_ALIGNMENT_LEFT;
  62752. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  62753. private static _HORIZONTAL_ALIGNMENT_CENTER;
  62754. private static _VERTICAL_ALIGNMENT_TOP;
  62755. private static _VERTICAL_ALIGNMENT_BOTTOM;
  62756. private static _VERTICAL_ALIGNMENT_CENTER;
  62757. /** HORIZONTAL_ALIGNMENT_LEFT */
  62758. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  62759. /** HORIZONTAL_ALIGNMENT_RIGHT */
  62760. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  62761. /** HORIZONTAL_ALIGNMENT_CENTER */
  62762. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  62763. /** VERTICAL_ALIGNMENT_TOP */
  62764. static readonly VERTICAL_ALIGNMENT_TOP: number;
  62765. /** VERTICAL_ALIGNMENT_BOTTOM */
  62766. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  62767. /** VERTICAL_ALIGNMENT_CENTER */
  62768. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  62769. private static _FontHeightSizes;
  62770. /** @hidden */ private static _GetFontOffset(font: string): {
  62771. ascent: number;
  62772. height: number;
  62773. descent: number;
  62774. };
  62775. /**
  62776. * Creates a stack panel that can be used to render headers
  62777. * @param control defines the control to associate with the header
  62778. * @param text defines the text of the header
  62779. * @param size defines the size of the header
  62780. * @param options defines options used to configure the header
  62781. * @returns a new StackPanel
  62782. * @ignore
  62783. * @hidden
  62784. */
  62785. static AddHeader: (control: Control, text: string, size: string | number, options: {
  62786. isHorizontal: boolean;
  62787. controlFirst: boolean;
  62788. }) => any;
  62789. /** @hidden */
  62790. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  62791. }
  62792. }
  62793. declare module BABYLON.GUI {
  62794. /**
  62795. * Root class for 2D containers
  62796. * @see http://doc.babylonjs.com/how_to/gui#containers
  62797. */
  62798. export class Container extends Control {
  62799. name?: string | undefined;
  62800. /** @hidden */
  62801. protected _children: Control[];
  62802. /** @hidden */
  62803. protected _measureForChildren: Measure;
  62804. /** @hidden */
  62805. protected _background: string;
  62806. /** @hidden */
  62807. protected _adaptWidthToChildren: boolean;
  62808. /** @hidden */
  62809. protected _adaptHeightToChildren: boolean;
  62810. /**
  62811. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  62812. */
  62813. logLayoutCycleErrors: boolean;
  62814. /**
  62815. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  62816. */
  62817. maxLayoutCycle: number;
  62818. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  62819. adaptHeightToChildren: boolean;
  62820. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  62821. adaptWidthToChildren: boolean;
  62822. /** Gets or sets background color */
  62823. background: string;
  62824. /** Gets the list of children */
  62825. readonly children: Control[];
  62826. /**
  62827. * Creates a new Container
  62828. * @param name defines the name of the container
  62829. */
  62830. constructor(name?: string | undefined);
  62831. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  62832. /**
  62833. * Gets a child using its name
  62834. * @param name defines the child name to look for
  62835. * @returns the child control if found
  62836. */
  62837. getChildByName(name: string): BABYLON.Nullable<Control>;
  62838. /**
  62839. * Gets a child using its type and its name
  62840. * @param name defines the child name to look for
  62841. * @param type defines the child type to look for
  62842. * @returns the child control if found
  62843. */
  62844. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62845. /**
  62846. * Search for a specific control in children
  62847. * @param control defines the control to look for
  62848. * @returns true if the control is in child list
  62849. */
  62850. containsControl(control: Control): boolean;
  62851. /**
  62852. * Adds a new control to the current container
  62853. * @param control defines the control to add
  62854. * @returns the current container
  62855. */
  62856. addControl(control: BABYLON.Nullable<Control>): Container;
  62857. /**
  62858. * Removes all controls from the current container
  62859. * @returns the current container
  62860. */
  62861. clearControls(): Container;
  62862. /**
  62863. * Removes a control from the current container
  62864. * @param control defines the control to remove
  62865. * @returns the current container
  62866. */
  62867. removeControl(control: Control): Container;
  62868. /** @hidden */ private _reOrderControl(control: Control): void;
  62869. /** @hidden */ private _offsetLeft(offset: number): void;
  62870. /** @hidden */ private _offsetTop(offset: number): void;
  62871. /** @hidden */ private _markAllAsDirty(): void;
  62872. /** @hidden */
  62873. protected _localDraw(context: CanvasRenderingContext2D): void;
  62874. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  62875. /** @hidden */
  62876. protected _beforeLayout(): void;
  62877. /** @hidden */
  62878. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62879. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62880. protected _postMeasure(): void;
  62881. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62882. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62883. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62884. /** @hidden */
  62885. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62886. /** Releases associated resources */
  62887. dispose(): void;
  62888. }
  62889. }
  62890. declare module BABYLON.GUI {
  62891. /** Class used to create rectangle container */
  62892. export class Rectangle extends Container {
  62893. name?: string | undefined;
  62894. private _thickness;
  62895. private _cornerRadius;
  62896. /** Gets or sets border thickness */
  62897. thickness: number;
  62898. /** Gets or sets the corner radius angle */
  62899. cornerRadius: number;
  62900. /**
  62901. * Creates a new Rectangle
  62902. * @param name defines the control name
  62903. */
  62904. constructor(name?: string | undefined);
  62905. protected _getTypeName(): string;
  62906. protected _localDraw(context: CanvasRenderingContext2D): void;
  62907. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62908. private _drawRoundedRect;
  62909. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62910. }
  62911. }
  62912. declare module BABYLON.GUI {
  62913. /**
  62914. * Enum that determines the text-wrapping mode to use.
  62915. */
  62916. export enum TextWrapping {
  62917. /**
  62918. * Clip the text when it's larger than Control.width; this is the default mode.
  62919. */
  62920. Clip = 0,
  62921. /**
  62922. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62923. */
  62924. WordWrap = 1,
  62925. /**
  62926. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62927. */
  62928. Ellipsis = 2
  62929. }
  62930. /**
  62931. * Class used to create text block control
  62932. */
  62933. export class TextBlock extends Control {
  62934. /**
  62935. * Defines the name of the control
  62936. */
  62937. name?: string | undefined;
  62938. private _text;
  62939. private _textWrapping;
  62940. private _textHorizontalAlignment;
  62941. private _textVerticalAlignment;
  62942. private _lines;
  62943. private _resizeToFit;
  62944. private _lineSpacing;
  62945. private _outlineWidth;
  62946. private _outlineColor;
  62947. /**
  62948. * An event triggered after the text is changed
  62949. */
  62950. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62951. /**
  62952. * An event triggered after the text was broken up into lines
  62953. */
  62954. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62955. /**
  62956. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62957. */
  62958. readonly lines: any[];
  62959. /**
  62960. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62961. */
  62962. /**
  62963. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62964. */
  62965. resizeToFit: boolean;
  62966. /**
  62967. * Gets or sets a boolean indicating if text must be wrapped
  62968. */
  62969. /**
  62970. * Gets or sets a boolean indicating if text must be wrapped
  62971. */
  62972. textWrapping: TextWrapping | boolean;
  62973. /**
  62974. * Gets or sets text to display
  62975. */
  62976. /**
  62977. * Gets or sets text to display
  62978. */
  62979. text: string;
  62980. /**
  62981. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62982. */
  62983. /**
  62984. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62985. */
  62986. textHorizontalAlignment: number;
  62987. /**
  62988. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62989. */
  62990. /**
  62991. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62992. */
  62993. textVerticalAlignment: number;
  62994. /**
  62995. * Gets or sets line spacing value
  62996. */
  62997. /**
  62998. * Gets or sets line spacing value
  62999. */
  63000. lineSpacing: string | number;
  63001. /**
  63002. * Gets or sets outlineWidth of the text to display
  63003. */
  63004. /**
  63005. * Gets or sets outlineWidth of the text to display
  63006. */
  63007. outlineWidth: number;
  63008. /**
  63009. * Gets or sets outlineColor of the text to display
  63010. */
  63011. /**
  63012. * Gets or sets outlineColor of the text to display
  63013. */
  63014. outlineColor: string;
  63015. /**
  63016. * Creates a new TextBlock object
  63017. * @param name defines the name of the control
  63018. * @param text defines the text to display (emptry string by default)
  63019. */
  63020. constructor(
  63021. /**
  63022. * Defines the name of the control
  63023. */
  63024. name?: string | undefined, text?: string);
  63025. protected _getTypeName(): string;
  63026. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63027. private _drawText;
  63028. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63029. protected _applyStates(context: CanvasRenderingContext2D): void;
  63030. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63031. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63032. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63033. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63034. protected _renderLines(context: CanvasRenderingContext2D): void;
  63035. /**
  63036. * Given a width constraint applied on the text block, find the expected height
  63037. * @returns expected height
  63038. */
  63039. computeExpectedHeight(): number;
  63040. dispose(): void;
  63041. }
  63042. }
  63043. declare module BABYLON.GUI {
  63044. /**
  63045. * Class used to create 2D images
  63046. */
  63047. export class Image extends Control {
  63048. name?: string | undefined;
  63049. private static _WorkingCanvas;
  63050. private _domImage;
  63051. private _imageWidth;
  63052. private _imageHeight;
  63053. private _loaded;
  63054. private _stretch;
  63055. private _source;
  63056. private _autoScale;
  63057. private _sourceLeft;
  63058. private _sourceTop;
  63059. private _sourceWidth;
  63060. private _sourceHeight;
  63061. private _cellWidth;
  63062. private _cellHeight;
  63063. private _cellId;
  63064. private _populateNinePatchSlicesFromImage;
  63065. private _sliceLeft;
  63066. private _sliceRight;
  63067. private _sliceTop;
  63068. private _sliceBottom;
  63069. private _detectPointerOnOpaqueOnly;
  63070. /**
  63071. * BABYLON.Observable notified when the content is loaded
  63072. */
  63073. onImageLoadedObservable: BABYLON.Observable<Image>;
  63074. /**
  63075. * Gets a boolean indicating that the content is loaded
  63076. */
  63077. readonly isLoaded: boolean;
  63078. /**
  63079. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63080. */
  63081. populateNinePatchSlicesFromImage: boolean;
  63082. /**
  63083. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63084. * Beware using this as this will comsume more memory as the image has to be stored twice
  63085. */
  63086. detectPointerOnOpaqueOnly: boolean;
  63087. /**
  63088. * Gets or sets the left value for slicing (9-patch)
  63089. */
  63090. sliceLeft: number;
  63091. /**
  63092. * Gets or sets the right value for slicing (9-patch)
  63093. */
  63094. sliceRight: number;
  63095. /**
  63096. * Gets or sets the top value for slicing (9-patch)
  63097. */
  63098. sliceTop: number;
  63099. /**
  63100. * Gets or sets the bottom value for slicing (9-patch)
  63101. */
  63102. sliceBottom: number;
  63103. /**
  63104. * Gets or sets the left coordinate in the source image
  63105. */
  63106. sourceLeft: number;
  63107. /**
  63108. * Gets or sets the top coordinate in the source image
  63109. */
  63110. sourceTop: number;
  63111. /**
  63112. * Gets or sets the width to capture in the source image
  63113. */
  63114. sourceWidth: number;
  63115. /**
  63116. * Gets or sets the height to capture in the source image
  63117. */
  63118. sourceHeight: number;
  63119. /**
  63120. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63121. * @see http://doc.babylonjs.com/how_to/gui#image
  63122. */
  63123. autoScale: boolean;
  63124. /** Gets or sets the streching mode used by the image */
  63125. stretch: number;
  63126. /**
  63127. * Gets or sets the internal DOM image used to render the control
  63128. */
  63129. domImage: HTMLImageElement;
  63130. private _onImageLoaded;
  63131. private _extractNinePatchSliceDataFromImage;
  63132. /**
  63133. * Gets or sets image source url
  63134. */
  63135. source: BABYLON.Nullable<string>;
  63136. /**
  63137. * Gets or sets the cell width to use when animation sheet is enabled
  63138. * @see http://doc.babylonjs.com/how_to/gui#image
  63139. */
  63140. cellWidth: number;
  63141. /**
  63142. * Gets or sets the cell height to use when animation sheet is enabled
  63143. * @see http://doc.babylonjs.com/how_to/gui#image
  63144. */
  63145. cellHeight: number;
  63146. /**
  63147. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63148. * @see http://doc.babylonjs.com/how_to/gui#image
  63149. */
  63150. cellId: number;
  63151. /**
  63152. * Creates a new Image
  63153. * @param name defines the control name
  63154. * @param url defines the image url
  63155. */
  63156. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63157. /**
  63158. * Tests if a given coordinates belong to the current control
  63159. * @param x defines x coordinate to test
  63160. * @param y defines y coordinate to test
  63161. * @returns true if the coordinates are inside the control
  63162. */
  63163. contains(x: number, y: number): boolean;
  63164. protected _getTypeName(): string;
  63165. /** Force the control to synchronize with its content */
  63166. synchronizeSizeWithContent(): void;
  63167. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63168. private _prepareWorkingCanvasForOpaqueDetection;
  63169. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  63170. private _renderCornerPatch;
  63171. private _renderNinePatch;
  63172. dispose(): void;
  63173. /** STRETCH_NONE */
  63174. static readonly STRETCH_NONE: number;
  63175. /** STRETCH_FILL */
  63176. static readonly STRETCH_FILL: number;
  63177. /** STRETCH_UNIFORM */
  63178. static readonly STRETCH_UNIFORM: number;
  63179. /** STRETCH_EXTEND */
  63180. static readonly STRETCH_EXTEND: number;
  63181. /** NINE_PATCH */
  63182. static readonly STRETCH_NINE_PATCH: number;
  63183. }
  63184. }
  63185. declare module BABYLON.GUI {
  63186. /**
  63187. * Class used to create 2D buttons
  63188. */
  63189. export class Button extends Rectangle {
  63190. name?: string | undefined;
  63191. /**
  63192. * Function called to generate a pointer enter animation
  63193. */
  63194. pointerEnterAnimation: () => void;
  63195. /**
  63196. * Function called to generate a pointer out animation
  63197. */
  63198. pointerOutAnimation: () => void;
  63199. /**
  63200. * Function called to generate a pointer down animation
  63201. */
  63202. pointerDownAnimation: () => void;
  63203. /**
  63204. * Function called to generate a pointer up animation
  63205. */
  63206. pointerUpAnimation: () => void;
  63207. /**
  63208. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63209. */
  63210. delegatePickingToChildren: boolean;
  63211. private _image;
  63212. /**
  63213. * Returns the image part of the button (if any)
  63214. */
  63215. readonly image: BABYLON.Nullable<Image>;
  63216. private _textBlock;
  63217. /**
  63218. * Returns the image part of the button (if any)
  63219. */
  63220. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63221. /**
  63222. * Creates a new Button
  63223. * @param name defines the name of the button
  63224. */
  63225. constructor(name?: string | undefined);
  63226. protected _getTypeName(): string;
  63227. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63228. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63229. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63230. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63231. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63232. /**
  63233. * Creates a new button made with an image and a text
  63234. * @param name defines the name of the button
  63235. * @param text defines the text of the button
  63236. * @param imageUrl defines the url of the image
  63237. * @returns a new Button
  63238. */
  63239. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63240. /**
  63241. * Creates a new button made with an image
  63242. * @param name defines the name of the button
  63243. * @param imageUrl defines the url of the image
  63244. * @returns a new Button
  63245. */
  63246. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63247. /**
  63248. * Creates a new button made with a text
  63249. * @param name defines the name of the button
  63250. * @param text defines the text of the button
  63251. * @returns a new Button
  63252. */
  63253. static CreateSimpleButton(name: string, text: string): Button;
  63254. /**
  63255. * Creates a new button made with an image and a centered text
  63256. * @param name defines the name of the button
  63257. * @param text defines the text of the button
  63258. * @param imageUrl defines the url of the image
  63259. * @returns a new Button
  63260. */
  63261. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63262. }
  63263. }
  63264. declare module BABYLON.GUI {
  63265. /**
  63266. * Class used to create a 2D stack panel container
  63267. */
  63268. export class StackPanel extends Container {
  63269. name?: string | undefined;
  63270. private _isVertical;
  63271. private _manualWidth;
  63272. private _manualHeight;
  63273. private _doNotTrackManualChanges;
  63274. /**
  63275. * Gets or sets a boolean indicating that layou warnings should be ignored
  63276. */
  63277. ignoreLayoutWarnings: boolean;
  63278. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63279. isVertical: boolean;
  63280. /**
  63281. * Gets or sets panel width.
  63282. * This value should not be set when in horizontal mode as it will be computed automatically
  63283. */
  63284. width: string | number;
  63285. /**
  63286. * Gets or sets panel height.
  63287. * This value should not be set when in vertical mode as it will be computed automatically
  63288. */
  63289. height: string | number;
  63290. /**
  63291. * Creates a new StackPanel
  63292. * @param name defines control name
  63293. */
  63294. constructor(name?: string | undefined);
  63295. protected _getTypeName(): string;
  63296. /** @hidden */
  63297. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63298. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63299. protected _postMeasure(): void;
  63300. }
  63301. }
  63302. declare module BABYLON.GUI {
  63303. /**
  63304. * Class used to represent a 2D checkbox
  63305. */
  63306. export class Checkbox extends Control {
  63307. name?: string | undefined;
  63308. private _isChecked;
  63309. private _background;
  63310. private _checkSizeRatio;
  63311. private _thickness;
  63312. /** Gets or sets border thickness */
  63313. thickness: number;
  63314. /**
  63315. * BABYLON.Observable raised when isChecked property changes
  63316. */
  63317. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63318. /** Gets or sets a value indicating the ratio between overall size and check size */
  63319. checkSizeRatio: number;
  63320. /** Gets or sets background color */
  63321. background: string;
  63322. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63323. isChecked: boolean;
  63324. /**
  63325. * Creates a new CheckBox
  63326. * @param name defines the control name
  63327. */
  63328. constructor(name?: string | undefined);
  63329. protected _getTypeName(): string;
  63330. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63331. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63332. /**
  63333. * Utility function to easily create a checkbox with a header
  63334. * @param title defines the label to use for the header
  63335. * @param onValueChanged defines the callback to call when value changes
  63336. * @returns a StackPanel containing the checkbox and a textBlock
  63337. */
  63338. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63339. }
  63340. }
  63341. declare module BABYLON.GUI {
  63342. /**
  63343. * Class used to store key control properties
  63344. */
  63345. export class KeyPropertySet {
  63346. /** Width */
  63347. width?: string;
  63348. /** Height */
  63349. height?: string;
  63350. /** Left padding */
  63351. paddingLeft?: string;
  63352. /** Right padding */
  63353. paddingRight?: string;
  63354. /** Top padding */
  63355. paddingTop?: string;
  63356. /** Bottom padding */
  63357. paddingBottom?: string;
  63358. /** Foreground color */
  63359. color?: string;
  63360. /** Background color */
  63361. background?: string;
  63362. }
  63363. /**
  63364. * Class used to create virtual keyboard
  63365. */
  63366. export class VirtualKeyboard extends StackPanel {
  63367. /** BABYLON.Observable raised when a key is pressed */
  63368. onKeyPressObservable: BABYLON.Observable<string>;
  63369. /** Gets or sets default key button width */
  63370. defaultButtonWidth: string;
  63371. /** Gets or sets default key button height */
  63372. defaultButtonHeight: string;
  63373. /** Gets or sets default key button left padding */
  63374. defaultButtonPaddingLeft: string;
  63375. /** Gets or sets default key button right padding */
  63376. defaultButtonPaddingRight: string;
  63377. /** Gets or sets default key button top padding */
  63378. defaultButtonPaddingTop: string;
  63379. /** Gets or sets default key button bottom padding */
  63380. defaultButtonPaddingBottom: string;
  63381. /** Gets or sets default key button foreground color */
  63382. defaultButtonColor: string;
  63383. /** Gets or sets default key button background color */
  63384. defaultButtonBackground: string;
  63385. /** Gets or sets shift button foreground color */
  63386. shiftButtonColor: string;
  63387. /** Gets or sets shift button thickness*/
  63388. selectedShiftThickness: number;
  63389. /** Gets shift key state */
  63390. shiftState: number;
  63391. protected _getTypeName(): string;
  63392. private _createKey;
  63393. /**
  63394. * Adds a new row of keys
  63395. * @param keys defines the list of keys to add
  63396. * @param propertySets defines the associated property sets
  63397. */
  63398. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63399. /**
  63400. * Set the shift key to a specific state
  63401. * @param shiftState defines the new shift state
  63402. */
  63403. applyShiftState(shiftState: number): void;
  63404. private _currentlyConnectedInputText;
  63405. private _connectedInputTexts;
  63406. private _onKeyPressObserver;
  63407. /** Gets the input text control currently attached to the keyboard */
  63408. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63409. /**
  63410. * Connects the keyboard with an input text control
  63411. *
  63412. * @param input defines the target control
  63413. */
  63414. connect(input: InputText): void;
  63415. /**
  63416. * Disconnects the keyboard from connected InputText controls
  63417. *
  63418. * @param input optionally defines a target control, otherwise all are disconnected
  63419. */
  63420. disconnect(input?: InputText): void;
  63421. private _removeConnectedInputObservables;
  63422. /**
  63423. * Release all resources
  63424. */
  63425. dispose(): void;
  63426. /**
  63427. * Creates a new keyboard using a default layout
  63428. *
  63429. * @param name defines control name
  63430. * @returns a new VirtualKeyboard
  63431. */
  63432. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63433. }
  63434. }
  63435. declare module BABYLON.GUI {
  63436. /**
  63437. * Class used to create input text control
  63438. */
  63439. export class InputText extends Control implements IFocusableControl {
  63440. name?: string | undefined;
  63441. private _text;
  63442. private _placeholderText;
  63443. private _background;
  63444. private _focusedBackground;
  63445. private _focusedColor;
  63446. private _placeholderColor;
  63447. private _thickness;
  63448. private _margin;
  63449. private _autoStretchWidth;
  63450. private _maxWidth;
  63451. private _isFocused;
  63452. private _blinkTimeout;
  63453. private _blinkIsEven;
  63454. private _cursorOffset;
  63455. private _scrollLeft;
  63456. private _textWidth;
  63457. private _clickedCoordinate;
  63458. private _deadKey;
  63459. private _addKey;
  63460. private _currentKey;
  63461. private _isTextHighlightOn;
  63462. private _textHighlightColor;
  63463. private _highligherOpacity;
  63464. private _highlightedText;
  63465. private _startHighlightIndex;
  63466. private _endHighlightIndex;
  63467. private _cursorIndex;
  63468. private _onFocusSelectAll;
  63469. private _isPointerDown;
  63470. private _onClipboardObserver;
  63471. private _onPointerDblTapObserver;
  63472. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63473. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63474. promptMessage: string;
  63475. /** Force disable prompt on mobile device */
  63476. disableMobilePrompt: boolean;
  63477. /** BABYLON.Observable raised when the text changes */
  63478. onTextChangedObservable: BABYLON.Observable<InputText>;
  63479. /** BABYLON.Observable raised just before an entered character is to be added */
  63480. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63481. /** BABYLON.Observable raised when the control gets the focus */
  63482. onFocusObservable: BABYLON.Observable<InputText>;
  63483. /** BABYLON.Observable raised when the control loses the focus */
  63484. onBlurObservable: BABYLON.Observable<InputText>;
  63485. /**Observable raised when the text is highlighted */
  63486. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63487. /**Observable raised when copy event is triggered */
  63488. onTextCopyObservable: BABYLON.Observable<InputText>;
  63489. /** BABYLON.Observable raised when cut event is triggered */
  63490. onTextCutObservable: BABYLON.Observable<InputText>;
  63491. /** BABYLON.Observable raised when paste event is triggered */
  63492. onTextPasteObservable: BABYLON.Observable<InputText>;
  63493. /** BABYLON.Observable raised when a key event was processed */
  63494. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63495. /** Gets or sets the maximum width allowed by the control */
  63496. maxWidth: string | number;
  63497. /** Gets the maximum width allowed by the control in pixels */
  63498. readonly maxWidthInPixels: number;
  63499. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63500. highligherOpacity: number;
  63501. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63502. onFocusSelectAll: boolean;
  63503. /** Gets or sets the text hightlight color */
  63504. textHighlightColor: string;
  63505. /** Gets or sets control margin */
  63506. margin: string;
  63507. /** Gets control margin in pixels */
  63508. readonly marginInPixels: number;
  63509. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63510. autoStretchWidth: boolean;
  63511. /** Gets or sets border thickness */
  63512. thickness: number;
  63513. /** Gets or sets the background color when focused */
  63514. focusedBackground: string;
  63515. /** Gets or sets the background color when focused */
  63516. focusedColor: string;
  63517. /** Gets or sets the background color */
  63518. background: string;
  63519. /** Gets or sets the placeholder color */
  63520. placeholderColor: string;
  63521. /** Gets or sets the text displayed when the control is empty */
  63522. placeholderText: string;
  63523. /** Gets or sets the dead key flag */
  63524. deadKey: boolean;
  63525. /** Gets or sets the highlight text */
  63526. highlightedText: string;
  63527. /** Gets or sets if the current key should be added */
  63528. addKey: boolean;
  63529. /** Gets or sets the value of the current key being entered */
  63530. currentKey: string;
  63531. /** Gets or sets the text displayed in the control */
  63532. text: string;
  63533. /** Gets or sets control width */
  63534. width: string | number;
  63535. /**
  63536. * Creates a new InputText
  63537. * @param name defines the control name
  63538. * @param text defines the text of the control
  63539. */
  63540. constructor(name?: string | undefined, text?: string);
  63541. /** @hidden */
  63542. onBlur(): void;
  63543. /** @hidden */
  63544. onFocus(): void;
  63545. protected _getTypeName(): string;
  63546. /**
  63547. * Function called to get the list of controls that should not steal the focus from this control
  63548. * @returns an array of controls
  63549. */
  63550. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63551. /** @hidden */
  63552. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63553. /** @hidden */
  63554. private _updateValueFromCursorIndex;
  63555. /** @hidden */
  63556. private _processDblClick;
  63557. /** @hidden */
  63558. private _selectAllText;
  63559. /**
  63560. * Handles the keyboard event
  63561. * @param evt Defines the KeyboardEvent
  63562. */
  63563. processKeyboard(evt: KeyboardEvent): void;
  63564. /** @hidden */
  63565. private _onCopyText;
  63566. /** @hidden */
  63567. private _onCutText;
  63568. /** @hidden */
  63569. 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;
  63570. protected _beforeRenderText(text: string): string;
  63571. dispose(): void;
  63572. }
  63573. }
  63574. declare module BABYLON.GUI {
  63575. /**
  63576. * Class used to create a 2D grid container
  63577. */
  63578. export class Grid extends Container {
  63579. name?: string | undefined;
  63580. private _rowDefinitions;
  63581. private _columnDefinitions;
  63582. private _cells;
  63583. private _childControls;
  63584. /**
  63585. * Gets the number of columns
  63586. */
  63587. readonly columnCount: number;
  63588. /**
  63589. * Gets the number of rows
  63590. */
  63591. readonly rowCount: number;
  63592. /** Gets the list of children */
  63593. readonly children: Control[];
  63594. /** Gets the list of cells (e.g. the containers) */
  63595. readonly cells: {
  63596. [key: string]: Container;
  63597. };
  63598. /**
  63599. * Gets the definition of a specific row
  63600. * @param index defines the index of the row
  63601. * @returns the row definition
  63602. */
  63603. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63604. /**
  63605. * Gets the definition of a specific column
  63606. * @param index defines the index of the column
  63607. * @returns the column definition
  63608. */
  63609. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  63610. /**
  63611. * Adds a new row to the grid
  63612. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63613. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  63614. * @returns the current grid
  63615. */
  63616. addRowDefinition(height: number, isPixel?: boolean): Grid;
  63617. /**
  63618. * Adds a new column to the grid
  63619. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63620. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63621. * @returns the current grid
  63622. */
  63623. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  63624. /**
  63625. * Update a row definition
  63626. * @param index defines the index of the row to update
  63627. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  63628. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  63629. * @returns the current grid
  63630. */
  63631. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  63632. /**
  63633. * Update a column definition
  63634. * @param index defines the index of the column to update
  63635. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  63636. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  63637. * @returns the current grid
  63638. */
  63639. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  63640. /**
  63641. * Gets the list of children stored in a specific cell
  63642. * @param row defines the row to check
  63643. * @param column defines the column to check
  63644. * @returns the list of controls
  63645. */
  63646. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  63647. /**
  63648. * Gets a string representing the child cell info (row x column)
  63649. * @param child defines the control to get info from
  63650. * @returns a string containing the child cell info (row x column)
  63651. */
  63652. getChildCellInfo(child: Control): string;
  63653. private _removeCell;
  63654. private _offsetCell;
  63655. /**
  63656. * Remove a column definition at specified index
  63657. * @param index defines the index of the column to remove
  63658. * @returns the current grid
  63659. */
  63660. removeColumnDefinition(index: number): Grid;
  63661. /**
  63662. * Remove a row definition at specified index
  63663. * @param index defines the index of the row to remove
  63664. * @returns the current grid
  63665. */
  63666. removeRowDefinition(index: number): Grid;
  63667. /**
  63668. * Adds a new control to the current grid
  63669. * @param control defines the control to add
  63670. * @param row defines the row where to add the control (0 by default)
  63671. * @param column defines the column where to add the control (0 by default)
  63672. * @returns the current grid
  63673. */
  63674. addControl(control: Control, row?: number, column?: number): Grid;
  63675. /**
  63676. * Removes a control from the current container
  63677. * @param control defines the control to remove
  63678. * @returns the current container
  63679. */
  63680. removeControl(control: Control): Container;
  63681. /**
  63682. * Creates a new Grid
  63683. * @param name defines control name
  63684. */
  63685. constructor(name?: string | undefined);
  63686. protected _getTypeName(): string;
  63687. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  63688. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63689. /** Releases associated resources */
  63690. dispose(): void;
  63691. }
  63692. }
  63693. declare module BABYLON.GUI {
  63694. /** Class used to create color pickers */
  63695. export class ColorPicker extends Control {
  63696. name?: string | undefined;
  63697. private static _Epsilon;
  63698. private _colorWheelCanvas;
  63699. private _value;
  63700. private _tmpColor;
  63701. private _pointerStartedOnSquare;
  63702. private _pointerStartedOnWheel;
  63703. private _squareLeft;
  63704. private _squareTop;
  63705. private _squareSize;
  63706. private _h;
  63707. private _s;
  63708. private _v;
  63709. private _lastPointerDownID;
  63710. /**
  63711. * BABYLON.Observable raised when the value changes
  63712. */
  63713. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  63714. /** Gets or sets the color of the color picker */
  63715. value: BABYLON.Color3;
  63716. /**
  63717. * Gets or sets control width
  63718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63719. */
  63720. width: string | number;
  63721. /**
  63722. * Gets or sets control height
  63723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63724. */
  63725. /** Gets or sets control height */
  63726. height: string | number;
  63727. /** Gets or sets control size */
  63728. size: string | number;
  63729. /**
  63730. * Creates a new ColorPicker
  63731. * @param name defines the control name
  63732. */
  63733. constructor(name?: string | undefined);
  63734. protected _getTypeName(): string;
  63735. /** @hidden */
  63736. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63737. private _updateSquareProps;
  63738. private _drawGradientSquare;
  63739. private _drawCircle;
  63740. private _createColorWheelCanvas;
  63741. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  63742. private _pointerIsDown;
  63743. private _updateValueFromPointer;
  63744. private _isPointOnSquare;
  63745. 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;
  63746. /**
  63747. * This function expands the color picker by creating a color picker dialog with manual
  63748. * color value input and the ability to save colors into an array to be used later in
  63749. * subsequent launches of the dialogue.
  63750. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  63751. * @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.
  63752. * @returns picked color as a hex string and the saved colors array as hex strings.
  63753. */
  63754. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  63755. pickerWidth?: string;
  63756. pickerHeight?: string;
  63757. headerHeight?: string;
  63758. lastColor?: string;
  63759. swatchLimit?: number;
  63760. numSwatchesPerLine?: number;
  63761. savedColors?: Array<string>;
  63762. }): Promise<{
  63763. savedColors?: string[];
  63764. pickedColor: string;
  63765. }>;
  63766. }
  63767. }
  63768. declare module BABYLON.GUI {
  63769. /** Class used to create 2D ellipse containers */
  63770. export class Ellipse extends Container {
  63771. name?: string | undefined;
  63772. private _thickness;
  63773. /** Gets or sets border thickness */
  63774. thickness: number;
  63775. /**
  63776. * Creates a new Ellipse
  63777. * @param name defines the control name
  63778. */
  63779. constructor(name?: string | undefined);
  63780. protected _getTypeName(): string;
  63781. protected _localDraw(context: CanvasRenderingContext2D): void;
  63782. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63783. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63784. }
  63785. }
  63786. declare module BABYLON.GUI {
  63787. /**
  63788. * Class used to create a password control
  63789. */
  63790. export class InputPassword extends InputText {
  63791. protected _beforeRenderText(text: string): string;
  63792. }
  63793. }
  63794. declare module BABYLON.GUI {
  63795. /** Class used to render 2D lines */
  63796. export class Line extends Control {
  63797. name?: string | undefined;
  63798. private _lineWidth;
  63799. private _x1;
  63800. private _y1;
  63801. private _x2;
  63802. private _y2;
  63803. private _dash;
  63804. private _connectedControl;
  63805. private _connectedControlDirtyObserver;
  63806. /** Gets or sets the dash pattern */
  63807. dash: Array<number>;
  63808. /** Gets or sets the control connected with the line end */
  63809. connectedControl: Control;
  63810. /** Gets or sets start coordinates on X axis */
  63811. x1: string | number;
  63812. /** Gets or sets start coordinates on Y axis */
  63813. y1: string | number;
  63814. /** Gets or sets end coordinates on X axis */
  63815. x2: string | number;
  63816. /** Gets or sets end coordinates on Y axis */
  63817. y2: string | number;
  63818. /** Gets or sets line width */
  63819. lineWidth: number;
  63820. /** Gets or sets horizontal alignment */
  63821. horizontalAlignment: number;
  63822. /** Gets or sets vertical alignment */
  63823. verticalAlignment: number;
  63824. private readonly _effectiveX2;
  63825. private readonly _effectiveY2;
  63826. /**
  63827. * Creates a new Line
  63828. * @param name defines the control name
  63829. */
  63830. constructor(name?: string | undefined);
  63831. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  63832. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63833. /**
  63834. * Move one end of the line given 3D cartesian coordinates.
  63835. * @param position Targeted world position
  63836. * @param scene BABYLON.Scene
  63837. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63838. */
  63839. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63840. /**
  63841. * Move one end of the line to a position in screen absolute space.
  63842. * @param projectedPosition Position in screen absolute space (X, Y)
  63843. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63844. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63845. }
  63846. }
  63847. declare module BABYLON.GUI {
  63848. /**
  63849. * Class used to store a point for a MultiLine object.
  63850. * The point can be pure 2D coordinates, a mesh or a control
  63851. */
  63852. export class MultiLinePoint {
  63853. private _multiLine;
  63854. private _x;
  63855. private _y;
  63856. private _control;
  63857. private _mesh;
  63858. private _controlObserver;
  63859. private _meshObserver;
  63860. /** @hidden */ private _point: BABYLON.Vector2;
  63861. /**
  63862. * Creates a new MultiLinePoint
  63863. * @param multiLine defines the source MultiLine object
  63864. */
  63865. constructor(multiLine: MultiLine);
  63866. /** Gets or sets x coordinate */
  63867. x: string | number;
  63868. /** Gets or sets y coordinate */
  63869. y: string | number;
  63870. /** Gets or sets the control associated with this point */
  63871. control: BABYLON.Nullable<Control>;
  63872. /** Gets or sets the mesh associated with this point */
  63873. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63874. /** Resets links */
  63875. resetLinks(): void;
  63876. /**
  63877. * Gets a translation vector
  63878. * @returns the translation vector
  63879. */
  63880. translate(): BABYLON.Vector2;
  63881. private _translatePoint;
  63882. /** Release associated resources */
  63883. dispose(): void;
  63884. }
  63885. }
  63886. declare module BABYLON.GUI {
  63887. /**
  63888. * Class used to create multi line control
  63889. */
  63890. export class MultiLine extends Control {
  63891. name?: string | undefined;
  63892. private _lineWidth;
  63893. private _dash;
  63894. private _points;
  63895. private _minX;
  63896. private _minY;
  63897. private _maxX;
  63898. private _maxY;
  63899. /**
  63900. * Creates a new MultiLine
  63901. * @param name defines the control name
  63902. */
  63903. constructor(name?: string | undefined);
  63904. /** Gets or sets dash pattern */
  63905. dash: Array<number>;
  63906. /**
  63907. * Gets point stored at specified index
  63908. * @param index defines the index to look for
  63909. * @returns the requested point if found
  63910. */
  63911. getAt(index: number): MultiLinePoint;
  63912. /** Function called when a point is updated */
  63913. onPointUpdate: () => void;
  63914. /**
  63915. * Adds new points to the point collection
  63916. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63917. * @returns the list of created MultiLinePoint
  63918. */
  63919. add(...items: (AbstractMesh | Control | {
  63920. x: string | number;
  63921. y: string | number;
  63922. })[]): MultiLinePoint[];
  63923. /**
  63924. * Adds a new point to the point collection
  63925. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63926. * @returns the created MultiLinePoint
  63927. */
  63928. push(item?: (AbstractMesh | Control | {
  63929. x: string | number;
  63930. y: string | number;
  63931. })): MultiLinePoint;
  63932. /**
  63933. * Remove a specific value or point from the active point collection
  63934. * @param value defines the value or point to remove
  63935. */
  63936. remove(value: number | MultiLinePoint): void;
  63937. /**
  63938. * Resets this object to initial state (no point)
  63939. */
  63940. reset(): void;
  63941. /**
  63942. * Resets all links
  63943. */
  63944. resetLinks(): void;
  63945. /** Gets or sets line width */
  63946. lineWidth: number;
  63947. horizontalAlignment: number;
  63948. verticalAlignment: number;
  63949. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63950. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  63951. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63952. dispose(): void;
  63953. }
  63954. }
  63955. declare module BABYLON.GUI {
  63956. /**
  63957. * Class used to create radio button controls
  63958. */
  63959. export class RadioButton extends Control {
  63960. name?: string | undefined;
  63961. private _isChecked;
  63962. private _background;
  63963. private _checkSizeRatio;
  63964. private _thickness;
  63965. /** Gets or sets border thickness */
  63966. thickness: number;
  63967. /** Gets or sets group name */
  63968. group: string;
  63969. /** BABYLON.Observable raised when isChecked is changed */
  63970. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63971. /** Gets or sets a value indicating the ratio between overall size and check size */
  63972. checkSizeRatio: number;
  63973. /** Gets or sets background color */
  63974. background: string;
  63975. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63976. isChecked: boolean;
  63977. /**
  63978. * Creates a new RadioButton
  63979. * @param name defines the control name
  63980. */
  63981. constructor(name?: string | undefined);
  63982. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63983. /**
  63984. * Utility function to easily create a radio button with a header
  63985. * @param title defines the label to use for the header
  63986. * @param group defines the group to use for the radio button
  63987. * @param isChecked defines the initial state of the radio button
  63988. * @param onValueChanged defines the callback to call when value changes
  63989. * @returns a StackPanel containing the radio button and a textBlock
  63990. */
  63991. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63992. }
  63993. }
  63994. declare module BABYLON.GUI {
  63995. /**
  63996. * Class used to create slider controls
  63997. */
  63998. export class BaseSlider extends Control {
  63999. name?: string | undefined;
  64000. protected _thumbWidth: ValueAndUnit;
  64001. private _minimum;
  64002. private _maximum;
  64003. private _value;
  64004. private _isVertical;
  64005. protected _barOffset: ValueAndUnit;
  64006. private _isThumbClamped;
  64007. protected _displayThumb: boolean;
  64008. private _step;
  64009. private _lastPointerDownID;
  64010. protected _effectiveBarOffset: number;
  64011. protected _renderLeft: number;
  64012. protected _renderTop: number;
  64013. protected _renderWidth: number;
  64014. protected _renderHeight: number;
  64015. protected _backgroundBoxLength: number;
  64016. protected _backgroundBoxThickness: number;
  64017. protected _effectiveThumbThickness: number;
  64018. /** BABYLON.Observable raised when the sldier value changes */
  64019. onValueChangedObservable: BABYLON.Observable<number>;
  64020. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64021. displayThumb: boolean;
  64022. /** Gets or sets a step to apply to values (0 by default) */
  64023. step: number;
  64024. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64025. barOffset: string | number;
  64026. /** Gets main bar offset in pixels*/
  64027. readonly barOffsetInPixels: number;
  64028. /** Gets or sets thumb width */
  64029. thumbWidth: string | number;
  64030. /** Gets thumb width in pixels */
  64031. readonly thumbWidthInPixels: number;
  64032. /** Gets or sets minimum value */
  64033. minimum: number;
  64034. /** Gets or sets maximum value */
  64035. maximum: number;
  64036. /** Gets or sets current value */
  64037. value: number;
  64038. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64039. isVertical: boolean;
  64040. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64041. isThumbClamped: boolean;
  64042. /**
  64043. * Creates a new BaseSlider
  64044. * @param name defines the control name
  64045. */
  64046. constructor(name?: string | undefined);
  64047. protected _getTypeName(): string;
  64048. protected _getThumbPosition(): number;
  64049. protected _getThumbThickness(type: string): number;
  64050. protected _prepareRenderingData(type: string): void;
  64051. private _pointerIsDown;
  64052. /** @hidden */
  64053. 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;
  64054. }
  64055. }
  64056. declare module BABYLON.GUI {
  64057. /**
  64058. * Class used to create slider controls
  64059. */
  64060. export class Slider extends BaseSlider {
  64061. name?: string | undefined;
  64062. private _background;
  64063. private _borderColor;
  64064. private _isThumbCircle;
  64065. protected _displayValueBar: boolean;
  64066. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64067. displayValueBar: boolean;
  64068. /** Gets or sets border color */
  64069. borderColor: string;
  64070. /** Gets or sets background color */
  64071. background: string;
  64072. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64073. isThumbCircle: boolean;
  64074. /**
  64075. * Creates a new Slider
  64076. * @param name defines the control name
  64077. */
  64078. constructor(name?: string | undefined);
  64079. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64080. }
  64081. }
  64082. declare module BABYLON.GUI {
  64083. /** Class used to create a RadioGroup
  64084. * which contains groups of radio buttons
  64085. */
  64086. export class SelectorGroup {
  64087. /** name of SelectorGroup */
  64088. name: string;
  64089. private _groupPanel;
  64090. private _selectors;
  64091. private _groupHeader;
  64092. /**
  64093. * Creates a new SelectorGroup
  64094. * @param name of group, used as a group heading
  64095. */
  64096. constructor(
  64097. /** name of SelectorGroup */
  64098. name: string);
  64099. /** Gets the groupPanel of the SelectorGroup */
  64100. readonly groupPanel: StackPanel;
  64101. /** Gets the selectors array */
  64102. readonly selectors: StackPanel[];
  64103. /** Gets and sets the group header */
  64104. header: string;
  64105. /** @hidden */
  64106. private _addGroupHeader;
  64107. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  64108. /** Removes the selector at the given position
  64109. * @param selectorNb the position of the selector within the group
  64110. */
  64111. removeSelector(selectorNb: number): void;
  64112. }
  64113. /** Class used to create a CheckboxGroup
  64114. * which contains groups of checkbox buttons
  64115. */
  64116. export class CheckboxGroup extends SelectorGroup {
  64117. /** Adds a checkbox as a control
  64118. * @param text is the label for the selector
  64119. * @param func is the function called when the Selector is checked
  64120. * @param checked is true when Selector is checked
  64121. */
  64122. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64123. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64124. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64125. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64126. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64127. }
  64128. /** Class used to create a RadioGroup
  64129. * which contains groups of radio buttons
  64130. */
  64131. export class RadioGroup extends SelectorGroup {
  64132. private _selectNb;
  64133. /** Adds a radio button as a control
  64134. * @param label is the label for the selector
  64135. * @param func is the function called when the Selector is checked
  64136. * @param checked is true when Selector is checked
  64137. */
  64138. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64139. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64140. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64141. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64142. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64143. }
  64144. /** Class used to create a SliderGroup
  64145. * which contains groups of slider buttons
  64146. */
  64147. export class SliderGroup extends SelectorGroup {
  64148. /**
  64149. * Adds a slider to the SelectorGroup
  64150. * @param label is the label for the SliderBar
  64151. * @param func is the function called when the Slider moves
  64152. * @param unit is a string describing the units used, eg degrees or metres
  64153. * @param min is the minimum value for the Slider
  64154. * @param max is the maximum value for the Slider
  64155. * @param value is the start value for the Slider between min and max
  64156. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64157. */
  64158. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64159. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  64160. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  64161. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  64162. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64163. }
  64164. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64165. * @see http://doc.babylonjs.com/how_to/selector
  64166. */
  64167. export class SelectionPanel extends Rectangle {
  64168. /** name of SelectionPanel */
  64169. name: string;
  64170. /** an array of SelectionGroups */
  64171. groups: SelectorGroup[];
  64172. private _panel;
  64173. private _buttonColor;
  64174. private _buttonBackground;
  64175. private _headerColor;
  64176. private _barColor;
  64177. private _barHeight;
  64178. private _spacerHeight;
  64179. private _labelColor;
  64180. private _groups;
  64181. private _bars;
  64182. /**
  64183. * Creates a new SelectionPanel
  64184. * @param name of SelectionPanel
  64185. * @param groups is an array of SelectionGroups
  64186. */
  64187. constructor(
  64188. /** name of SelectionPanel */
  64189. name: string,
  64190. /** an array of SelectionGroups */
  64191. groups?: SelectorGroup[]);
  64192. protected _getTypeName(): string;
  64193. /** Gets or sets the headerColor */
  64194. headerColor: string;
  64195. private _setHeaderColor;
  64196. /** Gets or sets the button color */
  64197. buttonColor: string;
  64198. private _setbuttonColor;
  64199. /** Gets or sets the label color */
  64200. labelColor: string;
  64201. private _setLabelColor;
  64202. /** Gets or sets the button background */
  64203. buttonBackground: string;
  64204. private _setButtonBackground;
  64205. /** Gets or sets the color of separator bar */
  64206. barColor: string;
  64207. private _setBarColor;
  64208. /** Gets or sets the height of separator bar */
  64209. barHeight: string;
  64210. private _setBarHeight;
  64211. /** Gets or sets the height of spacers*/
  64212. spacerHeight: string;
  64213. private _setSpacerHeight;
  64214. /** Adds a bar between groups */
  64215. private _addSpacer;
  64216. /** Add a group to the selection panel
  64217. * @param group is the selector group to add
  64218. */
  64219. addGroup(group: SelectorGroup): void;
  64220. /** Remove the group from the given position
  64221. * @param groupNb is the position of the group in the list
  64222. */
  64223. removeGroup(groupNb: number): void;
  64224. /** Change a group header label
  64225. * @param label is the new group header label
  64226. * @param groupNb is the number of the group to relabel
  64227. * */
  64228. setHeaderName(label: string, groupNb: number): void;
  64229. /** Change selector label to the one given
  64230. * @param label is the new selector label
  64231. * @param groupNb is the number of the groupcontaining the selector
  64232. * @param selectorNb is the number of the selector within a group to relabel
  64233. * */
  64234. relabel(label: string, groupNb: number, selectorNb: number): void;
  64235. /** For a given group position remove the selector at the given position
  64236. * @param groupNb is the number of the group to remove the selector from
  64237. * @param selectorNb is the number of the selector within the group
  64238. */
  64239. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64240. /** For a given group position of correct type add a checkbox button
  64241. * @param groupNb is the number of the group to remove the selector from
  64242. * @param label is the label for the selector
  64243. * @param func is the function called when the Selector is checked
  64244. * @param checked is true when Selector is checked
  64245. */
  64246. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64247. /** For a given group position of correct type add a radio button
  64248. * @param groupNb is the number of the group to remove the selector from
  64249. * @param label is the label for the selector
  64250. * @param func is the function called when the Selector is checked
  64251. * @param checked is true when Selector is checked
  64252. */
  64253. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64254. /**
  64255. * For a given slider group add a slider
  64256. * @param groupNb is the number of the group to add the slider to
  64257. * @param label is the label for the Slider
  64258. * @param func is the function called when the Slider moves
  64259. * @param unit is a string describing the units used, eg degrees or metres
  64260. * @param min is the minimum value for the Slider
  64261. * @param max is the maximum value for the Slider
  64262. * @param value is the start value for the Slider between min and max
  64263. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64264. */
  64265. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64266. }
  64267. }
  64268. declare module BABYLON.GUI {
  64269. /**
  64270. * Class used to hold a the container for ScrollViewer
  64271. * @hidden
  64272. */
  64273. export class _ScrollViewerWindow extends Container {
  64274. parentClientWidth: number;
  64275. parentClientHeight: number;
  64276. /**
  64277. * Creates a new ScrollViewerWindow
  64278. * @param name of ScrollViewerWindow
  64279. */
  64280. constructor(name?: string);
  64281. protected _getTypeName(): string;
  64282. /** @hidden */
  64283. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64284. protected _postMeasure(): void;
  64285. }
  64286. }
  64287. declare module BABYLON.GUI {
  64288. /**
  64289. * Class used to create slider controls
  64290. */
  64291. export class ScrollBar extends BaseSlider {
  64292. name?: string | undefined;
  64293. private _background;
  64294. private _borderColor;
  64295. private _thumbMeasure;
  64296. /** Gets or sets border color */
  64297. borderColor: string;
  64298. /** Gets or sets background color */
  64299. background: string;
  64300. /**
  64301. * Creates a new Slider
  64302. * @param name defines the control name
  64303. */
  64304. constructor(name?: string | undefined);
  64305. protected _getTypeName(): string;
  64306. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  64307. private _first;
  64308. private _originX;
  64309. private _originY;
  64310. /** @hidden */
  64311. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64312. }
  64313. }
  64314. declare module BABYLON.GUI {
  64315. /**
  64316. * Class used to hold a viewer window and sliders in a grid
  64317. */
  64318. export class ScrollViewer extends Rectangle {
  64319. private _grid;
  64320. private _horizontalBarSpace;
  64321. private _verticalBarSpace;
  64322. private _dragSpace;
  64323. private _horizontalBar;
  64324. private _verticalBar;
  64325. private _barColor;
  64326. private _barBackground;
  64327. private _barSize;
  64328. private _endLeft;
  64329. private _endTop;
  64330. private _window;
  64331. private _pointerIsOver;
  64332. private _wheelPrecision;
  64333. private _onPointerObserver;
  64334. private _clientWidth;
  64335. private _clientHeight;
  64336. /**
  64337. * Gets the horizontal scrollbar
  64338. */
  64339. readonly horizontalBar: ScrollBar;
  64340. /**
  64341. * Gets the vertical scrollbar
  64342. */
  64343. readonly verticalBar: ScrollBar;
  64344. /**
  64345. * Adds a new control to the current container
  64346. * @param control defines the control to add
  64347. * @returns the current container
  64348. */
  64349. addControl(control: BABYLON.Nullable<Control>): Container;
  64350. /**
  64351. * Removes a control from the current container
  64352. * @param control defines the control to remove
  64353. * @returns the current container
  64354. */
  64355. removeControl(control: Control): Container;
  64356. /** Gets the list of children */
  64357. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  64358. /**
  64359. * Creates a new ScrollViewer
  64360. * @param name of ScrollViewer
  64361. */
  64362. constructor(name?: string);
  64363. /** Reset the scroll viewer window to initial size */
  64364. resetWindow(): void;
  64365. protected _getTypeName(): string;
  64366. private _buildClientSizes;
  64367. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64368. protected _postMeasure(): void;
  64369. /**
  64370. * Gets or sets the mouse wheel precision
  64371. * from 0 to 1 with a default value of 0.05
  64372. * */
  64373. wheelPrecision: number;
  64374. /** Gets or sets the bar color */
  64375. barColor: string;
  64376. /** Gets or sets the size of the bar */
  64377. barSize: number;
  64378. /** Gets or sets the bar background */
  64379. barBackground: string;
  64380. /** @hidden */
  64381. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  64382. /** @hidden */
  64383. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64384. /** Releases associated resources */
  64385. dispose(): void;
  64386. }
  64387. }
  64388. declare module BABYLON.GUI {
  64389. /** Class used to render a grid */
  64390. export class DisplayGrid extends Control {
  64391. name?: string | undefined;
  64392. private _cellWidth;
  64393. private _cellHeight;
  64394. private _minorLineTickness;
  64395. private _minorLineColor;
  64396. private _majorLineTickness;
  64397. private _majorLineColor;
  64398. private _majorLineFrequency;
  64399. private _background;
  64400. private _displayMajorLines;
  64401. private _displayMinorLines;
  64402. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64403. displayMinorLines: boolean;
  64404. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64405. displayMajorLines: boolean;
  64406. /** Gets or sets background color (Black by default) */
  64407. background: string;
  64408. /** Gets or sets the width of each cell (20 by default) */
  64409. cellWidth: number;
  64410. /** Gets or sets the height of each cell (20 by default) */
  64411. cellHeight: number;
  64412. /** Gets or sets the tickness of minor lines (1 by default) */
  64413. minorLineTickness: number;
  64414. /** Gets or sets the color of minor lines (DarkGray by default) */
  64415. minorLineColor: string;
  64416. /** Gets or sets the tickness of major lines (2 by default) */
  64417. majorLineTickness: number;
  64418. /** Gets or sets the color of major lines (White by default) */
  64419. majorLineColor: string;
  64420. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64421. majorLineFrequency: number;
  64422. /**
  64423. * Creates a new GridDisplayRectangle
  64424. * @param name defines the control name
  64425. */
  64426. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  64427. protected _getTypeName(): string;
  64428. }
  64429. }
  64430. declare module BABYLON.GUI {
  64431. /**
  64432. * Class used to create slider controls based on images
  64433. */
  64434. export class ImageBasedSlider extends BaseSlider {
  64435. name?: string | undefined;
  64436. private _backgroundImage;
  64437. private _thumbImage;
  64438. private _valueBarImage;
  64439. private _tempMeasure;
  64440. displayThumb: boolean;
  64441. /**
  64442. * Gets or sets the image used to render the background
  64443. */
  64444. backgroundImage: Image;
  64445. /**
  64446. * Gets or sets the image used to render the value bar
  64447. */
  64448. valueBarImage: Image;
  64449. /**
  64450. * Gets or sets the image used to render the thumb
  64451. */
  64452. thumbImage: Image;
  64453. /**
  64454. * Creates a new ImageBasedSlider
  64455. * @param name defines the control name
  64456. */
  64457. constructor(name?: string | undefined);
  64458. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  64459. }
  64460. }
  64461. declare module BABYLON.GUI {
  64462. /**
  64463. * Forcing an export so that this code will execute
  64464. * @hidden
  64465. */
  64466. const name = "Statics";
  64467. }
  64468. declare module BABYLON.GUI {
  64469. /**
  64470. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64471. */
  64472. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64473. /**
  64474. * Define the instrumented AdvancedDynamicTexture.
  64475. */
  64476. texture: AdvancedDynamicTexture;
  64477. private _captureRenderTime;
  64478. private _renderTime;
  64479. private _captureLayoutTime;
  64480. private _layoutTime;
  64481. private _onBeginRenderObserver;
  64482. private _onEndRenderObserver;
  64483. private _onBeginLayoutObserver;
  64484. private _onEndLayoutObserver;
  64485. /**
  64486. * Gets the perf counter used to capture render time
  64487. */
  64488. readonly renderTimeCounter: BABYLON.PerfCounter;
  64489. /**
  64490. * Gets the perf counter used to capture layout time
  64491. */
  64492. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64493. /**
  64494. * Enable or disable the render time capture
  64495. */
  64496. captureRenderTime: boolean;
  64497. /**
  64498. * Enable or disable the layout time capture
  64499. */
  64500. captureLayoutTime: boolean;
  64501. /**
  64502. * Instantiates a new advanced dynamic texture instrumentation.
  64503. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64504. * @param texture Defines the AdvancedDynamicTexture to instrument
  64505. */
  64506. constructor(
  64507. /**
  64508. * Define the instrumented AdvancedDynamicTexture.
  64509. */
  64510. texture: AdvancedDynamicTexture);
  64511. /**
  64512. * Dispose and release associated resources.
  64513. */
  64514. dispose(): void;
  64515. }
  64516. }
  64517. declare module BABYLON.GUI {
  64518. /**
  64519. * Class used to create containers for controls
  64520. */
  64521. export class Container3D extends Control3D {
  64522. private _blockLayout;
  64523. /**
  64524. * Gets the list of child controls
  64525. */
  64526. protected _children: Control3D[];
  64527. /**
  64528. * Gets the list of child controls
  64529. */
  64530. readonly children: Array<Control3D>;
  64531. /**
  64532. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  64533. * This is helpful to optimize layout operation when adding multiple children in a row
  64534. */
  64535. blockLayout: boolean;
  64536. /**
  64537. * Creates a new container
  64538. * @param name defines the container name
  64539. */
  64540. constructor(name?: string);
  64541. /**
  64542. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  64543. * @returns the current container
  64544. */
  64545. updateLayout(): Container3D;
  64546. /**
  64547. * Gets a boolean indicating if the given control is in the children of this control
  64548. * @param control defines the control to check
  64549. * @returns true if the control is in the child list
  64550. */
  64551. containsControl(control: Control3D): boolean;
  64552. /**
  64553. * Adds a control to the children of this control
  64554. * @param control defines the control to add
  64555. * @returns the current container
  64556. */
  64557. addControl(control: Control3D): Container3D;
  64558. /**
  64559. * This function will be called everytime a new control is added
  64560. */
  64561. protected _arrangeChildren(): void;
  64562. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64563. /**
  64564. * Removes a control from the children of this control
  64565. * @param control defines the control to remove
  64566. * @returns the current container
  64567. */
  64568. removeControl(control: Control3D): Container3D;
  64569. protected _getTypeName(): string;
  64570. /**
  64571. * Releases all associated resources
  64572. */
  64573. dispose(): void;
  64574. /** Control rotation will remain unchanged */
  64575. static readonly UNSET_ORIENTATION: number;
  64576. /** Control will rotate to make it look at sphere central axis */
  64577. static readonly FACEORIGIN_ORIENTATION: number;
  64578. /** Control will rotate to make it look back at sphere central axis */
  64579. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  64580. /** Control will rotate to look at z axis (0, 0, 1) */
  64581. static readonly FACEFORWARD_ORIENTATION: number;
  64582. /** Control will rotate to look at negative z axis (0, 0, -1) */
  64583. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  64584. }
  64585. }
  64586. declare module BABYLON.GUI {
  64587. /**
  64588. * Class used to manage 3D user interface
  64589. * @see http://doc.babylonjs.com/how_to/gui3d
  64590. */
  64591. export class GUI3DManager implements BABYLON.IDisposable {
  64592. private _scene;
  64593. private _sceneDisposeObserver;
  64594. private _utilityLayer;
  64595. private _rootContainer;
  64596. private _pointerObserver;
  64597. private _pointerOutObserver;
  64598. /** @hidden */ private _lastPickedControl: Control3D;
  64599. /** @hidden */ private _lastControlOver: {
  64600. [pointerId: number]: Control3D;
  64601. };
  64602. /** @hidden */ private _lastControlDown: {
  64603. [pointerId: number]: Control3D;
  64604. };
  64605. /**
  64606. * BABYLON.Observable raised when the point picked by the pointer events changed
  64607. */
  64608. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  64609. /** @hidden */ private _sharedMaterials: {
  64610. [key: string]: BABYLON.Material;
  64611. };
  64612. /** Gets the hosting scene */
  64613. readonly scene: BABYLON.Scene;
  64614. /** Gets associated utility layer */
  64615. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  64616. /**
  64617. * Creates a new GUI3DManager
  64618. * @param scene
  64619. */
  64620. constructor(scene?: BABYLON.Scene);
  64621. private _handlePointerOut;
  64622. private _doPicking;
  64623. /**
  64624. * Gets the root container
  64625. */
  64626. readonly rootContainer: Container3D;
  64627. /**
  64628. * Gets a boolean indicating if the given control is in the root child list
  64629. * @param control defines the control to check
  64630. * @returns true if the control is in the root child list
  64631. */
  64632. containsControl(control: Control3D): boolean;
  64633. /**
  64634. * Adds a control to the root child list
  64635. * @param control defines the control to add
  64636. * @returns the current manager
  64637. */
  64638. addControl(control: Control3D): GUI3DManager;
  64639. /**
  64640. * Removes a control from the root child list
  64641. * @param control defines the control to remove
  64642. * @returns the current container
  64643. */
  64644. removeControl(control: Control3D): GUI3DManager;
  64645. /**
  64646. * Releases all associated resources
  64647. */
  64648. dispose(): void;
  64649. }
  64650. }
  64651. declare module BABYLON.GUI {
  64652. /**
  64653. * Class used to transport BABYLON.Vector3 information for pointer events
  64654. */
  64655. export class Vector3WithInfo extends BABYLON.Vector3 {
  64656. /** defines the current mouse button index */
  64657. buttonIndex: number;
  64658. /**
  64659. * Creates a new Vector3WithInfo
  64660. * @param source defines the vector3 data to transport
  64661. * @param buttonIndex defines the current mouse button index
  64662. */
  64663. constructor(source: BABYLON.Vector3,
  64664. /** defines the current mouse button index */
  64665. buttonIndex?: number);
  64666. }
  64667. }
  64668. declare module BABYLON.GUI {
  64669. /**
  64670. * Class used as base class for controls
  64671. */
  64672. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  64673. /** Defines the control name */
  64674. name?: string | undefined;
  64675. /** @hidden */ private _host: GUI3DManager;
  64676. private _node;
  64677. private _downCount;
  64678. private _enterCount;
  64679. private _downPointerIds;
  64680. private _isVisible;
  64681. /** Gets or sets the control position in world space */
  64682. position: BABYLON.Vector3;
  64683. /** Gets or sets the control scaling in world space */
  64684. scaling: BABYLON.Vector3;
  64685. /** Callback used to start pointer enter animation */
  64686. pointerEnterAnimation: () => void;
  64687. /** Callback used to start pointer out animation */
  64688. pointerOutAnimation: () => void;
  64689. /** Callback used to start pointer down animation */
  64690. pointerDownAnimation: () => void;
  64691. /** Callback used to start pointer up animation */
  64692. pointerUpAnimation: () => void;
  64693. /**
  64694. * An event triggered when the pointer move over the control
  64695. */
  64696. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  64697. /**
  64698. * An event triggered when the pointer move out of the control
  64699. */
  64700. onPointerOutObservable: BABYLON.Observable<Control3D>;
  64701. /**
  64702. * An event triggered when the pointer taps the control
  64703. */
  64704. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  64705. /**
  64706. * An event triggered when pointer is up
  64707. */
  64708. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  64709. /**
  64710. * An event triggered when a control is clicked on (with a mouse)
  64711. */
  64712. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  64713. /**
  64714. * An event triggered when pointer enters the control
  64715. */
  64716. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  64717. /**
  64718. * Gets or sets the parent container
  64719. */
  64720. parent: BABYLON.Nullable<Container3D>;
  64721. private _behaviors;
  64722. /**
  64723. * Gets the list of attached behaviors
  64724. * @see http://doc.babylonjs.com/features/behaviour
  64725. */
  64726. readonly behaviors: BABYLON.Behavior<Control3D>[];
  64727. /**
  64728. * Attach a behavior to the control
  64729. * @see http://doc.babylonjs.com/features/behaviour
  64730. * @param behavior defines the behavior to attach
  64731. * @returns the current control
  64732. */
  64733. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64734. /**
  64735. * Remove an attached behavior
  64736. * @see http://doc.babylonjs.com/features/behaviour
  64737. * @param behavior defines the behavior to attach
  64738. * @returns the current control
  64739. */
  64740. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  64741. /**
  64742. * Gets an attached behavior by name
  64743. * @param name defines the name of the behavior to look for
  64744. * @see http://doc.babylonjs.com/features/behaviour
  64745. * @returns null if behavior was not found else the requested behavior
  64746. */
  64747. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  64748. /** Gets or sets a boolean indicating if the control is visible */
  64749. isVisible: boolean;
  64750. /**
  64751. * Creates a new control
  64752. * @param name defines the control name
  64753. */
  64754. constructor(
  64755. /** Defines the control name */
  64756. name?: string | undefined);
  64757. /**
  64758. * Gets a string representing the class name
  64759. */
  64760. readonly typeName: string;
  64761. /**
  64762. * Get the current class name of the control.
  64763. * @returns current class name
  64764. */
  64765. getClassName(): string;
  64766. protected _getTypeName(): string;
  64767. /**
  64768. * Gets the transform node used by this control
  64769. */
  64770. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  64771. /**
  64772. * Gets the mesh used to render this control
  64773. */
  64774. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64775. /**
  64776. * Link the control as child of the given node
  64777. * @param node defines the node to link to. Use null to unlink the control
  64778. * @returns the current control
  64779. */
  64780. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  64781. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  64782. /**
  64783. * Node creation.
  64784. * Can be overriden by children
  64785. * @param scene defines the scene where the node must be attached
  64786. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  64787. */
  64788. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  64789. /**
  64790. * Affect a material to the given mesh
  64791. * @param mesh defines the mesh which will represent the control
  64792. */
  64793. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64794. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  64795. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  64796. /** @hidden */ private _onPointerOut(target: Control3D): void;
  64797. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64798. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64799. /** @hidden */
  64800. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64801. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  64802. /** @hidden */ private _disposeNode(): void;
  64803. /**
  64804. * Releases all associated resources
  64805. */
  64806. dispose(): void;
  64807. }
  64808. }
  64809. declare module BABYLON.GUI {
  64810. /**
  64811. * Class used as a root to all buttons
  64812. */
  64813. export class AbstractButton3D extends Control3D {
  64814. /**
  64815. * Creates a new button
  64816. * @param name defines the control name
  64817. */
  64818. constructor(name?: string);
  64819. protected _getTypeName(): string;
  64820. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64821. }
  64822. }
  64823. declare module BABYLON.GUI {
  64824. /**
  64825. * Class used to create a button in 3D
  64826. */
  64827. export class Button3D extends AbstractButton3D {
  64828. /** @hidden */
  64829. protected _currentMaterial: BABYLON.Material;
  64830. private _facadeTexture;
  64831. private _content;
  64832. private _contentResolution;
  64833. private _contentScaleRatio;
  64834. /**
  64835. * Gets or sets the texture resolution used to render content (512 by default)
  64836. */
  64837. contentResolution: BABYLON.int;
  64838. /**
  64839. * Gets or sets the texture scale ratio used to render content (2 by default)
  64840. */
  64841. contentScaleRatio: number;
  64842. protected _disposeFacadeTexture(): void;
  64843. protected _resetContent(): void;
  64844. /**
  64845. * Creates a new button
  64846. * @param name defines the control name
  64847. */
  64848. constructor(name?: string);
  64849. /**
  64850. * Gets or sets the GUI 2D content used to display the button's facade
  64851. */
  64852. content: Control;
  64853. /**
  64854. * Apply the facade texture (created from the content property).
  64855. * This function can be overloaded by child classes
  64856. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64857. */
  64858. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64859. protected _getTypeName(): string;
  64860. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64861. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64862. /**
  64863. * Releases all associated resources
  64864. */
  64865. dispose(): void;
  64866. }
  64867. }
  64868. declare module BABYLON.GUI {
  64869. /**
  64870. * Abstract class used to create a container panel deployed on the surface of a volume
  64871. */
  64872. export abstract class VolumeBasedPanel extends Container3D {
  64873. private _columns;
  64874. private _rows;
  64875. private _rowThenColum;
  64876. private _orientation;
  64877. protected _cellWidth: number;
  64878. protected _cellHeight: number;
  64879. /**
  64880. * Gets or sets the distance between elements
  64881. */
  64882. margin: number;
  64883. /**
  64884. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64885. * | Value | Type | Description |
  64886. * | ----- | ----------------------------------- | ----------- |
  64887. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64888. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64889. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64890. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64891. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64892. */
  64893. orientation: number;
  64894. /**
  64895. * Gets or sets the number of columns requested (10 by default).
  64896. * The panel will automatically compute the number of rows based on number of child controls.
  64897. */
  64898. columns: BABYLON.int;
  64899. /**
  64900. * Gets or sets a the number of rows requested.
  64901. * The panel will automatically compute the number of columns based on number of child controls.
  64902. */
  64903. rows: BABYLON.int;
  64904. /**
  64905. * Creates new VolumeBasedPanel
  64906. */
  64907. constructor();
  64908. protected _arrangeChildren(): void;
  64909. /** Child classes must implement this function to provide correct control positioning */
  64910. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64911. /** Child classes can implement this function to provide additional processing */
  64912. protected _finalProcessing(): void;
  64913. }
  64914. }
  64915. declare module BABYLON.GUI {
  64916. /**
  64917. * Class used to create a container panel deployed on the surface of a cylinder
  64918. */
  64919. export class CylinderPanel extends VolumeBasedPanel {
  64920. private _radius;
  64921. /**
  64922. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64923. */
  64924. radius: BABYLON.float;
  64925. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64926. private _cylindricalMapping;
  64927. }
  64928. }
  64929. declare module BABYLON.GUI {
  64930. /** @hidden */
  64931. export var fluentVertexShader: {
  64932. name: string;
  64933. shader: string;
  64934. };
  64935. }
  64936. declare module BABYLON.GUI {
  64937. /** @hidden */
  64938. export var fluentPixelShader: {
  64939. name: string;
  64940. shader: string;
  64941. };
  64942. }
  64943. declare module BABYLON.GUI {
  64944. /** @hidden */
  64945. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64946. INNERGLOW: boolean;
  64947. BORDER: boolean;
  64948. HOVERLIGHT: boolean;
  64949. TEXTURE: boolean;
  64950. constructor();
  64951. }
  64952. /**
  64953. * Class used to render controls with fluent desgin
  64954. */
  64955. export class FluentMaterial extends BABYLON.PushMaterial {
  64956. /**
  64957. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64958. */
  64959. innerGlowColorIntensity: number;
  64960. /**
  64961. * Gets or sets the inner glow color (white by default)
  64962. */
  64963. innerGlowColor: BABYLON.Color3;
  64964. /**
  64965. * Gets or sets alpha value (default is 1.0)
  64966. */
  64967. alpha: number;
  64968. /**
  64969. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64970. */
  64971. albedoColor: BABYLON.Color3;
  64972. /**
  64973. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64974. */
  64975. renderBorders: boolean;
  64976. /**
  64977. * Gets or sets border width (default is 0.5)
  64978. */
  64979. borderWidth: number;
  64980. /**
  64981. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64982. */
  64983. edgeSmoothingValue: number;
  64984. /**
  64985. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64986. */
  64987. borderMinValue: number;
  64988. /**
  64989. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64990. */
  64991. renderHoverLight: boolean;
  64992. /**
  64993. * Gets or sets the radius used to render the hover light (default is 1.0)
  64994. */
  64995. hoverRadius: number;
  64996. /**
  64997. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64998. */
  64999. hoverColor: BABYLON.Color4;
  65000. /**
  65001. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65002. */
  65003. hoverPosition: BABYLON.Vector3;
  65004. private _albedoTexture;
  65005. /** Gets or sets the texture to use for albedo color */
  65006. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65007. /**
  65008. * Creates a new Fluent material
  65009. * @param name defines the name of the material
  65010. * @param scene defines the hosting scene
  65011. */
  65012. constructor(name: string, scene: BABYLON.Scene);
  65013. needAlphaBlending(): boolean;
  65014. needAlphaTesting(): boolean;
  65015. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65016. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65017. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65018. getActiveTextures(): BABYLON.BaseTexture[];
  65019. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65020. dispose(forceDisposeEffect?: boolean): void;
  65021. clone(name: string): FluentMaterial;
  65022. serialize(): any;
  65023. getClassName(): string;
  65024. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65025. }
  65026. }
  65027. declare module BABYLON.GUI {
  65028. /**
  65029. * Class used to create a holographic button in 3D
  65030. */
  65031. export class HolographicButton extends Button3D {
  65032. private _backPlate;
  65033. private _textPlate;
  65034. private _frontPlate;
  65035. private _text;
  65036. private _imageUrl;
  65037. private _shareMaterials;
  65038. private _frontMaterial;
  65039. private _backMaterial;
  65040. private _plateMaterial;
  65041. private _pickedPointObserver;
  65042. private _tooltipFade;
  65043. private _tooltipTextBlock;
  65044. private _tooltipTexture;
  65045. private _tooltipMesh;
  65046. private _tooltipHoverObserver;
  65047. private _tooltipOutObserver;
  65048. private _disposeTooltip;
  65049. /**
  65050. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65051. */
  65052. tooltipText: BABYLON.Nullable<string>;
  65053. /**
  65054. * Gets or sets text for the button
  65055. */
  65056. text: string;
  65057. /**
  65058. * Gets or sets the image url for the button
  65059. */
  65060. imageUrl: string;
  65061. /**
  65062. * Gets the back material used by this button
  65063. */
  65064. readonly backMaterial: FluentMaterial;
  65065. /**
  65066. * Gets the front material used by this button
  65067. */
  65068. readonly frontMaterial: FluentMaterial;
  65069. /**
  65070. * Gets the plate material used by this button
  65071. */
  65072. readonly plateMaterial: BABYLON.StandardMaterial;
  65073. /**
  65074. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65075. */
  65076. readonly shareMaterials: boolean;
  65077. /**
  65078. * Creates a new button
  65079. * @param name defines the control name
  65080. */
  65081. constructor(name?: string, shareMaterials?: boolean);
  65082. protected _getTypeName(): string;
  65083. private _rebuildContent;
  65084. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65085. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65086. private _createBackMaterial;
  65087. private _createFrontMaterial;
  65088. private _createPlateMaterial;
  65089. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65090. /**
  65091. * Releases all associated resources
  65092. */
  65093. dispose(): void;
  65094. }
  65095. }
  65096. declare module BABYLON.GUI {
  65097. /**
  65098. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65099. */
  65100. export class MeshButton3D extends Button3D {
  65101. /** @hidden */
  65102. protected _currentMesh: BABYLON.Mesh;
  65103. /**
  65104. * Creates a new 3D button based on a mesh
  65105. * @param mesh mesh to become a 3D button
  65106. * @param name defines the control name
  65107. */
  65108. constructor(mesh: BABYLON.Mesh, name?: string);
  65109. protected _getTypeName(): string;
  65110. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65111. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65112. }
  65113. }
  65114. declare module BABYLON.GUI {
  65115. /**
  65116. * Class used to create a container panel deployed on the surface of a plane
  65117. */
  65118. export class PlanePanel extends VolumeBasedPanel {
  65119. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65120. }
  65121. }
  65122. declare module BABYLON.GUI {
  65123. /**
  65124. * Class used to create a container panel where items get randomized planar mapping
  65125. */
  65126. export class ScatterPanel extends VolumeBasedPanel {
  65127. private _iteration;
  65128. /**
  65129. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65130. */
  65131. iteration: BABYLON.float;
  65132. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65133. private _scatterMapping;
  65134. protected _finalProcessing(): void;
  65135. }
  65136. }
  65137. declare module BABYLON.GUI {
  65138. /**
  65139. * Class used to create a container panel deployed on the surface of a sphere
  65140. */
  65141. export class SpherePanel extends VolumeBasedPanel {
  65142. private _radius;
  65143. /**
  65144. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65145. */
  65146. radius: BABYLON.float;
  65147. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65148. private _sphericalMapping;
  65149. }
  65150. }
  65151. declare module BABYLON.GUI {
  65152. /**
  65153. * Class used to create a stack panel in 3D on XY plane
  65154. */
  65155. export class StackPanel3D extends Container3D {
  65156. private _isVertical;
  65157. /**
  65158. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65159. */
  65160. isVertical: boolean;
  65161. /**
  65162. * Gets or sets the distance between elements
  65163. */
  65164. margin: number;
  65165. /**
  65166. * Creates new StackPanel
  65167. * @param isVertical
  65168. */
  65169. constructor(isVertical?: boolean);
  65170. protected _arrangeChildren(): void;
  65171. }
  65172. }
  65173. declare module BABYLON {
  65174. /**
  65175. * Mode that determines the coordinate system to use.
  65176. */
  65177. export enum GLTFLoaderCoordinateSystemMode {
  65178. /**
  65179. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65180. */
  65181. AUTO = 0,
  65182. /**
  65183. * Sets the useRightHandedSystem flag on the scene.
  65184. */
  65185. FORCE_RIGHT_HANDED = 1
  65186. }
  65187. /**
  65188. * Mode that determines what animations will start.
  65189. */
  65190. export enum GLTFLoaderAnimationStartMode {
  65191. /**
  65192. * No animation will start.
  65193. */
  65194. NONE = 0,
  65195. /**
  65196. * The first animation will start.
  65197. */
  65198. FIRST = 1,
  65199. /**
  65200. * All animations will start.
  65201. */
  65202. ALL = 2
  65203. }
  65204. /**
  65205. * Interface that contains the data for the glTF asset.
  65206. */
  65207. export interface IGLTFLoaderData {
  65208. /**
  65209. * Object that represents the glTF JSON.
  65210. */
  65211. json: Object;
  65212. /**
  65213. * The BIN chunk of a binary glTF.
  65214. */
  65215. bin: Nullable<ArrayBufferView>;
  65216. }
  65217. /**
  65218. * Interface for extending the loader.
  65219. */
  65220. export interface IGLTFLoaderExtension {
  65221. /**
  65222. * The name of this extension.
  65223. */
  65224. readonly name: string;
  65225. /**
  65226. * Defines whether this extension is enabled.
  65227. */
  65228. enabled: boolean;
  65229. }
  65230. /**
  65231. * Loader state.
  65232. */
  65233. export enum GLTFLoaderState {
  65234. /**
  65235. * The asset is loading.
  65236. */
  65237. LOADING = 0,
  65238. /**
  65239. * The asset is ready for rendering.
  65240. */
  65241. READY = 1,
  65242. /**
  65243. * The asset is completely loaded.
  65244. */
  65245. COMPLETE = 2
  65246. }
  65247. /** @hidden */
  65248. export interface IGLTFLoader extends IDisposable {
  65249. readonly state: Nullable<GLTFLoaderState>;
  65250. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65251. meshes: AbstractMesh[];
  65252. particleSystems: IParticleSystem[];
  65253. skeletons: Skeleton[];
  65254. animationGroups: AnimationGroup[];
  65255. }>;
  65256. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65257. }
  65258. /**
  65259. * File loader for loading glTF files into a scene.
  65260. */
  65261. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65262. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65263. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65264. /**
  65265. * Raised when the asset has been parsed
  65266. */
  65267. onParsedObservable: Observable<IGLTFLoaderData>;
  65268. private _onParsedObserver;
  65269. /**
  65270. * Raised when the asset has been parsed
  65271. */
  65272. onParsed: (loaderData: IGLTFLoaderData) => void;
  65273. /**
  65274. * 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.
  65275. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65276. * Defaults to true.
  65277. * @hidden
  65278. */
  65279. static IncrementalLoading: boolean;
  65280. /**
  65281. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65282. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65283. * @hidden
  65284. */
  65285. static HomogeneousCoordinates: boolean;
  65286. /**
  65287. * The coordinate system mode. Defaults to AUTO.
  65288. */
  65289. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65290. /**
  65291. * The animation start mode. Defaults to FIRST.
  65292. */
  65293. animationStartMode: GLTFLoaderAnimationStartMode;
  65294. /**
  65295. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65296. */
  65297. compileMaterials: boolean;
  65298. /**
  65299. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65300. */
  65301. useClipPlane: boolean;
  65302. /**
  65303. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65304. */
  65305. compileShadowGenerators: boolean;
  65306. /**
  65307. * Defines if the Alpha blended materials are only applied as coverage.
  65308. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65309. * If true, no extra effects are applied to transparent pixels.
  65310. */
  65311. transparencyAsCoverage: boolean;
  65312. /**
  65313. * Function called before loading a url referenced by the asset.
  65314. */
  65315. preprocessUrlAsync: (url: string) => Promise<string>;
  65316. /**
  65317. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65318. */
  65319. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65320. private _onMeshLoadedObserver;
  65321. /**
  65322. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65323. */
  65324. onMeshLoaded: (mesh: AbstractMesh) => void;
  65325. /**
  65326. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65327. */
  65328. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65329. private _onTextureLoadedObserver;
  65330. /**
  65331. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65332. */
  65333. onTextureLoaded: (texture: BaseTexture) => void;
  65334. /**
  65335. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65336. */
  65337. readonly onMaterialLoadedObservable: Observable<Material>;
  65338. private _onMaterialLoadedObserver;
  65339. /**
  65340. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65341. */
  65342. onMaterialLoaded: (material: Material) => void;
  65343. /**
  65344. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65345. */
  65346. readonly onCameraLoadedObservable: Observable<Camera>;
  65347. private _onCameraLoadedObserver;
  65348. /**
  65349. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65350. */
  65351. onCameraLoaded: (camera: Camera) => void;
  65352. /**
  65353. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65354. * For assets with LODs, raised when all of the LODs are complete.
  65355. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65356. */
  65357. readonly onCompleteObservable: Observable<void>;
  65358. private _onCompleteObserver;
  65359. /**
  65360. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65361. * For assets with LODs, raised when all of the LODs are complete.
  65362. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65363. */
  65364. onComplete: () => void;
  65365. /**
  65366. * Observable raised when an error occurs.
  65367. */
  65368. readonly onErrorObservable: Observable<any>;
  65369. private _onErrorObserver;
  65370. /**
  65371. * Callback raised when an error occurs.
  65372. */
  65373. onError: (reason: any) => void;
  65374. /**
  65375. * Observable raised after the loader is disposed.
  65376. */
  65377. readonly onDisposeObservable: Observable<void>;
  65378. private _onDisposeObserver;
  65379. /**
  65380. * Callback raised after the loader is disposed.
  65381. */
  65382. onDispose: () => void;
  65383. /**
  65384. * Observable raised after a loader extension is created.
  65385. * Set additional options for a loader extension in this event.
  65386. */
  65387. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65388. private _onExtensionLoadedObserver;
  65389. /**
  65390. * Callback raised after a loader extension is created.
  65391. */
  65392. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65393. /**
  65394. * Defines if the loader logging is enabled.
  65395. */
  65396. loggingEnabled: boolean;
  65397. /**
  65398. * Defines if the loader should capture performance counters.
  65399. */
  65400. capturePerformanceCounters: boolean;
  65401. /**
  65402. * Defines if the loader should validate the asset.
  65403. */
  65404. validate: boolean;
  65405. /**
  65406. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65407. */
  65408. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65409. private _onValidatedObserver;
  65410. /**
  65411. * Callback raised after a loader extension is created.
  65412. */
  65413. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65414. private _loader;
  65415. /**
  65416. * Name of the loader ("gltf")
  65417. */
  65418. name: string;
  65419. /**
  65420. * Supported file extensions of the loader (.gltf, .glb)
  65421. */
  65422. extensions: ISceneLoaderPluginExtensions;
  65423. /**
  65424. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65425. */
  65426. dispose(): void;
  65427. /** @hidden */ private _clear(): void;
  65428. /**
  65429. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65430. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65431. * @param scene the scene the meshes should be added to
  65432. * @param data the glTF data to load
  65433. * @param rootUrl root url to load from
  65434. * @param onProgress event that fires when loading progress has occured
  65435. * @param fileName Defines the name of the file to load
  65436. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65437. */
  65438. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65439. meshes: AbstractMesh[];
  65440. particleSystems: IParticleSystem[];
  65441. skeletons: Skeleton[];
  65442. animationGroups: AnimationGroup[];
  65443. }>;
  65444. /**
  65445. * Imports all objects from the loaded glTF data and adds them to the scene
  65446. * @param scene the scene the objects should be added to
  65447. * @param data the glTF data to load
  65448. * @param rootUrl root url to load from
  65449. * @param onProgress event that fires when loading progress has occured
  65450. * @param fileName Defines the name of the file to load
  65451. * @returns a promise which completes when objects have been loaded to the scene
  65452. */
  65453. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65454. /**
  65455. * Load into an asset container.
  65456. * @param scene The scene to load into
  65457. * @param data The data to import
  65458. * @param rootUrl The root url for scene and resources
  65459. * @param onProgress The callback when the load progresses
  65460. * @param fileName Defines the name of the file to load
  65461. * @returns The loaded asset container
  65462. */
  65463. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65464. /**
  65465. * If the data string can be loaded directly.
  65466. * @param data string contianing the file data
  65467. * @returns if the data can be loaded directly
  65468. */
  65469. canDirectLoad(data: string): boolean;
  65470. /**
  65471. * Rewrites a url by combining a root url and response url.
  65472. */
  65473. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65474. /**
  65475. * Instantiates a glTF file loader plugin.
  65476. * @returns the created plugin
  65477. */
  65478. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65479. /**
  65480. * The loader state or null if the loader is not active.
  65481. */
  65482. readonly loaderState: Nullable<GLTFLoaderState>;
  65483. /**
  65484. * Returns a promise that resolves when the asset is completely loaded.
  65485. * @returns a promise that resolves when the asset is completely loaded.
  65486. */
  65487. whenCompleteAsync(): Promise<void>;
  65488. private _parseAsync;
  65489. private _validateAsync;
  65490. private _getLoader;
  65491. private _unpackBinary;
  65492. private _unpackBinaryV1;
  65493. private _unpackBinaryV2;
  65494. private static _parseVersion;
  65495. private static _compareVersion;
  65496. private static _decodeBufferToText;
  65497. private static readonly _logSpaces;
  65498. private _logIndentLevel;
  65499. private _loggingEnabled;
  65500. /** @hidden */ private _log: (message: string) => void;
  65501. /** @hidden */ private _logOpen(message: string): void;
  65502. /** @hidden */ private _logClose(): void;
  65503. private _logEnabled;
  65504. private _logDisabled;
  65505. private _capturePerformanceCounters;
  65506. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  65507. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  65508. private _startPerformanceCounterEnabled;
  65509. private _startPerformanceCounterDisabled;
  65510. private _endPerformanceCounterEnabled;
  65511. private _endPerformanceCounterDisabled;
  65512. }
  65513. }
  65514. declare module BABYLON.GLTF1 {
  65515. /**
  65516. * Enums
  65517. * @hidden
  65518. */
  65519. export enum EComponentType {
  65520. BYTE = 5120,
  65521. UNSIGNED_BYTE = 5121,
  65522. SHORT = 5122,
  65523. UNSIGNED_SHORT = 5123,
  65524. FLOAT = 5126
  65525. }
  65526. /** @hidden */
  65527. export enum EShaderType {
  65528. FRAGMENT = 35632,
  65529. VERTEX = 35633
  65530. }
  65531. /** @hidden */
  65532. export enum EParameterType {
  65533. BYTE = 5120,
  65534. UNSIGNED_BYTE = 5121,
  65535. SHORT = 5122,
  65536. UNSIGNED_SHORT = 5123,
  65537. INT = 5124,
  65538. UNSIGNED_INT = 5125,
  65539. FLOAT = 5126,
  65540. FLOAT_VEC2 = 35664,
  65541. FLOAT_VEC3 = 35665,
  65542. FLOAT_VEC4 = 35666,
  65543. INT_VEC2 = 35667,
  65544. INT_VEC3 = 35668,
  65545. INT_VEC4 = 35669,
  65546. BOOL = 35670,
  65547. BOOL_VEC2 = 35671,
  65548. BOOL_VEC3 = 35672,
  65549. BOOL_VEC4 = 35673,
  65550. FLOAT_MAT2 = 35674,
  65551. FLOAT_MAT3 = 35675,
  65552. FLOAT_MAT4 = 35676,
  65553. SAMPLER_2D = 35678
  65554. }
  65555. /** @hidden */
  65556. export enum ETextureWrapMode {
  65557. CLAMP_TO_EDGE = 33071,
  65558. MIRRORED_REPEAT = 33648,
  65559. REPEAT = 10497
  65560. }
  65561. /** @hidden */
  65562. export enum ETextureFilterType {
  65563. NEAREST = 9728,
  65564. LINEAR = 9728,
  65565. NEAREST_MIPMAP_NEAREST = 9984,
  65566. LINEAR_MIPMAP_NEAREST = 9985,
  65567. NEAREST_MIPMAP_LINEAR = 9986,
  65568. LINEAR_MIPMAP_LINEAR = 9987
  65569. }
  65570. /** @hidden */
  65571. export enum ETextureFormat {
  65572. ALPHA = 6406,
  65573. RGB = 6407,
  65574. RGBA = 6408,
  65575. LUMINANCE = 6409,
  65576. LUMINANCE_ALPHA = 6410
  65577. }
  65578. /** @hidden */
  65579. export enum ECullingType {
  65580. FRONT = 1028,
  65581. BACK = 1029,
  65582. FRONT_AND_BACK = 1032
  65583. }
  65584. /** @hidden */
  65585. export enum EBlendingFunction {
  65586. ZERO = 0,
  65587. ONE = 1,
  65588. SRC_COLOR = 768,
  65589. ONE_MINUS_SRC_COLOR = 769,
  65590. DST_COLOR = 774,
  65591. ONE_MINUS_DST_COLOR = 775,
  65592. SRC_ALPHA = 770,
  65593. ONE_MINUS_SRC_ALPHA = 771,
  65594. DST_ALPHA = 772,
  65595. ONE_MINUS_DST_ALPHA = 773,
  65596. CONSTANT_COLOR = 32769,
  65597. ONE_MINUS_CONSTANT_COLOR = 32770,
  65598. CONSTANT_ALPHA = 32771,
  65599. ONE_MINUS_CONSTANT_ALPHA = 32772,
  65600. SRC_ALPHA_SATURATE = 776
  65601. }
  65602. /** @hidden */
  65603. export interface IGLTFProperty {
  65604. extensions?: {
  65605. [key: string]: any;
  65606. };
  65607. extras?: Object;
  65608. }
  65609. /** @hidden */
  65610. export interface IGLTFChildRootProperty extends IGLTFProperty {
  65611. name?: string;
  65612. }
  65613. /** @hidden */
  65614. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65615. bufferView: string;
  65616. byteOffset: number;
  65617. byteStride: number;
  65618. count: number;
  65619. type: string;
  65620. componentType: EComponentType;
  65621. max?: number[];
  65622. min?: number[];
  65623. name?: string;
  65624. }
  65625. /** @hidden */
  65626. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  65627. buffer: string;
  65628. byteOffset: number;
  65629. byteLength: number;
  65630. byteStride: number;
  65631. target?: number;
  65632. }
  65633. /** @hidden */
  65634. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  65635. uri: string;
  65636. byteLength?: number;
  65637. type?: string;
  65638. }
  65639. /** @hidden */
  65640. export interface IGLTFShader extends IGLTFChildRootProperty {
  65641. uri: string;
  65642. type: EShaderType;
  65643. }
  65644. /** @hidden */
  65645. export interface IGLTFProgram extends IGLTFChildRootProperty {
  65646. attributes: string[];
  65647. fragmentShader: string;
  65648. vertexShader: string;
  65649. }
  65650. /** @hidden */
  65651. export interface IGLTFTechniqueParameter {
  65652. type: number;
  65653. count?: number;
  65654. semantic?: string;
  65655. node?: string;
  65656. value?: number | boolean | string | Array<any>;
  65657. source?: string;
  65658. babylonValue?: any;
  65659. }
  65660. /** @hidden */
  65661. export interface IGLTFTechniqueCommonProfile {
  65662. lightingModel: string;
  65663. texcoordBindings: Object;
  65664. parameters?: Array<any>;
  65665. }
  65666. /** @hidden */
  65667. export interface IGLTFTechniqueStatesFunctions {
  65668. blendColor?: number[];
  65669. blendEquationSeparate?: number[];
  65670. blendFuncSeparate?: number[];
  65671. colorMask: boolean[];
  65672. cullFace: number[];
  65673. }
  65674. /** @hidden */
  65675. export interface IGLTFTechniqueStates {
  65676. enable: number[];
  65677. functions: IGLTFTechniqueStatesFunctions;
  65678. }
  65679. /** @hidden */
  65680. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  65681. parameters: {
  65682. [key: string]: IGLTFTechniqueParameter;
  65683. };
  65684. program: string;
  65685. attributes: {
  65686. [key: string]: string;
  65687. };
  65688. uniforms: {
  65689. [key: string]: string;
  65690. };
  65691. states: IGLTFTechniqueStates;
  65692. }
  65693. /** @hidden */
  65694. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  65695. technique?: string;
  65696. values: string[];
  65697. }
  65698. /** @hidden */
  65699. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  65700. attributes: {
  65701. [key: string]: string;
  65702. };
  65703. indices: string;
  65704. material: string;
  65705. mode?: number;
  65706. }
  65707. /** @hidden */
  65708. export interface IGLTFMesh extends IGLTFChildRootProperty {
  65709. primitives: IGLTFMeshPrimitive[];
  65710. }
  65711. /** @hidden */
  65712. export interface IGLTFImage extends IGLTFChildRootProperty {
  65713. uri: string;
  65714. }
  65715. /** @hidden */
  65716. export interface IGLTFSampler extends IGLTFChildRootProperty {
  65717. magFilter?: number;
  65718. minFilter?: number;
  65719. wrapS?: number;
  65720. wrapT?: number;
  65721. }
  65722. /** @hidden */
  65723. export interface IGLTFTexture extends IGLTFChildRootProperty {
  65724. sampler: string;
  65725. source: string;
  65726. format?: ETextureFormat;
  65727. internalFormat?: ETextureFormat;
  65728. target?: number;
  65729. type?: number;
  65730. babylonTexture?: Texture;
  65731. }
  65732. /** @hidden */
  65733. export interface IGLTFAmbienLight {
  65734. color?: number[];
  65735. }
  65736. /** @hidden */
  65737. export interface IGLTFDirectionalLight {
  65738. color?: number[];
  65739. }
  65740. /** @hidden */
  65741. export interface IGLTFPointLight {
  65742. color?: number[];
  65743. constantAttenuation?: number;
  65744. linearAttenuation?: number;
  65745. quadraticAttenuation?: number;
  65746. }
  65747. /** @hidden */
  65748. export interface IGLTFSpotLight {
  65749. color?: number[];
  65750. constantAttenuation?: number;
  65751. fallOfAngle?: number;
  65752. fallOffExponent?: number;
  65753. linearAttenuation?: number;
  65754. quadraticAttenuation?: number;
  65755. }
  65756. /** @hidden */
  65757. export interface IGLTFLight extends IGLTFChildRootProperty {
  65758. type: string;
  65759. }
  65760. /** @hidden */
  65761. export interface IGLTFCameraOrthographic {
  65762. xmag: number;
  65763. ymag: number;
  65764. zfar: number;
  65765. znear: number;
  65766. }
  65767. /** @hidden */
  65768. export interface IGLTFCameraPerspective {
  65769. aspectRatio: number;
  65770. yfov: number;
  65771. zfar: number;
  65772. znear: number;
  65773. }
  65774. /** @hidden */
  65775. export interface IGLTFCamera extends IGLTFChildRootProperty {
  65776. type: string;
  65777. }
  65778. /** @hidden */
  65779. export interface IGLTFAnimationChannelTarget {
  65780. id: string;
  65781. path: string;
  65782. }
  65783. /** @hidden */
  65784. export interface IGLTFAnimationChannel {
  65785. sampler: string;
  65786. target: IGLTFAnimationChannelTarget;
  65787. }
  65788. /** @hidden */
  65789. export interface IGLTFAnimationSampler {
  65790. input: string;
  65791. output: string;
  65792. interpolation?: string;
  65793. }
  65794. /** @hidden */
  65795. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  65796. channels?: IGLTFAnimationChannel[];
  65797. parameters?: {
  65798. [key: string]: string;
  65799. };
  65800. samplers?: {
  65801. [key: string]: IGLTFAnimationSampler;
  65802. };
  65803. }
  65804. /** @hidden */
  65805. export interface IGLTFNodeInstanceSkin {
  65806. skeletons: string[];
  65807. skin: string;
  65808. meshes: string[];
  65809. }
  65810. /** @hidden */
  65811. export interface IGLTFSkins extends IGLTFChildRootProperty {
  65812. bindShapeMatrix: number[];
  65813. inverseBindMatrices: string;
  65814. jointNames: string[];
  65815. babylonSkeleton?: Skeleton;
  65816. }
  65817. /** @hidden */
  65818. export interface IGLTFNode extends IGLTFChildRootProperty {
  65819. camera?: string;
  65820. children: string[];
  65821. skin?: string;
  65822. jointName?: string;
  65823. light?: string;
  65824. matrix: number[];
  65825. mesh?: string;
  65826. meshes?: string[];
  65827. rotation?: number[];
  65828. scale?: number[];
  65829. translation?: number[];
  65830. babylonNode?: Node;
  65831. }
  65832. /** @hidden */
  65833. export interface IGLTFScene extends IGLTFChildRootProperty {
  65834. nodes: string[];
  65835. }
  65836. /** @hidden */
  65837. export interface IGLTFRuntime {
  65838. extensions: {
  65839. [key: string]: any;
  65840. };
  65841. accessors: {
  65842. [key: string]: IGLTFAccessor;
  65843. };
  65844. buffers: {
  65845. [key: string]: IGLTFBuffer;
  65846. };
  65847. bufferViews: {
  65848. [key: string]: IGLTFBufferView;
  65849. };
  65850. meshes: {
  65851. [key: string]: IGLTFMesh;
  65852. };
  65853. lights: {
  65854. [key: string]: IGLTFLight;
  65855. };
  65856. cameras: {
  65857. [key: string]: IGLTFCamera;
  65858. };
  65859. nodes: {
  65860. [key: string]: IGLTFNode;
  65861. };
  65862. images: {
  65863. [key: string]: IGLTFImage;
  65864. };
  65865. textures: {
  65866. [key: string]: IGLTFTexture;
  65867. };
  65868. shaders: {
  65869. [key: string]: IGLTFShader;
  65870. };
  65871. programs: {
  65872. [key: string]: IGLTFProgram;
  65873. };
  65874. samplers: {
  65875. [key: string]: IGLTFSampler;
  65876. };
  65877. techniques: {
  65878. [key: string]: IGLTFTechnique;
  65879. };
  65880. materials: {
  65881. [key: string]: IGLTFMaterial;
  65882. };
  65883. animations: {
  65884. [key: string]: IGLTFAnimation;
  65885. };
  65886. skins: {
  65887. [key: string]: IGLTFSkins;
  65888. };
  65889. currentScene?: Object;
  65890. scenes: {
  65891. [key: string]: IGLTFScene;
  65892. };
  65893. extensionsUsed: string[];
  65894. extensionsRequired?: string[];
  65895. buffersCount: number;
  65896. shaderscount: number;
  65897. scene: Scene;
  65898. rootUrl: string;
  65899. loadedBufferCount: number;
  65900. loadedBufferViews: {
  65901. [name: string]: ArrayBufferView;
  65902. };
  65903. loadedShaderCount: number;
  65904. importOnlyMeshes: boolean;
  65905. importMeshesNames?: string[];
  65906. dummyNodes: Node[];
  65907. }
  65908. /** @hidden */
  65909. export interface INodeToRoot {
  65910. bone: Bone;
  65911. node: IGLTFNode;
  65912. id: string;
  65913. }
  65914. /** @hidden */
  65915. export interface IJointNode {
  65916. node: IGLTFNode;
  65917. id: string;
  65918. }
  65919. }
  65920. declare module BABYLON.GLTF1 {
  65921. /**
  65922. * Utils functions for GLTF
  65923. * @hidden
  65924. */
  65925. export class GLTFUtils {
  65926. /**
  65927. * Sets the given "parameter" matrix
  65928. * @param scene: the Scene object
  65929. * @param source: the source node where to pick the matrix
  65930. * @param parameter: the GLTF technique parameter
  65931. * @param uniformName: the name of the shader's uniform
  65932. * @param shaderMaterial: the shader material
  65933. */
  65934. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65935. /**
  65936. * Sets the given "parameter" matrix
  65937. * @param shaderMaterial: the shader material
  65938. * @param uniform: the name of the shader's uniform
  65939. * @param value: the value of the uniform
  65940. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65941. */
  65942. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65943. /**
  65944. * Returns the wrap mode of the texture
  65945. * @param mode: the mode value
  65946. */
  65947. static GetWrapMode(mode: number): number;
  65948. /**
  65949. * Returns the byte stride giving an accessor
  65950. * @param accessor: the GLTF accessor objet
  65951. */
  65952. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65953. /**
  65954. * Returns the texture filter mode giving a mode value
  65955. * @param mode: the filter mode value
  65956. */
  65957. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65958. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65959. /**
  65960. * Returns a buffer from its accessor
  65961. * @param gltfRuntime: the GLTF runtime
  65962. * @param accessor: the GLTF accessor
  65963. */
  65964. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65965. /**
  65966. * Decodes a buffer view into a string
  65967. * @param view: the buffer view
  65968. */
  65969. static DecodeBufferToText(view: ArrayBufferView): string;
  65970. /**
  65971. * Returns the default material of gltf. Related to
  65972. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65973. * @param scene: the Babylon.js scene
  65974. */
  65975. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65976. private static _DefaultMaterial;
  65977. }
  65978. }
  65979. declare module BABYLON.GLTF1 {
  65980. /**
  65981. * Implementation of the base glTF spec
  65982. * @hidden
  65983. */
  65984. export class GLTFLoaderBase {
  65985. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65986. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65987. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65988. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65989. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65990. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65991. }
  65992. /**
  65993. * glTF V1 Loader
  65994. * @hidden
  65995. */
  65996. export class GLTFLoader implements IGLTFLoader {
  65997. static Extensions: {
  65998. [name: string]: GLTFLoaderExtension;
  65999. };
  66000. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66001. state: Nullable<GLTFLoaderState>;
  66002. dispose(): void;
  66003. private _importMeshAsync;
  66004. /**
  66005. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66006. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66007. * @param scene the scene the meshes should be added to
  66008. * @param data gltf data containing information of the meshes in a loaded file
  66009. * @param rootUrl root url to load from
  66010. * @param onProgress event that fires when loading progress has occured
  66011. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66012. */
  66013. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66014. meshes: AbstractMesh[];
  66015. particleSystems: IParticleSystem[];
  66016. skeletons: Skeleton[];
  66017. animationGroups: AnimationGroup[];
  66018. }>;
  66019. private _loadAsync;
  66020. /**
  66021. * Imports all objects from a loaded gltf file and adds them to the scene
  66022. * @param scene the scene the objects should be added to
  66023. * @param data gltf data containing information of the meshes in a loaded file
  66024. * @param rootUrl root url to load from
  66025. * @param onProgress event that fires when loading progress has occured
  66026. * @returns a promise which completes when objects have been loaded to the scene
  66027. */
  66028. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66029. private _loadShadersAsync;
  66030. private _loadBuffersAsync;
  66031. private _createNodes;
  66032. }
  66033. /** @hidden */
  66034. export abstract class GLTFLoaderExtension {
  66035. private _name;
  66036. constructor(name: string);
  66037. readonly name: string;
  66038. /**
  66039. * Defines an override for loading the runtime
  66040. * Return true to stop further extensions from loading the runtime
  66041. */
  66042. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66043. /**
  66044. * Defines an onverride for creating gltf runtime
  66045. * Return true to stop further extensions from creating the runtime
  66046. */
  66047. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66048. /**
  66049. * Defines an override for loading buffers
  66050. * Return true to stop further extensions from loading this buffer
  66051. */
  66052. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66053. /**
  66054. * Defines an override for loading texture buffers
  66055. * Return true to stop further extensions from loading this texture data
  66056. */
  66057. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66058. /**
  66059. * Defines an override for creating textures
  66060. * Return true to stop further extensions from loading this texture
  66061. */
  66062. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66063. /**
  66064. * Defines an override for loading shader strings
  66065. * Return true to stop further extensions from loading this shader data
  66066. */
  66067. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66068. /**
  66069. * Defines an override for loading materials
  66070. * Return true to stop further extensions from loading this material
  66071. */
  66072. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66073. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66074. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66075. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66076. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66077. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66078. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66079. private static LoadTextureBufferAsync;
  66080. private static CreateTextureAsync;
  66081. private static ApplyExtensions;
  66082. }
  66083. }
  66084. declare module BABYLON.GLTF1 {
  66085. /** @hidden */
  66086. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66087. private _bin;
  66088. constructor();
  66089. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66090. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66091. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66092. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66093. }
  66094. }
  66095. declare module BABYLON.GLTF1 {
  66096. /** @hidden */
  66097. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66098. constructor();
  66099. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66100. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66101. private _loadTexture;
  66102. }
  66103. }
  66104. declare module BABYLON.GLTF2.Loader {
  66105. /**
  66106. * Loader interface with an index field.
  66107. */
  66108. export interface IArrayItem {
  66109. /**
  66110. * The index of this item in the array.
  66111. */
  66112. index: number;
  66113. }
  66114. /**
  66115. * Loader interface with additional members.
  66116. */
  66117. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66118. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66119. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  66120. }
  66121. /**
  66122. * Loader interface with additional members.
  66123. */
  66124. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66125. }
  66126. /** @hidden */
  66127. export interface _IAnimationSamplerData {
  66128. input: Float32Array;
  66129. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66130. output: Float32Array;
  66131. }
  66132. /**
  66133. * Loader interface with additional members.
  66134. */
  66135. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66136. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  66137. }
  66138. /**
  66139. * Loader interface with additional members.
  66140. */
  66141. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66142. channels: IAnimationChannel[];
  66143. samplers: IAnimationSampler[];
  66144. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  66145. }
  66146. /**
  66147. * Loader interface with additional members.
  66148. */
  66149. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66150. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66151. }
  66152. /**
  66153. * Loader interface with additional members.
  66154. */
  66155. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66156. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66157. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  66158. }
  66159. /**
  66160. * Loader interface with additional members.
  66161. */
  66162. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66163. }
  66164. /**
  66165. * Loader interface with additional members.
  66166. */
  66167. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66168. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  66169. }
  66170. /**
  66171. * Loader interface with additional members.
  66172. */
  66173. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66174. }
  66175. /**
  66176. * Loader interface with additional members.
  66177. */
  66178. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66179. }
  66180. /**
  66181. * Loader interface with additional members.
  66182. */
  66183. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66184. baseColorTexture?: ITextureInfo;
  66185. metallicRoughnessTexture?: ITextureInfo;
  66186. }
  66187. /**
  66188. * Loader interface with additional members.
  66189. */
  66190. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66191. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66192. normalTexture?: IMaterialNormalTextureInfo;
  66193. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66194. emissiveTexture?: ITextureInfo;
  66195. /** @hidden */ private _data?: {
  66196. [babylonDrawMode: number]: {
  66197. babylonMaterial: Material;
  66198. babylonMeshes: AbstractMesh[];
  66199. promise: Promise<void>;
  66200. };
  66201. };
  66202. }
  66203. /**
  66204. * Loader interface with additional members.
  66205. */
  66206. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66207. primitives: IMeshPrimitive[];
  66208. }
  66209. /**
  66210. * Loader interface with additional members.
  66211. */
  66212. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66213. /** @hidden */ private _instanceData?: {
  66214. babylonSourceMesh: Mesh;
  66215. promise: Promise<any>;
  66216. };
  66217. }
  66218. /**
  66219. * Loader interface with additional members.
  66220. */
  66221. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66222. /**
  66223. * The parent glTF node.
  66224. */
  66225. parent?: INode;
  66226. /** @hidden */ private _babylonTransformNode?: TransformNode;
  66227. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  66228. /** @hidden */ private _babylonBones?: Bone[];
  66229. /** @hidden */ private _numMorphTargets?: number;
  66230. }
  66231. /** @hidden */
  66232. export interface _ISamplerData {
  66233. noMipMaps: boolean;
  66234. samplingMode: number;
  66235. wrapU: number;
  66236. wrapV: number;
  66237. }
  66238. /**
  66239. * Loader interface with additional members.
  66240. */
  66241. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66242. /** @hidden */ private _data?: _ISamplerData;
  66243. }
  66244. /**
  66245. * Loader interface with additional members.
  66246. */
  66247. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66248. }
  66249. /**
  66250. * Loader interface with additional members.
  66251. */
  66252. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66253. /** @hidden */ private _data?: {
  66254. babylonSkeleton: Skeleton;
  66255. promise: Promise<void>;
  66256. };
  66257. }
  66258. /**
  66259. * Loader interface with additional members.
  66260. */
  66261. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66262. }
  66263. /**
  66264. * Loader interface with additional members.
  66265. */
  66266. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66267. }
  66268. /**
  66269. * Loader interface with additional members.
  66270. */
  66271. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66272. accessors?: IAccessor[];
  66273. animations?: IAnimation[];
  66274. buffers?: IBuffer[];
  66275. bufferViews?: IBufferView[];
  66276. cameras?: ICamera[];
  66277. images?: IImage[];
  66278. materials?: IMaterial[];
  66279. meshes?: IMesh[];
  66280. nodes?: INode[];
  66281. samplers?: ISampler[];
  66282. scenes?: IScene[];
  66283. skins?: ISkin[];
  66284. textures?: ITexture[];
  66285. }
  66286. }
  66287. declare module BABYLON.GLTF2 {
  66288. /**
  66289. * Interface for a glTF loader extension.
  66290. */
  66291. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66292. /**
  66293. * Called after the loader state changes to LOADING.
  66294. */
  66295. onLoading?(): void;
  66296. /**
  66297. * Called after the loader state changes to READY.
  66298. */
  66299. onReady?(): void;
  66300. /**
  66301. * Define this method to modify the default behavior when loading scenes.
  66302. * @param context The context when loading the asset
  66303. * @param scene The glTF scene property
  66304. * @returns A promise that resolves when the load is complete or null if not handled
  66305. */
  66306. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66307. /**
  66308. * Define this method to modify the default behavior when loading nodes.
  66309. * @param context The context when loading the asset
  66310. * @param node The glTF node property
  66311. * @param assign A function called synchronously after parsing the glTF properties
  66312. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66313. */
  66314. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66315. /**
  66316. * Define this method to modify the default behavior when loading cameras.
  66317. * @param context The context when loading the asset
  66318. * @param camera The glTF camera property
  66319. * @param assign A function called synchronously after parsing the glTF properties
  66320. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66321. */
  66322. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66323. /**
  66324. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66325. * @param context The context when loading the asset
  66326. * @param primitive The glTF mesh primitive property
  66327. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66328. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66329. /**
  66330. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66331. * @param context The context when loading the asset
  66332. * @param name The mesh name when loading the asset
  66333. * @param node The glTF node when loading the asset
  66334. * @param mesh The glTF mesh when loading the asset
  66335. * @param primitive The glTF mesh primitive property
  66336. * @param assign A function called synchronously after parsing the glTF properties
  66337. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66338. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66339. /**
  66340. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66341. * @param context The context when loading the asset
  66342. * @param material The glTF material property
  66343. * @param assign A function called synchronously after parsing the glTF properties
  66344. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66345. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66346. /**
  66347. * Define this method to modify the default behavior when creating materials.
  66348. * @param context The context when loading the asset
  66349. * @param material The glTF material property
  66350. * @param babylonDrawMode The draw mode for the Babylon material
  66351. * @returns The Babylon material or null if not handled
  66352. */
  66353. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66354. /**
  66355. * Define this method to modify the default behavior when loading material properties.
  66356. * @param context The context when loading the asset
  66357. * @param material The glTF material property
  66358. * @param babylonMaterial The Babylon material
  66359. * @returns A promise that resolves when the load is complete or null if not handled
  66360. */
  66361. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66362. /**
  66363. * Define this method to modify the default behavior when loading texture infos.
  66364. * @param context The context when loading the asset
  66365. * @param textureInfo The glTF texture info property
  66366. * @param assign A function called synchronously after parsing the glTF properties
  66367. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66368. */
  66369. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66370. /**
  66371. * Define this method to modify the default behavior when loading animations.
  66372. * @param context The context when loading the asset
  66373. * @param animation The glTF animation property
  66374. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66375. */
  66376. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66377. /**
  66378. * @hidden Define this method to modify the default behavior when loading skins.
  66379. * @param context The context when loading the asset
  66380. * @param node The glTF node property
  66381. * @param skin The glTF skin property
  66382. * @returns A promise that resolves when the load is complete or null if not handled
  66383. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66384. /**
  66385. * @hidden Define this method to modify the default behavior when loading uris.
  66386. * @param context The context when loading the asset
  66387. * @param property The glTF property associated with the uri
  66388. * @param uri The uri to load
  66389. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66390. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66391. }
  66392. }
  66393. declare module BABYLON.GLTF2 {
  66394. /**
  66395. * Helper class for working with arrays when loading the glTF asset
  66396. */
  66397. export class ArrayItem {
  66398. /**
  66399. * Gets an item from the given array.
  66400. * @param context The context when loading the asset
  66401. * @param array The array to get the item from
  66402. * @param index The index to the array
  66403. * @returns The array item
  66404. */
  66405. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66406. /**
  66407. * Assign an `index` field to each item of the given array.
  66408. * @param array The array of items
  66409. */
  66410. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66411. }
  66412. /**
  66413. * The glTF 2.0 loader
  66414. */
  66415. export class GLTFLoader implements IGLTFLoader {
  66416. /** @hidden */ private _completePromises: Promise<any>[];
  66417. private _disposed;
  66418. private _parent;
  66419. private _state;
  66420. private _extensions;
  66421. private _rootUrl;
  66422. private _fileName;
  66423. private _uniqueRootUrl;
  66424. private _gltf;
  66425. private _babylonScene;
  66426. private _rootBabylonMesh;
  66427. private _defaultBabylonMaterialData;
  66428. private _progressCallback?;
  66429. private _requests;
  66430. private static readonly _DefaultSampler;
  66431. private static _ExtensionNames;
  66432. private static _ExtensionFactories;
  66433. /**
  66434. * Registers a loader extension.
  66435. * @param name The name of the loader extension.
  66436. * @param factory The factory function that creates the loader extension.
  66437. */
  66438. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66439. /**
  66440. * Unregisters a loader extension.
  66441. * @param name The name of the loader extenion.
  66442. * @returns A boolean indicating whether the extension has been unregistered
  66443. */
  66444. static UnregisterExtension(name: string): boolean;
  66445. /**
  66446. * Gets the loader state.
  66447. */
  66448. readonly state: Nullable<GLTFLoaderState>;
  66449. /**
  66450. * The glTF object parsed from the JSON.
  66451. */
  66452. readonly gltf: IGLTF;
  66453. /**
  66454. * The Babylon scene when loading the asset.
  66455. */
  66456. readonly babylonScene: Scene;
  66457. /**
  66458. * The root Babylon mesh when loading the asset.
  66459. */
  66460. readonly rootBabylonMesh: Mesh;
  66461. /** @hidden */
  66462. constructor(parent: GLTFFileLoader);
  66463. /** @hidden */
  66464. dispose(): void;
  66465. /** @hidden */
  66466. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66467. meshes: AbstractMesh[];
  66468. particleSystems: IParticleSystem[];
  66469. skeletons: Skeleton[];
  66470. animationGroups: AnimationGroup[];
  66471. }>;
  66472. /** @hidden */
  66473. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66474. private _loadAsync;
  66475. private _loadData;
  66476. private _setupData;
  66477. private _loadExtensions;
  66478. private _checkExtensions;
  66479. private _setState;
  66480. private _createRootNode;
  66481. /**
  66482. * Loads a glTF scene.
  66483. * @param context The context when loading the asset
  66484. * @param scene The glTF scene property
  66485. * @returns A promise that resolves when the load is complete
  66486. */
  66487. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  66488. private _forEachPrimitive;
  66489. private _getMeshes;
  66490. private _getSkeletons;
  66491. private _getAnimationGroups;
  66492. private _startAnimations;
  66493. /**
  66494. * Loads a glTF node.
  66495. * @param context The context when loading the asset
  66496. * @param node The glTF node property
  66497. * @param assign A function called synchronously after parsing the glTF properties
  66498. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  66499. */
  66500. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  66501. private _loadMeshAsync;
  66502. /**
  66503. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66504. * @param context The context when loading the asset
  66505. * @param name The mesh name when loading the asset
  66506. * @param node The glTF node when loading the asset
  66507. * @param mesh The glTF mesh when loading the asset
  66508. * @param primitive The glTF mesh primitive property
  66509. * @param assign A function called synchronously after parsing the glTF properties
  66510. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66511. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66512. private _loadVertexDataAsync;
  66513. private _createMorphTargets;
  66514. private _loadMorphTargetsAsync;
  66515. private _loadMorphTargetVertexDataAsync;
  66516. private static _LoadTransform;
  66517. private _loadSkinAsync;
  66518. private _loadBones;
  66519. private _loadBone;
  66520. private _loadSkinInverseBindMatricesDataAsync;
  66521. private _updateBoneMatrices;
  66522. private _getNodeMatrix;
  66523. /**
  66524. * Loads a glTF camera.
  66525. * @param context The context when loading the asset
  66526. * @param camera The glTF camera property
  66527. * @param assign A function called synchronously after parsing the glTF properties
  66528. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  66529. */
  66530. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  66531. private _loadAnimationsAsync;
  66532. /**
  66533. * Loads a glTF animation.
  66534. * @param context The context when loading the asset
  66535. * @param animation The glTF animation property
  66536. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  66537. */
  66538. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  66539. /**
  66540. * @hidden Loads a glTF animation channel.
  66541. * @param context The context when loading the asset
  66542. * @param animationContext The context of the animation when loading the asset
  66543. * @param animation The glTF animation property
  66544. * @param channel The glTF animation channel property
  66545. * @param babylonAnimationGroup The babylon animation group property
  66546. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  66547. * @returns A void promise when the channel load is complete
  66548. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  66549. private _loadAnimationSamplerAsync;
  66550. private _loadBufferAsync;
  66551. /**
  66552. * Loads a glTF buffer view.
  66553. * @param context The context when loading the asset
  66554. * @param bufferView The glTF buffer view property
  66555. * @returns A promise that resolves with the loaded data when the load is complete
  66556. */
  66557. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  66558. private _loadAccessorAsync;
  66559. private _loadFloatAccessorAsync;
  66560. private _loadIndicesAccessorAsync;
  66561. private _loadVertexBufferViewAsync;
  66562. private _loadVertexAccessorAsync;
  66563. private _loadMaterialMetallicRoughnessPropertiesAsync;
  66564. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  66565. private _createDefaultMaterial;
  66566. /**
  66567. * Creates a Babylon material from a glTF material.
  66568. * @param context The context when loading the asset
  66569. * @param material The glTF material property
  66570. * @param babylonDrawMode The draw mode for the Babylon material
  66571. * @returns The Babylon material
  66572. */
  66573. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  66574. /**
  66575. * Loads properties from a glTF material into a Babylon material.
  66576. * @param context The context when loading the asset
  66577. * @param material The glTF material property
  66578. * @param babylonMaterial The Babylon material
  66579. * @returns A promise that resolves when the load is complete
  66580. */
  66581. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66582. /**
  66583. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  66584. * @param context The context when loading the asset
  66585. * @param material The glTF material property
  66586. * @param babylonMaterial The Babylon material
  66587. * @returns A promise that resolves when the load is complete
  66588. */
  66589. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  66590. /**
  66591. * Loads the alpha properties from a glTF material into a Babylon material.
  66592. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  66593. * @param context The context when loading the asset
  66594. * @param material The glTF material property
  66595. * @param babylonMaterial The Babylon material
  66596. */
  66597. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  66598. /**
  66599. * Loads a glTF texture info.
  66600. * @param context The context when loading the asset
  66601. * @param textureInfo The glTF texture info property
  66602. * @param assign A function called synchronously after parsing the glTF properties
  66603. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  66604. */
  66605. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  66606. private _loadTextureAsync;
  66607. private _loadSampler;
  66608. /**
  66609. * Loads a glTF image.
  66610. * @param context The context when loading the asset
  66611. * @param image The glTF image property
  66612. * @returns A promise that resolves with the loaded data when the load is complete
  66613. */
  66614. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  66615. /**
  66616. * Loads a glTF uri.
  66617. * @param context The context when loading the asset
  66618. * @param property The glTF property associated with the uri
  66619. * @param uri The base64 or relative uri
  66620. * @returns A promise that resolves with the loaded data when the load is complete
  66621. */
  66622. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  66623. private _onProgress;
  66624. /**
  66625. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  66626. * @param babylonObject the Babylon object with metadata
  66627. * @param pointer the JSON pointer
  66628. */
  66629. static AddPointerMetadata(babylonObject: {
  66630. metadata: any;
  66631. }, pointer: string): void;
  66632. private static _GetTextureWrapMode;
  66633. private static _GetTextureSamplingMode;
  66634. private static _GetTypedArrayConstructor;
  66635. private static _GetTypedArray;
  66636. private static _GetNumComponents;
  66637. private static _ValidateUri;
  66638. private static _GetDrawMode;
  66639. private _compileMaterialsAsync;
  66640. private _compileShadowGeneratorsAsync;
  66641. private _forEachExtensions;
  66642. private _applyExtensions;
  66643. private _extensionsOnLoading;
  66644. private _extensionsOnReady;
  66645. private _extensionsLoadSceneAsync;
  66646. private _extensionsLoadNodeAsync;
  66647. private _extensionsLoadCameraAsync;
  66648. private _extensionsLoadVertexDataAsync;
  66649. private _extensionsLoadMeshPrimitiveAsync;
  66650. private _extensionsLoadMaterialAsync;
  66651. private _extensionsCreateMaterial;
  66652. private _extensionsLoadMaterialPropertiesAsync;
  66653. private _extensionsLoadTextureInfoAsync;
  66654. private _extensionsLoadAnimationAsync;
  66655. private _extensionsLoadSkinAsync;
  66656. private _extensionsLoadUriAsync;
  66657. /**
  66658. * Helper method called by a loader extension to load an glTF extension.
  66659. * @param context The context when loading the asset
  66660. * @param property The glTF property to load the extension from
  66661. * @param extensionName The name of the extension to load
  66662. * @param actionAsync The action to run
  66663. * @returns The promise returned by actionAsync or null if the extension does not exist
  66664. */
  66665. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66666. /**
  66667. * Helper method called by a loader extension to load a glTF extra.
  66668. * @param context The context when loading the asset
  66669. * @param property The glTF property to load the extra from
  66670. * @param extensionName The name of the extension to load
  66671. * @param actionAsync The action to run
  66672. * @returns The promise returned by actionAsync or null if the extra does not exist
  66673. */
  66674. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  66675. /**
  66676. * Increments the indentation level and logs a message.
  66677. * @param message The message to log
  66678. */
  66679. logOpen(message: string): void;
  66680. /**
  66681. * Decrements the indentation level.
  66682. */
  66683. logClose(): void;
  66684. /**
  66685. * Logs a message
  66686. * @param message The message to log
  66687. */
  66688. log(message: string): void;
  66689. /**
  66690. * Starts a performance counter.
  66691. * @param counterName The name of the performance counter
  66692. */
  66693. startPerformanceCounter(counterName: string): void;
  66694. /**
  66695. * Ends a performance counter.
  66696. * @param counterName The name of the performance counter
  66697. */
  66698. endPerformanceCounter(counterName: string): void;
  66699. }
  66700. }
  66701. declare module BABYLON.GLTF2.Loader.Extensions {
  66702. /**
  66703. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  66704. */
  66705. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  66706. /** The name of this extension. */
  66707. readonly name: string;
  66708. /** Defines whether this extension is enabled. */
  66709. enabled: boolean;
  66710. private _loader;
  66711. private _lights?;
  66712. /** @hidden */
  66713. constructor(loader: GLTFLoader);
  66714. /** @hidden */
  66715. dispose(): void;
  66716. /** @hidden */
  66717. onLoading(): void;
  66718. /** @hidden */
  66719. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66720. private _loadLightAsync;
  66721. }
  66722. }
  66723. declare module BABYLON.GLTF2.Loader.Extensions {
  66724. /**
  66725. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  66726. */
  66727. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  66728. /** The name of this extension. */
  66729. readonly name: string;
  66730. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  66731. dracoCompression?: DracoCompression;
  66732. /** Defines whether this extension is enabled. */
  66733. enabled: boolean;
  66734. private _loader;
  66735. /** @hidden */
  66736. constructor(loader: GLTFLoader);
  66737. /** @hidden */
  66738. dispose(): void;
  66739. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66740. }
  66741. }
  66742. declare module BABYLON.GLTF2.Loader.Extensions {
  66743. /**
  66744. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  66745. */
  66746. export class KHR_lights implements IGLTFLoaderExtension {
  66747. /** The name of this extension. */
  66748. readonly name: string;
  66749. /** Defines whether this extension is enabled. */
  66750. enabled: boolean;
  66751. private _loader;
  66752. private _lights?;
  66753. /** @hidden */
  66754. constructor(loader: GLTFLoader);
  66755. /** @hidden */
  66756. dispose(): void;
  66757. /** @hidden */
  66758. onLoading(): void;
  66759. /** @hidden */
  66760. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66761. }
  66762. }
  66763. declare module BABYLON.GLTF2.Loader.Extensions {
  66764. /**
  66765. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  66766. */
  66767. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  66768. /** The name of this extension. */
  66769. readonly name: string;
  66770. /** Defines whether this extension is enabled. */
  66771. enabled: boolean;
  66772. private _loader;
  66773. /** @hidden */
  66774. constructor(loader: GLTFLoader);
  66775. /** @hidden */
  66776. dispose(): void;
  66777. /** @hidden */
  66778. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66779. private _loadSpecularGlossinessPropertiesAsync;
  66780. }
  66781. }
  66782. declare module BABYLON.GLTF2.Loader.Extensions {
  66783. /**
  66784. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  66785. */
  66786. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  66787. /** The name of this extension. */
  66788. readonly name: string;
  66789. /** Defines whether this extension is enabled. */
  66790. enabled: boolean;
  66791. private _loader;
  66792. /** @hidden */
  66793. constructor(loader: GLTFLoader);
  66794. /** @hidden */
  66795. dispose(): void;
  66796. /** @hidden */
  66797. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66798. private _loadUnlitPropertiesAsync;
  66799. }
  66800. }
  66801. declare module BABYLON.GLTF2.Loader.Extensions {
  66802. /**
  66803. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  66804. */
  66805. export class KHR_texture_transform implements IGLTFLoaderExtension {
  66806. /** The name of this extension. */
  66807. readonly name: string;
  66808. /** Defines whether this extension is enabled. */
  66809. enabled: boolean;
  66810. private _loader;
  66811. /** @hidden */
  66812. constructor(loader: GLTFLoader);
  66813. /** @hidden */
  66814. dispose(): void;
  66815. /** @hidden */
  66816. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66817. }
  66818. }
  66819. declare module BABYLON.GLTF2.Loader.Extensions {
  66820. /**
  66821. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  66822. */
  66823. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66824. /** The name of this extension. */
  66825. readonly name: string;
  66826. /** Defines whether this extension is enabled. */
  66827. enabled: boolean;
  66828. private _loader;
  66829. private _clips;
  66830. private _emitters;
  66831. /** @hidden */
  66832. constructor(loader: GLTFLoader);
  66833. /** @hidden */
  66834. dispose(): void;
  66835. /** @hidden */
  66836. onLoading(): void;
  66837. /** @hidden */
  66838. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66839. /** @hidden */
  66840. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66841. /** @hidden */
  66842. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66843. private _loadClipAsync;
  66844. private _loadEmitterAsync;
  66845. private _getEventAction;
  66846. private _loadAnimationEventAsync;
  66847. }
  66848. }
  66849. declare module BABYLON.GLTF2.Loader.Extensions {
  66850. /**
  66851. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66852. */
  66853. export class MSFT_lod implements IGLTFLoaderExtension {
  66854. /** The name of this extension. */
  66855. readonly name: string;
  66856. /** Defines whether this extension is enabled. */
  66857. enabled: boolean;
  66858. /**
  66859. * Maximum number of LODs to load, starting from the lowest LOD.
  66860. */
  66861. maxLODsToLoad: number;
  66862. /**
  66863. * Observable raised when all node LODs of one level are loaded.
  66864. * The event data is the index of the loaded LOD starting from zero.
  66865. * Dispose the loader to cancel the loading of the next level of LODs.
  66866. */
  66867. onNodeLODsLoadedObservable: Observable<number>;
  66868. /**
  66869. * Observable raised when all material LODs of one level are loaded.
  66870. * The event data is the index of the loaded LOD starting from zero.
  66871. * Dispose the loader to cancel the loading of the next level of LODs.
  66872. */
  66873. onMaterialLODsLoadedObservable: Observable<number>;
  66874. private _loader;
  66875. private _nodeIndexLOD;
  66876. private _nodeSignalLODs;
  66877. private _nodePromiseLODs;
  66878. private _materialIndexLOD;
  66879. private _materialSignalLODs;
  66880. private _materialPromiseLODs;
  66881. /** @hidden */
  66882. constructor(loader: GLTFLoader);
  66883. /** @hidden */
  66884. dispose(): void;
  66885. /** @hidden */
  66886. onReady(): void;
  66887. /** @hidden */
  66888. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66889. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66890. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66891. /**
  66892. * Gets an array of LOD properties from lowest to highest.
  66893. */
  66894. private _getLODs;
  66895. private _disposeUnusedMaterials;
  66896. }
  66897. }
  66898. declare module BABYLON.GLTF2.Loader.Extensions {
  66899. /** @hidden */
  66900. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66901. readonly name: string;
  66902. enabled: boolean;
  66903. private _loader;
  66904. constructor(loader: GLTFLoader);
  66905. dispose(): void;
  66906. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66907. }
  66908. }
  66909. declare module BABYLON.GLTF2.Loader.Extensions {
  66910. /** @hidden */
  66911. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66912. readonly name: string;
  66913. enabled: boolean;
  66914. private _loader;
  66915. constructor(loader: GLTFLoader);
  66916. dispose(): void;
  66917. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66918. }
  66919. }
  66920. declare module BABYLON.GLTF2.Loader.Extensions {
  66921. /**
  66922. * Store glTF extras (if present) in BJS objects' metadata
  66923. */
  66924. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66925. /** The name of this extension. */
  66926. readonly name: string;
  66927. /** Defines whether this extension is enabled. */
  66928. enabled: boolean;
  66929. private _loader;
  66930. private _assignExtras;
  66931. /** @hidden */
  66932. constructor(loader: GLTFLoader);
  66933. /** @hidden */
  66934. dispose(): void;
  66935. /** @hidden */
  66936. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66937. /** @hidden */
  66938. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66939. /** @hidden */
  66940. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66941. }
  66942. }
  66943. declare module BABYLON {
  66944. /**
  66945. * Class reading and parsing the MTL file bundled with the obj file.
  66946. */
  66947. export class MTLFileLoader {
  66948. /**
  66949. * All material loaded from the mtl will be set here
  66950. */
  66951. materials: StandardMaterial[];
  66952. /**
  66953. * This function will read the mtl file and create each material described inside
  66954. * This function could be improve by adding :
  66955. * -some component missing (Ni, Tf...)
  66956. * -including the specific options available
  66957. *
  66958. * @param scene defines the scene the material will be created in
  66959. * @param data defines the mtl data to parse
  66960. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66961. */
  66962. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66963. /**
  66964. * Gets the texture for the material.
  66965. *
  66966. * If the material is imported from input file,
  66967. * We sanitize the url to ensure it takes the textre from aside the material.
  66968. *
  66969. * @param rootUrl The root url to load from
  66970. * @param value The value stored in the mtl
  66971. * @return The Texture
  66972. */
  66973. private static _getTexture;
  66974. }
  66975. /**
  66976. * Options for loading OBJ/MTL files
  66977. */
  66978. type MeshLoadOptions = {
  66979. /**
  66980. * Defines if UVs are optimized by default during load.
  66981. */
  66982. OptimizeWithUV: boolean;
  66983. /**
  66984. * Defines custom scaling of UV coordinates of loaded meshes.
  66985. */
  66986. UVScaling: Vector2;
  66987. /**
  66988. * Invert model on y-axis (does a model scaling inversion)
  66989. */
  66990. InvertY: boolean;
  66991. /**
  66992. * Invert Y-Axis of referenced textures on load
  66993. */
  66994. InvertTextureY: boolean;
  66995. /**
  66996. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66997. */
  66998. ImportVertexColors: boolean;
  66999. /**
  67000. * Compute the normals for the model, even if normals are present in the file.
  67001. */
  67002. ComputeNormals: boolean;
  67003. /**
  67004. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67005. */
  67006. SkipMaterials: boolean;
  67007. /**
  67008. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67009. */
  67010. MaterialLoadingFailsSilently: boolean;
  67011. };
  67012. /**
  67013. * OBJ file type loader.
  67014. * This is a babylon scene loader plugin.
  67015. */
  67016. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67017. /**
  67018. * Defines if UVs are optimized by default during load.
  67019. */
  67020. static OPTIMIZE_WITH_UV: boolean;
  67021. /**
  67022. * Invert model on y-axis (does a model scaling inversion)
  67023. */
  67024. static INVERT_Y: boolean;
  67025. /**
  67026. * Invert Y-Axis of referenced textures on load
  67027. */
  67028. static INVERT_TEXTURE_Y: boolean;
  67029. /**
  67030. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67031. */
  67032. static IMPORT_VERTEX_COLORS: boolean;
  67033. /**
  67034. * Compute the normals for the model, even if normals are present in the file.
  67035. */
  67036. static COMPUTE_NORMALS: boolean;
  67037. /**
  67038. * Defines custom scaling of UV coordinates of loaded meshes.
  67039. */
  67040. static UV_SCALING: Vector2;
  67041. /**
  67042. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67043. */
  67044. static SKIP_MATERIALS: boolean;
  67045. /**
  67046. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67047. *
  67048. * Defaults to true for backwards compatibility.
  67049. */
  67050. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67051. /**
  67052. * Defines the name of the plugin.
  67053. */
  67054. name: string;
  67055. /**
  67056. * Defines the extension the plugin is able to load.
  67057. */
  67058. extensions: string;
  67059. /** @hidden */
  67060. obj: RegExp;
  67061. /** @hidden */
  67062. group: RegExp;
  67063. /** @hidden */
  67064. mtllib: RegExp;
  67065. /** @hidden */
  67066. usemtl: RegExp;
  67067. /** @hidden */
  67068. smooth: RegExp;
  67069. /** @hidden */
  67070. vertexPattern: RegExp;
  67071. /** @hidden */
  67072. normalPattern: RegExp;
  67073. /** @hidden */
  67074. uvPattern: RegExp;
  67075. /** @hidden */
  67076. facePattern1: RegExp;
  67077. /** @hidden */
  67078. facePattern2: RegExp;
  67079. /** @hidden */
  67080. facePattern3: RegExp;
  67081. /** @hidden */
  67082. facePattern4: RegExp;
  67083. /** @hidden */
  67084. facePattern5: RegExp;
  67085. private _meshLoadOptions;
  67086. /**
  67087. * Creates loader for .OBJ files
  67088. *
  67089. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67090. */
  67091. constructor(meshLoadOptions?: MeshLoadOptions);
  67092. private static readonly currentMeshLoadOptions;
  67093. /**
  67094. * Calls synchronously the MTL file attached to this obj.
  67095. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67096. * Without this function materials are not displayed in the first frame (but displayed after).
  67097. * In consequence it is impossible to get material information in your HTML file
  67098. *
  67099. * @param url The URL of the MTL file
  67100. * @param rootUrl
  67101. * @param onSuccess Callback function to be called when the MTL file is loaded
  67102. * @private
  67103. */
  67104. private _loadMTL;
  67105. /**
  67106. * Instantiates a OBJ file loader plugin.
  67107. * @returns the created plugin
  67108. */
  67109. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67110. /**
  67111. * If the data string can be loaded directly.
  67112. *
  67113. * @param data string containing the file data
  67114. * @returns if the data can be loaded directly
  67115. */
  67116. canDirectLoad(data: string): boolean;
  67117. /**
  67118. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67119. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67120. * @param scene the scene the meshes should be added to
  67121. * @param data the OBJ data to load
  67122. * @param rootUrl root url to load from
  67123. * @param onProgress event that fires when loading progress has occured
  67124. * @param fileName Defines the name of the file to load
  67125. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67126. */
  67127. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67128. meshes: AbstractMesh[];
  67129. particleSystems: IParticleSystem[];
  67130. skeletons: Skeleton[];
  67131. animationGroups: AnimationGroup[];
  67132. }>;
  67133. /**
  67134. * Imports all objects from the loaded OBJ data and adds them to the scene
  67135. * @param scene the scene the objects should be added to
  67136. * @param data the OBJ data to load
  67137. * @param rootUrl root url to load from
  67138. * @param onProgress event that fires when loading progress has occured
  67139. * @param fileName Defines the name of the file to load
  67140. * @returns a promise which completes when objects have been loaded to the scene
  67141. */
  67142. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67143. /**
  67144. * Load into an asset container.
  67145. * @param scene The scene to load into
  67146. * @param data The data to import
  67147. * @param rootUrl The root url for scene and resources
  67148. * @param onProgress The callback when the load progresses
  67149. * @param fileName Defines the name of the file to load
  67150. * @returns The loaded asset container
  67151. */
  67152. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67153. /**
  67154. * Read the OBJ file and create an Array of meshes.
  67155. * Each mesh contains all information given by the OBJ and the MTL file.
  67156. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67157. *
  67158. * @param meshesNames
  67159. * @param scene Scene The scene where are displayed the data
  67160. * @param data String The content of the obj file
  67161. * @param rootUrl String The path to the folder
  67162. * @returns Array<AbstractMesh>
  67163. * @private
  67164. */
  67165. private _parseSolid;
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. /**
  67170. * STL file type loader.
  67171. * This is a babylon scene loader plugin.
  67172. */
  67173. export class STLFileLoader implements ISceneLoaderPlugin {
  67174. /** @hidden */
  67175. solidPattern: RegExp;
  67176. /** @hidden */
  67177. facetsPattern: RegExp;
  67178. /** @hidden */
  67179. normalPattern: RegExp;
  67180. /** @hidden */
  67181. vertexPattern: RegExp;
  67182. /**
  67183. * Defines the name of the plugin.
  67184. */
  67185. name: string;
  67186. /**
  67187. * Defines the extensions the stl loader is able to load.
  67188. * force data to come in as an ArrayBuffer
  67189. * we'll convert to string if it looks like it's an ASCII .stl
  67190. */
  67191. extensions: ISceneLoaderPluginExtensions;
  67192. /**
  67193. * Import meshes into a scene.
  67194. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67195. * @param scene The scene to import into
  67196. * @param data The data to import
  67197. * @param rootUrl The root url for scene and resources
  67198. * @param meshes The meshes array to import into
  67199. * @param particleSystems The particle systems array to import into
  67200. * @param skeletons The skeletons array to import into
  67201. * @param onError The callback when import fails
  67202. * @returns True if successful or false otherwise
  67203. */
  67204. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67205. /**
  67206. * Load into a scene.
  67207. * @param scene The scene to load into
  67208. * @param data The data to import
  67209. * @param rootUrl The root url for scene and resources
  67210. * @param onError The callback when import fails
  67211. * @returns true if successful or false otherwise
  67212. */
  67213. load(scene: Scene, data: any, rootUrl: string): boolean;
  67214. /**
  67215. * Load into an asset container.
  67216. * @param scene The scene to load into
  67217. * @param data The data to import
  67218. * @param rootUrl The root url for scene and resources
  67219. * @param onError The callback when import fails
  67220. * @returns The loaded asset container
  67221. */
  67222. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67223. private _isBinary;
  67224. private _parseBinary;
  67225. private _parseASCII;
  67226. }
  67227. }
  67228. declare module BABYLON {
  67229. /**
  67230. * Class for generating OBJ data from a Babylon scene.
  67231. */
  67232. export class OBJExport {
  67233. /**
  67234. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67235. * @param mesh defines the list of meshes to serialize
  67236. * @param materials defines if materials should be exported
  67237. * @param matlibname defines the name of the associated mtl file
  67238. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67239. * @returns the OBJ content
  67240. */
  67241. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67242. /**
  67243. * Exports the material(s) of a mesh in .MTL file format (text)
  67244. * @param mesh defines the mesh to extract the material from
  67245. * @returns the mtl content
  67246. */
  67247. static MTL(mesh: Mesh): string;
  67248. }
  67249. }
  67250. declare module BABYLON {
  67251. /** @hidden */
  67252. export var __IGLTFExporterExtension: number;
  67253. /**
  67254. * Interface for extending the exporter
  67255. * @hidden
  67256. */
  67257. export interface IGLTFExporterExtension {
  67258. /**
  67259. * The name of this extension
  67260. */
  67261. readonly name: string;
  67262. /**
  67263. * Defines whether this extension is enabled
  67264. */
  67265. enabled: boolean;
  67266. /**
  67267. * Defines whether this extension is required
  67268. */
  67269. required: boolean;
  67270. }
  67271. }
  67272. declare module BABYLON.GLTF2.Exporter {
  67273. /** @hidden */
  67274. export var __IGLTFExporterExtensionV2: number;
  67275. /**
  67276. * Interface for a glTF exporter extension
  67277. * @hidden
  67278. */
  67279. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67280. /**
  67281. * Define this method to modify the default behavior before exporting a texture
  67282. * @param context The context when loading the asset
  67283. * @param babylonTexture The glTF texture info property
  67284. * @param mimeType The mime-type of the generated image
  67285. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67286. */
  67287. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67288. /**
  67289. * Define this method to modify the default behavior when exporting texture info
  67290. * @param context The context when loading the asset
  67291. * @param meshPrimitive glTF mesh primitive
  67292. * @param babylonSubMesh Babylon submesh
  67293. * @param binaryWriter glTF serializer binary writer instance
  67294. * @returns nullable IMeshPrimitive promise
  67295. */
  67296. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67297. /**
  67298. * Define this method to modify the default behavior when exporting a node
  67299. * @param context The context when exporting the node
  67300. * @param node glTF node
  67301. * @param babylonNode BabylonJS node
  67302. * @returns nullable INode promise
  67303. */
  67304. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67305. /**
  67306. * Called after the exporter state changes to EXPORTING
  67307. */
  67308. onExporting?(): void;
  67309. }
  67310. }
  67311. declare module BABYLON.GLTF2.Exporter {
  67312. /**
  67313. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67314. * @hidden
  67315. */
  67316. export class _GLTFMaterialExporter {
  67317. /**
  67318. * Represents the dielectric specular values for R, G and B
  67319. */
  67320. private static readonly _DielectricSpecular;
  67321. /**
  67322. * Allows the maximum specular power to be defined for material calculations
  67323. */
  67324. private static readonly _MaxSpecularPower;
  67325. /**
  67326. * Mapping to store textures
  67327. */
  67328. private _textureMap;
  67329. /**
  67330. * Numeric tolerance value
  67331. */
  67332. private static readonly _Epsilon;
  67333. /**
  67334. * Reference to the glTF Exporter
  67335. */
  67336. private _exporter;
  67337. constructor(exporter: _Exporter);
  67338. /**
  67339. * Specifies if two colors are approximately equal in value
  67340. * @param color1 first color to compare to
  67341. * @param color2 second color to compare to
  67342. * @param epsilon threshold value
  67343. */
  67344. private static FuzzyEquals;
  67345. /**
  67346. * Gets the materials from a Babylon scene and converts them to glTF materials
  67347. * @param scene babylonjs scene
  67348. * @param mimeType texture mime type
  67349. * @param images array of images
  67350. * @param textures array of textures
  67351. * @param materials array of materials
  67352. * @param imageData mapping of texture names to base64 textures
  67353. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67354. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67355. /**
  67356. * Makes a copy of the glTF material without the texture parameters
  67357. * @param originalMaterial original glTF material
  67358. * @returns glTF material without texture parameters
  67359. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67360. /**
  67361. * Specifies if the material has any texture parameters present
  67362. * @param material glTF Material
  67363. * @returns boolean specifying if texture parameters are present
  67364. */ private _hasTexturesPresent(material: IMaterial): boolean;
  67365. /**
  67366. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67367. * @param babylonStandardMaterial
  67368. * @returns glTF Metallic Roughness Material representation
  67369. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67370. /**
  67371. * Computes the metallic factor
  67372. * @param diffuse diffused value
  67373. * @param specular specular value
  67374. * @param oneMinusSpecularStrength one minus the specular strength
  67375. * @returns metallic value
  67376. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67377. /**
  67378. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67379. * @param glTFMaterial glTF material
  67380. * @param babylonMaterial Babylon material
  67381. */
  67382. private static _SetAlphaMode;
  67383. /**
  67384. * Converts a Babylon Standard Material to a glTF Material
  67385. * @param babylonStandardMaterial BJS Standard Material
  67386. * @param mimeType mime type to use for the textures
  67387. * @param images array of glTF image interfaces
  67388. * @param textures array of glTF texture interfaces
  67389. * @param materials array of glTF material interfaces
  67390. * @param imageData map of image file name to data
  67391. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67392. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67393. /**
  67394. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67395. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67396. * @param mimeType mime type to use for the textures
  67397. * @param images array of glTF image interfaces
  67398. * @param textures array of glTF texture interfaces
  67399. * @param materials array of glTF material interfaces
  67400. * @param imageData map of image file name to data
  67401. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67402. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67403. /**
  67404. * Converts an image typed array buffer to a base64 image
  67405. * @param buffer typed array buffer
  67406. * @param width width of the image
  67407. * @param height height of the image
  67408. * @param mimeType mimetype of the image
  67409. * @returns base64 image string
  67410. */
  67411. private _createBase64FromCanvasAsync;
  67412. /**
  67413. * Generates a white texture based on the specified width and height
  67414. * @param width width of the texture in pixels
  67415. * @param height height of the texture in pixels
  67416. * @param scene babylonjs scene
  67417. * @returns white texture
  67418. */
  67419. private _createWhiteTexture;
  67420. /**
  67421. * 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
  67422. * @param texture1 first texture to resize
  67423. * @param texture2 second texture to resize
  67424. * @param scene babylonjs scene
  67425. * @returns resized textures or null
  67426. */
  67427. private _resizeTexturesToSameDimensions;
  67428. /**
  67429. * Converts an array of pixels to a Float32Array
  67430. * Throws an error if the pixel format is not supported
  67431. * @param pixels - array buffer containing pixel values
  67432. * @returns Float32 of pixels
  67433. */
  67434. private _convertPixelArrayToFloat32;
  67435. /**
  67436. * Convert Specular Glossiness Textures to Metallic Roughness
  67437. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67438. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67439. * @param diffuseTexture texture used to store diffuse information
  67440. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67441. * @param factors specular glossiness material factors
  67442. * @param mimeType the mime type to use for the texture
  67443. * @returns pbr metallic roughness interface or null
  67444. */
  67445. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67446. /**
  67447. * Converts specular glossiness material properties to metallic roughness
  67448. * @param specularGlossiness interface with specular glossiness material properties
  67449. * @returns interface with metallic roughness material properties
  67450. */
  67451. private _convertSpecularGlossinessToMetallicRoughness;
  67452. /**
  67453. * Calculates the surface reflectance, independent of lighting conditions
  67454. * @param color Color source to calculate brightness from
  67455. * @returns number representing the perceived brightness, or zero if color is undefined
  67456. */
  67457. private _getPerceivedBrightness;
  67458. /**
  67459. * Returns the maximum color component value
  67460. * @param color
  67461. * @returns maximum color component value, or zero if color is null or undefined
  67462. */
  67463. private _getMaxComponent;
  67464. /**
  67465. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  67466. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67467. * @param mimeType mime type to use for the textures
  67468. * @param images array of glTF image interfaces
  67469. * @param textures array of glTF texture interfaces
  67470. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67471. * @param imageData map of image file name to data
  67472. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67473. * @returns glTF PBR Metallic Roughness factors
  67474. */
  67475. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  67476. private _getGLTFTextureSampler;
  67477. private _getGLTFTextureWrapMode;
  67478. private _getGLTFTextureWrapModesSampler;
  67479. /**
  67480. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  67481. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67482. * @param mimeType mime type to use for the textures
  67483. * @param images array of glTF image interfaces
  67484. * @param textures array of glTF texture interfaces
  67485. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  67486. * @param imageData map of image file name to data
  67487. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67488. * @returns glTF PBR Metallic Roughness factors
  67489. */
  67490. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  67491. /**
  67492. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67493. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  67494. * @param mimeType mime type to use for the textures
  67495. * @param images array of glTF image interfaces
  67496. * @param textures array of glTF texture interfaces
  67497. * @param materials array of glTF material interfaces
  67498. * @param imageData map of image file name to data
  67499. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67500. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67501. private setMetallicRoughnessPbrMaterial;
  67502. private getPixelsFromTexture;
  67503. /**
  67504. * Extracts a texture from a Babylon texture into file data and glTF data
  67505. * @param babylonTexture Babylon texture to extract
  67506. * @param mimeType Mime Type of the babylonTexture
  67507. * @return glTF texture info, or null if the texture format is not supported
  67508. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  67509. /**
  67510. * Builds a texture from base64 string
  67511. * @param base64Texture base64 texture string
  67512. * @param baseTextureName Name to use for the texture
  67513. * @param mimeType image mime type for the texture
  67514. * @param images array of images
  67515. * @param textures array of textures
  67516. * @param imageData map of image data
  67517. * @returns glTF texture info, or null if the texture format is not supported
  67518. */
  67519. private _getTextureInfoFromBase64;
  67520. }
  67521. }
  67522. declare module BABYLON {
  67523. /**
  67524. * Class for holding and downloading glTF file data
  67525. */
  67526. export class GLTFData {
  67527. /**
  67528. * Object which contains the file name as the key and its data as the value
  67529. */
  67530. glTFFiles: {
  67531. [fileName: string]: string | Blob;
  67532. };
  67533. /**
  67534. * Initializes the glTF file object
  67535. */
  67536. constructor();
  67537. /**
  67538. * Downloads the glTF data as files based on their names and data
  67539. */
  67540. downloadFiles(): void;
  67541. }
  67542. }
  67543. declare module BABYLON {
  67544. /**
  67545. * Holds a collection of exporter options and parameters
  67546. */
  67547. export interface IExportOptions {
  67548. /**
  67549. * Function which indicates whether a babylon node should be exported or not
  67550. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  67551. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  67552. */
  67553. shouldExportNode?(node: Node): boolean;
  67554. /**
  67555. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  67556. * @param metadata source metadata to read from
  67557. * @returns the data to store to glTF node extras
  67558. */
  67559. metadataSelector?(metadata: any): any;
  67560. /**
  67561. * The sample rate to bake animation curves
  67562. */
  67563. animationSampleRate?: number;
  67564. /**
  67565. * Begin serialization without waiting for the scene to be ready
  67566. */
  67567. exportWithoutWaitingForScene?: boolean;
  67568. }
  67569. /**
  67570. * Class for generating glTF data from a Babylon scene.
  67571. */
  67572. export class GLTF2Export {
  67573. /**
  67574. * Exports the geometry of the scene to .gltf file format asynchronously
  67575. * @param scene Babylon scene with scene hierarchy information
  67576. * @param filePrefix File prefix to use when generating the glTF file
  67577. * @param options Exporter options
  67578. * @returns Returns an object with a .gltf file and associates texture names
  67579. * as keys and their data and paths as values
  67580. */
  67581. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67582. private static _PreExportAsync;
  67583. private static _PostExportAsync;
  67584. /**
  67585. * Exports the geometry of the scene to .glb file format asychronously
  67586. * @param scene Babylon scene with scene hierarchy information
  67587. * @param filePrefix File prefix to use when generating glb file
  67588. * @param options Exporter options
  67589. * @returns Returns an object with a .glb filename as key and data as value
  67590. */
  67591. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  67592. }
  67593. }
  67594. declare module BABYLON.GLTF2.Exporter {
  67595. /**
  67596. * @hidden
  67597. */
  67598. export class _GLTFUtilities {
  67599. /**
  67600. * Creates a buffer view based on the supplied arguments
  67601. * @param bufferIndex index value of the specified buffer
  67602. * @param byteOffset byte offset value
  67603. * @param byteLength byte length of the bufferView
  67604. * @param byteStride byte distance between conequential elements
  67605. * @param name name of the buffer view
  67606. * @returns bufferView for glTF
  67607. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  67608. /**
  67609. * Creates an accessor based on the supplied arguments
  67610. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  67611. * @param name The name of the accessor
  67612. * @param type The type of the accessor
  67613. * @param componentType The datatype of components in the attribute
  67614. * @param count The number of attributes referenced by this accessor
  67615. * @param byteOffset The offset relative to the start of the bufferView in bytes
  67616. * @param min Minimum value of each component in this attribute
  67617. * @param max Maximum value of each component in this attribute
  67618. * @returns accessor for glTF
  67619. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  67620. /**
  67621. * Calculates the minimum and maximum values of an array of position floats
  67622. * @param positions Positions array of a mesh
  67623. * @param vertexStart Starting vertex offset to calculate min and max values
  67624. * @param vertexCount Number of vertices to check for min and max values
  67625. * @returns min number array and max number array
  67626. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  67627. min: number[];
  67628. max: number[];
  67629. };
  67630. /**
  67631. * Converts a new right-handed Vector3
  67632. * @param vector vector3 array
  67633. * @returns right-handed Vector3
  67634. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  67635. /**
  67636. * Converts a Vector3 to right-handed
  67637. * @param vector Vector3 to convert to right-handed
  67638. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  67639. /**
  67640. * Converts a three element number array to right-handed
  67641. * @param vector number array to convert to right-handed
  67642. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  67643. /**
  67644. * Converts a new right-handed Vector3
  67645. * @param vector vector3 array
  67646. * @returns right-handed Vector3
  67647. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  67648. /**
  67649. * Converts a Vector3 to right-handed
  67650. * @param vector Vector3 to convert to right-handed
  67651. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  67652. /**
  67653. * Converts a three element number array to right-handed
  67654. * @param vector number array to convert to right-handed
  67655. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  67656. /**
  67657. * Converts a Vector4 to right-handed
  67658. * @param vector Vector4 to convert to right-handed
  67659. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  67660. /**
  67661. * Converts a Vector4 to right-handed
  67662. * @param vector Vector4 to convert to right-handed
  67663. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  67664. /**
  67665. * Converts a Quaternion to right-handed
  67666. * @param quaternion Source quaternion to convert to right-handed
  67667. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  67668. /**
  67669. * Converts a Quaternion to right-handed
  67670. * @param quaternion Source quaternion to convert to right-handed
  67671. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  67672. }
  67673. }
  67674. declare module BABYLON.GLTF2.Exporter {
  67675. /**
  67676. * Converts Babylon Scene into glTF 2.0.
  67677. * @hidden
  67678. */
  67679. export class _Exporter {
  67680. /**
  67681. * Stores the glTF to export
  67682. */ private _glTF: IGLTF;
  67683. /**
  67684. * Stores all generated buffer views, which represents views into the main glTF buffer data
  67685. */ private _bufferViews: IBufferView[];
  67686. /**
  67687. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  67688. */ private _accessors: IAccessor[];
  67689. /**
  67690. * Stores all the generated nodes, which contains transform and/or mesh information per node
  67691. */
  67692. private _nodes;
  67693. /**
  67694. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  67695. */
  67696. private _scenes;
  67697. /**
  67698. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  67699. */
  67700. private _meshes;
  67701. /**
  67702. * Stores all the generated material information, which represents the appearance of each primitive
  67703. */ private _materials: IMaterial[]; private _materialMap: {
  67704. [materialID: number]: number;
  67705. };
  67706. /**
  67707. * Stores all the generated texture information, which is referenced by glTF materials
  67708. */ private _textures: ITexture[];
  67709. /**
  67710. * Stores all the generated image information, which is referenced by glTF textures
  67711. */ private _images: IImage[];
  67712. /**
  67713. * Stores all the texture samplers
  67714. */ private _samplers: ISampler[];
  67715. /**
  67716. * Stores all the generated animation samplers, which is referenced by glTF animations
  67717. */
  67718. /**
  67719. * Stores the animations for glTF models
  67720. */
  67721. private _animations;
  67722. /**
  67723. * Stores the total amount of bytes stored in the glTF buffer
  67724. */
  67725. private _totalByteLength;
  67726. /**
  67727. * Stores a reference to the Babylon scene containing the source geometry and material information
  67728. */ private _babylonScene: Scene;
  67729. /**
  67730. * Stores a map of the image data, where the key is the file name and the value
  67731. * is the image data
  67732. */ private _imageData: {
  67733. [fileName: string]: {
  67734. data: Uint8Array;
  67735. mimeType: ImageMimeType;
  67736. };
  67737. };
  67738. /**
  67739. * Stores a map of the unique id of a node to its index in the node array
  67740. */
  67741. private _nodeMap;
  67742. /**
  67743. * Specifies if the Babylon scene should be converted to right-handed on export
  67744. */ private _convertToRightHandedSystem: boolean;
  67745. /**
  67746. * Baked animation sample rate
  67747. */
  67748. private _animationSampleRate;
  67749. private _options;
  67750. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  67751. private _extensions;
  67752. private static _ExtensionNames;
  67753. private static _ExtensionFactories;
  67754. 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>>;
  67755. private _forEachExtensions;
  67756. private _extensionsOnExporting;
  67757. /**
  67758. * Load glTF serializer extensions
  67759. */
  67760. private _loadExtensions;
  67761. /**
  67762. * Creates a glTF Exporter instance, which can accept optional exporter options
  67763. * @param babylonScene Babylon scene object
  67764. * @param options Options to modify the behavior of the exporter
  67765. */
  67766. constructor(babylonScene: Scene, options?: IExportOptions);
  67767. /**
  67768. * Registers a glTF exporter extension
  67769. * @param name Name of the extension to export
  67770. * @param factory The factory function that creates the exporter extension
  67771. */
  67772. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  67773. /**
  67774. * Un-registers an exporter extension
  67775. * @param name The name fo the exporter extension
  67776. * @returns A boolean indicating whether the extension has been un-registered
  67777. */
  67778. static UnregisterExtension(name: string): boolean;
  67779. /**
  67780. * Lazy load a local engine with premultiplied alpha set to false
  67781. */ private _getLocalEngine(): Engine;
  67782. private reorderIndicesBasedOnPrimitiveMode;
  67783. /**
  67784. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  67785. * clock-wise during export to glTF
  67786. * @param submesh BabylonJS submesh
  67787. * @param primitiveMode Primitive mode of the mesh
  67788. * @param sideOrientation the winding order of the submesh
  67789. * @param vertexBufferKind The type of vertex attribute
  67790. * @param meshAttributeArray The vertex attribute data
  67791. * @param byteOffset The offset to the binary data
  67792. * @param binaryWriter The binary data for the glTF file
  67793. */
  67794. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  67795. /**
  67796. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  67797. * clock-wise during export to glTF
  67798. * @param submesh BabylonJS submesh
  67799. * @param primitiveMode Primitive mode of the mesh
  67800. * @param sideOrientation the winding order of the submesh
  67801. * @param vertexBufferKind The type of vertex attribute
  67802. * @param meshAttributeArray The vertex attribute data
  67803. * @param byteOffset The offset to the binary data
  67804. * @param binaryWriter The binary data for the glTF file
  67805. */
  67806. private reorderTriangleFillMode;
  67807. /**
  67808. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  67809. * clock-wise during export to glTF
  67810. * @param submesh BabylonJS submesh
  67811. * @param primitiveMode Primitive mode of the mesh
  67812. * @param sideOrientation the winding order of the submesh
  67813. * @param vertexBufferKind The type of vertex attribute
  67814. * @param meshAttributeArray The vertex attribute data
  67815. * @param byteOffset The offset to the binary data
  67816. * @param binaryWriter The binary data for the glTF file
  67817. */
  67818. private reorderTriangleStripDrawMode;
  67819. /**
  67820. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  67821. * clock-wise during export to glTF
  67822. * @param submesh BabylonJS submesh
  67823. * @param primitiveMode Primitive mode of the mesh
  67824. * @param sideOrientation the winding order of the submesh
  67825. * @param vertexBufferKind The type of vertex attribute
  67826. * @param meshAttributeArray The vertex attribute data
  67827. * @param byteOffset The offset to the binary data
  67828. * @param binaryWriter The binary data for the glTF file
  67829. */
  67830. private reorderTriangleFanMode;
  67831. /**
  67832. * Writes the vertex attribute data to binary
  67833. * @param vertices The vertices to write to the binary writer
  67834. * @param byteOffset The offset into the binary writer to overwrite binary data
  67835. * @param vertexAttributeKind The vertex attribute type
  67836. * @param meshAttributeArray The vertex attribute data
  67837. * @param binaryWriter The writer containing the binary data
  67838. */
  67839. private writeVertexAttributeData;
  67840. /**
  67841. * Writes mesh attribute data to a data buffer
  67842. * Returns the bytelength of the data
  67843. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67844. * @param meshAttributeArray Array containing the attribute data
  67845. * @param binaryWriter The buffer to write the binary data to
  67846. * @param indices Used to specify the order of the vertex data
  67847. */
  67848. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67849. /**
  67850. * Generates glTF json data
  67851. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67852. * @param glTFPrefix Text to use when prefixing a glTF file
  67853. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67854. * @returns json data as string
  67855. */
  67856. private generateJSON;
  67857. /**
  67858. * Generates data for .gltf and .bin files based on the glTF prefix string
  67859. * @param glTFPrefix Text to use when prefixing a glTF file
  67860. * @returns GLTFData with glTF file data
  67861. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67862. /**
  67863. * Creates a binary buffer for glTF
  67864. * @returns array buffer for binary data
  67865. */
  67866. private _generateBinaryAsync;
  67867. /**
  67868. * Pads the number to a multiple of 4
  67869. * @param num number to pad
  67870. * @returns padded number
  67871. */
  67872. private _getPadding;
  67873. /**
  67874. * Generates a glb file from the json and binary data
  67875. * Returns an object with the glb file name as the key and data as the value
  67876. * @param glTFPrefix
  67877. * @returns object with glb filename as key and data as value
  67878. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67879. /**
  67880. * Sets the TRS for each node
  67881. * @param node glTF Node for storing the transformation data
  67882. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67883. */
  67884. private setNodeTransformation;
  67885. private getVertexBufferFromMesh;
  67886. /**
  67887. * Creates a bufferview based on the vertices type for the Babylon mesh
  67888. * @param kind Indicates the type of vertices data
  67889. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67890. * @param binaryWriter The buffer to write the bufferview data to
  67891. */
  67892. private createBufferViewKind;
  67893. /**
  67894. * The primitive mode of the Babylon mesh
  67895. * @param babylonMesh The BabylonJS mesh
  67896. */
  67897. private getMeshPrimitiveMode;
  67898. /**
  67899. * Sets the primitive mode of the glTF mesh primitive
  67900. * @param meshPrimitive glTF mesh primitive
  67901. * @param primitiveMode The primitive mode
  67902. */
  67903. private setPrimitiveMode;
  67904. /**
  67905. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67906. * @param meshPrimitive glTF mesh primitive
  67907. * @param attributeKind vertex attribute
  67908. * @returns boolean specifying if uv coordinates are present
  67909. */
  67910. private setAttributeKind;
  67911. /**
  67912. * Sets data for the primitive attributes of each submesh
  67913. * @param mesh glTF Mesh object to store the primitive attribute information
  67914. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67915. * @param binaryWriter Buffer to write the attribute data to
  67916. */
  67917. private setPrimitiveAttributesAsync;
  67918. /**
  67919. * Creates a glTF scene based on the array of meshes
  67920. * Returns the the total byte offset
  67921. * @param babylonScene Babylon scene to get the mesh data from
  67922. * @param binaryWriter Buffer to write binary data to
  67923. */
  67924. private createSceneAsync;
  67925. /**
  67926. * Creates a mapping of Node unique id to node index and handles animations
  67927. * @param babylonScene Babylon Scene
  67928. * @param nodes Babylon transform nodes
  67929. * @param binaryWriter Buffer to write binary data to
  67930. * @returns Node mapping of unique id to index
  67931. */
  67932. private createNodeMapAndAnimationsAsync;
  67933. /**
  67934. * Creates a glTF node from a Babylon mesh
  67935. * @param babylonMesh Source Babylon mesh
  67936. * @param binaryWriter Buffer for storing geometry data
  67937. * @returns glTF node
  67938. */
  67939. private createNodeAsync;
  67940. }
  67941. /**
  67942. * @hidden
  67943. *
  67944. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67945. */
  67946. export class _BinaryWriter {
  67947. /**
  67948. * Array buffer which stores all binary data
  67949. */
  67950. private _arrayBuffer;
  67951. /**
  67952. * View of the array buffer
  67953. */
  67954. private _dataView;
  67955. /**
  67956. * byte offset of data in array buffer
  67957. */
  67958. private _byteOffset;
  67959. /**
  67960. * Initialize binary writer with an initial byte length
  67961. * @param byteLength Initial byte length of the array buffer
  67962. */
  67963. constructor(byteLength: number);
  67964. /**
  67965. * Resize the array buffer to the specified byte length
  67966. * @param byteLength
  67967. */
  67968. private resizeBuffer;
  67969. /**
  67970. * Get an array buffer with the length of the byte offset
  67971. * @returns ArrayBuffer resized to the byte offset
  67972. */
  67973. getArrayBuffer(): ArrayBuffer;
  67974. /**
  67975. * Get the byte offset of the array buffer
  67976. * @returns byte offset
  67977. */
  67978. getByteOffset(): number;
  67979. /**
  67980. * Stores an UInt8 in the array buffer
  67981. * @param entry
  67982. * @param byteOffset If defined, specifies where to set the value as an offset.
  67983. */
  67984. setUInt8(entry: number, byteOffset?: number): void;
  67985. /**
  67986. * Gets an UInt32 in the array buffer
  67987. * @param entry
  67988. * @param byteOffset If defined, specifies where to set the value as an offset.
  67989. */
  67990. getUInt32(byteOffset: number): number;
  67991. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67992. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67993. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67994. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67995. /**
  67996. * Stores a Float32 in the array buffer
  67997. * @param entry
  67998. */
  67999. setFloat32(entry: number, byteOffset?: number): void;
  68000. /**
  68001. * Stores an UInt32 in the array buffer
  68002. * @param entry
  68003. * @param byteOffset If defined, specifies where to set the value as an offset.
  68004. */
  68005. setUInt32(entry: number, byteOffset?: number): void;
  68006. }
  68007. }
  68008. declare module BABYLON.GLTF2.Exporter {
  68009. /**
  68010. * @hidden
  68011. * Interface to store animation data.
  68012. */
  68013. export interface _IAnimationData {
  68014. /**
  68015. * Keyframe data.
  68016. */
  68017. inputs: number[];
  68018. /**
  68019. * Value data.
  68020. */
  68021. outputs: number[][];
  68022. /**
  68023. * Animation interpolation data.
  68024. */
  68025. samplerInterpolation: AnimationSamplerInterpolation;
  68026. /**
  68027. * Minimum keyframe value.
  68028. */
  68029. inputsMin: number;
  68030. /**
  68031. * Maximum keyframe value.
  68032. */
  68033. inputsMax: number;
  68034. }
  68035. /**
  68036. * @hidden
  68037. */
  68038. export interface _IAnimationInfo {
  68039. /**
  68040. * The target channel for the animation
  68041. */
  68042. animationChannelTargetPath: AnimationChannelTargetPath;
  68043. /**
  68044. * The glTF accessor type for the data.
  68045. */
  68046. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68047. /**
  68048. * Specifies if quaternions should be used.
  68049. */
  68050. useQuaternion: boolean;
  68051. }
  68052. /**
  68053. * @hidden
  68054. * Utility class for generating glTF animation data from BabylonJS.
  68055. */
  68056. export class _GLTFAnimation {
  68057. /**
  68058. * @ignore
  68059. *
  68060. * Creates glTF channel animation from BabylonJS animation.
  68061. * @param babylonTransformNode - BabylonJS mesh.
  68062. * @param animation - animation.
  68063. * @param animationChannelTargetPath - The target animation channel.
  68064. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68065. * @param useQuaternion - Specifies if quaternions are used.
  68066. * @returns nullable IAnimationData
  68067. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68068. private static _DeduceAnimationInfo;
  68069. /**
  68070. * @ignore
  68071. * Create node animations from the transform node animations
  68072. * @param babylonNode
  68073. * @param runtimeGLTFAnimation
  68074. * @param idleGLTFAnimations
  68075. * @param nodeMap
  68076. * @param nodes
  68077. * @param binaryWriter
  68078. * @param bufferViews
  68079. * @param accessors
  68080. * @param convertToRightHandedSystem
  68081. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68082. [key: number]: number;
  68083. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68084. /**
  68085. * @ignore
  68086. * Create node animations from the animation groups
  68087. * @param babylonScene
  68088. * @param glTFAnimations
  68089. * @param nodeMap
  68090. * @param nodes
  68091. * @param binaryWriter
  68092. * @param bufferViews
  68093. * @param accessors
  68094. * @param convertToRightHandedSystem
  68095. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68096. [key: number]: number;
  68097. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68098. private static AddAnimation;
  68099. /**
  68100. * Create a baked animation
  68101. * @param babylonTransformNode BabylonJS mesh
  68102. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68103. * @param animationChannelTargetPath animation target channel
  68104. * @param minFrame minimum animation frame
  68105. * @param maxFrame maximum animation frame
  68106. * @param fps frames per second of the animation
  68107. * @param inputs input key frames of the animation
  68108. * @param outputs output key frame data of the animation
  68109. * @param convertToRightHandedSystem converts the values to right-handed
  68110. * @param useQuaternion specifies if quaternions should be used
  68111. */
  68112. private static _CreateBakedAnimation;
  68113. private static _ConvertFactorToVector3OrQuaternion;
  68114. private static _SetInterpolatedValue;
  68115. /**
  68116. * Creates linear animation from the animation key frames
  68117. * @param babylonTransformNode BabylonJS mesh
  68118. * @param animation BabylonJS animation
  68119. * @param animationChannelTargetPath The target animation channel
  68120. * @param frameDelta The difference between the last and first frame of the animation
  68121. * @param inputs Array to store the key frame times
  68122. * @param outputs Array to store the key frame data
  68123. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68124. * @param useQuaternion Specifies if quaternions are used in the animation
  68125. */
  68126. private static _CreateLinearOrStepAnimation;
  68127. /**
  68128. * Creates cubic spline animation from the animation key frames
  68129. * @param babylonTransformNode BabylonJS mesh
  68130. * @param animation BabylonJS animation
  68131. * @param animationChannelTargetPath The target animation channel
  68132. * @param frameDelta The difference between the last and first frame of the animation
  68133. * @param inputs Array to store the key frame times
  68134. * @param outputs Array to store the key frame data
  68135. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68136. * @param useQuaternion Specifies if quaternions are used in the animation
  68137. */
  68138. private static _CreateCubicSplineAnimation;
  68139. private static _GetBasePositionRotationOrScale;
  68140. /**
  68141. * Adds a key frame value
  68142. * @param keyFrame
  68143. * @param animation
  68144. * @param outputs
  68145. * @param animationChannelTargetPath
  68146. * @param basePositionRotationOrScale
  68147. * @param convertToRightHandedSystem
  68148. * @param useQuaternion
  68149. */
  68150. private static _AddKeyframeValue;
  68151. /**
  68152. * Determine the interpolation based on the key frames
  68153. * @param keyFrames
  68154. * @param animationChannelTargetPath
  68155. * @param useQuaternion
  68156. */
  68157. private static _DeduceInterpolation;
  68158. /**
  68159. * Adds an input tangent or output tangent to the output data
  68160. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68161. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68162. * @param outputs The animation data by keyframe
  68163. * @param animationChannelTargetPath The target animation channel
  68164. * @param interpolation The interpolation type
  68165. * @param keyFrame The key frame with the animation data
  68166. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68167. * @param useQuaternion Specifies if quaternions are used
  68168. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68169. */
  68170. private static AddSplineTangent;
  68171. /**
  68172. * Get the minimum and maximum key frames' frame values
  68173. * @param keyFrames animation key frames
  68174. * @returns the minimum and maximum key frame value
  68175. */
  68176. private static calculateMinMaxKeyFrames;
  68177. }
  68178. }
  68179. declare module BABYLON.GLTF2.Exporter {
  68180. /** @hidden */
  68181. export var textureTransformPixelShader: {
  68182. name: string;
  68183. shader: string;
  68184. };
  68185. }
  68186. declare module BABYLON.GLTF2.Exporter.Extensions {
  68187. /**
  68188. * @hidden
  68189. */
  68190. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68191. /** Name of this extension */
  68192. readonly name: string;
  68193. /** Defines whether this extension is enabled */
  68194. enabled: boolean;
  68195. /** Defines whether this extension is required */
  68196. required: boolean;
  68197. /** Reference to the glTF exporter */
  68198. private _exporter;
  68199. constructor(exporter: _Exporter);
  68200. dispose(): void;
  68201. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68202. /**
  68203. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68204. * @param babylonTexture
  68205. * @param offset
  68206. * @param rotation
  68207. * @param scale
  68208. * @param scene
  68209. */
  68210. private _textureTransformTextureAsync;
  68211. }
  68212. }
  68213. declare module BABYLON.GLTF2.Exporter.Extensions {
  68214. /**
  68215. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68216. */
  68217. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68218. /** The name of this extension. */
  68219. readonly name: string;
  68220. /** Defines whether this extension is enabled. */
  68221. enabled: boolean;
  68222. /** Defines whether this extension is required */
  68223. required: boolean;
  68224. /** Reference to the glTF exporter */
  68225. private _exporter;
  68226. private _lights;
  68227. /** @hidden */
  68228. constructor(exporter: _Exporter);
  68229. /** @hidden */
  68230. dispose(): void;
  68231. /** @hidden */
  68232. onExporting(): void;
  68233. /**
  68234. * Define this method to modify the default behavior when exporting a node
  68235. * @param context The context when exporting the node
  68236. * @param node glTF node
  68237. * @param babylonNode BabylonJS node
  68238. * @returns nullable INode promise
  68239. */
  68240. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68241. }
  68242. }
  68243. declare module BABYLON {
  68244. /**
  68245. * Class for generating STL data from a Babylon scene.
  68246. */
  68247. export class STLExport {
  68248. /**
  68249. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68250. * @param meshes list defines the mesh to serialize
  68251. * @param download triggers the automatic download of the file.
  68252. * @param fileName changes the downloads fileName.
  68253. * @param binary changes the STL to a binary type.
  68254. * @param isLittleEndian toggle for binary type exporter.
  68255. * @returns the STL as UTF8 string
  68256. */
  68257. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68258. }
  68259. }
  68260. /**
  68261. * @ignoreChildren
  68262. * @ignore
  68263. */
  68264. declare module "babylonjs-gltf2interface" {
  68265. export = BABYLON.GLTF2;
  68266. }
  68267. /**
  68268. * Module for glTF 2.0 Interface
  68269. * @ignoreChildren
  68270. * @ignore
  68271. */
  68272. declare module BABYLON.GLTF2 {
  68273. /**
  68274. * The datatype of the components in the attribute
  68275. */
  68276. const enum AccessorComponentType {
  68277. /**
  68278. * Byte
  68279. */
  68280. BYTE = 5120,
  68281. /**
  68282. * Unsigned Byte
  68283. */
  68284. UNSIGNED_BYTE = 5121,
  68285. /**
  68286. * Short
  68287. */
  68288. SHORT = 5122,
  68289. /**
  68290. * Unsigned Short
  68291. */
  68292. UNSIGNED_SHORT = 5123,
  68293. /**
  68294. * Unsigned Int
  68295. */
  68296. UNSIGNED_INT = 5125,
  68297. /**
  68298. * Float
  68299. */
  68300. FLOAT = 5126,
  68301. }
  68302. /**
  68303. * Specifies if the attirbute is a scalar, vector, or matrix
  68304. */
  68305. const enum AccessorType {
  68306. /**
  68307. * Scalar
  68308. */
  68309. SCALAR = "SCALAR",
  68310. /**
  68311. * Vector2
  68312. */
  68313. VEC2 = "VEC2",
  68314. /**
  68315. * Vector3
  68316. */
  68317. VEC3 = "VEC3",
  68318. /**
  68319. * Vector4
  68320. */
  68321. VEC4 = "VEC4",
  68322. /**
  68323. * Matrix2x2
  68324. */
  68325. MAT2 = "MAT2",
  68326. /**
  68327. * Matrix3x3
  68328. */
  68329. MAT3 = "MAT3",
  68330. /**
  68331. * Matrix4x4
  68332. */
  68333. MAT4 = "MAT4",
  68334. }
  68335. /**
  68336. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68337. */
  68338. const enum AnimationChannelTargetPath {
  68339. /**
  68340. * Translation
  68341. */
  68342. TRANSLATION = "translation",
  68343. /**
  68344. * Rotation
  68345. */
  68346. ROTATION = "rotation",
  68347. /**
  68348. * Scale
  68349. */
  68350. SCALE = "scale",
  68351. /**
  68352. * Weights
  68353. */
  68354. WEIGHTS = "weights",
  68355. }
  68356. /**
  68357. * Interpolation algorithm
  68358. */
  68359. const enum AnimationSamplerInterpolation {
  68360. /**
  68361. * The animated values are linearly interpolated between keyframes
  68362. */
  68363. LINEAR = "LINEAR",
  68364. /**
  68365. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68366. */
  68367. STEP = "STEP",
  68368. /**
  68369. * The animation's interpolation is computed using a cubic spline with specified tangents
  68370. */
  68371. CUBICSPLINE = "CUBICSPLINE",
  68372. }
  68373. /**
  68374. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68375. */
  68376. const enum CameraType {
  68377. /**
  68378. * A perspective camera containing properties to create a perspective projection matrix
  68379. */
  68380. PERSPECTIVE = "perspective",
  68381. /**
  68382. * An orthographic camera containing properties to create an orthographic projection matrix
  68383. */
  68384. ORTHOGRAPHIC = "orthographic",
  68385. }
  68386. /**
  68387. * The mime-type of the image
  68388. */
  68389. const enum ImageMimeType {
  68390. /**
  68391. * JPEG Mime-type
  68392. */
  68393. JPEG = "image/jpeg",
  68394. /**
  68395. * PNG Mime-type
  68396. */
  68397. PNG = "image/png",
  68398. }
  68399. /**
  68400. * The alpha rendering mode of the material
  68401. */
  68402. const enum MaterialAlphaMode {
  68403. /**
  68404. * The alpha value is ignored and the rendered output is fully opaque
  68405. */
  68406. OPAQUE = "OPAQUE",
  68407. /**
  68408. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68409. */
  68410. MASK = "MASK",
  68411. /**
  68412. * 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)
  68413. */
  68414. BLEND = "BLEND",
  68415. }
  68416. /**
  68417. * The type of the primitives to render
  68418. */
  68419. const enum MeshPrimitiveMode {
  68420. /**
  68421. * Points
  68422. */
  68423. POINTS = 0,
  68424. /**
  68425. * Lines
  68426. */
  68427. LINES = 1,
  68428. /**
  68429. * Line Loop
  68430. */
  68431. LINE_LOOP = 2,
  68432. /**
  68433. * Line Strip
  68434. */
  68435. LINE_STRIP = 3,
  68436. /**
  68437. * Triangles
  68438. */
  68439. TRIANGLES = 4,
  68440. /**
  68441. * Triangle Strip
  68442. */
  68443. TRIANGLE_STRIP = 5,
  68444. /**
  68445. * Triangle Fan
  68446. */
  68447. TRIANGLE_FAN = 6,
  68448. }
  68449. /**
  68450. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68451. */
  68452. const enum TextureMagFilter {
  68453. /**
  68454. * Nearest
  68455. */
  68456. NEAREST = 9728,
  68457. /**
  68458. * Linear
  68459. */
  68460. LINEAR = 9729,
  68461. }
  68462. /**
  68463. * Minification filter. All valid values correspond to WebGL enums
  68464. */
  68465. const enum TextureMinFilter {
  68466. /**
  68467. * Nearest
  68468. */
  68469. NEAREST = 9728,
  68470. /**
  68471. * Linear
  68472. */
  68473. LINEAR = 9729,
  68474. /**
  68475. * Nearest Mip-Map Nearest
  68476. */
  68477. NEAREST_MIPMAP_NEAREST = 9984,
  68478. /**
  68479. * Linear Mipmap Nearest
  68480. */
  68481. LINEAR_MIPMAP_NEAREST = 9985,
  68482. /**
  68483. * Nearest Mipmap Linear
  68484. */
  68485. NEAREST_MIPMAP_LINEAR = 9986,
  68486. /**
  68487. * Linear Mipmap Linear
  68488. */
  68489. LINEAR_MIPMAP_LINEAR = 9987,
  68490. }
  68491. /**
  68492. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68493. */
  68494. const enum TextureWrapMode {
  68495. /**
  68496. * Clamp to Edge
  68497. */
  68498. CLAMP_TO_EDGE = 33071,
  68499. /**
  68500. * Mirrored Repeat
  68501. */
  68502. MIRRORED_REPEAT = 33648,
  68503. /**
  68504. * Repeat
  68505. */
  68506. REPEAT = 10497,
  68507. }
  68508. /**
  68509. * glTF Property
  68510. */
  68511. interface IProperty {
  68512. /**
  68513. * Dictionary object with extension-specific objects
  68514. */
  68515. extensions?: {
  68516. [key: string]: any;
  68517. };
  68518. /**
  68519. * Application-Specific data
  68520. */
  68521. extras?: any;
  68522. }
  68523. /**
  68524. * glTF Child of Root Property
  68525. */
  68526. interface IChildRootProperty extends IProperty {
  68527. /**
  68528. * The user-defined name of this object
  68529. */
  68530. name?: string;
  68531. }
  68532. /**
  68533. * Indices of those attributes that deviate from their initialization value
  68534. */
  68535. interface IAccessorSparseIndices extends IProperty {
  68536. /**
  68537. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68538. */
  68539. bufferView: number;
  68540. /**
  68541. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68542. */
  68543. byteOffset?: number;
  68544. /**
  68545. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  68546. */
  68547. componentType: AccessorComponentType;
  68548. }
  68549. /**
  68550. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  68551. */
  68552. interface IAccessorSparseValues extends IProperty {
  68553. /**
  68554. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  68555. */
  68556. bufferView: number;
  68557. /**
  68558. * The offset relative to the start of the bufferView in bytes. Must be aligned
  68559. */
  68560. byteOffset?: number;
  68561. }
  68562. /**
  68563. * Sparse storage of attributes that deviate from their initialization value
  68564. */
  68565. interface IAccessorSparse extends IProperty {
  68566. /**
  68567. * The number of attributes encoded in this sparse accessor
  68568. */
  68569. count: number;
  68570. /**
  68571. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  68572. */
  68573. indices: IAccessorSparseIndices;
  68574. /**
  68575. * 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
  68576. */
  68577. values: IAccessorSparseValues;
  68578. }
  68579. /**
  68580. * 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
  68581. */
  68582. interface IAccessor extends IChildRootProperty {
  68583. /**
  68584. * The index of the bufferview
  68585. */
  68586. bufferView?: number;
  68587. /**
  68588. * The offset relative to the start of the bufferView in bytes
  68589. */
  68590. byteOffset?: number;
  68591. /**
  68592. * The datatype of components in the attribute
  68593. */
  68594. componentType: AccessorComponentType;
  68595. /**
  68596. * Specifies whether integer data values should be normalized
  68597. */
  68598. normalized?: boolean;
  68599. /**
  68600. * The number of attributes referenced by this accessor
  68601. */
  68602. count: number;
  68603. /**
  68604. * Specifies if the attribute is a scalar, vector, or matrix
  68605. */
  68606. type: AccessorType;
  68607. /**
  68608. * Maximum value of each component in this attribute
  68609. */
  68610. max?: number[];
  68611. /**
  68612. * Minimum value of each component in this attribute
  68613. */
  68614. min?: number[];
  68615. /**
  68616. * Sparse storage of attributes that deviate from their initialization value
  68617. */
  68618. sparse?: IAccessorSparse;
  68619. }
  68620. /**
  68621. * Targets an animation's sampler at a node's property
  68622. */
  68623. interface IAnimationChannel extends IProperty {
  68624. /**
  68625. * The index of a sampler in this animation used to compute the value for the target
  68626. */
  68627. sampler: number;
  68628. /**
  68629. * The index of the node and TRS property to target
  68630. */
  68631. target: IAnimationChannelTarget;
  68632. }
  68633. /**
  68634. * The index of the node and TRS property that an animation channel targets
  68635. */
  68636. interface IAnimationChannelTarget extends IProperty {
  68637. /**
  68638. * The index of the node to target
  68639. */
  68640. node: number;
  68641. /**
  68642. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68643. */
  68644. path: AnimationChannelTargetPath;
  68645. }
  68646. /**
  68647. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68648. */
  68649. interface IAnimationSampler extends IProperty {
  68650. /**
  68651. * The index of an accessor containing keyframe input values, e.g., time
  68652. */
  68653. input: number;
  68654. /**
  68655. * Interpolation algorithm
  68656. */
  68657. interpolation?: AnimationSamplerInterpolation;
  68658. /**
  68659. * The index of an accessor, containing keyframe output values
  68660. */
  68661. output: number;
  68662. }
  68663. /**
  68664. * A keyframe animation
  68665. */
  68666. interface IAnimation extends IChildRootProperty {
  68667. /**
  68668. * An array of channels, each of which targets an animation's sampler at a node's property
  68669. */
  68670. channels: IAnimationChannel[];
  68671. /**
  68672. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  68673. */
  68674. samplers: IAnimationSampler[];
  68675. }
  68676. /**
  68677. * Metadata about the glTF asset
  68678. */
  68679. interface IAsset extends IChildRootProperty {
  68680. /**
  68681. * A copyright message suitable for display to credit the content creator
  68682. */
  68683. copyright?: string;
  68684. /**
  68685. * Tool that generated this glTF model. Useful for debugging
  68686. */
  68687. generator?: string;
  68688. /**
  68689. * The glTF version that this asset targets
  68690. */
  68691. version: string;
  68692. /**
  68693. * The minimum glTF version that this asset targets
  68694. */
  68695. minVersion?: string;
  68696. }
  68697. /**
  68698. * A buffer points to binary geometry, animation, or skins
  68699. */
  68700. interface IBuffer extends IChildRootProperty {
  68701. /**
  68702. * 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
  68703. */
  68704. uri?: string;
  68705. /**
  68706. * The length of the buffer in bytes
  68707. */
  68708. byteLength: number;
  68709. }
  68710. /**
  68711. * A view into a buffer generally representing a subset of the buffer
  68712. */
  68713. interface IBufferView extends IChildRootProperty {
  68714. /**
  68715. * The index of the buffer
  68716. */
  68717. buffer: number;
  68718. /**
  68719. * The offset into the buffer in bytes
  68720. */
  68721. byteOffset?: number;
  68722. /**
  68723. * The lenth of the bufferView in bytes
  68724. */
  68725. byteLength: number;
  68726. /**
  68727. * The stride, in bytes
  68728. */
  68729. byteStride?: number;
  68730. }
  68731. /**
  68732. * An orthographic camera containing properties to create an orthographic projection matrix
  68733. */
  68734. interface ICameraOrthographic extends IProperty {
  68735. /**
  68736. * The floating-point horizontal magnification of the view. Must not be zero
  68737. */
  68738. xmag: number;
  68739. /**
  68740. * The floating-point vertical magnification of the view. Must not be zero
  68741. */
  68742. ymag: number;
  68743. /**
  68744. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  68745. */
  68746. zfar: number;
  68747. /**
  68748. * The floating-point distance to the near clipping plane
  68749. */
  68750. znear: number;
  68751. }
  68752. /**
  68753. * A perspective camera containing properties to create a perspective projection matrix
  68754. */
  68755. interface ICameraPerspective extends IProperty {
  68756. /**
  68757. * The floating-point aspect ratio of the field of view
  68758. */
  68759. aspectRatio?: number;
  68760. /**
  68761. * The floating-point vertical field of view in radians
  68762. */
  68763. yfov: number;
  68764. /**
  68765. * The floating-point distance to the far clipping plane
  68766. */
  68767. zfar?: number;
  68768. /**
  68769. * The floating-point distance to the near clipping plane
  68770. */
  68771. znear: number;
  68772. }
  68773. /**
  68774. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68775. */
  68776. interface ICamera extends IChildRootProperty {
  68777. /**
  68778. * An orthographic camera containing properties to create an orthographic projection matrix
  68779. */
  68780. orthographic?: ICameraOrthographic;
  68781. /**
  68782. * A perspective camera containing properties to create a perspective projection matrix
  68783. */
  68784. perspective?: ICameraPerspective;
  68785. /**
  68786. * Specifies if the camera uses a perspective or orthographic projection
  68787. */
  68788. type: CameraType;
  68789. }
  68790. /**
  68791. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  68792. */
  68793. interface IImage extends IChildRootProperty {
  68794. /**
  68795. * 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
  68796. */
  68797. uri?: string;
  68798. /**
  68799. * The image's MIME type
  68800. */
  68801. mimeType?: ImageMimeType;
  68802. /**
  68803. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  68804. */
  68805. bufferView?: number;
  68806. }
  68807. /**
  68808. * Material Normal Texture Info
  68809. */
  68810. interface IMaterialNormalTextureInfo extends ITextureInfo {
  68811. /**
  68812. * The scalar multiplier applied to each normal vector of the normal texture
  68813. */
  68814. scale?: number;
  68815. }
  68816. /**
  68817. * Material Occlusion Texture Info
  68818. */
  68819. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  68820. /**
  68821. * A scalar multiplier controlling the amount of occlusion applied
  68822. */
  68823. strength?: number;
  68824. }
  68825. /**
  68826. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68827. */
  68828. interface IMaterialPbrMetallicRoughness {
  68829. /**
  68830. * The material's base color factor
  68831. */
  68832. baseColorFactor?: number[];
  68833. /**
  68834. * The base color texture
  68835. */
  68836. baseColorTexture?: ITextureInfo;
  68837. /**
  68838. * The metalness of the material
  68839. */
  68840. metallicFactor?: number;
  68841. /**
  68842. * The roughness of the material
  68843. */
  68844. roughnessFactor?: number;
  68845. /**
  68846. * The metallic-roughness texture
  68847. */
  68848. metallicRoughnessTexture?: ITextureInfo;
  68849. }
  68850. /**
  68851. * The material appearance of a primitive
  68852. */
  68853. interface IMaterial extends IChildRootProperty {
  68854. /**
  68855. * 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
  68856. */
  68857. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68858. /**
  68859. * The normal map texture
  68860. */
  68861. normalTexture?: IMaterialNormalTextureInfo;
  68862. /**
  68863. * The occlusion map texture
  68864. */
  68865. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68866. /**
  68867. * The emissive map texture
  68868. */
  68869. emissiveTexture?: ITextureInfo;
  68870. /**
  68871. * 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
  68872. */
  68873. emissiveFactor?: number[];
  68874. /**
  68875. * The alpha rendering mode of the material
  68876. */
  68877. alphaMode?: MaterialAlphaMode;
  68878. /**
  68879. * The alpha cutoff value of the material
  68880. */
  68881. alphaCutoff?: number;
  68882. /**
  68883. * Specifies whether the material is double sided
  68884. */
  68885. doubleSided?: boolean;
  68886. }
  68887. /**
  68888. * Geometry to be rendered with the given material
  68889. */
  68890. interface IMeshPrimitive extends IProperty {
  68891. /**
  68892. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68893. */
  68894. attributes: {
  68895. [name: string]: number;
  68896. };
  68897. /**
  68898. * The index of the accessor that contains the indices
  68899. */
  68900. indices?: number;
  68901. /**
  68902. * The index of the material to apply to this primitive when rendering
  68903. */
  68904. material?: number;
  68905. /**
  68906. * The type of primitives to render. All valid values correspond to WebGL enums
  68907. */
  68908. mode?: MeshPrimitiveMode;
  68909. /**
  68910. * 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
  68911. */
  68912. targets?: {
  68913. [name: string]: number;
  68914. }[];
  68915. }
  68916. /**
  68917. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68918. */
  68919. interface IMesh extends IChildRootProperty {
  68920. /**
  68921. * An array of primitives, each defining geometry to be rendered with a material
  68922. */
  68923. primitives: IMeshPrimitive[];
  68924. /**
  68925. * Array of weights to be applied to the Morph Targets
  68926. */
  68927. weights?: number[];
  68928. }
  68929. /**
  68930. * A node in the node hierarchy
  68931. */
  68932. interface INode extends IChildRootProperty {
  68933. /**
  68934. * The index of the camera referenced by this node
  68935. */
  68936. camera?: number;
  68937. /**
  68938. * The indices of this node's children
  68939. */
  68940. children?: number[];
  68941. /**
  68942. * The index of the skin referenced by this node
  68943. */
  68944. skin?: number;
  68945. /**
  68946. * A floating-point 4x4 transformation matrix stored in column-major order
  68947. */
  68948. matrix?: number[];
  68949. /**
  68950. * The index of the mesh in this node
  68951. */
  68952. mesh?: number;
  68953. /**
  68954. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68955. */
  68956. rotation?: number[];
  68957. /**
  68958. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68959. */
  68960. scale?: number[];
  68961. /**
  68962. * The node's translation along the x, y, and z axes
  68963. */
  68964. translation?: number[];
  68965. /**
  68966. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68967. */
  68968. weights?: number[];
  68969. }
  68970. /**
  68971. * Texture sampler properties for filtering and wrapping modes
  68972. */
  68973. interface ISampler extends IChildRootProperty {
  68974. /**
  68975. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68976. */
  68977. magFilter?: TextureMagFilter;
  68978. /**
  68979. * Minification filter. All valid values correspond to WebGL enums
  68980. */
  68981. minFilter?: TextureMinFilter;
  68982. /**
  68983. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68984. */
  68985. wrapS?: TextureWrapMode;
  68986. /**
  68987. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68988. */
  68989. wrapT?: TextureWrapMode;
  68990. }
  68991. /**
  68992. * The root nodes of a scene
  68993. */
  68994. interface IScene extends IChildRootProperty {
  68995. /**
  68996. * The indices of each root node
  68997. */
  68998. nodes: number[];
  68999. }
  69000. /**
  69001. * Joints and matrices defining a skin
  69002. */
  69003. interface ISkin extends IChildRootProperty {
  69004. /**
  69005. * 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
  69006. */
  69007. inverseBindMatrices?: number;
  69008. /**
  69009. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69010. */
  69011. skeleton?: number;
  69012. /**
  69013. * 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)
  69014. */
  69015. joints: number[];
  69016. }
  69017. /**
  69018. * A texture and its sampler
  69019. */
  69020. interface ITexture extends IChildRootProperty {
  69021. /**
  69022. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69023. */
  69024. sampler?: number;
  69025. /**
  69026. * The index of the image used by this texture
  69027. */
  69028. source: number;
  69029. }
  69030. /**
  69031. * Reference to a texture
  69032. */
  69033. interface ITextureInfo extends IProperty {
  69034. /**
  69035. * The index of the texture
  69036. */
  69037. index: number;
  69038. /**
  69039. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69040. */
  69041. texCoord?: number;
  69042. }
  69043. /**
  69044. * The root object for a glTF asset
  69045. */
  69046. interface IGLTF extends IProperty {
  69047. /**
  69048. * An array of accessors. An accessor is a typed view into a bufferView
  69049. */
  69050. accessors?: IAccessor[];
  69051. /**
  69052. * An array of keyframe animations
  69053. */
  69054. animations?: IAnimation[];
  69055. /**
  69056. * Metadata about the glTF asset
  69057. */
  69058. asset: IAsset;
  69059. /**
  69060. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69061. */
  69062. buffers?: IBuffer[];
  69063. /**
  69064. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69065. */
  69066. bufferViews?: IBufferView[];
  69067. /**
  69068. * An array of cameras
  69069. */
  69070. cameras?: ICamera[];
  69071. /**
  69072. * Names of glTF extensions used somewhere in this asset
  69073. */
  69074. extensionsUsed?: string[];
  69075. /**
  69076. * Names of glTF extensions required to properly load this asset
  69077. */
  69078. extensionsRequired?: string[];
  69079. /**
  69080. * An array of images. An image defines data used to create a texture
  69081. */
  69082. images?: IImage[];
  69083. /**
  69084. * An array of materials. A material defines the appearance of a primitive
  69085. */
  69086. materials?: IMaterial[];
  69087. /**
  69088. * An array of meshes. A mesh is a set of primitives to be rendered
  69089. */
  69090. meshes?: IMesh[];
  69091. /**
  69092. * An array of nodes
  69093. */
  69094. nodes?: INode[];
  69095. /**
  69096. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69097. */
  69098. samplers?: ISampler[];
  69099. /**
  69100. * The index of the default scene
  69101. */
  69102. scene?: number;
  69103. /**
  69104. * An array of scenes
  69105. */
  69106. scenes?: IScene[];
  69107. /**
  69108. * An array of skins. A skin is defined by joints and matrices
  69109. */
  69110. skins?: ISkin[];
  69111. /**
  69112. * An array of textures
  69113. */
  69114. textures?: ITexture[];
  69115. }
  69116. /**
  69117. * The glTF validation results
  69118. */
  69119. interface IGLTFValidationResults {
  69120. info: {
  69121. generator: string;
  69122. hasAnimations: boolean;
  69123. hasDefaultScene: boolean;
  69124. hasMaterials: boolean;
  69125. hasMorphTargets: boolean;
  69126. hasSkins: boolean;
  69127. hasTextures: boolean;
  69128. maxAttributesUsed: number;
  69129. primitivesCount: number
  69130. };
  69131. issues: {
  69132. messages: Array<string>;
  69133. numErrors: number;
  69134. numHints: number;
  69135. numInfos: number;
  69136. numWarnings: number;
  69137. truncated: boolean
  69138. };
  69139. mimeType: string;
  69140. uri: string;
  69141. validatedAt: string;
  69142. validatorVersion: string;
  69143. }
  69144. /**
  69145. * The glTF validation options
  69146. */
  69147. interface IGLTFValidationOptions {
  69148. uri?: string;
  69149. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69150. validateAccessorData?: boolean;
  69151. maxIssues?: number;
  69152. ignoredIssues?: Array<string>;
  69153. severityOverrides?: Object;
  69154. }
  69155. /**
  69156. * The glTF validator object
  69157. */
  69158. interface IGLTFValidator {
  69159. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69160. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69161. }
  69162. }
  69163. declare module BABYLON {
  69164. /** @hidden */
  69165. export var cellPixelShader: {
  69166. name: string;
  69167. shader: string;
  69168. };
  69169. }
  69170. declare module BABYLON {
  69171. /** @hidden */
  69172. export var cellVertexShader: {
  69173. name: string;
  69174. shader: string;
  69175. };
  69176. }
  69177. declare module BABYLON {
  69178. export class CellMaterial extends BABYLON.PushMaterial {
  69179. private _diffuseTexture;
  69180. diffuseTexture: BABYLON.BaseTexture;
  69181. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  69182. computeHighLevel: boolean;
  69183. private _disableLighting;
  69184. disableLighting: boolean;
  69185. private _maxSimultaneousLights;
  69186. maxSimultaneousLights: number;
  69187. private _renderId;
  69188. constructor(name: string, scene: BABYLON.Scene);
  69189. needAlphaBlending(): boolean;
  69190. needAlphaTesting(): boolean;
  69191. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69192. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69193. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69194. getAnimatables(): BABYLON.IAnimatable[];
  69195. getActiveTextures(): BABYLON.BaseTexture[];
  69196. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69197. dispose(forceDisposeEffect?: boolean): void;
  69198. getClassName(): string;
  69199. clone(name: string): CellMaterial;
  69200. serialize(): any;
  69201. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69202. }
  69203. }
  69204. declare module BABYLON {
  69205. export class CustomShaderStructure {
  69206. FragmentStore: string;
  69207. VertexStore: string;
  69208. constructor();
  69209. }
  69210. export class ShaderSpecialParts {
  69211. constructor();
  69212. Fragment_Begin: string;
  69213. Fragment_Definitions: string;
  69214. Fragment_MainBegin: string;
  69215. Fragment_Custom_Diffuse: string;
  69216. Fragment_Before_Lights: string;
  69217. Fragment_Before_Fog: string;
  69218. Fragment_Custom_Alpha: string;
  69219. Fragment_Before_FragColor: string;
  69220. Vertex_Begin: string;
  69221. Vertex_Definitions: string;
  69222. Vertex_MainBegin: string;
  69223. Vertex_Before_PositionUpdated: string;
  69224. Vertex_Before_NormalUpdated: string;
  69225. Vertex_MainEnd: string;
  69226. }
  69227. export class CustomMaterial extends BABYLON.StandardMaterial {
  69228. static ShaderIndexer: number;
  69229. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69230. FragmentShader: string;
  69231. VertexShader: string;
  69232. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69233. ReviewUniform(name: string, arr: string[]): string[];
  69234. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69235. constructor(name: string, scene: BABYLON.Scene);
  69236. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69237. Fragment_Begin(shaderPart: string): CustomMaterial;
  69238. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69239. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69240. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69241. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69242. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69243. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69244. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69245. Vertex_Begin(shaderPart: string): CustomMaterial;
  69246. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69247. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69248. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69249. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69250. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69251. }
  69252. }
  69253. declare module BABYLON {
  69254. export class ShaderAlebdoParts {
  69255. constructor();
  69256. Fragment_Begin: string;
  69257. Fragment_Definitions: string;
  69258. Fragment_MainBegin: string;
  69259. Fragment_Custom_Albedo: string;
  69260. Fragment_Before_Lights: string;
  69261. Fragment_Custom_MetallicRoughness: string;
  69262. Fragment_Custom_MicroSurface: string;
  69263. Fragment_Before_Fog: string;
  69264. Fragment_Custom_Alpha: string;
  69265. Fragment_Before_FragColor: string;
  69266. Vertex_Begin: string;
  69267. Vertex_Definitions: string;
  69268. Vertex_MainBegin: string;
  69269. Vertex_Before_PositionUpdated: string;
  69270. Vertex_Before_NormalUpdated: string;
  69271. Vertex_MainEnd: string;
  69272. }
  69273. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69274. static ShaderIndexer: number;
  69275. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  69276. FragmentShader: string;
  69277. VertexShader: string;
  69278. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69279. ReviewUniform(name: string, arr: string[]): string[];
  69280. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69281. constructor(name: string, scene: BABYLON.Scene);
  69282. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69283. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69284. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69285. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69286. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69287. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69288. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69289. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69290. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69291. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69292. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69293. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69294. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69295. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69296. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69297. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69298. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69299. }
  69300. }
  69301. declare module BABYLON {
  69302. /** @hidden */
  69303. export var firePixelShader: {
  69304. name: string;
  69305. shader: string;
  69306. };
  69307. }
  69308. declare module BABYLON {
  69309. /** @hidden */
  69310. export var fireVertexShader: {
  69311. name: string;
  69312. shader: string;
  69313. };
  69314. }
  69315. declare module BABYLON {
  69316. export class FireMaterial extends BABYLON.PushMaterial {
  69317. private _diffuseTexture;
  69318. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69319. private _distortionTexture;
  69320. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69321. private _opacityTexture;
  69322. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69323. diffuseColor: BABYLON.Color3;
  69324. speed: number;
  69325. private _scaledDiffuse;
  69326. private _renderId;
  69327. private _lastTime;
  69328. constructor(name: string, scene: BABYLON.Scene);
  69329. needAlphaBlending(): boolean;
  69330. needAlphaTesting(): boolean;
  69331. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69334. getAnimatables(): BABYLON.IAnimatable[];
  69335. getActiveTextures(): BABYLON.BaseTexture[];
  69336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69337. getClassName(): string;
  69338. dispose(forceDisposeEffect?: boolean): void;
  69339. clone(name: string): FireMaterial;
  69340. serialize(): any;
  69341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /** @hidden */
  69346. export var furPixelShader: {
  69347. name: string;
  69348. shader: string;
  69349. };
  69350. }
  69351. declare module BABYLON {
  69352. /** @hidden */
  69353. export var furVertexShader: {
  69354. name: string;
  69355. shader: string;
  69356. };
  69357. }
  69358. declare module BABYLON {
  69359. export class FurMaterial extends BABYLON.PushMaterial {
  69360. private _diffuseTexture;
  69361. diffuseTexture: BABYLON.BaseTexture;
  69362. private _heightTexture;
  69363. heightTexture: BABYLON.BaseTexture;
  69364. diffuseColor: BABYLON.Color3;
  69365. furLength: number;
  69366. furAngle: number;
  69367. furColor: BABYLON.Color3;
  69368. furOffset: number;
  69369. furSpacing: number;
  69370. furGravity: BABYLON.Vector3;
  69371. furSpeed: number;
  69372. furDensity: number;
  69373. furOcclusion: number;
  69374. furTexture: BABYLON.DynamicTexture;
  69375. private _disableLighting;
  69376. disableLighting: boolean;
  69377. private _maxSimultaneousLights;
  69378. maxSimultaneousLights: number;
  69379. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  69380. private _renderId;
  69381. private _furTime;
  69382. constructor(name: string, scene: BABYLON.Scene);
  69383. furTime: number;
  69384. needAlphaBlending(): boolean;
  69385. needAlphaTesting(): boolean;
  69386. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69387. updateFur(): void;
  69388. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69389. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69390. getAnimatables(): BABYLON.IAnimatable[];
  69391. getActiveTextures(): BABYLON.BaseTexture[];
  69392. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69393. dispose(forceDisposeEffect?: boolean): void;
  69394. clone(name: string): FurMaterial;
  69395. serialize(): any;
  69396. getClassName(): string;
  69397. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69398. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69399. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69400. }
  69401. }
  69402. declare module BABYLON {
  69403. /** @hidden */
  69404. export var gradientPixelShader: {
  69405. name: string;
  69406. shader: string;
  69407. };
  69408. }
  69409. declare module BABYLON {
  69410. /** @hidden */
  69411. export var gradientVertexShader: {
  69412. name: string;
  69413. shader: string;
  69414. };
  69415. }
  69416. declare module BABYLON {
  69417. export class GradientMaterial extends BABYLON.PushMaterial {
  69418. private _maxSimultaneousLights;
  69419. maxSimultaneousLights: number;
  69420. topColor: BABYLON.Color3;
  69421. topColorAlpha: number;
  69422. bottomColor: BABYLON.Color3;
  69423. bottomColorAlpha: number;
  69424. offset: number;
  69425. scale: number;
  69426. smoothness: number;
  69427. private _disableLighting;
  69428. disableLighting: boolean;
  69429. private _renderId;
  69430. constructor(name: string, scene: BABYLON.Scene);
  69431. needAlphaBlending(): boolean;
  69432. needAlphaTesting(): boolean;
  69433. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69434. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69435. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69436. getAnimatables(): BABYLON.IAnimatable[];
  69437. dispose(forceDisposeEffect?: boolean): void;
  69438. clone(name: string): GradientMaterial;
  69439. serialize(): any;
  69440. getClassName(): string;
  69441. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  69442. }
  69443. }
  69444. declare module BABYLON {
  69445. /** @hidden */
  69446. export var gridPixelShader: {
  69447. name: string;
  69448. shader: string;
  69449. };
  69450. }
  69451. declare module BABYLON {
  69452. /** @hidden */
  69453. export var gridVertexShader: {
  69454. name: string;
  69455. shader: string;
  69456. };
  69457. }
  69458. declare module BABYLON {
  69459. /**
  69460. * The grid materials allows you to wrap any shape with a grid.
  69461. * Colors are customizable.
  69462. */
  69463. export class GridMaterial extends BABYLON.PushMaterial {
  69464. /**
  69465. * Main color of the grid (e.g. between lines)
  69466. */
  69467. mainColor: BABYLON.Color3;
  69468. /**
  69469. * Color of the grid lines.
  69470. */
  69471. lineColor: BABYLON.Color3;
  69472. /**
  69473. * The scale of the grid compared to unit.
  69474. */
  69475. gridRatio: number;
  69476. /**
  69477. * Allows setting an offset for the grid lines.
  69478. */
  69479. gridOffset: BABYLON.Vector3;
  69480. /**
  69481. * The frequency of thicker lines.
  69482. */
  69483. majorUnitFrequency: number;
  69484. /**
  69485. * The visibility of minor units in the grid.
  69486. */
  69487. minorUnitVisibility: number;
  69488. /**
  69489. * The grid opacity outside of the lines.
  69490. */
  69491. opacity: number;
  69492. /**
  69493. * Determine RBG output is premultiplied by alpha value.
  69494. */
  69495. preMultiplyAlpha: boolean;
  69496. private _opacityTexture;
  69497. opacityTexture: BABYLON.BaseTexture;
  69498. private _gridControl;
  69499. private _renderId;
  69500. /**
  69501. * constructor
  69502. * @param name The name given to the material in order to identify it afterwards.
  69503. * @param scene The scene the material is used in.
  69504. */
  69505. constructor(name: string, scene: BABYLON.Scene);
  69506. /**
  69507. * Returns wehter or not the grid requires alpha blending.
  69508. */
  69509. needAlphaBlending(): boolean;
  69510. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69511. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69512. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69513. /**
  69514. * Dispose the material and its associated resources.
  69515. * @param forceDisposeEffect will also dispose the used effect when true
  69516. */
  69517. dispose(forceDisposeEffect?: boolean): void;
  69518. clone(name: string): GridMaterial;
  69519. serialize(): any;
  69520. getClassName(): string;
  69521. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  69522. }
  69523. }
  69524. declare module BABYLON {
  69525. /** @hidden */
  69526. export var lavaPixelShader: {
  69527. name: string;
  69528. shader: string;
  69529. };
  69530. }
  69531. declare module BABYLON {
  69532. /** @hidden */
  69533. export var lavaVertexShader: {
  69534. name: string;
  69535. shader: string;
  69536. };
  69537. }
  69538. declare module BABYLON {
  69539. export class LavaMaterial extends BABYLON.PushMaterial {
  69540. private _diffuseTexture;
  69541. diffuseTexture: BABYLON.BaseTexture;
  69542. noiseTexture: BABYLON.BaseTexture;
  69543. fogColor: BABYLON.Color3;
  69544. speed: number;
  69545. movingSpeed: number;
  69546. lowFrequencySpeed: number;
  69547. fogDensity: number;
  69548. private _lastTime;
  69549. diffuseColor: BABYLON.Color3;
  69550. private _disableLighting;
  69551. disableLighting: boolean;
  69552. private _unlit;
  69553. unlit: boolean;
  69554. private _maxSimultaneousLights;
  69555. maxSimultaneousLights: number;
  69556. private _scaledDiffuse;
  69557. private _renderId;
  69558. constructor(name: string, scene: BABYLON.Scene);
  69559. needAlphaBlending(): boolean;
  69560. needAlphaTesting(): boolean;
  69561. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69564. getAnimatables(): BABYLON.IAnimatable[];
  69565. getActiveTextures(): BABYLON.BaseTexture[];
  69566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69567. dispose(forceDisposeEffect?: boolean): void;
  69568. clone(name: string): LavaMaterial;
  69569. serialize(): any;
  69570. getClassName(): string;
  69571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  69572. }
  69573. }
  69574. declare module BABYLON {
  69575. /** @hidden */
  69576. export var mixPixelShader: {
  69577. name: string;
  69578. shader: string;
  69579. };
  69580. }
  69581. declare module BABYLON {
  69582. /** @hidden */
  69583. export var mixVertexShader: {
  69584. name: string;
  69585. shader: string;
  69586. };
  69587. }
  69588. declare module BABYLON {
  69589. export class MixMaterial extends BABYLON.PushMaterial {
  69590. /**
  69591. * Mix textures
  69592. */
  69593. private _mixTexture1;
  69594. mixTexture1: BABYLON.BaseTexture;
  69595. private _mixTexture2;
  69596. mixTexture2: BABYLON.BaseTexture;
  69597. /**
  69598. * Diffuse textures
  69599. */
  69600. private _diffuseTexture1;
  69601. diffuseTexture1: BABYLON.Texture;
  69602. private _diffuseTexture2;
  69603. diffuseTexture2: BABYLON.Texture;
  69604. private _diffuseTexture3;
  69605. diffuseTexture3: BABYLON.Texture;
  69606. private _diffuseTexture4;
  69607. diffuseTexture4: BABYLON.Texture;
  69608. private _diffuseTexture5;
  69609. diffuseTexture5: BABYLON.Texture;
  69610. private _diffuseTexture6;
  69611. diffuseTexture6: BABYLON.Texture;
  69612. private _diffuseTexture7;
  69613. diffuseTexture7: BABYLON.Texture;
  69614. private _diffuseTexture8;
  69615. diffuseTexture8: BABYLON.Texture;
  69616. /**
  69617. * Uniforms
  69618. */
  69619. diffuseColor: BABYLON.Color3;
  69620. specularColor: BABYLON.Color3;
  69621. specularPower: number;
  69622. private _disableLighting;
  69623. disableLighting: boolean;
  69624. private _maxSimultaneousLights;
  69625. maxSimultaneousLights: number;
  69626. private _renderId;
  69627. constructor(name: string, scene: BABYLON.Scene);
  69628. needAlphaBlending(): boolean;
  69629. needAlphaTesting(): boolean;
  69630. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69631. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69632. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69633. getAnimatables(): BABYLON.IAnimatable[];
  69634. getActiveTextures(): BABYLON.BaseTexture[];
  69635. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69636. dispose(forceDisposeEffect?: boolean): void;
  69637. clone(name: string): MixMaterial;
  69638. serialize(): any;
  69639. getClassName(): string;
  69640. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  69641. }
  69642. }
  69643. declare module BABYLON {
  69644. /** @hidden */
  69645. export var normalPixelShader: {
  69646. name: string;
  69647. shader: string;
  69648. };
  69649. }
  69650. declare module BABYLON {
  69651. /** @hidden */
  69652. export var normalVertexShader: {
  69653. name: string;
  69654. shader: string;
  69655. };
  69656. }
  69657. declare module BABYLON {
  69658. export class NormalMaterial extends BABYLON.PushMaterial {
  69659. private _diffuseTexture;
  69660. diffuseTexture: BABYLON.BaseTexture;
  69661. diffuseColor: BABYLON.Color3;
  69662. private _disableLighting;
  69663. disableLighting: boolean;
  69664. private _maxSimultaneousLights;
  69665. maxSimultaneousLights: number;
  69666. private _renderId;
  69667. constructor(name: string, scene: BABYLON.Scene);
  69668. needAlphaBlending(): boolean;
  69669. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  69670. needAlphaTesting(): boolean;
  69671. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69672. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69673. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69674. getAnimatables(): BABYLON.IAnimatable[];
  69675. getActiveTextures(): BABYLON.BaseTexture[];
  69676. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69677. dispose(forceDisposeEffect?: boolean): void;
  69678. clone(name: string): NormalMaterial;
  69679. serialize(): any;
  69680. getClassName(): string;
  69681. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  69682. }
  69683. }
  69684. declare module BABYLON {
  69685. /** @hidden */
  69686. export var shadowOnlyPixelShader: {
  69687. name: string;
  69688. shader: string;
  69689. };
  69690. }
  69691. declare module BABYLON {
  69692. /** @hidden */
  69693. export var shadowOnlyVertexShader: {
  69694. name: string;
  69695. shader: string;
  69696. };
  69697. }
  69698. declare module BABYLON {
  69699. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  69700. private _renderId;
  69701. private _activeLight;
  69702. constructor(name: string, scene: BABYLON.Scene);
  69703. shadowColor: BABYLON.Color3;
  69704. needAlphaBlending(): boolean;
  69705. needAlphaTesting(): boolean;
  69706. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69707. activeLight: BABYLON.IShadowLight;
  69708. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69709. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69710. clone(name: string): ShadowOnlyMaterial;
  69711. serialize(): any;
  69712. getClassName(): string;
  69713. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  69714. }
  69715. }
  69716. declare module BABYLON {
  69717. /** @hidden */
  69718. export var simplePixelShader: {
  69719. name: string;
  69720. shader: string;
  69721. };
  69722. }
  69723. declare module BABYLON {
  69724. /** @hidden */
  69725. export var simpleVertexShader: {
  69726. name: string;
  69727. shader: string;
  69728. };
  69729. }
  69730. declare module BABYLON {
  69731. export class SimpleMaterial extends BABYLON.PushMaterial {
  69732. private _diffuseTexture;
  69733. diffuseTexture: BABYLON.BaseTexture;
  69734. diffuseColor: BABYLON.Color3;
  69735. private _disableLighting;
  69736. disableLighting: boolean;
  69737. private _maxSimultaneousLights;
  69738. maxSimultaneousLights: number;
  69739. private _renderId;
  69740. constructor(name: string, scene: BABYLON.Scene);
  69741. needAlphaBlending(): boolean;
  69742. needAlphaTesting(): boolean;
  69743. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69744. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69745. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69746. getAnimatables(): BABYLON.IAnimatable[];
  69747. getActiveTextures(): BABYLON.BaseTexture[];
  69748. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69749. dispose(forceDisposeEffect?: boolean): void;
  69750. clone(name: string): SimpleMaterial;
  69751. serialize(): any;
  69752. getClassName(): string;
  69753. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  69754. }
  69755. }
  69756. declare module BABYLON {
  69757. /** @hidden */
  69758. export var skyPixelShader: {
  69759. name: string;
  69760. shader: string;
  69761. };
  69762. }
  69763. declare module BABYLON {
  69764. /** @hidden */
  69765. export var skyVertexShader: {
  69766. name: string;
  69767. shader: string;
  69768. };
  69769. }
  69770. declare module BABYLON {
  69771. /**
  69772. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  69773. * @see https://doc.babylonjs.com/extensions/sky
  69774. */
  69775. export class SkyMaterial extends BABYLON.PushMaterial {
  69776. /**
  69777. * Defines the overall luminance of sky in interval ]0, 1[.
  69778. */
  69779. luminance: number;
  69780. /**
  69781. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  69782. */
  69783. turbidity: number;
  69784. /**
  69785. * Defines the sky appearance (light intensity).
  69786. */
  69787. rayleigh: number;
  69788. /**
  69789. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  69790. */
  69791. mieCoefficient: number;
  69792. /**
  69793. * Defines the amount of haze particles following the Mie scattering theory.
  69794. */
  69795. mieDirectionalG: number;
  69796. /**
  69797. * Defines the distance of the sun according to the active scene camera.
  69798. */
  69799. distance: number;
  69800. /**
  69801. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  69802. * "inclined".
  69803. */
  69804. inclination: number;
  69805. /**
  69806. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  69807. * an object direction and a reference direction.
  69808. */
  69809. azimuth: number;
  69810. /**
  69811. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  69812. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  69813. */
  69814. sunPosition: BABYLON.Vector3;
  69815. /**
  69816. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  69817. * .sunPosition property.
  69818. */
  69819. useSunPosition: boolean;
  69820. /**
  69821. * Defines an offset vector used to get a horizon offset.
  69822. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69823. */
  69824. cameraOffset: BABYLON.Vector3;
  69825. private _cameraPosition;
  69826. private _renderId;
  69827. /**
  69828. * Instantiates a new sky material.
  69829. * This material allows to create dynamic and texture free
  69830. * effects for skyboxes by taking care of the atmosphere state.
  69831. * @see https://doc.babylonjs.com/extensions/sky
  69832. * @param name Define the name of the material in the scene
  69833. * @param scene Define the scene the material belong to
  69834. */
  69835. constructor(name: string, scene: BABYLON.Scene);
  69836. /**
  69837. * Specifies if the material will require alpha blending
  69838. * @returns a boolean specifying if alpha blending is needed
  69839. */
  69840. needAlphaBlending(): boolean;
  69841. /**
  69842. * Specifies if this material should be rendered in alpha test mode
  69843. * @returns false as the sky material doesn't need alpha testing.
  69844. */
  69845. needAlphaTesting(): boolean;
  69846. /**
  69847. * Get the texture used for alpha test purpose.
  69848. * @returns null as the sky material has no texture.
  69849. */
  69850. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69851. /**
  69852. * Get if the submesh is ready to be used and all its information available.
  69853. * Child classes can use it to update shaders
  69854. * @param mesh defines the mesh to check
  69855. * @param subMesh defines which submesh to check
  69856. * @param useInstances specifies that instances should be used
  69857. * @returns a boolean indicating that the submesh is ready or not
  69858. */
  69859. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69860. /**
  69861. * Binds the submesh to this material by preparing the effect and shader to draw
  69862. * @param world defines the world transformation matrix
  69863. * @param mesh defines the mesh containing the submesh
  69864. * @param subMesh defines the submesh to bind the material to
  69865. */
  69866. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69867. /**
  69868. * Get the list of animatables in the material.
  69869. * @returns the list of animatables object used in the material
  69870. */
  69871. getAnimatables(): BABYLON.IAnimatable[];
  69872. /**
  69873. * Disposes the material
  69874. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69875. */
  69876. dispose(forceDisposeEffect?: boolean): void;
  69877. /**
  69878. * Makes a duplicate of the material, and gives it a new name
  69879. * @param name defines the new name for the duplicated material
  69880. * @returns the cloned material
  69881. */
  69882. clone(name: string): SkyMaterial;
  69883. /**
  69884. * Serializes this material in a JSON representation
  69885. * @returns the serialized material object
  69886. */
  69887. serialize(): any;
  69888. /**
  69889. * Gets the current class name of the material e.g. "SkyMaterial"
  69890. * Mainly use in serialization.
  69891. * @returns the class name
  69892. */
  69893. getClassName(): string;
  69894. /**
  69895. * Creates a sky material from parsed material data
  69896. * @param source defines the JSON representation of the material
  69897. * @param scene defines the hosting scene
  69898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69899. * @returns a new sky material
  69900. */
  69901. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /** @hidden */
  69906. export var terrainPixelShader: {
  69907. name: string;
  69908. shader: string;
  69909. };
  69910. }
  69911. declare module BABYLON {
  69912. /** @hidden */
  69913. export var terrainVertexShader: {
  69914. name: string;
  69915. shader: string;
  69916. };
  69917. }
  69918. declare module BABYLON {
  69919. export class TerrainMaterial extends BABYLON.PushMaterial {
  69920. private _mixTexture;
  69921. mixTexture: BABYLON.BaseTexture;
  69922. private _diffuseTexture1;
  69923. diffuseTexture1: BABYLON.Texture;
  69924. private _diffuseTexture2;
  69925. diffuseTexture2: BABYLON.Texture;
  69926. private _diffuseTexture3;
  69927. diffuseTexture3: BABYLON.Texture;
  69928. private _bumpTexture1;
  69929. bumpTexture1: BABYLON.Texture;
  69930. private _bumpTexture2;
  69931. bumpTexture2: BABYLON.Texture;
  69932. private _bumpTexture3;
  69933. bumpTexture3: BABYLON.Texture;
  69934. diffuseColor: BABYLON.Color3;
  69935. specularColor: BABYLON.Color3;
  69936. specularPower: number;
  69937. private _disableLighting;
  69938. disableLighting: boolean;
  69939. private _maxSimultaneousLights;
  69940. maxSimultaneousLights: number;
  69941. private _renderId;
  69942. constructor(name: string, scene: BABYLON.Scene);
  69943. needAlphaBlending(): boolean;
  69944. needAlphaTesting(): boolean;
  69945. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69946. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69947. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69948. getAnimatables(): BABYLON.IAnimatable[];
  69949. getActiveTextures(): BABYLON.BaseTexture[];
  69950. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69951. dispose(forceDisposeEffect?: boolean): void;
  69952. clone(name: string): TerrainMaterial;
  69953. serialize(): any;
  69954. getClassName(): string;
  69955. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69956. }
  69957. }
  69958. declare module BABYLON {
  69959. /** @hidden */
  69960. export var triplanarPixelShader: {
  69961. name: string;
  69962. shader: string;
  69963. };
  69964. }
  69965. declare module BABYLON {
  69966. /** @hidden */
  69967. export var triplanarVertexShader: {
  69968. name: string;
  69969. shader: string;
  69970. };
  69971. }
  69972. declare module BABYLON {
  69973. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69974. mixTexture: BABYLON.BaseTexture;
  69975. private _diffuseTextureX;
  69976. diffuseTextureX: BABYLON.BaseTexture;
  69977. private _diffuseTextureY;
  69978. diffuseTextureY: BABYLON.BaseTexture;
  69979. private _diffuseTextureZ;
  69980. diffuseTextureZ: BABYLON.BaseTexture;
  69981. private _normalTextureX;
  69982. normalTextureX: BABYLON.BaseTexture;
  69983. private _normalTextureY;
  69984. normalTextureY: BABYLON.BaseTexture;
  69985. private _normalTextureZ;
  69986. normalTextureZ: BABYLON.BaseTexture;
  69987. tileSize: number;
  69988. diffuseColor: BABYLON.Color3;
  69989. specularColor: BABYLON.Color3;
  69990. specularPower: number;
  69991. private _disableLighting;
  69992. disableLighting: boolean;
  69993. private _maxSimultaneousLights;
  69994. maxSimultaneousLights: number;
  69995. private _renderId;
  69996. constructor(name: string, scene: BABYLON.Scene);
  69997. needAlphaBlending(): boolean;
  69998. needAlphaTesting(): boolean;
  69999. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70000. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70001. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70002. getAnimatables(): BABYLON.IAnimatable[];
  70003. getActiveTextures(): BABYLON.BaseTexture[];
  70004. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70005. dispose(forceDisposeEffect?: boolean): void;
  70006. clone(name: string): TriPlanarMaterial;
  70007. serialize(): any;
  70008. getClassName(): string;
  70009. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70010. }
  70011. }
  70012. declare module BABYLON {
  70013. /** @hidden */
  70014. export var waterPixelShader: {
  70015. name: string;
  70016. shader: string;
  70017. };
  70018. }
  70019. declare module BABYLON {
  70020. /** @hidden */
  70021. export var waterVertexShader: {
  70022. name: string;
  70023. shader: string;
  70024. };
  70025. }
  70026. declare module BABYLON {
  70027. export class WaterMaterial extends BABYLON.PushMaterial {
  70028. renderTargetSize: BABYLON.Vector2;
  70029. private _bumpTexture;
  70030. bumpTexture: BABYLON.BaseTexture;
  70031. diffuseColor: BABYLON.Color3;
  70032. specularColor: BABYLON.Color3;
  70033. specularPower: number;
  70034. private _disableLighting;
  70035. disableLighting: boolean;
  70036. private _maxSimultaneousLights;
  70037. maxSimultaneousLights: number;
  70038. /**
  70039. * @param {number}: Represents the wind force
  70040. */
  70041. windForce: number;
  70042. /**
  70043. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70044. */
  70045. windDirection: BABYLON.Vector2;
  70046. /**
  70047. * @param {number}: Wave height, represents the height of the waves
  70048. */
  70049. waveHeight: number;
  70050. /**
  70051. * @param {number}: Bump height, represents the bump height related to the bump map
  70052. */
  70053. bumpHeight: number;
  70054. /**
  70055. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70056. */
  70057. private _bumpSuperimpose;
  70058. bumpSuperimpose: boolean;
  70059. /**
  70060. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70061. */
  70062. private _fresnelSeparate;
  70063. fresnelSeparate: boolean;
  70064. /**
  70065. * @param {boolean}: bump Waves modify the reflection.
  70066. */
  70067. private _bumpAffectsReflection;
  70068. bumpAffectsReflection: boolean;
  70069. /**
  70070. * @param {number}: The water color blended with the refraction (near)
  70071. */
  70072. waterColor: BABYLON.Color3;
  70073. /**
  70074. * @param {number}: The blend factor related to the water color
  70075. */
  70076. colorBlendFactor: number;
  70077. /**
  70078. * @param {number}: The water color blended with the reflection (far)
  70079. */
  70080. waterColor2: BABYLON.Color3;
  70081. /**
  70082. * @param {number}: The blend factor related to the water color (reflection, far)
  70083. */
  70084. colorBlendFactor2: number;
  70085. /**
  70086. * @param {number}: Represents the maximum length of a wave
  70087. */
  70088. waveLength: number;
  70089. /**
  70090. * @param {number}: Defines the waves speed
  70091. */
  70092. waveSpeed: number;
  70093. /**
  70094. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70095. * will avoid calculating useless pixels in the pixel shader of the water material.
  70096. */
  70097. disableClipPlane: boolean;
  70098. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70099. private _mesh;
  70100. private _refractionRTT;
  70101. private _reflectionRTT;
  70102. private _reflectionTransform;
  70103. private _lastTime;
  70104. private _lastDeltaTime;
  70105. private _renderId;
  70106. private _useLogarithmicDepth;
  70107. private _waitingRenderList;
  70108. private _imageProcessingConfiguration;
  70109. private _imageProcessingObserver;
  70110. /**
  70111. * Gets a boolean indicating that current material needs to register RTT
  70112. */
  70113. readonly hasRenderTargetTextures: boolean;
  70114. /**
  70115. * Constructor
  70116. */
  70117. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70118. useLogarithmicDepth: boolean;
  70119. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70120. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70121. addToRenderList(node: any): void;
  70122. enableRenderTargets(enable: boolean): void;
  70123. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70124. readonly renderTargetsEnabled: boolean;
  70125. needAlphaBlending(): boolean;
  70126. needAlphaTesting(): boolean;
  70127. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70128. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70129. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70130. private _createRenderTargets;
  70131. getAnimatables(): BABYLON.IAnimatable[];
  70132. getActiveTextures(): BABYLON.BaseTexture[];
  70133. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70134. dispose(forceDisposeEffect?: boolean): void;
  70135. clone(name: string): WaterMaterial;
  70136. serialize(): any;
  70137. getClassName(): string;
  70138. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70139. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70140. }
  70141. }
  70142. declare module BABYLON {
  70143. /** @hidden */
  70144. export var asciiartPixelShader: {
  70145. name: string;
  70146. shader: string;
  70147. };
  70148. }
  70149. declare module BABYLON {
  70150. /**
  70151. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70152. *
  70153. * It basically takes care rendering the font front the given font size to a texture.
  70154. * This is used later on in the postprocess.
  70155. */
  70156. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70157. private _font;
  70158. private _text;
  70159. private _charSize;
  70160. /**
  70161. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70162. */
  70163. readonly charSize: number;
  70164. /**
  70165. * Create a new instance of the Ascii Art FontTexture class
  70166. * @param name the name of the texture
  70167. * @param font the font to use, use the W3C CSS notation
  70168. * @param text the caracter set to use in the rendering.
  70169. * @param scene the scene that owns the texture
  70170. */
  70171. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70172. /**
  70173. * Gets the max char width of a font.
  70174. * @param font the font to use, use the W3C CSS notation
  70175. * @return the max char width
  70176. */
  70177. private getFontWidth;
  70178. /**
  70179. * Gets the max char height of a font.
  70180. * @param font the font to use, use the W3C CSS notation
  70181. * @return the max char height
  70182. */
  70183. private getFontHeight;
  70184. /**
  70185. * Clones the current AsciiArtTexture.
  70186. * @return the clone of the texture.
  70187. */
  70188. clone(): AsciiArtFontTexture;
  70189. /**
  70190. * Parses a json object representing the texture and returns an instance of it.
  70191. * @param source the source JSON representation
  70192. * @param scene the scene to create the texture for
  70193. * @return the parsed texture
  70194. */
  70195. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70196. }
  70197. /**
  70198. * Option available in the Ascii Art Post Process.
  70199. */
  70200. export interface IAsciiArtPostProcessOptions {
  70201. /**
  70202. * The font to use following the w3c font definition.
  70203. */
  70204. font?: string;
  70205. /**
  70206. * The character set to use in the postprocess.
  70207. */
  70208. characterSet?: string;
  70209. /**
  70210. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70211. * This number is defined between 0 and 1;
  70212. */
  70213. mixToTile?: number;
  70214. /**
  70215. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70216. * This number is defined between 0 and 1;
  70217. */
  70218. mixToNormal?: number;
  70219. }
  70220. /**
  70221. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70222. *
  70223. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70224. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70225. */
  70226. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70227. /**
  70228. * The font texture used to render the char in the post process.
  70229. */
  70230. private _asciiArtFontTexture;
  70231. /**
  70232. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70233. * This number is defined between 0 and 1;
  70234. */
  70235. mixToTile: number;
  70236. /**
  70237. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70238. * This number is defined between 0 and 1;
  70239. */
  70240. mixToNormal: number;
  70241. /**
  70242. * Instantiates a new Ascii Art Post Process.
  70243. * @param name the name to give to the postprocess
  70244. * @camera the camera to apply the post process to.
  70245. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70246. */
  70247. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70248. }
  70249. }
  70250. declare module BABYLON {
  70251. /** @hidden */
  70252. export var digitalrainPixelShader: {
  70253. name: string;
  70254. shader: string;
  70255. };
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70260. *
  70261. * It basically takes care rendering the font front the given font size to a texture.
  70262. * This is used later on in the postprocess.
  70263. */
  70264. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70265. private _font;
  70266. private _text;
  70267. private _charSize;
  70268. /**
  70269. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70270. */
  70271. readonly charSize: number;
  70272. /**
  70273. * Create a new instance of the Digital Rain FontTexture class
  70274. * @param name the name of the texture
  70275. * @param font the font to use, use the W3C CSS notation
  70276. * @param text the caracter set to use in the rendering.
  70277. * @param scene the scene that owns the texture
  70278. */
  70279. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70280. /**
  70281. * Gets the max char width of a font.
  70282. * @param font the font to use, use the W3C CSS notation
  70283. * @return the max char width
  70284. */
  70285. private getFontWidth;
  70286. /**
  70287. * Gets the max char height of a font.
  70288. * @param font the font to use, use the W3C CSS notation
  70289. * @return the max char height
  70290. */
  70291. private getFontHeight;
  70292. /**
  70293. * Clones the current DigitalRainFontTexture.
  70294. * @return the clone of the texture.
  70295. */
  70296. clone(): DigitalRainFontTexture;
  70297. /**
  70298. * Parses a json object representing the texture and returns an instance of it.
  70299. * @param source the source JSON representation
  70300. * @param scene the scene to create the texture for
  70301. * @return the parsed texture
  70302. */
  70303. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70304. }
  70305. /**
  70306. * Option available in the Digital Rain Post Process.
  70307. */
  70308. export interface IDigitalRainPostProcessOptions {
  70309. /**
  70310. * The font to use following the w3c font definition.
  70311. */
  70312. font?: string;
  70313. /**
  70314. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70315. * This number is defined between 0 and 1;
  70316. */
  70317. mixToTile?: number;
  70318. /**
  70319. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70320. * This number is defined between 0 and 1;
  70321. */
  70322. mixToNormal?: number;
  70323. }
  70324. /**
  70325. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70326. *
  70327. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70328. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70329. */
  70330. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70331. /**
  70332. * The font texture used to render the char in the post process.
  70333. */
  70334. private _digitalRainFontTexture;
  70335. /**
  70336. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70337. * This number is defined between 0 and 1;
  70338. */
  70339. mixToTile: number;
  70340. /**
  70341. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70342. * This number is defined between 0 and 1;
  70343. */
  70344. mixToNormal: number;
  70345. /**
  70346. * Instantiates a new Digital Rain Post Process.
  70347. * @param name the name to give to the postprocess
  70348. * @camera the camera to apply the post process to.
  70349. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70350. */
  70351. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70352. }
  70353. }
  70354. declare module BABYLON {
  70355. /** @hidden */
  70356. export var oceanPostProcessPixelShader: {
  70357. name: string;
  70358. shader: string;
  70359. };
  70360. }
  70361. declare module BABYLON {
  70362. /**
  70363. * Option available in the Ocean Post Process.
  70364. */
  70365. export interface IOceanPostProcessOptions {
  70366. /**
  70367. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70368. */
  70369. reflectionSize?: number | {
  70370. width: number;
  70371. height: number;
  70372. } | {
  70373. ratio: number;
  70374. };
  70375. /**
  70376. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70377. */
  70378. refractionSize?: number | {
  70379. width: number;
  70380. height: number;
  70381. } | {
  70382. ratio: number;
  70383. };
  70384. }
  70385. /**
  70386. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70387. *
  70388. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70389. * Example usage:
  70390. * var pp = new OceanPostProcess("myOcean", camera);
  70391. * pp.reflectionEnabled = true;
  70392. * pp.refractionEnabled = true;
  70393. */
  70394. export class OceanPostProcess extends BABYLON.PostProcess {
  70395. /**
  70396. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70397. */
  70398. /**
  70399. * Sets weither or not the real-time reflection is enabled on the ocean.
  70400. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70401. */
  70402. reflectionEnabled: boolean;
  70403. /**
  70404. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70405. */
  70406. /**
  70407. * Sets weither or not the real-time refraction is enabled on the ocean.
  70408. * Is set to true, the refraction render target texture will be used as refraction texture.
  70409. */
  70410. refractionEnabled: boolean;
  70411. /**
  70412. * Gets wether or not the post-processes is supported by the running hardware.
  70413. * This requires draw buffer supports.
  70414. */
  70415. readonly isSupported: boolean;
  70416. /**
  70417. * This is the reflection mirror texture used to display reflections on the ocean.
  70418. * By default, render list is empty.
  70419. */
  70420. reflectionTexture: BABYLON.MirrorTexture;
  70421. /**
  70422. * This is the refraction render target texture used to display refraction on the ocean.
  70423. * By default, render list is empty.
  70424. */
  70425. refractionTexture: BABYLON.RenderTargetTexture;
  70426. private _time;
  70427. private _cameraRotation;
  70428. private _cameraViewMatrix;
  70429. private _reflectionEnabled;
  70430. private _refractionEnabled;
  70431. private _geometryRenderer;
  70432. /**
  70433. * Instantiates a new Ocean Post Process.
  70434. * @param name the name to give to the postprocess.
  70435. * @camera the camera to apply the post process to.
  70436. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  70437. */
  70438. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  70439. /**
  70440. * Returns the appropriate defines according to the current configuration.
  70441. */
  70442. private _getDefines;
  70443. /**
  70444. * Computes the current camera rotation as the shader requires a camera rotation.
  70445. */
  70446. private _computeCameraRotation;
  70447. }
  70448. }
  70449. declare module BABYLON {
  70450. /** @hidden */
  70451. export var brickProceduralTexturePixelShader: {
  70452. name: string;
  70453. shader: string;
  70454. };
  70455. }
  70456. declare module BABYLON {
  70457. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  70458. private _numberOfBricksHeight;
  70459. private _numberOfBricksWidth;
  70460. private _jointColor;
  70461. private _brickColor;
  70462. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70463. updateShaderUniforms(): void;
  70464. numberOfBricksHeight: number;
  70465. numberOfBricksWidth: number;
  70466. jointColor: BABYLON.Color3;
  70467. brickColor: BABYLON.Color3;
  70468. /**
  70469. * Serializes this brick procedural texture
  70470. * @returns a serialized brick procedural texture object
  70471. */
  70472. serialize(): any;
  70473. /**
  70474. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  70475. * @param parsedTexture defines parsed texture data
  70476. * @param scene defines the current scene
  70477. * @param rootUrl defines the root URL containing brick procedural texture information
  70478. * @returns a parsed Brick Procedural BABYLON.Texture
  70479. */
  70480. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  70481. }
  70482. }
  70483. declare module BABYLON {
  70484. /** @hidden */
  70485. export var cloudProceduralTexturePixelShader: {
  70486. name: string;
  70487. shader: string;
  70488. };
  70489. }
  70490. declare module BABYLON {
  70491. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  70492. private _skyColor;
  70493. private _cloudColor;
  70494. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70495. updateShaderUniforms(): void;
  70496. skyColor: BABYLON.Color4;
  70497. cloudColor: BABYLON.Color4;
  70498. /**
  70499. * Serializes this cloud procedural texture
  70500. * @returns a serialized cloud procedural texture object
  70501. */
  70502. serialize(): any;
  70503. /**
  70504. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  70505. * @param parsedTexture defines parsed texture data
  70506. * @param scene defines the current scene
  70507. * @param rootUrl defines the root URL containing cloud procedural texture information
  70508. * @returns a parsed Cloud Procedural BABYLON.Texture
  70509. */
  70510. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /** @hidden */
  70515. export var fireProceduralTexturePixelShader: {
  70516. name: string;
  70517. shader: string;
  70518. };
  70519. }
  70520. declare module BABYLON {
  70521. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  70522. private _time;
  70523. private _speed;
  70524. private _autoGenerateTime;
  70525. private _fireColors;
  70526. private _alphaThreshold;
  70527. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70528. updateShaderUniforms(): void;
  70529. render(useCameraPostProcess?: boolean): void;
  70530. static readonly PurpleFireColors: BABYLON.Color3[];
  70531. static readonly GreenFireColors: BABYLON.Color3[];
  70532. static readonly RedFireColors: BABYLON.Color3[];
  70533. static readonly BlueFireColors: BABYLON.Color3[];
  70534. autoGenerateTime: boolean;
  70535. fireColors: BABYLON.Color3[];
  70536. time: number;
  70537. speed: BABYLON.Vector2;
  70538. alphaThreshold: number;
  70539. /**
  70540. * Serializes this fire procedural texture
  70541. * @returns a serialized fire procedural texture object
  70542. */
  70543. serialize(): any;
  70544. /**
  70545. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  70546. * @param parsedTexture defines parsed texture data
  70547. * @param scene defines the current scene
  70548. * @param rootUrl defines the root URL containing fire procedural texture information
  70549. * @returns a parsed Fire Procedural BABYLON.Texture
  70550. */
  70551. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  70552. }
  70553. }
  70554. declare module BABYLON {
  70555. /** @hidden */
  70556. export var grassProceduralTexturePixelShader: {
  70557. name: string;
  70558. shader: string;
  70559. };
  70560. }
  70561. declare module BABYLON {
  70562. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  70563. private _grassColors;
  70564. private _groundColor;
  70565. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70566. updateShaderUniforms(): void;
  70567. grassColors: BABYLON.Color3[];
  70568. groundColor: BABYLON.Color3;
  70569. /**
  70570. * Serializes this grass procedural texture
  70571. * @returns a serialized grass procedural texture object
  70572. */
  70573. serialize(): any;
  70574. /**
  70575. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  70576. * @param parsedTexture defines parsed texture data
  70577. * @param scene defines the current scene
  70578. * @param rootUrl defines the root URL containing grass procedural texture information
  70579. * @returns a parsed Grass Procedural BABYLON.Texture
  70580. */
  70581. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  70582. }
  70583. }
  70584. declare module BABYLON {
  70585. /** @hidden */
  70586. export var marbleProceduralTexturePixelShader: {
  70587. name: string;
  70588. shader: string;
  70589. };
  70590. }
  70591. declare module BABYLON {
  70592. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  70593. private _numberOfTilesHeight;
  70594. private _numberOfTilesWidth;
  70595. private _amplitude;
  70596. private _jointColor;
  70597. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70598. updateShaderUniforms(): void;
  70599. numberOfTilesHeight: number;
  70600. amplitude: number;
  70601. numberOfTilesWidth: number;
  70602. jointColor: BABYLON.Color3;
  70603. /**
  70604. * Serializes this marble procedural texture
  70605. * @returns a serialized marble procedural texture object
  70606. */
  70607. serialize(): any;
  70608. /**
  70609. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  70610. * @param parsedTexture defines parsed texture data
  70611. * @param scene defines the current scene
  70612. * @param rootUrl defines the root URL containing marble procedural texture information
  70613. * @returns a parsed Marble Procedural BABYLON.Texture
  70614. */
  70615. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  70616. }
  70617. }
  70618. declare module BABYLON {
  70619. /** @hidden */
  70620. export var normalMapProceduralTexturePixelShader: {
  70621. name: string;
  70622. shader: string;
  70623. };
  70624. }
  70625. declare module BABYLON {
  70626. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  70627. private _baseTexture;
  70628. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70629. updateShaderUniforms(): void;
  70630. render(useCameraPostProcess?: boolean): void;
  70631. resize(size: any, generateMipMaps: any): void;
  70632. baseTexture: BABYLON.Texture;
  70633. /**
  70634. * Serializes this normal map procedural texture
  70635. * @returns a serialized normal map procedural texture object
  70636. */
  70637. serialize(): any;
  70638. /**
  70639. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  70640. * @param parsedTexture defines parsed texture data
  70641. * @param scene defines the current scene
  70642. * @param rootUrl defines the root URL containing normal map procedural texture information
  70643. * @returns a parsed Normal Map Procedural BABYLON.Texture
  70644. */
  70645. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  70646. }
  70647. }
  70648. declare module BABYLON {
  70649. /** @hidden */
  70650. export var perlinNoiseProceduralTexturePixelShader: {
  70651. name: string;
  70652. shader: string;
  70653. };
  70654. }
  70655. declare module BABYLON {
  70656. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  70657. time: number;
  70658. timeScale: number;
  70659. translationSpeed: number;
  70660. private _currentTranslation;
  70661. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70662. updateShaderUniforms(): void;
  70663. render(useCameraPostProcess?: boolean): void;
  70664. resize(size: any, generateMipMaps: any): void;
  70665. /**
  70666. * Serializes this perlin noise procedural texture
  70667. * @returns a serialized perlin noise procedural texture object
  70668. */
  70669. serialize(): any;
  70670. /**
  70671. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  70672. * @param parsedTexture defines parsed texture data
  70673. * @param scene defines the current scene
  70674. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  70675. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  70676. */
  70677. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  70678. }
  70679. }
  70680. declare module BABYLON {
  70681. /** @hidden */
  70682. export var roadProceduralTexturePixelShader: {
  70683. name: string;
  70684. shader: string;
  70685. };
  70686. }
  70687. declare module BABYLON {
  70688. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  70689. private _roadColor;
  70690. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70691. updateShaderUniforms(): void;
  70692. roadColor: BABYLON.Color3;
  70693. /**
  70694. * Serializes this road procedural texture
  70695. * @returns a serialized road procedural texture object
  70696. */
  70697. serialize(): any;
  70698. /**
  70699. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  70700. * @param parsedTexture defines parsed texture data
  70701. * @param scene defines the current scene
  70702. * @param rootUrl defines the root URL containing road procedural texture information
  70703. * @returns a parsed Road Procedural BABYLON.Texture
  70704. */
  70705. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  70706. }
  70707. }
  70708. declare module BABYLON {
  70709. /** @hidden */
  70710. export var starfieldProceduralTexturePixelShader: {
  70711. name: string;
  70712. shader: string;
  70713. };
  70714. }
  70715. declare module BABYLON {
  70716. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  70717. private _time;
  70718. private _alpha;
  70719. private _beta;
  70720. private _zoom;
  70721. private _formuparam;
  70722. private _stepsize;
  70723. private _tile;
  70724. private _brightness;
  70725. private _darkmatter;
  70726. private _distfading;
  70727. private _saturation;
  70728. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70729. updateShaderUniforms(): void;
  70730. time: number;
  70731. alpha: number;
  70732. beta: number;
  70733. formuparam: number;
  70734. stepsize: number;
  70735. zoom: number;
  70736. tile: number;
  70737. brightness: number;
  70738. darkmatter: number;
  70739. distfading: number;
  70740. saturation: number;
  70741. /**
  70742. * Serializes this starfield procedural texture
  70743. * @returns a serialized starfield procedural texture object
  70744. */
  70745. serialize(): any;
  70746. /**
  70747. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  70748. * @param parsedTexture defines parsed texture data
  70749. * @param scene defines the current scene
  70750. * @param rootUrl defines the root URL containing startfield procedural texture information
  70751. * @returns a parsed Starfield Procedural BABYLON.Texture
  70752. */
  70753. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  70754. }
  70755. }
  70756. declare module BABYLON {
  70757. /** @hidden */
  70758. export var woodProceduralTexturePixelShader: {
  70759. name: string;
  70760. shader: string;
  70761. };
  70762. }
  70763. declare module BABYLON {
  70764. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  70765. private _ampScale;
  70766. private _woodColor;
  70767. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  70768. updateShaderUniforms(): void;
  70769. ampScale: number;
  70770. woodColor: BABYLON.Color3;
  70771. /**
  70772. * Serializes this wood procedural texture
  70773. * @returns a serialized wood procedural texture object
  70774. */
  70775. serialize(): any;
  70776. /**
  70777. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  70778. * @param parsedTexture defines parsed texture data
  70779. * @param scene defines the current scene
  70780. * @param rootUrl defines the root URL containing wood procedural texture information
  70781. * @returns a parsed Wood Procedural BABYLON.Texture
  70782. */
  70783. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  70784. }
  70785. }